diff options
Diffstat (limited to 'runtime/lua/vim/lsp/codelens.lua')
-rw-r--r-- | runtime/lua/vim/lsp/codelens.lua | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/runtime/lua/vim/lsp/codelens.lua b/runtime/lua/vim/lsp/codelens.lua index 20b203fe99..9eb64c9a2e 100644 --- a/runtime/lua/vim/lsp/codelens.lua +++ b/runtime/lua/vim/lsp/codelens.lua @@ -31,15 +31,15 @@ local function execute_lens(lens, bufnr, client_id) local line = lens.range.start.line api.nvim_buf_clear_namespace(bufnr, namespaces[client_id], line, line + 1) + local client = vim.lsp.get_client_by_id(client_id) + assert(client, 'Client is required to execute lens, client_id=' .. client_id) local command = lens.command - local fn = vim.lsp.commands[command.command] + local fn = client.commands[command.command] or vim.lsp.commands[command.command] if fn then fn(command, { bufnr = bufnr, client_id = client_id }) return end -- Need to use the client that returned the lens → must not use buf_request - local client = vim.lsp.get_client_by_id(client_id) - assert(client, 'Client is required to execute lens, client_id=' .. client_id) local command_provider = client.server_capabilities.executeCommandProvider local commands = type(command_provider) == 'table' and command_provider.commands or {} if not vim.tbl_contains(commands, command.command) then @@ -91,16 +91,16 @@ function M.run() local option = options[1] execute_lens(option.lens, bufnr, option.client) else - local options_strings = {"Code lenses:"} - for i, option in ipairs(options) do - table.insert(options_strings, string.format('%d. %s', i, option.lens.command.title)) - end - local choice = vim.fn.inputlist(options_strings) - if choice < 1 or choice > #options then - return - end - local option = options[choice] - execute_lens(option.lens, bufnr, option.client) + vim.ui.select(options, { + prompt = 'Code lenses:', + format_item = function(option) + return option.lens.command.title + end, + }, function(option) + if option then + execute_lens(option.lens, bufnr, option.client) + end + end) end end @@ -138,7 +138,8 @@ function M.display(lenses, bufnr, client_id) end end if #chunks > 0 then - api.nvim_buf_set_extmark(bufnr, ns, i, 0, { virt_text = chunks }) + api.nvim_buf_set_extmark(bufnr, ns, i, 0, { virt_text = chunks, + hl_mode="combine" }) end end end @@ -199,7 +200,8 @@ local function resolve_lenses(lenses, bufnr, client_id, callback) ns, lens.range.start.line, 0, - { virt_text = {{ lens.command.title, 'LspCodeLens' }} } + { virt_text = {{ lens.command.title, 'LspCodeLens' }}, + hl_mode="combine" } ) end countdown() |