diff options
Diffstat (limited to 'runtime/lua/vim/lsp/completion.lua')
-rw-r--r-- | runtime/lua/vim/lsp/completion.lua | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/runtime/lua/vim/lsp/completion.lua b/runtime/lua/vim/lsp/completion.lua index cf6d07745f..f287304508 100644 --- a/runtime/lua/vim/lsp/completion.lua +++ b/runtime/lua/vim/lsp/completion.lua @@ -493,6 +493,7 @@ local function trigger(bufnr, clients) end end local start_col = (server_start_boundary or word_boundary) + 1 + Context.cursor = { cursor_row, start_col } vim.fn.complete(start_col, matches) end) @@ -518,11 +519,14 @@ local function on_insert_char_pre(handle) end local char = api.nvim_get_vvar('char') - if not completion_timer and handle.triggers[char] then + local matched_clients = handle.triggers[char] + if not completion_timer and matched_clients then completion_timer = assert(vim.uv.new_timer()) completion_timer:start(25, 0, function() reset_timer() - vim.schedule(M.trigger) + vim.schedule(function() + trigger(api.nvim_get_current_buf(), matched_clients) + end) end) end end @@ -569,8 +573,14 @@ local function on_complete_done() end -- Remove the already inserted word. - local start_char = cursor_col - #completed_item.word - api.nvim_buf_set_text(bufnr, cursor_row, start_char, cursor_row, cursor_col, { '' }) + api.nvim_buf_set_text( + bufnr, + Context.cursor[1] - 1, + Context.cursor[2] - 1, + cursor_row, + cursor_col, + { '' } + ) end local function apply_snippet_and_command() |