diff options
Diffstat (limited to 'test/functional/plugin/lsp/completion_spec.lua')
-rw-r--r-- | test/functional/plugin/lsp/completion_spec.lua | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/test/functional/plugin/lsp/completion_spec.lua b/test/functional/plugin/lsp/completion_spec.lua index 4e90c2fd1b..0b202724ed 100644 --- a/test/functional/plugin/lsp/completion_spec.lua +++ b/test/functional/plugin/lsp/completion_spec.lua @@ -770,13 +770,14 @@ end) --- @param name string --- @param completion_result lsp.CompletionList +--- @param trigger_chars? string[] --- @return integer -local function create_server(name, completion_result) +local function create_server(name, completion_result, trigger_chars) return exec_lua(function() local server = _G._create_server({ capabilities = { completionProvider = { - triggerCharacters = { '.' }, + triggerCharacters = trigger_chars or { '.' }, }, }, handlers = { @@ -793,6 +794,7 @@ local function create_server(name, completion_result) cmd = server.cmd, on_attach = function(client, bufnr0) vim.lsp.completion.enable(true, client.id, bufnr0, { + autotrigger = trigger_chars ~= nil, convert = function(item) return { abbr = item.label:gsub('%b()', '') } end, @@ -957,6 +959,39 @@ describe('vim.lsp.completion: protocol', function() end) end) + it('insert char triggers clients matching trigger characters', function() + local results1 = { + isIncomplete = false, + items = { + { + label = 'hello', + }, + }, + } + create_server('dummy1', results1, { 'e' }) + local results2 = { + isIncomplete = false, + items = { + { + label = 'hallo', + }, + }, + } + create_server('dummy2', results2, { 'h' }) + + feed('h') + exec_lua(function() + vim.v.char = 'h' + vim.cmd.startinsert() + vim.api.nvim_exec_autocmds('InsertCharPre', {}) + end) + + assert_matches(function(matches) + eq(1, #matches) + eq('hallo', matches[1].word) + end) + end) + it('executes commands', function() local completion_list = { isIncomplete = false, |