|lsp-handler| for the method `textDocument/codeLens`
Parameters: ~
• {err} (`lsp.ResponseError?`)
• {result} (`lsp.CodeLens[]`)
• {ctx} (`lsp.HandlerContext`)
refresh({opts}) *vim.lsp.codelens.refresh()*
Refresh the lenses.
It is recommended to trigger this using an autocmd or via keymap.
Example: >vim
autocmd BufEnter,CursorHold,InsertLeave <buffer> lua vim.lsp.codelens.refresh({ bufnr = 0 })
<
Parameters: ~
• {opts} (`table?`) Optional fields
• {bufnr} (`integer?`) filter by buffer. All buffers if nil, 0
for current buffer
run() *vim.lsp.codelens.run()*
Run the code lens in the current line
save({lenses}, {bufnr}, {client_id}) *vim.lsp.codelens.save()*
Store lenses for a specific buffer and client
Parameters: ~
• {lenses} (`lsp.CodeLens[]?`) lenses to store
• {bufnr} (`integer`)
• {client_id} (`integer`)
==============================================================================
Lua module: vim.lsp.completion *lsp-completion*
The `vim.lsp.completion` module enables insert-mode completion driven by an
LSP server. Call `enable()` to make it available through Nvim builtin
completion (via the |CompleteDone| event). Specify `autotrigger=true` to
activate "auto-completion" when you type any of the server-defined
`triggerCharacters`. Use CTRL-Y to select an item from the completion menu.
|complete_CTRL-Y|
Example: activate LSP-driven auto-completion: >lua
-- Works best with completeopt=noselect.
-- Use CTRL-Y to select an item. |complete_CTRL-Y|
vim.cmd[[set completeopt+=menuone,noselect,popup]]
vim.lsp.start({
name = 'ts_ls',
cmd = …,
on_attach = function(client, bufnr)
vim.lsp.completion.enable(true, client.id, bufnr, {
autotrigger = true,
convert = function(item)
return { abbr = item.label:gsub('%b()', '') }
end,
})
end,
})
<
*lsp-autocompletion*
The LSP `triggerCharacters` field decides when to trigger autocompletion. If
you want to trigger on EVERY keypress you can either:
• Extend `client.server_capabilities.completionProvider.triggerCharacters` on
`LspAttach`, before you call
`vim.lsp.completion.enable(… {autotrigger=true})`. See the |lsp-attach|
example.
• Call `vim.lsp.completion.get()` from the handler described at
|compl-autocomplete|.
*vim.lsp.completion.enable()*
enable({enable}, {client_id}, {bufnr}, {opts})
Enables or disables completions from the given language client in the
given buffer. Effects of enabling completions are:
• Calling |vim.lsp.completion.get()| uses the enabled clients to retrieve
completion candidates
• Accepting a completion candidate using `<c-y>` applies side effects like
expanding snippets, text edits (e.g. insert import statements) and
executing associated commands. This works for completions triggered via
autotrigger, omnifunc or completion.get()
Example: |lsp-attach| |lsp-completion|
Note: the behavior of `autotrigger=true` is controlled by the LSP
`triggerCharacters` field. You can override it on LspAttach, see
|lsp-autocompletion|.
Parameters: ~
• {enable} (`boolean`) True to enable, false to disable
• {client_id} (`integer`) Client ID
• {bufnr} (`integer`) Buffer handle, or 0 for the current buffer
• {opts} (`table?`) A table with the following fields:
• {autotrigger}? (`boolean`) (default: false) When true,
completion triggers automatically based on the server's
`triggerCharacters`.
• {convert}? (`fun(item: lsp.CompletionItem):