around {client.rpc.request} with some additional
checks for capabilities and handler availability.
Parameters: ~
• {method} (`string`) LSP method name.
• {params} (`table?`) LSP request params.
• {handler} (`lsp.Handler?`) Response |lsp-handler| for this method.
• {bufnr} (`integer?`) (default: 0) Buffer handle, or 0 for current.
Return (multiple): ~
(`boolean`) status indicates whether the request was successful. If it
is `false`, then it will always be `false` (the client has shutdown).
(`integer?`) request_id Can be used with |Client:cancel_request()|.
`nil` is request failed.
See also: ~
• |vim.lsp.buf_request_all()|
*Client:request_sync()*
Client:request_sync({method}, {params}, {timeout_ms}, {bufnr})
Sends a request to the server and synchronously waits for the response.
This is a wrapper around |Client:request()|
Parameters: ~
• {method} (`string`) LSP method name.
• {params} (`table`) LSP request params.
• {timeout_ms} (`integer?`) Maximum time in milliseconds to wait for a
result. Defaults to 1000
• {bufnr} (`integer?`) (default: 0) Buffer handle, or 0 for
current.
Return (multiple): ~
(`{err: lsp.ResponseError?, result:any}?`) `result` and `err` from the
|lsp-handler|. `nil` is the request was unsuccessful
(`string?`) err On timeout, cancel or error, where `err` is a string
describing the failure reason.
See also: ~
• |vim.lsp.buf_request_sync()|
Client:stop({force}) *Client:stop()*
Stops a client, optionally with force.
By default, it will just request the server to shutdown without force. If
you request to stop a client which has previously been requested to
shutdown, it will automatically escalate and force shutdown.
Parameters: ~
• {force} (`boolean?`)
Client:supports_method({method}, {bufnr}) *Client:supports_method()*
Checks if a client supports a given method. Always returns true for
unknown off-spec methods.
Note: Some language server capabilities can be file specific.
Parameters: ~
• {method} (`string`)
• {bufnr} (`integer?`)
==============================================================================
Lua module: vim.lsp.buf *lsp-buf*
The `vim.lsp.buf_…` functions perform operations for LSP clients attached to
the current buffer.
*vim.lsp.ListOpts*
Fields: ~
• {on_list}? (`fun(t: vim.lsp.LocationOpts.OnList)`) list-handler
replacing the default handler. Called for any non-empty
result. This table can be used with |setqflist()| or
|setloclist()|. E.g.: >lua
local function on_list(options)
vim.fn.setqflist({}, ' ', options)
vim.cmd.cfirst()
end
vim.lsp.buf.definition({ on_list = on_list })
vim.lsp.buf.references(nil, { on_list = on_list })
<
• {loclist}? (`boolean`) Whether to use the |location-list| or the
|quickfix| list in the default handler. >lua
vim.lsp.buf.definition({ loclist = true })
vim.lsp.buf.references(nil, { loclist = false })
<
*vim.lsp.LocationOpts*
Extends: |vim.lsp.ListOpts|
Fields: ~
• {reuse_win}? (`boolean`) Jump to existing window if buffer is already
open.
*vim.lsp.LocationOpts.OnList*
Fields: ~
• {items} (`table[]`) Structured like |setqflist-what|
• {title}? (`string`) Title for the list.
• {context}? (`{ bufnr: integer, method: string }`) Subset of `ctx`