variables and member fields (constants)
@lsp.mod.static Class members (static members)
==============================================================================
EVENTS *lsp-events*
LspAttach *LspAttach*
After an LSP client performs "initialize" and attaches to a buffer. The
|autocmd-pattern| is the buffer name. The client ID is passed in the
Lua handler |event-data| argument.
Example: >lua
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(ev)
local client = vim.lsp.get_client_by_id(ev.data.client_id)
-- ...
end
})
<
Note: If the LSP server performs dynamic registration, capabilities may be
registered any time _after_ LspAttach. In that case you may want to handle
the "registerCapability" event.
Example: >lua
vim.lsp.handlers['client/registerCapability'] = (function(overridden)
return function(err, res, ctx)
local result = overridden(err, res, ctx)
local client = vim.lsp.get_client_by_id(ctx.client_id)
if not client then
return
end
for bufnr, _ in pairs(client.attached_buffers) do
-- Call your custom on_attach logic...
-- my_on_attach(client, bufnr)
end
return result
end
end)(vim.lsp.handlers['client/registerCapability'])
LspDetach *LspDetach*
Just before an LSP client detaches from a buffer. The |autocmd-pattern| is
the buffer name. The client ID is passed in the Lua handler |event-data|
argument.
Example: >lua
vim.api.nvim_create_autocmd('LspDetach', {
callback = function(args)
-- Get the detaching client
local client = vim.lsp.get_client_by_id(args.data.client_id)
-- Remove the autocommand to format the buffer on save, if it exists
if client:supports_method('textDocument/formatting') then
vim.api.nvim_clear_autocmds({
event = 'BufWritePre',
buffer = args.buf,
})
end
end,
})
<
LspNotify *LspNotify*
This event is triggered after each successful notification sent to an
LSP server.
The client_id, LSP method, and parameters are sent in the Lua handler
|event-data| table argument.
Example: >lua
vim.api.nvim_create_autocmd('LspNotify', {
callback = function(args)
local bufnr = args.buf
local client_id = args.data.client_id
local method = args.data.method
local params = args.data.params
-- do something with the notification
if method == 'textDocument/...' then
update_buffer(bufnr)
end
end,
})
<
LspProgress *LspProgress*
Upon receipt of a progress notification from the server. Notifications can
be polled from a `progress` ring buffer of a |vim.lsp.Client| or use
|vim.lsp.status()| to get an aggregate message.
If the server sends a "work done progress", the `pattern` is set to `kind`
(one of `begin`, `report` or `end`).
The Lua handler |event-data| argument has `client_id` and `params`
properties, where `params` is the request params sent by the server (see
`lsp.ProgressParams`).
Example: >vim
autocmd LspProgress * redrawstatus
<
LspRequest *LspRequest*
For each request sent to an LSP server, this event is triggered for
every change to the request's status. The status can be one of
`pending`, `complete`, or `cancel` and is sent as the {type} on the
"data" table passed to the callback function.
It triggers when the initial request is sent ({type} == `pending`) and
when the LSP server responds ({type}