diff options
| author | kylo252 <59826753+kylo252@users.noreply.github.com> | 2021-11-03 14:11:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-03 14:11:10 +0100 |
| commit | bc6dd6050e4ab710bbbfb1a3e6d2e315f1232734 (patch) | |
| tree | 054b79fb18b7fd3e0760ba4ddb7c84765a65b520 /doc | |
| parent | fix attaching servers with no filetypes defined (#237) (diff) | |
| download | mason-bc6dd6050e4ab710bbbfb1a3e6d2e315f1232734.tar mason-bc6dd6050e4ab710bbbfb1a3e6d2e315f1232734.tar.gz mason-bc6dd6050e4ab710bbbfb1a3e6d2e315f1232734.tar.bz2 mason-bc6dd6050e4ab710bbbfb1a3e6d2e315f1232734.tar.lz mason-bc6dd6050e4ab710bbbfb1a3e6d2e315f1232734.tar.xz mason-bc6dd6050e4ab710bbbfb1a3e6d2e315f1232734.tar.zst mason-bc6dd6050e4ab710bbbfb1a3e6d2e315f1232734.zip | |
fix: add server setup example (#192)
Co-authored-by: William Boman <william@redwill.se>
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/nvim-lsp-installer.txt | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/doc/nvim-lsp-installer.txt b/doc/nvim-lsp-installer.txt index 78e2ebab..3cb7bf08 100644 --- a/doc/nvim-lsp-installer.txt +++ b/doc/nvim-lsp-installer.txt @@ -70,14 +70,10 @@ Then, somewhere in your initialization script (see `:h init.lua`): > local lsp_installer = require("nvim-lsp-installer") - function common_on_attach(client, bufnr) - -- ... set up buffer keymaps, etc. - end - + -- Register a handler that will be called for all installed servers. + -- Alternatively, you may also register handlers on specific server instances instead (see example below). lsp_installer.on_server_ready(function(server) - local opts = { - on_attach = common_on_attach, - } + local opts = {} -- (optional) Customize the options passed to the server -- if server.name == "tsserver" then @@ -90,6 +86,25 @@ Then, somewhere in your initialization script (see `:h init.lua`): > end) < +For more advanced use cases you may also interact with more APIs +nvim-lsp-installer has to offer, for example the following (refer +to `:help nvim-lsp-installer` for more docs): > + + local lsp_installer_servers = require'nvim-lsp-installer.servers' + + local server_available, requested_server = lsp_installer_servers.get_server("rust_analyzer") + if server_available then + requested_server:on_ready(function () + local opts = {} + requested_server:setup(opts) + end) + if not requested_server:is_installed() then + -- Queue the server to be installed + requested_server:install() + end + end +< + ============================================================================== COMMANDS *nvim-lsp-installer-commands* |
