Skip to content
This repository was archived by the owner on Oct 13, 2021. It is now read-only.

Commit 275d588

Browse files
committed
feat: apply additional additionalTextEdits on confirm completion(#64)
1 parent e559e80 commit 275d588

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lua/completion.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ end
5151
function M.confirmCompletion()
5252
if M.completionConfirm == true then
5353
local complete_item = api.nvim_get_vvar('completed_item')
54+
local lnum, _ = api.nvim_win_get_cursor(0)
55+
local item = complete_item.user_data.lsp.completion_item
56+
local bufnr = api.nvim_get_current_buf()
57+
if item.additionalTextEdits then
58+
local edits = vim.tbl_filter(
59+
function(x) return x.range.start.line ~= (lnum - 1) end,
60+
item.additionalTextEdits
61+
)
62+
vim.lsp.util.apply_text_edits(edits, bufnr)
63+
end
64+
5465
if vim.g.completion_enable_auto_paren == 1 then
5566
M.autoAddParens(complete_item)
5667
end

0 commit comments

Comments
 (0)