diff --git a/plugins/cmp.nix b/plugins/cmp.nix index d9b700f..9789277 100644 --- a/plugins/cmp.nix +++ b/plugins/cmp.nix @@ -38,7 +38,12 @@ _: "" = "cmp.config.disable"; "" = "cmp.mapping { i = cmp.mapping.abort(), c = cmp.mapping.close() }"; "" = "cmp.mapping.confirm { select = false }"; - "" = "cmp.mapping(function(fallback) + "" = ''cmp.mapping(function(fallback) + local function has_words_before() + local line, col = (unpack or table.unpack)(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match "%s" == nil + end + if (cmp.core.view:visible() or vim.fn.pumvisible() == 1) then cmp.select_next_item() elseif vim.snippet and vim.snippet.active { direction = 1 } then @@ -48,7 +53,7 @@ _: else fallback() end - end, { 'i', 's' })"; + end, { 'i', 's' })''; "" = "cmp.mapping(function(fallback) if (cmp.core.view:visible() or vim.fn.pumvisible() == 1) then cmp.select_prev_item()