From bc6dd6050e4ab710bbbfb1a3e6d2e315f1232734 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Wed, 3 Nov 2021 14:11:10 +0100 Subject: fix: add server setup example (#192) Co-authored-by: William Boman --- doc/nvim-lsp-installer.txt | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'doc') 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* -- cgit v1.2.3-70-g09d2