From 095ab4eb6a02d5fd3ea4b782a0e868e2c65e4427 Mon Sep 17 00:00:00 2001 From: William Boman Date: Sun, 2 Jan 2022 17:54:56 +0100 Subject: leverage PATH for locating local executables (#283) 1. This is a breaking change for the following servers, which will have to be reinstalled: - ltex - clangd 2. This is a breaking change for users who reach into the default options (for example via server:get_default_options()) to access the `cmd` property. nvim-lsp-installer no longer provides the `cmd` (except in a few instances), but instead provides an amended PATH which allows neovim's LSP client to locate the locally installed executable. To access the `cmd`, simply access it via lspconfig instead, for example like so: local default_config = require("lspconfig.server_configurations.rust_analyzer").default_config print("I can now access the cmd governed by lspconfig:", default_config.cmd) 3. This is a breaking change for 3rd party use cases that makes use of the `executable()` APIs (e.g., `npm.executable(root_dir, "tsserver")`). The recommended usage is to instead to use the canonical name of the command ("tsserver"), while providing an amended PATH, for example: local npm = require("nvim-lsp-installer.installers.npm") local server = server.Server:new { ..., root_dir = root_dir, installer = npm.packages { "tsserver" }, default_options = { cmd = { "tsserver" }, cmd_env = npm.env(root_dir), } } --- lua/nvim-lsp-installer/path.lua | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'lua/nvim-lsp-installer/path.lua') diff --git a/lua/nvim-lsp-installer/path.lua b/lua/nvim-lsp-installer/path.lua index 533be48d..5d3fcee4 100644 --- a/lua/nvim-lsp-installer/path.lua +++ b/lua/nvim-lsp-installer/path.lua @@ -27,17 +27,6 @@ function M.concat(path_components) return table.concat(path_components, sep) end --- @param relpath string The relative path to get the realpath(1) to. --- @param depth number The depth in the call stack to introspect. This effectively controls which stack frame should be used when producing the realpath. --- The file of the elected stack frame will be used as the "starting point" for the provided relpath. --- --- @return The realpath (absolute path). Note that this will currently produce results such as /Users/zuck/./script.js which may not be compatible with some tools. -function M.realpath(relpath, depth) - local callsite_abs_path = debug.getinfo(depth or 2, "S").source:sub(2) - local normalized_relpath = relpath:gsub("./", "") - return M.concat { vim.fn.fnamemodify(callsite_abs_path, ":h"), normalized_relpath } -end - function M.is_subdirectory(root_path, path) return root_path == path or path:sub(1, #root_path + 1) == root_path .. sep end -- cgit v1.2.3-70-g09d2