diff options
| author | William Boman <william@redwill.se> | 2022-04-27 21:20:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-27 21:20:45 +0200 |
| commit | 090c8a87b31de5c5a21eebc55adb22ddab625015 (patch) | |
| tree | 3c92027c937bcca88547d2654d91f24574653634 /lua/nvim-lsp-installer/servers/init.lua | |
| parent | run autogen_metadata.lua (diff) | |
| download | mason-090c8a87b31de5c5a21eebc55adb22ddab625015.tar mason-090c8a87b31de5c5a21eebc55adb22ddab625015.tar.gz mason-090c8a87b31de5c5a21eebc55adb22ddab625015.tar.bz2 mason-090c8a87b31de5c5a21eebc55adb22ddab625015.tar.lz mason-090c8a87b31de5c5a21eebc55adb22ddab625015.tar.xz mason-090c8a87b31de5c5a21eebc55adb22ddab625015.tar.zst mason-090c8a87b31de5c5a21eebc55adb22ddab625015.zip | |
feat: integrate with lspconfig's on_setup hook (#631)
* feat: integrate with lspconfig's on_setup hook
* fix!: don't use aliased installation directories if new .setup() fn is used
This makes it so servers are always installed in a directory name that
corresponds with the server name. The reason aliased installation directories
is supported is lost on me, but it's legacy and complicates things
unnecessarily.
This is a breaking change for users who previously were using the `.on_server_ready()`
hook, and now transitioned to setting up servers directly via lspconfig.
These users will need to reinstall the server.
* fix: block usage of the deprecated server:setup() method if new setup method is used
* fix: allow passing no arg to setup()
* docs: ok final.v3 readme
Diffstat (limited to 'lua/nvim-lsp-installer/servers/init.lua')
| -rw-r--r-- | lua/nvim-lsp-installer/servers/init.lua | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lua/nvim-lsp-installer/servers/init.lua b/lua/nvim-lsp-installer/servers/init.lua index efca1dd5..9af4c1bb 100644 --- a/lua/nvim-lsp-installer/servers/init.lua +++ b/lua/nvim-lsp-installer/servers/init.lua @@ -2,6 +2,7 @@ local Data = require "nvim-lsp-installer.data" local path = require "nvim-lsp-installer.path" local fs = require "nvim-lsp-installer.fs" local settings = require "nvim-lsp-installer.settings" +local log = require "nvim-lsp-installer.log" local M = {} @@ -180,15 +181,22 @@ end ---@param server_name string ---@return string local function get_server_install_dir(server_name) - return INSTALL_DIRS[server_name] or server_name + log.fmt_trace("Getting server installation dirname. uses_new_setup=%s", settings.uses_new_setup) + if settings.uses_new_setup then + return server_name + else + return INSTALL_DIRS[server_name] or server_name + end end function M.get_server_install_path(dirname) + log.trace("Getting server installation path", settings.current.install_root_dir, dirname) return path.concat { settings.current.install_root_dir, dirname } end ---@param server_name string function M.is_server_installed(server_name) + log.trace("Checking if server is installed", server_name) local scanned_server_dirs = scan_server_roots() local dirname = get_server_install_dir(server_name) return scanned_server_dirs[dirname] or false @@ -213,6 +221,7 @@ function M.get_server(server_name) local ok, server_factory = pcall(require, ("nvim-lsp-installer.servers.%s"):format(server_name)) if ok then + log.trace("Initializing core server", server_name) INITIALIZED_SERVERS[server_name] = server_factory( server_name, M.get_server_install_path(get_server_install_dir(server_name)) |
