diff --git a/lua/cmp/config/context.lua b/lua/cmp/config/context.lua index f7a1ac4..c9a8717 100644 --- a/lua/cmp/config/context.lua +++ b/lua/cmp/config/context.lua @@ -1,3 +1,5 @@ +local api = require('cmp.utils.api') + local context = {} ---Check if cursor is in syntax group @@ -5,7 +7,7 @@ local context = {} ---@return boolean context.in_syntax_group = function(group) local row, col = unpack(vim.api.nvim_win_get_cursor(0)) - if not vim.api.nvim_get_mode().mode == 'i' then + if not api.is_insert_mode() then col = col + 1 end @@ -34,8 +36,7 @@ context.in_treesitter_capture = function(capture) end local get_captures_at_pos = -- See neovim/neovim#20331 - require('vim.treesitter').get_captures_at_pos -- for neovim >= 0.8 - or require('vim.treesitter').get_captures_at_position -- for neovim < 0.8 + require('vim.treesitter').get_captures_at_pos -- for neovim >= 0.8 or require('vim.treesitter').get_captures_at_position -- for neovim < 0.8 local captures_at_cursor = vim.tbl_map(function(x) return x.capture diff --git a/lua/cmp/entry.lua b/lua/cmp/entry.lua index be9e88d..756dce7 100644 --- a/lua/cmp/entry.lua +++ b/lua/cmp/entry.lua @@ -239,14 +239,14 @@ entry.get_vim_item = function(self, suggest_offset) local is_expandable = false local expandable_indicator = config.get().formatting.expandable_indicator if #(misc.safe(completion_item.additionalTextEdits) or {}) > 0 then - is_expandable = true + is_expandable = true elseif completion_item.insertTextFormat == types.lsp.InsertTextFormat.Snippet then - is_expandable = self:get_insert_text() ~= word + is_expandable = self:get_insert_text() ~= word elseif completion_item.kind == types.lsp.CompletionItemKind.Snippet then - is_expandable = true + is_expandable = true end if expandable_indicator and is_expandable then - abbr = abbr .. '~' + abbr = abbr .. '~' end -- append delta text diff --git a/lua/cmp/entry_spec.lua b/lua/cmp/entry_spec.lua index a22648f..c491f17 100644 --- a/lua/cmp/entry_spec.lua +++ b/lua/cmp/entry_spec.lua @@ -1,6 +1,4 @@ local spec = require('cmp.utils.spec') -local source = require('cmp.source') -local async = require('cmp.utils.async') local entry = require('cmp.entry') diff --git a/lua/cmp/utils/api.lua b/lua/cmp/utils/api.lua index 1381781..8153c9e 100644 --- a/lua/cmp/utils/api.lua +++ b/lua/cmp/utils/api.lua @@ -48,7 +48,6 @@ end api.get_cursor = function() if api.is_cmdline_mode() then return { math.min(vim.o.lines, vim.o.lines - (vim.api.nvim_get_option('cmdheight') - 1)), vim.fn.getcmdpos() - 1 } - end return vim.api.nvim_win_get_cursor(0) end