nvim_runtime_lua

vim.lsp.ClientConfig

Fields23

ClientConfig.before_init : fun(params: lsp.InitializeParams, config: vim.lsp.ClientConfig) -> nil | nil
ClientConfig.capabilities : lsp.ClientCapabilities | nil

Map overriding the default capabilities defined by |vim.lsp.protocol.makeclientcapabilities()|, passed to the language server on initialization. Hint: use makeclientcapabilities() and modify its result.

  • Note: To send an empty dictionary use |vim.empty_dict()|, else it will be encoded as an
  • array.

ClientConfig.cmd : string[] | fun(dispatchers: vim.lsp.rpc.Dispatchers, config: vim.lsp.ClientConfig) -> vim.lsp.rpc.Client

Command string[] that launches the language server (treated as in |jobstart()|, must be absolute or on $PATH, shell constructs like "~" are not expanded), or function that creates an RPC client (or an in-process |lsp-server|). Function receives a dispatchers table and the resolved config, and must return an object in the form of |vim.lsp.rpc.Client|.

Example (list):

 cmd = { 'flow', 'lsp' }

Example (function):

 cmd = function(dispatchers, config)
   local cmd = vim.fn.executable('flow') == 1 and { 'flow', 'lsp' } or { 'npx', '--no-install', 'flow', 'lsp' }
   return vim.lsp.rpc.start(cmd, dispatchers)
 end
  • See |vim.lsp.rpc.Client|.
  • For TCP there is a builtin RPC client factory: |vim.lsp.rpc.connect()|
ClientConfig.cmd_cwd : nil | string

Directory where the cmd process is launched when cmd is a string array. Defaults to root_dir when available, then the current working directory.

ClientConfig.cmd_env : nil | table

Environment variables passed to the LSP process on spawn. Non-string values are coerced to string. Example:

 { PORT = 8080, HOST = '0.0.0.0' }
ClientConfig.commands : {string, fun(command: lsp.Command, ctx: table) -> nil} | nil

Map of client-defined commands overriding the global |vim.lsp.commands|.

ClientConfig.detached : nil | boolean

Daemonize the server process so that it runs in a separate process group from Nvim. Nvim will shutdown the process on exit, but if Nvim fails to exit cleanly this could leave behind orphaned server processes. (default: true)

ClientConfig.exit_timeout : nil | boolean | integer

Decides if/when to force-stop the server after sending the "shutdown" request. See |Client:stop()|. Note: when Nvim itself is exiting,

  • false: Nvim will not force-stop LSP server(s).
  • true: Nvim will force-stop LSP server(s) that did not comply with the "shutdown" request.
  • number: Nvim will wait up to exit_timeout milliseconds before performing force-stop.
  • (default: false)

ClientConfig.flags : vim.lsp.Client.Flags | nil

Experimental client flags:

ClientConfig.get_language_id : fun(bufnr: integer, filetype: string) -> string | nil
ClientConfig.handlers : {string, function} | nil

Map of LSP method names to |lsp-handler|s.

ClientConfig.init_options : lsp.LSPObject | nil

Values to pass in the initialization request as initializationOptions. See initialize in the LSP spec.

ClientConfig.name : nil | string

Name in logs and user messages. (default: client-id)

ClientConfig.offset_encoding : "utf-8" | "utf-16" | "utf-32" | nil

Called "position encoding" in LSP spec. The encoding that the LSP server expects, used for communication. Not validated. Can be modified in on_init before text is sent to the server.

ClientConfig.on_attach : elem_or_list<fun(client: vim.lsp.Client, bufnr: integer) -> nil> | nil

Callback invoked when client attaches to a buffer.

ClientConfig.on_error : fun(code: integer, err: string) -> nil | nil
ClientConfig.on_exit : elem_or_list<fun(code: integer, signal: integer, client_id: integer) -> nil> | nil

Callback invoked on client exit.

  • code: exit code of the process
  • signal: number describing the signal used to terminate (if any)
  • client_id: client handle
ClientConfig.on_init : elem_or_list<fun(client: vim.lsp.Client, init_result: lsp.InitializeResult) -> nil> | nil

Callback invoked after LSP "initialize", where result is a table of capabilities and anything else the server may send. For example, clangd sends init_result.offsetEncoding if capabilities.offsetEncoding was sent to it. You can only modify the client.offset_encoding here before any notifications are sent.

ClientConfig.root_dir : nil | string

Directory where the LSP server will base its workspaceFolders, rootUri, and rootPath on initialization.

ClientConfig.settings : lsp.LSPObject | nil

Map of language server-specific settings, decided by the client. Sent to the LS if requested via workspace/configuration. Keys are case-sensitive.

ClientConfig.trace : "off" | "messages" | "verbose" | nil

Passed directly to the language server in the initialize request. Invalid/empty values will (default: "off")

ClientConfig.workspace_folders : lsp.WorkspaceFolder[] | nil

List of workspace folders passed to the language server. For backwards compatibility rootUri and rootPath are derived from the first workspace folder in this list. Can be null if the client supports workspace folders but none are configured. See workspaceFolders in LSP spec.

ClientConfig.workspace_required : nil | boolean

Server requires a workspace (no "single file" support). Note: Without a workspace, cross-file features (navigation, hover) may or may not work depending on the language server, even if the server doesn't require a workspace. (default: false)