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

Commit 81ec73b

Browse files
authored
Merge pull request #135 from hrsh7th/improve-additional-text-edits
Prefer vsnip's additionalTextEdits expansion
2 parents 393d67a + 5b56f18 commit 81ec73b

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

lua/completion.lua

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,23 @@ function M.confirmCompletion()
5555
local lnum, _ = unpack(api.nvim_win_get_cursor(0))
5656
if complete_item.user_data.lsp ~= nil then
5757
local item = complete_item.user_data.lsp.completion_item
58-
local bufnr = api.nvim_get_current_buf()
59-
if item.additionalTextEdits then
60-
local edits = vim.tbl_filter(
61-
function(x) return x.range.start.line ~= (lnum - 1) end,
62-
item.additionalTextEdits
63-
)
64-
vim.lsp.util.apply_text_edits(edits, bufnr)
65-
end
6658
if vim.fn.exists('g:loaded_vsnip_integ') == 1 then
67-
api.nvim_call_function('vsnip_integ#on_complete_done_for_lsp',
68-
{ { completed_item = complete_item, completion_item = item } })
59+
api.nvim_call_function('vsnip_integ#do_complete_done', {
60+
{
61+
completed_item = complete_item,
62+
completion_item = item,
63+
apply_additional_text_edits = true
64+
}
65+
})
66+
else
67+
if item.additionalTextEdits then
68+
local bufnr = api.nvim_get_current_buf()
69+
local edits = vim.tbl_filter(
70+
function(x) return x.range.start.line ~= (lnum - 1) end,
71+
item.additionalTextEdits
72+
)
73+
vim.lsp.util.apply_text_edits(edits, bufnr)
74+
end
6975
end
7076
end
7177

0 commit comments

Comments
 (0)