aboutsummaryrefslogtreecommitdiffstats
path: root/doc/lspconfig.txt
diff options
context:
space:
mode:
Diffstat (limited to 'doc/lspconfig.txt')
-rw-r--r--doc/lspconfig.txt63
1 files changed, 39 insertions, 24 deletions
diff --git a/doc/lspconfig.txt b/doc/lspconfig.txt
index 70339a8b..b5f2c4aa 100644
--- a/doc/lspconfig.txt
+++ b/doc/lspconfig.txt
@@ -215,12 +215,12 @@ The global defaults for all servers can be overridden by extending the
if params and params.type <= vim.lsp.protocol.MessageType.Log then
vim.lsp.handlers["window/logMessage"](err, method, params, client_id)
end
- end;
+ end,
["window/showMessage"] = function(err, method, params, client_id)
if params and params.type <= vim.lsp.protocol.MessageType.Warning.Error then
vim.lsp.handlers["window/showMessage"](err, method, params, client_id)
end
- end;
+ end,
}
}
)
@@ -264,35 +264,49 @@ The `configs` module is a singleton where configs are defined. The schema for
validating using `vim.validate` is:
>
configs.SERVER_NAME = {
- default_config = {'t'};
- on_new_config = {'f', true};
- on_attach = {'f', true};
- commands = {'t', true};
- docs = {'t', true};
+ default_config = {'t'},
+ on_new_config = {'f', true},
+ on_attach = {'f', true},
+ commands = {'t', true},
+ docs = {'t', true},
}
<
where the structure of the docs table is as follows:
>
docs = {
- description = {'s', true};
- default_config = {'t', true};
+ description = {'s', true},
+ default_config = {'t', true},
}
<
`commands` is a map of `name:definition` key:value pairs, where `definition`
is a list whose first value is a function implementing the command, and the
rest are either array values which will be formed into flags for the command,
-or special keys like `description`. Example:
+or special keys like `description`.
+
+Warning: Commands is deprecated and will be removed in future releases.
+It is recommended to use `vim.api.nvim_create_user_command()` instead in an `on_attach` function.
+
+Example:
>
- commands = {
- TexlabBuild = {
- function()
- buf_build(0)
- end;
- "-range";
- description = "Build the current buffer";
- };
- };
+ local function organize_imports()
+ local params = {
+ command = 'pyright.organizeimports',
+ arguments = { vim.uri_from_bufnr(0) },
+ }
+ vim.lsp.buf.execute_command(params)
+ end
+
+ local on_attach = function(client, bufnr)
+ if client.name == "pyright" then
+ vim.api.nvim_create_user_command("PyrightOrganizeImports", organize_imports, {desc = 'Organize Imports'})
+ end
+ end
+
+ require("lspconfig")['pyright'].setup({
+ on_attach = on_attach
+ })
<
+
The `configs.__newindex` metamethod consumes the config definition and returns
an object with a `setup()` method, to be invoked by users:
>
@@ -305,6 +319,7 @@ Example:
>
configs.texlab.buf_build = buf_build
<
+
==============================================================================
ADDING NEW SERVERS *lspconfig-new*
@@ -320,13 +335,13 @@ The steps for adding and enabling a new server configuration are:
if not configs.foo_lsp then
configs.foo_lsp = {
default_config = {
- cmd = {'/home/neovim/lua-language-server/run.sh'};
- filetypes = {'lua'};
+ cmd = {'/home/neovim/lua-language-server/run.sh'},
+ filetypes = {'lua'},
root_dir = function(fname)
return lspconfig.util.find_git_ancestor(fname)
- end;
- settings = {};
- };
+ end,
+ settings = {},
+ },
}
end