diff options
Diffstat (limited to 'runtime/doc/lsp.txt')
-rw-r--r-- | runtime/doc/lsp.txt | 147 |
1 files changed, 72 insertions, 75 deletions
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index 29c08fb32d..5103cc223f 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -901,12 +901,11 @@ start({config}, {opts}) *vim.lsp.start()* the current buffer to the client. Example: >lua - - vim.lsp.start({ - name = 'my-server-name', - cmd = {'name-of-language-server-executable'}, - root_dir = vim.fs.dirname(vim.fs.find({'pyproject.toml', 'setup.py'}, { upward = true })[1]), - }) + vim.lsp.start({ + name = 'my-server-name', + cmd = {'name-of-language-server-executable'}, + root_dir = vim.fs.dirname(vim.fs.find({'pyproject.toml', 'setup.py'}, { upward = true })[1]), + }) < See |vim.lsp.start_client()| for all available options. The most important @@ -1078,9 +1077,9 @@ status() *vim.lsp.status()* stop_client({client_id}, {force}) *vim.lsp.stop_client()* Stops a client(s). - You can also use the `stop()` function on a |vim.lsp.client| object. To stop all clients: >lua - - vim.lsp.stop_client(vim.lsp.get_clients()) + You can also use the `stop()` function on a |vim.lsp.client| object. To + stop all clients: >lua + vim.lsp.stop_client(vim.lsp.get_clients()) < By default asks the server to shutdown, unless stop was requested already @@ -1196,10 +1195,10 @@ definition({options}) *vim.lsp.buf.definition()* document_highlight() *vim.lsp.buf.document_highlight()* Send request to the server to resolve document highlights for the current text document position. This request can be triggered by a key mapping or - by events such as `CursorHold` , e.g.: >vim - autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight() - autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight() - autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references() + by events such as `CursorHold`, e.g.: >vim + autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight() + autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight() + autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references() < Note: Usage of |vim.lsp.buf.document_highlight()| requires the following @@ -1242,12 +1241,12 @@ format({options}) *vim.lsp.buf.format()* buffer (0). • filter (function|nil): Predicate used to filter clients. Receives a client as argument and must return a boolean. - Clients matching the predicate are included. Example: • >lua + Clients matching the predicate are included. Example: >lua - -- Never request typescript-language-server for formatting - vim.lsp.buf.format { - filter = function(client) return client.name ~= "tsserver" end - } + -- Never request typescript-language-server for formatting + vim.lsp.buf.format { + filter = function(client) return client.name ~= "tsserver" end + } < • async boolean|nil If true the method won't block. Defaults to false. Editing the buffer while formatting @@ -1366,24 +1365,23 @@ on_diagnostic({_}, {result}, {ctx}, {config}) See |vim.diagnostic.config()| for configuration options. Handler-specific configuration can be set using |vim.lsp.with()|: >lua - - vim.lsp.handlers["textDocument/diagnostic"] = vim.lsp.with( - vim.lsp.diagnostic.on_diagnostic, { - -- Enable underline, use default values - underline = true, - -- Enable virtual text, override spacing to 4 - virtual_text = { - spacing = 4, - }, - -- Use a function to dynamically turn signs off - -- and on, using buffer local variables - signs = function(namespace, bufnr) - return vim.b[bufnr].show_signs == true - end, - -- Disable a feature - update_in_insert = false, - } - ) + vim.lsp.handlers["textDocument/diagnostic"] = vim.lsp.with( + vim.lsp.diagnostic.on_diagnostic, { + -- Enable underline, use default values + underline = true, + -- Enable virtual text, override spacing to 4 + virtual_text = { + spacing = 4, + }, + -- Use a function to dynamically turn signs off + -- and on, using buffer local variables + signs = function(namespace, bufnr) + return vim.b[bufnr].show_signs == true + end, + -- Disable a feature + update_in_insert = false, + } + ) < Parameters: ~ @@ -1395,24 +1393,23 @@ on_publish_diagnostics({_}, {result}, {ctx}, {config}) See |vim.diagnostic.config()| for configuration options. Handler-specific configuration can be set using |vim.lsp.with()|: >lua - - vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( - vim.lsp.diagnostic.on_publish_diagnostics, { - -- Enable underline, use default values - underline = true, - -- Enable virtual text, override spacing to 4 - virtual_text = { - spacing = 4, - }, - -- Use a function to dynamically turn signs off - -- and on, using buffer local variables - signs = function(namespace, bufnr) - return vim.b[bufnr].show_signs == true - end, - -- Disable a feature - update_in_insert = false, - } - ) + vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( + vim.lsp.diagnostic.on_publish_diagnostics, { + -- Enable underline, use default values + underline = true, + -- Enable virtual text, override spacing to 4 + virtual_text = { + spacing = 4, + }, + -- Use a function to dynamically turn signs off + -- and on, using buffer local variables + signs = function(namespace, bufnr) + return vim.b[bufnr].show_signs == true + end, + -- Disable a feature + update_in_insert = false, + } + ) < Parameters: ~ @@ -1457,7 +1454,7 @@ refresh() *vim.lsp.codelens.refresh()* It is recommended to trigger this using an autocmd or via keymap. Example: >vim - autocmd BufEnter,CursorHold,InsertLeave <buffer> lua vim.lsp.codelens.refresh() + autocmd BufEnter,CursorHold,InsertLeave <buffer> lua vim.lsp.codelens.refresh() < run() *vim.lsp.codelens.run()* @@ -1534,8 +1531,7 @@ start({bufnr}, {client_id}, {opts}) *vim.lsp.semantic_tokens.start()* server that supports it, you can delete the semanticTokensProvider table from the {server_capabilities} of your client in your |LspAttach| callback or your configuration's `on_attach` callback: >lua - - client.server_capabilities.semanticTokensProvider = nil + client.server_capabilities.semanticTokensProvider = nil < Parameters: ~ @@ -1565,15 +1561,14 @@ Lua module: vim.lsp.handlers *lsp-handlers* hover({_}, {result}, {ctx}, {config}) *vim.lsp.handlers.hover()* |lsp-handler| for the method "textDocument/hover" >lua - - vim.lsp.handlers["textDocument/hover"] = vim.lsp.with( - vim.lsp.handlers.hover, { - -- Use a sharp border with `FloatBorder` highlights - border = "single", - -- add the title in hover float window - title = "hover" - } - ) + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with( + vim.lsp.handlers.hover, { + -- Use a sharp border with `FloatBorder` highlights + border = "single", + -- add the title in hover float window + title = "hover" + } + ) < Parameters: ~ @@ -1585,18 +1580,20 @@ hover({_}, {result}, {ctx}, {config}) *vim.lsp.handlers.hover()* *vim.lsp.handlers.signature_help()* signature_help({_}, {result}, {ctx}, {config}) - |lsp-handler| for the method "textDocument/signatureHelp". The active - parameter is highlighted with |hl-LspSignatureActiveParameter|. >lua - - vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with( - vim.lsp.handlers.signature_help, { - -- Use a sharp border with `FloatBorder` highlights - border = "single" - } - ) + |lsp-handler| for the method "textDocument/signatureHelp". + + The active parameter is highlighted with |hl-LspSignatureActiveParameter|. >lua + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with( + vim.lsp.handlers.signature_help, { + -- Use a sharp border with `FloatBorder` highlights + border = "single" + } + ) < Parameters: ~ + • {result} (table) Response from the language server + • {ctx} (table) Client context • {config} (table) Configuration table. • border: (default=nil) • Add borders to the floating window |