Attributes: ~
Since: 0.11.0
Parameters: ~
• {kind} (`lsp.FoldingRangeKind`) Kind to close, one of "comment",
"imports" or "region".
• {winid} (`integer?`) Defaults to the current window.
foldexpr({lnum}) *vim.lsp.foldexpr()*
Provides an interface between the built-in client and a `foldexpr`
function.
To use, set 'foldmethod' to "expr" and set the value of 'foldexpr': >lua
vim.o.foldmethod = 'expr'
vim.o.foldexpr = 'v:lua.vim.lsp.foldexpr()'
<
Or use it only when supported by checking for the
"textDocument/foldingRange" capability in an |LspAttach| autocommand.
Example: >lua
vim.o.foldmethod = 'expr'
-- Default to treesitter folding
vim.o.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
-- Prefer LSP folding if client supports it
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if client:supports_method('textDocument/foldingRange') then
local win = vim.api.nvim_get_current_win()
vim.wo[win][0].foldexpr = 'v:lua.vim.lsp.foldexpr()'
end
end,
})
<
Parameters: ~
• {lnum} (`integer`) line number
foldtext() *vim.lsp.foldtext()*
Provides a `foldtext` function that shows the `collapsedText` retrieved,
defaults to the first folded line if `collapsedText` is not provided.
formatexpr({opts}) *vim.lsp.formatexpr()*
Provides an interface between the built-in client and a `formatexpr`
function.
Currently only supports a single client. This can be set via
`setlocal formatexpr=v:lua.vim.lsp.formatexpr()` or (more typically) in
`on_attach` via
`vim.bo[bufnr].formatexpr = 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})'`.
Parameters: ~
• {opts} (`table?`) A table with the following fields:
• {timeout_ms} (`integer`, default: 500ms) The timeout period
for the formatting request..
*vim.lsp.get_buffers_by_client_id()*
get_buffers_by_client_id({client_id})
Returns list of buffers attached to client_id.
Parameters: ~
• {client_id} (`integer`) client id
Return: ~
(`integer[]`) buffers list of buffer ids
get_client_by_id({client_id}) *vim.lsp.get_client_by_id()*
Gets a client by id, or nil if the id is invalid or the client was
stopped. The returned client may not yet be fully initialized.
Parameters: ~
• {client_id} (`integer`) client id
Return: ~
(`vim.lsp.Client?`) client rpc object. See |vim.lsp.Client|.
get_clients({filter}) *vim.lsp.get_clients()*
Get active clients.
Attributes: ~
Since: 0.10.0
Parameters: ~
• {filter} (`table?`) Key-value pairs used to filter the returned
clients.
• {id}? (`integer`) Only return clients with the given id
• {bufnr}? (`integer`) Only return clients attached to this
buffer
• {name}? (`string`) Only return clients with the given name
• {method}? (`string`) Only return clients supporting the
given method
Return: ~
(`vim.lsp.Client[]`) List of |vim.lsp.Client| objects
get_log_path() *vim.lsp.get_log_path()*
Gets the path of the logfile used by the LSP client.
Return: ~
(`string`) path to log file
is_enabled({name}) *vim.lsp.is_enabled()*
Checks if the given LSP config is enabled (globally, not per-buffer).
Unlike `vim.lsp.config['…']`, this does not have the side-effect of
resolving the