diff options
author | glepnir <glephunter@gmail.com> | 2024-08-23 03:42:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-22 21:42:27 +0200 |
commit | 1f5bcc7c4ed7a68ae4e23933aee04c50b4df8bb5 (patch) | |
tree | 49e13c9e7bbb791055fcd858482fb8cee8911560 /test/functional/plugin/lsp/completion_spec.lua | |
parent | e48179f31e6503bfa86bf08538e64456e96446a8 (diff) | |
download | rneovim-1f5bcc7c4ed7a68ae4e23933aee04c50b4df8bb5.tar.gz rneovim-1f5bcc7c4ed7a68ae4e23933aee04c50b4df8bb5.tar.bz2 rneovim-1f5bcc7c4ed7a68ae4e23933aee04c50b4df8bb5.zip |
feat(lsp): completion opts support custom item conversion (#30060)
Problem: Some items of completion results include function signatures that can
cause the pum to be very long when a function has many params, because pum
scales with the longest word/abbr.
Solution: add custom covert function that can customise abbr to remove params.
Diffstat (limited to 'test/functional/plugin/lsp/completion_spec.lua')
-rw-r--r-- | test/functional/plugin/lsp/completion_spec.lua | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/test/functional/plugin/lsp/completion_spec.lua b/test/functional/plugin/lsp/completion_spec.lua index aad7e350ee..766dd16541 100644 --- a/test/functional/plugin/lsp/completion_spec.lua +++ b/test/functional/plugin/lsp/completion_spec.lua @@ -495,7 +495,9 @@ describe('vim.lsp.completion: protocol', function() bufnr = vim.api.nvim_get_current_buf() vim.api.nvim_win_set_buf(0, bufnr) return vim.lsp.start({ name = 'dummy', cmd = server.cmd, on_attach = function(client, bufnr) - vim.lsp.completion.enable(true, client.id, bufnr) + vim.lsp.completion.enable(true, client.id, bufnr, { convert = function(item) + return { abbr = item.label:gsub('%b()', '')} + end}) end}) ]], completion_result @@ -700,4 +702,21 @@ describe('vim.lsp.completion: protocol', function() eq(true, exec_lua('return _G.called')) end) end) + + it('custom word/abbar format', function() + create_server({ + isIncomplete = false, + items = { + { + label = 'foo(bar)', + }, + }, + }) + + feed('ifo') + trigger_at_pos({ 1, 1 }) + assert_matches(function(matches) + eq('foo', matches[1].abbr) + end) + end) end) |