Skip to content

Commands

LspZeroFormat

Formats the current buffer or range. Under the hood lsp-zero is using the function vim.lsp.buf.format(). If the "bang" is provided formatting will be asynchronous (ex: LspZeroFormat!). If you provide the name of a language server as a first argument it will try to format only using that server. Otherwise, it will use every active language server with formatting capabilities. With the timeout parameter you can configure the time in milliseconds to wait for the response of the formatting requests.

Examples:

Format buffer using all active language servers with formatting capabilities.

vim
:LspZeroFormat

Format buffer using lua_ls and set a timeout (in milliseconds).

vim
:LspZeroFormat lua_ls timeout=1000

LspZeroSetupServers

It takes a space separated list of servers and configures them. If the bang is provided the root directory will be set to the current working directory.

Example:

Setup the language servers for gleam and lua.

vim
:LspZeroSetupServers gleam lua_ls

Setup the lua language server using the current working directory as the root directory.

vim
:LspZeroSetupServers! lua_ls

LspZeroViewConfigSource

Opens a split with the source code of the configuration for a language server. So you can inspect the requirements the language server needs to attach to a buffer. You'll be able to read what filetypes it needs and the config files it looks to detect the root directory.

Example:

vim
:LspZeroViewConfigSource lua_ls

LspZeroWorkspaceRemove

Remove current folder from the workspace folders. See :help vim.lsp.buf.remove_workspace_folder().

LspZeroWorkspaceAdd

Add current folder the workspace folders. See :help vim.lsp.buf.add_workspace_folder().

LspZeroWorkspaceList

List workspace folders. See :help vim.lsp.buf.list_workspace_folders().