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 /README.md | |
| 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 'README.md')
| -rw-r--r-- | README.md | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -71,6 +71,8 @@ Plug 'williamboman/nvim-lsp-installer' ```lua local lsp_installer = require("nvim-lsp-installer") +-- 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 = {} @@ -85,15 +87,20 @@ lsp_installer.on_server_ready(function(server) 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): +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). ```lua local lsp_installer_servers = require'nvim-lsp-installer.servers' -local ok, rust_analyzer = lsp_installer_servers.get_server("rust_analyzer") -if ok then - if not rust_analyzer:is_installed() then - rust_analyzer:install() +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 ``` |
