diff options
| author | William Boman <william@redwill.se> | 2022-01-02 17:54:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-02 17:54:56 +0100 |
| commit | 095ab4eb6a02d5fd3ea4b782a0e868e2c65e4427 (patch) | |
| tree | f5d97077ad721f916c97d989906cb01f9f7d9e93 /lua | |
| parent | fix(texlab): fix installing on windows (diff) | |
| download | mason-095ab4eb6a02d5fd3ea4b782a0e868e2c65e4427.tar mason-095ab4eb6a02d5fd3ea4b782a0e868e2c65e4427.tar.gz mason-095ab4eb6a02d5fd3ea4b782a0e868e2c65e4427.tar.bz2 mason-095ab4eb6a02d5fd3ea4b782a0e868e2c65e4427.tar.lz mason-095ab4eb6a02d5fd3ea4b782a0e868e2c65e4427.tar.xz mason-095ab4eb6a02d5fd3ea4b782a0e868e2c65e4427.tar.zst mason-095ab4eb6a02d5fd3ea4b782a0e868e2c65e4427.zip | |
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),
}
}
Diffstat (limited to 'lua')
82 files changed, 206 insertions, 253 deletions
diff --git a/lua/nvim-lsp-installer/installers/composer.lua b/lua/nvim-lsp-installer/installers/composer.lua index efb5038f..c0e8fe0a 100644 --- a/lua/nvim-lsp-installer/installers/composer.lua +++ b/lua/nvim-lsp-installer/installers/composer.lua @@ -67,10 +67,4 @@ function M.install() ) end ----@param root_dir string @The directory to resolve the executable from. ----@param executable string -function M.executable(root_dir, executable) - return path.concat { root_dir, "vendor", "bin", platform.is_win and ("%s.bat"):format(executable) or executable } -end - return M diff --git a/lua/nvim-lsp-installer/installers/gem.lua b/lua/nvim-lsp-installer/installers/gem.lua index a2e3945f..62a7d222 100644 --- a/lua/nvim-lsp-installer/installers/gem.lua +++ b/lua/nvim-lsp-installer/installers/gem.lua @@ -40,17 +40,12 @@ function M.packages(packages) } end ----@param root_dir string @The directory to resolve the executable from. ----@param executable string -function M.executable(root_dir, executable) - return path.concat { root_dir, "bin", executable } -end - ---@param root_dir string function M.env(root_dir) return { GEM_HOME = root_dir, GEM_PATH = root_dir, + PATH = process.extend_path { path.concat { root_dir, "bin" } }, } end diff --git a/lua/nvim-lsp-installer/installers/go.lua b/lua/nvim-lsp-installer/installers/go.lua index 7fbc1ddc..10ac74d8 100644 --- a/lua/nvim-lsp-installer/installers/go.lua +++ b/lua/nvim-lsp-installer/installers/go.lua @@ -1,4 +1,3 @@ -local path = require "nvim-lsp-installer.path" local std = require "nvim-lsp-installer.installers.std" local installers = require "nvim-lsp-installer.installers" local Data = require "nvim-lsp-installer.data" @@ -36,10 +35,10 @@ function M.packages(packages) } end ----@param root_dir string @The directory to resolve the executable from. ----@param executable string -function M.executable(root_dir, executable) - return path.concat { root_dir, executable } +function M.env(root_dir) + return { + PATH = process.extend_path { root_dir }, + } end return M diff --git a/lua/nvim-lsp-installer/installers/npm.lua b/lua/nvim-lsp-installer/installers/npm.lua index b0ae52eb..d479d0d5 100644 --- a/lua/nvim-lsp-installer/installers/npm.lua +++ b/lua/nvim-lsp-installer/installers/npm.lua @@ -79,16 +79,17 @@ M.packages = create_installer(false) ---This is useful in situation where there's a need to install an auxiliary npm package. M.install = create_installer(true) ----Creates a server installer that executes the given executable. +---Creates a server installer that executes the given locally installed npm executable. ---@param executable string ---@param args string[] function M.exec(executable, args) ---@type ServerInstallerFunction return function(_, callback, ctx) - process.spawn(M.executable(ctx.install_dir, executable), { + process.spawn(executable, { args = args, cwd = ctx.install_dir, stdio_sink = ctx.stdio_sink, + env = process.graft_env(M.env(ctx.install_dir)), }, callback) end end @@ -109,13 +110,9 @@ function M.run(script) end ---@param root_dir string @The directory to resolve the executable from. ----@param executable string -function M.executable(root_dir, executable) - return path.concat { - root_dir, - "node_modules", - ".bin", - platform.is_win and ("%s.cmd"):format(executable) or executable, +function M.env(root_dir) + return { + PATH = process.extend_path { path.concat { root_dir, "node_modules", ".bin" } }, } end diff --git a/lua/nvim-lsp-installer/installers/pip3.lua b/lua/nvim-lsp-installer/installers/pip3.lua index 234aad98..3dd44167 100644 --- a/lua/nvim-lsp-installer/installers/pip3.lua +++ b/lua/nvim-lsp-installer/installers/pip3.lua @@ -28,6 +28,7 @@ local function create_installer(python_executable, packages) local c = process.chain { cwd = ctx.install_dir, stdio_sink = ctx.stdio_sink, + env = process.graft_env(M.env(ctx.install_dir)), } c.run(python_executable, { "-m", "venv", REL_INSTALL_DIR }) @@ -38,7 +39,7 @@ local function create_installer(python_executable, packages) local install_command = { "-m", "pip", "install", "-U" } vim.list_extend(install_command, settings.current.pip.install_args) - c.run(M.executable(ctx.install_dir, "python"), vim.list_extend(install_command, pkgs)) + c.run("python", vim.list_extend(install_command, pkgs)) c.spawn(callback) end, @@ -65,9 +66,12 @@ function M.packages(packages) end ---@param root_dir string @The directory to resolve the executable from. ----@param executable string -function M.executable(root_dir, executable) - return path.concat { root_dir, REL_INSTALL_DIR, platform.is_win and "Scripts" or "bin", executable } +function M.env(root_dir) + return { + PATH = process.extend_path { + path.concat { root_dir, REL_INSTALL_DIR, platform.is_win and "Scripts" or "bin" }, + }, + } end return M diff --git a/lua/nvim-lsp-installer/installers/std.lua b/lua/nvim-lsp-installer/installers/std.lua index a80b6f97..2d3a8155 100644 --- a/lua/nvim-lsp-installer/installers/std.lua +++ b/lua/nvim-lsp-installer/installers/std.lua @@ -217,19 +217,6 @@ function M.write_file(rel_path, contents) end end ----@param script_rel_path string @The relative path to the script file to write. ----@param abs_target_executable_path string @The absolute path to the executable that is being aliased. -function M.executable_alias(script_rel_path, abs_target_executable_path) - local windows_script = "@call %q %%" - local unix_script = [[#!/usr/bin/env sh -exec %q -]] - return installers.when { - unix = M.write_file(script_rel_path, unix_script:format(abs_target_executable_path)), - win = M.write_file(script_rel_path, windows_script:format(abs_target_executable_path)), - } -end - ---Shallow git clone. ---@param repo_url string ---@param opts {directory: string, recursive: boolean} 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 diff --git a/lua/nvim-lsp-installer/process.lua b/lua/nvim-lsp-installer/process.lua index 9316fd38..87a4b950 100644 --- a/lua/nvim-lsp-installer/process.lua +++ b/lua/nvim-lsp-installer/process.lua @@ -39,10 +39,7 @@ local initial_environ = vim.fn.environ() ---@param new_paths string[] @A list of paths to prepend the existing PATH with. function M.extend_path(new_paths) local new_path_str = table.concat(new_paths, platform.path_sep) - if initial_environ["PATH"] then - return new_path_str .. platform.path_sep .. initial_environ["PATH"] - end - return new_path_str + return ("%s%s%s"):format(new_path_str, platform.path_sep, initial_environ.PATH or "") end ---Merges the provided env param with the user's full environent. Provided env has precedence. diff --git a/lua/nvim-lsp-installer/server.lua b/lua/nvim-lsp-installer/server.lua index 1a23bbbd..153b0605 100644 --- a/lua/nvim-lsp-installer/server.lua +++ b/lua/nvim-lsp-installer/server.lua @@ -72,7 +72,7 @@ end ---Attaches this server to all current open buffers with a 'filetype' that matches the server's configured filetypes. function M.Server:attach_buffers() - log.debug("Attaching server to buffers", self.name) + log.trace("Attaching server to buffers", self.name) local lsp_server = require("lspconfig")[self.name] for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do if lsp_server.filetypes then @@ -83,7 +83,7 @@ function M.Server:attach_buffers() lsp_server.manager.try_add(bufnr) end end - log.debug("Successfully attached server to buffers", self.name) + log.trace("Successfully attached server to buffers", self.name) end ---Registers a handler (callback) to be executed when the server is ready to be setup. diff --git a/lua/nvim-lsp-installer/servers/angularls/init.lua b/lua/nvim-lsp-installer/servers/angularls/init.lua index 8492749c..7e2efa27 100644 --- a/lua/nvim-lsp-installer/servers/angularls/init.lua +++ b/lua/nvim-lsp-installer/servers/angularls/init.lua @@ -14,7 +14,7 @@ end return function(name, root_dir) local function get_cmd(workspace_dir) return { - npm.executable(root_dir, "ngserver"), + "ngserver", "--stdio", "--tsProbeLocations", table.concat(append_node_modules { root_dir, workspace_dir }, ","), @@ -37,6 +37,7 @@ return function(name, root_dir) installer = npm.packages { "@angular/language-server", "typescript" }, default_options = { cmd = get_cmd(path.cwd()), + cmd_env = npm.env(root_dir), on_new_config = function(new_config, new_root_dir) new_config.cmd = get_cmd(new_root_dir) end, diff --git a/lua/nvim-lsp-installer/servers/arduino_language_server/init.lua b/lua/nvim-lsp-installer/servers/arduino_language_server/init.lua index 3f794a65..557b0ebe 100644 --- a/lua/nvim-lsp-installer/servers/arduino_language_server/init.lua +++ b/lua/nvim-lsp-installer/servers/arduino_language_server/init.lua @@ -97,7 +97,7 @@ return function(name, root_dir) default_options = { cmd = { -- This cmd is incomplete. Users need to manually append their FQBN (e.g., -fqbn arduino:avr:nano) - go.executable(path.concat { root_dir, "arduino-language-server" }, "arduino-language-server"), + "arduino-language-server", "-cli", path.concat { root_dir, "arduino-cli", platform.is_win and "arduino-cli.exe" or "arduino-cli" }, "-cli-config", @@ -105,6 +105,7 @@ return function(name, root_dir) "-clangd", path.concat { root_dir, "clangd", "bin", platform.is_win and "clangd.bat" or "clangd" }, }, + cmd_env = go.env(path.concat { root_dir, "arduino-language-server" }), }, } end diff --git a/lua/nvim-lsp-installer/servers/bashls/init.lua b/lua/nvim-lsp-installer/servers/bashls/init.lua index 4a6b234c..e8a2553e 100644 --- a/lua/nvim-lsp-installer/servers/bashls/init.lua +++ b/lua/nvim-lsp-installer/servers/bashls/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) homepage = "https://github.com/bash-lsp/bash-language-server", installer = npm.packages { "bash-language-server" }, default_options = { - cmd = { npm.executable(root_dir, "bash-language-server"), "start" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/ccls/init.lua b/lua/nvim-lsp-installer/servers/ccls/init.lua index d5dde3e0..60a72a66 100644 --- a/lua/nvim-lsp-installer/servers/ccls/init.lua +++ b/lua/nvim-lsp-installer/servers/ccls/init.lua @@ -172,7 +172,9 @@ return function(name, root_dir) linux = linux_ccls_installer, }, default_options = { - cmd = { path.concat { root_dir, "bin", "ccls" } }, + cmd_env = { + PATH = process.extend_path { path.concat { root_dir, "bin" } }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/clangd/init.lua b/lua/nvim-lsp-installer/servers/clangd/init.lua index 5ec3e351..7aea65c3 100644 --- a/lua/nvim-lsp-installer/servers/clangd/init.lua +++ b/lua/nvim-lsp-installer/servers/clangd/init.lua @@ -1,13 +1,12 @@ local server = require "nvim-lsp-installer.server" local path = require "nvim-lsp-installer.path" +local process = require "nvim-lsp-installer.process" local Data = require "nvim-lsp-installer.data" local std = require "nvim-lsp-installer.installers.std" local platform = require "nvim-lsp-installer.platform" local context = require "nvim-lsp-installer.installers.context" return function(name, root_dir) - local script_name = platform.is_win and "clangd.bat" or "clangd" - return server.Server:new { name = name, root_dir = root_dir, @@ -26,22 +25,13 @@ return function(name, root_dir) return std.unzip_remote(ctx.github_release_file) end), context.capture(function(ctx) - -- Preferably we'd not have to write a script file that captures the installed version. - -- But in order to not break backwards compatibility for existing installations of clangd, we do it. - return std.executable_alias( - script_name, - path.concat { - root_dir, - ("clangd_%s"):format(ctx.requested_server_version), - "bin", - platform.is_win and "clangd.exe" or "clangd", - } - ) + return std.rename(("clangd_%s"):format(ctx.requested_server_version), "clangd") end), - std.chmod("+x", { "clangd" }), }, default_options = { - cmd = { path.concat { root_dir, script_name } }, + cmd_env = { + PATH = process.extend_path { path.concat { root_dir, "clangd", "bin" } }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/clojure_lsp/init.lua b/lua/nvim-lsp-installer/servers/clojure_lsp/init.lua index 3b822b9b..c1c9cde4 100644 --- a/lua/nvim-lsp-installer/servers/clojure_lsp/init.lua +++ b/lua/nvim-lsp-installer/servers/clojure_lsp/init.lua @@ -1,5 +1,5 @@ local server = require "nvim-lsp-installer.server" -local path = require "nvim-lsp-installer.path" +local process = require "nvim-lsp-installer.process" local std = require "nvim-lsp-installer.installers.std" local context = require "nvim-lsp-installer.installers.context" local Data = require "nvim-lsp-installer.data" @@ -26,7 +26,9 @@ return function(name, root_dir) std.chmod("+x", { "clojure-lsp" }), }, default_options = { - cmd = { path.concat { root_dir, "clojure-lsp" } }, + cmd_env = { + PATH = process.extend_path { root_dir }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/cmake/init.lua b/lua/nvim-lsp-installer/servers/cmake/init.lua index a2182697..f70624cb 100644 --- a/lua/nvim-lsp-installer/servers/cmake/init.lua +++ b/lua/nvim-lsp-installer/servers/cmake/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) languages = { "cmake" }, installer = pip3.packages { "cmake-language-server" }, default_options = { - cmd = { pip3.executable(root_dir, "cmake-language-server") }, + cmd_env = pip3.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/codeqlls/init.lua b/lua/nvim-lsp-installer/servers/codeqlls/init.lua index 4e2bc168..64d3a48a 100644 --- a/lua/nvim-lsp-installer/servers/codeqlls/init.lua +++ b/lua/nvim-lsp-installer/servers/codeqlls/init.lua @@ -1,30 +1,14 @@ local server = require "nvim-lsp-installer.server" -local path = require "nvim-lsp-installer.path" local std = require "nvim-lsp-installer.installers.std" local Data = require "nvim-lsp-installer.data" local platform = require "nvim-lsp-installer.platform" local context = require "nvim-lsp-installer.installers.context" +local process = require "nvim-lsp-installer.process" +local path = require "nvim-lsp-installer.path" local coalesce, when = Data.coalesce, Data.when return function(name, root_dir) - ---@param search_path string|nil - ---@return string[] - local function create_cmd(search_path) - local cmd = { - path.concat { root_dir, "codeql", platform.is_win and "codeql.cmd" or "codeql" }, - "execute", - "language-server", - "--check-errors", - "ON_CHANGE", - "-q", - } - if search_path then - table.insert(cmd, search_path) - end - return cmd - end - return server.Server:new { name = name, root_dir = root_dir, @@ -43,20 +27,9 @@ return function(name, root_dir) end), }, default_options = { - cmd = create_cmd(), - on_new_config = function(config) - if - type(config.settings.search_path) == "table" and not vim.tbl_isempty(config.settings.search_path) - then - local search_path = "--search-path=" - for _, path_entry in ipairs(config.settings.search_path) do - search_path = search_path .. vim.fn.expand(path_entry) .. ":" - end - config.cmd = create_cmd(search_path) - else - config.cmd = create_cmd() - end - end, + cmd_env = { + PATH = process.extend_path { path.concat { root_dir, "codeql" } }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/csharp_ls/init.lua b/lua/nvim-lsp-installer/servers/csharp_ls/init.lua index 956689e6..b77030cf 100644 --- a/lua/nvim-lsp-installer/servers/csharp_ls/init.lua +++ b/lua/nvim-lsp-installer/servers/csharp_ls/init.lua @@ -1,5 +1,4 @@ local server = require "nvim-lsp-installer.server" -local path = require "nvim-lsp-installer.path" local process = require "nvim-lsp-installer.process" local std = require "nvim-lsp-installer.installers.std" @@ -33,8 +32,8 @@ return function(name, root_dir) end, }, default_options = { - cmd = { - path.concat { root_dir, "csharp-ls" }, + cmd_env = { + PATH = process.extend_path { root_dir }, }, }, } diff --git a/lua/nvim-lsp-installer/servers/cssls/init.lua b/lua/nvim-lsp-installer/servers/cssls/init.lua index f99df56c..0f2c7e0c 100644 --- a/lua/nvim-lsp-installer/servers/cssls/init.lua +++ b/lua/nvim-lsp-installer/servers/cssls/init.lua @@ -1 +1 @@ -return require "nvim-lsp-installer.servers.vscode-langservers-extracted"("vscode-css-language-server", { "css" }) +return require "nvim-lsp-installer.servers.vscode-langservers-extracted" { "css" } diff --git a/lua/nvim-lsp-installer/servers/cssmodules_ls/init.lua b/lua/nvim-lsp-installer/servers/cssmodules_ls/init.lua index 48cd57a4..b1a6c188 100644 --- a/lua/nvim-lsp-installer/servers/cssmodules_ls/init.lua +++ b/lua/nvim-lsp-installer/servers/cssmodules_ls/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) languages = { "css" }, installer = npm.packages { "cssmodules-language-server" }, default_options = { - cmd = { npm.executable(root_dir, "cssmodules-language-server") }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/denols/init.lua b/lua/nvim-lsp-installer/servers/denols/init.lua index 99ecd422..ae1a856c 100644 --- a/lua/nvim-lsp-installer/servers/denols/init.lua +++ b/lua/nvim-lsp-installer/servers/denols/init.lua @@ -1,5 +1,5 @@ local server = require "nvim-lsp-installer.server" -local path = require "nvim-lsp-installer.path" +local process = require "nvim-lsp-installer.process" local platform = require "nvim-lsp-installer.platform" local Data = require "nvim-lsp-installer.data" local std = require "nvim-lsp-installer.installers.std" @@ -33,7 +33,9 @@ return function(name, root_dir) end), }, default_options = { - cmd = { path.concat { root_dir, "deno" }, "lsp" }, + cmd_env = { + PATH = process.extend_path { root_dir }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/diagnosticls/init.lua b/lua/nvim-lsp-installer/servers/diagnosticls/init.lua index 98abf552..5594eca2 100644 --- a/lua/nvim-lsp-installer/servers/diagnosticls/init.lua +++ b/lua/nvim-lsp-installer/servers/diagnosticls/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) homepage = "https://github.com/iamcco/diagnostic-languageserver", installer = npm.packages { "diagnostic-languageserver" }, default_options = { - cmd = { npm.executable(root_dir, "diagnostic-languageserver"), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/dockerls/init.lua b/lua/nvim-lsp-installer/servers/dockerls/init.lua index 595d1533..ab306ff2 100644 --- a/lua/nvim-lsp-installer/servers/dockerls/init.lua +++ b/lua/nvim-lsp-installer/servers/dockerls/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) languages = { "docker" }, installer = npm.packages { "dockerfile-language-server-nodejs" }, default_options = { - cmd = { npm.executable(root_dir, "docker-langserver"), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/dotls/init.lua b/lua/nvim-lsp-installer/servers/dotls/init.lua index 86182a17..b4655e52 100644 --- a/lua/nvim-lsp-installer/servers/dotls/init.lua +++ b/lua/nvim-lsp-installer/servers/dotls/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) languages = { "dot" }, installer = npm.packages { "dot-language-server" }, default_options = { - cmd = { npm.executable(root_dir, "dot-language-server"), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/efm/init.lua b/lua/nvim-lsp-installer/servers/efm/init.lua index 135e72e9..c665df7a 100644 --- a/lua/nvim-lsp-installer/servers/efm/init.lua +++ b/lua/nvim-lsp-installer/servers/efm/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) languages = {}, installer = go.packages { "github.com/mattn/efm-langserver" }, default_options = { - cmd = { go.executable(root_dir, "efm-langserver") }, + cmd_env = go.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/elixirls/init.lua b/lua/nvim-lsp-installer/servers/elixirls/init.lua index 181b2b49..e0f638ea 100644 --- a/lua/nvim-lsp-installer/servers/elixirls/init.lua +++ b/lua/nvim-lsp-installer/servers/elixirls/init.lua @@ -2,6 +2,7 @@ local server = require "nvim-lsp-installer.server" local path = require "nvim-lsp-installer.path" local std = require "nvim-lsp-installer.installers.std" local context = require "nvim-lsp-installer.installers.context" +local platform = require "nvim-lsp-installer.platform" return function(name, root_dir) return server.Server:new { @@ -17,7 +18,13 @@ return function(name, root_dir) std.chmod("+x", { "elixir-ls/language_server.sh" }), }, default_options = { - cmd = { path.concat { root_dir, "elixir-ls", "language_server.sh" } }, + cmd = { + path.concat { + root_dir, + "elixir-ls", + platform.is_win and "language_server.bat" or "language_server.sh", + }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/elmls/init.lua b/lua/nvim-lsp-installer/servers/elmls/init.lua index eeff7841..8d5e0041 100644 --- a/lua/nvim-lsp-installer/servers/elmls/init.lua +++ b/lua/nvim-lsp-installer/servers/elmls/init.lua @@ -9,13 +9,7 @@ return function(name, root_dir) languages = { "elm" }, installer = npm.packages { "@elm-tooling/elm-language-server", "elm", "elm-test", "elm-format" }, default_options = { - cmd = { npm.executable(root_dir, "elm-language-server") }, - init_options = { - elmPath = npm.executable(root_dir, "elm"), - elmFormatPath = npm.executable(root_dir, "elm-format"), - elmTestPath = npm.executable(root_dir, "elm-test"), - elmAnalyseTrigger = "change", - }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/ember/init.lua b/lua/nvim-lsp-installer/servers/ember/init.lua index f4ee38d7..80c417b6 100644 --- a/lua/nvim-lsp-installer/servers/ember/init.lua +++ b/lua/nvim-lsp-installer/servers/ember/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) homepage = "https://github.com/lifeart/ember-language-server", installer = npm.packages { "@lifeart/ember-language-server" }, default_options = { - cmd = { npm.executable(root_dir, "ember-language-server"), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/emmet_ls/init.lua b/lua/nvim-lsp-installer/servers/emmet_ls/init.lua index 622d0ab5..93fa181c 100644 --- a/lua/nvim-lsp-installer/servers/emmet_ls/init.lua +++ b/lua/nvim-lsp-installer/servers/emmet_ls/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) languages = { "emmet" }, installer = npm.packages { "emmet-ls" }, default_options = { - cmd = { npm.executable(root_dir, "emmet-ls"), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/erlangls/init.lua b/lua/nvim-lsp-installer/servers/erlangls/init.lua index 9815a506..787fee0b 100644 --- a/lua/nvim-lsp-installer/servers/erlangls/init.lua +++ b/lua/nvim-lsp-installer/servers/erlangls/init.lua @@ -30,14 +30,8 @@ return function(name, root_dir) end, }, default_options = { - cmd = { - path.concat { - root_dir, - "_build", - "default", - "bin", - platform.is_win and "erlang_ls.cmd" or "erlang_ls", - }, + cmd_env = { + PATH = process.extend_path { path.concat { root_dir, "_build", "default", "bin" } }, }, }, } diff --git a/lua/nvim-lsp-installer/servers/esbonio/init.lua b/lua/nvim-lsp-installer/servers/esbonio/init.lua index 7ecbf822..173eb44c 100644 --- a/lua/nvim-lsp-installer/servers/esbonio/init.lua +++ b/lua/nvim-lsp-installer/servers/esbonio/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) homepage = "https://pypi.org/project/esbonio/", installer = pip3.packages { "esbonio" }, default_options = { - cmd = { pip3.executable(root_dir, "esbonio") }, + cmd_env = pip3.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/eslint/README.md b/lua/nvim-lsp-installer/servers/eslint/README.md index 3bbcbb8b..f10cd1fa 100644 --- a/lua/nvim-lsp-installer/servers/eslint/README.md +++ b/lua/nvim-lsp-installer/servers/eslint/README.md @@ -8,7 +8,7 @@ setting. This is done when setting up the LSP server, like so: ```lua local lsp_installer = require "nvim-lsp-installer" -function common_on_attach(client, bufnr) +function common_on_attach(client, bufnr) -- add your code here end @@ -51,8 +51,8 @@ lsp_installer.on_server_ready(function (server) } if server.name == "eslint" then - local default_opts = server:get_default_options() - opts.cmd = vim.list_extend({"yarn", "node"}, default_opts.cmd) + local eslint_config = require("lspconfig.server_configurations.eslint") + opts.cmd = vim.list_extend({"yarn", "node"}, eslint_config.default_config.cmd) end server:setup(opts) diff --git a/lua/nvim-lsp-installer/servers/eslint/init.lua b/lua/nvim-lsp-installer/servers/eslint/init.lua index 67284160..8fcb06fe 100644 --- a/lua/nvim-lsp-installer/servers/eslint/init.lua +++ b/lua/nvim-lsp-installer/servers/eslint/init.lua @@ -1,4 +1 @@ -return require "nvim-lsp-installer.servers.vscode-langservers-extracted"( - "vscode-eslint-language-server", - { "eslint", "javascript", "typescript" } -) +return require "nvim-lsp-installer.servers.vscode-langservers-extracted" { "eslint", "javascript", "typescript" } diff --git a/lua/nvim-lsp-installer/servers/fortls/init.lua b/lua/nvim-lsp-installer/servers/fortls/init.lua index 079b55e3..aade0502 100644 --- a/lua/nvim-lsp-installer/servers/fortls/init.lua +++ b/lua/nvim-lsp-installer/servers/fortls/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) languages = { "fortran" }, installer = pip3.packages { "fortran-language-server" }, default_options = { - cmd = { pip3.executable(root_dir, "fortls") }, + cmd_env = pip3.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/fsautocomplete/init.lua b/lua/nvim-lsp-installer/servers/fsautocomplete/init.lua index 5c951a8a..a14a7286 100644 --- a/lua/nvim-lsp-installer/servers/fsautocomplete/init.lua +++ b/lua/nvim-lsp-installer/servers/fsautocomplete/init.lua @@ -1,5 +1,4 @@ local server = require "nvim-lsp-installer.server" -local path = require "nvim-lsp-installer.path" local process = require "nvim-lsp-installer.process" local std = require "nvim-lsp-installer.installers.std" @@ -33,9 +32,8 @@ return function(name, root_dir) end, }, default_options = { - cmd = { - path.concat { root_dir, "fsautocomplete" }, - "--background-service-enabled", + cmd_env = { + PATH = process.extend_path { root_dir }, }, }, } diff --git a/lua/nvim-lsp-installer/servers/gopls/init.lua b/lua/nvim-lsp-installer/servers/gopls/init.lua index b38cd7a6..9b1f8c09 100644 --- a/lua/nvim-lsp-installer/servers/gopls/init.lua +++ b/lua/nvim-lsp-installer/servers/gopls/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) languages = { "go" }, installer = go.packages { "golang.org/x/tools/gopls" }, default_options = { - cmd = { go.executable(root_dir, "gopls") }, + cmd_env = go.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/grammarly/init.lua b/lua/nvim-lsp-installer/servers/grammarly/init.lua index 8406edf4..1c8d7646 100644 --- a/lua/nvim-lsp-installer/servers/grammarly/init.lua +++ b/lua/nvim-lsp-installer/servers/grammarly/init.lua @@ -9,10 +9,7 @@ return function(name, root_dir) languages = {}, installer = npm.packages { "@emacs-grammarly/unofficial-grammarly-language-server" }, default_options = { - cmd = { - npm.executable(root_dir, "unofficial-grammarly-language-server"), - "--stdio", - }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/graphql/init.lua b/lua/nvim-lsp-installer/servers/graphql/init.lua index 612b5c84..c513208e 100644 --- a/lua/nvim-lsp-installer/servers/graphql/init.lua +++ b/lua/nvim-lsp-installer/servers/graphql/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) languages = { "graphql" }, installer = npm.packages { "graphql-language-service-cli", "graphql" }, default_options = { - cmd = { npm.executable(root_dir, "graphql-lsp"), "server", "-m", "stream" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/hls/init.lua b/lua/nvim-lsp-installer/servers/hls/init.lua index 198df3e5..d1987b22 100644 --- a/lua/nvim-lsp-installer/servers/hls/init.lua +++ b/lua/nvim-lsp-installer/servers/hls/init.lua @@ -1,6 +1,6 @@ local server = require "nvim-lsp-installer.server" local platform = require "nvim-lsp-installer.platform" -local path = require "nvim-lsp-installer.path" +local process = require "nvim-lsp-installer.process" local installers = require "nvim-lsp-installer.installers" local std = require "nvim-lsp-installer.installers.std" local context = require "nvim-lsp-installer.installers.context" @@ -30,9 +30,8 @@ return function(name, root_dir) }, }, default_options = { - cmd = { path.concat { root_dir, "haskell-language-server-wrapper" }, "--lsp" }, cmd_env = { - PATH = table.concat({ root_dir, vim.env.PATH }, platform.path_sep), + PATH = process.extend_path { root_dir }, }, }, } diff --git a/lua/nvim-lsp-installer/servers/html/init.lua b/lua/nvim-lsp-installer/servers/html/init.lua index 86018d46..37c6e7a9 100644 --- a/lua/nvim-lsp-installer/servers/html/init.lua +++ b/lua/nvim-lsp-installer/servers/html/init.lua @@ -1 +1 @@ -return require "nvim-lsp-installer.servers.vscode-langservers-extracted"("vscode-html-language-server", { "html" }) +return require "nvim-lsp-installer.servers.vscode-langservers-extracted" { "html" } diff --git a/lua/nvim-lsp-installer/servers/intelephense/init.lua b/lua/nvim-lsp-installer/servers/intelephense/init.lua index a2166800..a606ce35 100644 --- a/lua/nvim-lsp-installer/servers/intelephense/init.lua +++ b/lua/nvim-lsp-installer/servers/intelephense/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) languages = { "php" }, installer = npm.packages { "intelephense" }, default_options = { - cmd = { npm.executable(root_dir, "intelephense"), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/jedi_language_server/init.lua b/lua/nvim-lsp-installer/servers/jedi_language_server/init.lua index 70d4b6fb..2a7b300a 100644 --- a/lua/nvim-lsp-installer/servers/jedi_language_server/init.lua +++ b/lua/nvim-lsp-installer/servers/jedi_language_server/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) homepage = "https://github.com/pappasam/jedi-language-server", installer = pip3.packages { "jedi-language-server" }, default_options = { - cmd = { pip3.executable(root_dir, "jedi-language-server") }, + cmd_env = pip3.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/jsonls/init.lua b/lua/nvim-lsp-installer/servers/jsonls/init.lua index 5b4fbac9..6f7d6059 100644 --- a/lua/nvim-lsp-installer/servers/jsonls/init.lua +++ b/lua/nvim-lsp-installer/servers/jsonls/init.lua @@ -1 +1 @@ -return require "nvim-lsp-installer.servers.vscode-langservers-extracted"("vscode-json-language-server", { "json" }) +return require "nvim-lsp-installer.servers.vscode-langservers-extracted" { "json" } diff --git a/lua/nvim-lsp-installer/servers/jsonnet_ls/init.lua b/lua/nvim-lsp-installer/servers/jsonnet_ls/init.lua index acb24d9d..6ac0f995 100644 --- a/lua/nvim-lsp-installer/servers/jsonnet_ls/init.lua +++ b/lua/nvim-lsp-installer/servers/jsonnet_ls/init.lua @@ -1,5 +1,6 @@ local server = require "nvim-lsp-installer.server" local go = require "nvim-lsp-installer.installers.go" +local path = require "nvim-lsp-installer.path" return function(name, root_dir) return server.Server:new { @@ -8,7 +9,8 @@ return function(name, root_dir) homepage = "https://github.com/jdbaldry/jsonnet-language-server", installer = go.packages { "github.com/jdbaldry/jsonnet-language-server" }, default_options = { - cmd = { go.executable(root_dir, "jsonnet-language-server") }, + -- TODO: use env instead of cmd once https://github.com/neovim/nvim-lspconfig/pull/1559 is merged + cmd = { path.concat { root_dir, "jsonnet-language-server" } }, }, } end diff --git a/lua/nvim-lsp-installer/servers/kotlin_language_server/init.lua b/lua/nvim-lsp-installer/servers/kotlin_language_server/init.lua index 0000917b..2d70c2b3 100644 --- a/lua/nvim-lsp-installer/servers/kotlin_language_server/init.lua +++ b/lua/nvim-lsp-installer/servers/kotlin_language_server/init.lua @@ -1,5 +1,5 @@ local server = require "nvim-lsp-installer.server" -local platform = require "nvim-lsp-installer.platform" +local process = require "nvim-lsp-installer.process" local path = require "nvim-lsp-installer.path" local std = require "nvim-lsp-installer.installers.std" local context = require "nvim-lsp-installer.installers.context" @@ -17,12 +17,13 @@ return function(name, root_dir) end), }, default_options = { - cmd = { - path.concat { - root_dir, - "server", - "bin", - platform.is_win and "kotlin-language-server.bat" or "kotlin-language-server", + cmd_env = { + PATH = process.extend_path { + path.concat { + root_dir, + "server", + "bin", + }, }, }, }, diff --git a/lua/nvim-lsp-installer/servers/lemminx/init.lua b/lua/nvim-lsp-installer/servers/lemminx/init.lua index 06853d2b..eedce082 100644 --- a/lua/nvim-lsp-installer/servers/lemminx/init.lua +++ b/lua/nvim-lsp-installer/servers/lemminx/init.lua @@ -1,9 +1,9 @@ local server = require "nvim-lsp-installer.server" -local path = require "nvim-lsp-installer.path" local std = require "nvim-lsp-installer.installers.std" local Data = require "nvim-lsp-installer.data" local context = require "nvim-lsp-installer.installers.context" local platform = require "nvim-lsp-installer.platform" +local process = require "nvim-lsp-installer.process" local coalesce, when = Data.coalesce, Data.when @@ -47,7 +47,9 @@ return function(name, root_dir) ), }, default_options = { - cmd = { path.concat { root_dir, "lemminx" } }, + cmd_env = { + PATH = process.extend_path { root_dir }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/ltex/init.lua b/lua/nvim-lsp-installer/servers/ltex/init.lua index 4996eeb0..3cb8259f 100644 --- a/lua/nvim-lsp-installer/servers/ltex/init.lua +++ b/lua/nvim-lsp-installer/servers/ltex/init.lua @@ -4,12 +4,11 @@ local std = require "nvim-lsp-installer.installers.std" local context = require "nvim-lsp-installer.installers.context" local Data = require "nvim-lsp-installer.data" local platform = require "nvim-lsp-installer.platform" +local process = require "nvim-lsp-installer.process" local coalesce, when = Data.coalesce, Data.when return function(name, root_dir) - local script_name = platform.is_win and "ltex-ls.bat" or "ltex-ls" - return server.Server:new { name = name, root_dir = root_dir, @@ -25,29 +24,19 @@ return function(name, root_dir) end), context.capture(function(ctx) if platform.is_win then - -- todo strip components unzip return std.unzip_remote(ctx.github_release_file) else return std.untargz_remote(ctx.github_release_file) end end), context.capture(function(ctx) - -- Preferably we'd not have to write a script file that captures the installed version. - -- But in order to not break backwards compatibility for existing installations of ltex, we do it. - return std.executable_alias( - script_name, - path.concat { - root_dir, - ("ltex-ls-%s"):format(ctx.requested_server_version), - "bin", - platform.is_win and "ltex-ls.bat" or "ltex-ls", - } - ) + return std.rename(("ltex-ls-%s"):format(ctx.requested_server_version), "ltex-ls") end), - std.chmod("+x", { "ltex-ls" }), }, default_options = { - cmd = { path.concat { root_dir, script_name } }, + cmd_env = { + PATH = process.extend_path { path.concat { root_dir, "ltex-ls", "bin" } }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/ocamlls/init.lua b/lua/nvim-lsp-installer/servers/ocamlls/init.lua index 9218672b..fc86d267 100644 --- a/lua/nvim-lsp-installer/servers/ocamlls/init.lua +++ b/lua/nvim-lsp-installer/servers/ocamlls/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) languages = { "ocaml" }, installer = npm.packages { "ocaml-language-server" }, default_options = { - cmd = { npm.executable(root_dir, "ocaml-language-server"), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/phpactor/init.lua b/lua/nvim-lsp-installer/servers/phpactor/init.lua index 5a58bce7..d48f9a2b 100644 --- a/lua/nvim-lsp-installer/servers/phpactor/init.lua +++ b/lua/nvim-lsp-installer/servers/phpactor/init.lua @@ -3,6 +3,7 @@ local path = require "nvim-lsp-installer.path" local server = require "nvim-lsp-installer.server" local composer = require "nvim-lsp-installer.installers.composer" local std = require "nvim-lsp-installer.installers.std" +local process = require "nvim-lsp-installer.process" return function(name, root_dir) return server.Server:new { @@ -17,7 +18,9 @@ return function(name, root_dir) }, }, default_options = { - cmd = { path.concat { root_dir, "bin", "phpactor" }, "language-server" }, + cmd_env = { + PATH = process.extend_path { path.concat { root_dir, "bin" } }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/prismals/init.lua b/lua/nvim-lsp-installer/servers/prismals/init.lua index e6f0b348..e7e38391 100644 --- a/lua/nvim-lsp-installer/servers/prismals/init.lua +++ b/lua/nvim-lsp-installer/servers/prismals/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) homepage = "https://github.com/prisma/language-tools", installer = npm.packages { "@prisma/language-server" }, default_options = { - cmd = { npm.executable(root_dir, "prisma-language-server"), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/puppet/init.lua b/lua/nvim-lsp-installer/servers/puppet/init.lua index b26b028a..759fefe1 100644 --- a/lua/nvim-lsp-installer/servers/puppet/init.lua +++ b/lua/nvim-lsp-installer/servers/puppet/init.lua @@ -1,7 +1,7 @@ -local path = require "nvim-lsp-installer.path" local server = require "nvim-lsp-installer.server" local context = require "nvim-lsp-installer.installers.context" local std = require "nvim-lsp-installer.installers.std" +local process = require "nvim-lsp-installer.process" return function(name, root_dir) return server.Server:new { @@ -18,7 +18,9 @@ return function(name, root_dir) end), }, default_options = { - cmd = { path.concat { root_dir, "puppet-languageserver" }, "--stdio" }, + cmd_env = { + PATH = process.extend_path { root_dir }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/purescriptls/init.lua b/lua/nvim-lsp-installer/servers/purescriptls/init.lua index 141f6b1e..710d6d47 100644 --- a/lua/nvim-lsp-installer/servers/purescriptls/init.lua +++ b/lua/nvim-lsp-installer/servers/purescriptls/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) homepage = "https://github.com/nwolverson/purescript-language-server", installer = npm.packages { "purescript-language-server" }, default_options = { - cmd = { npm.executable(root_dir, "purescript-language-server"), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/pylsp/init.lua b/lua/nvim-lsp-installer/servers/pylsp/init.lua index 9905dd68..87db157d 100644 --- a/lua/nvim-lsp-installer/servers/pylsp/init.lua +++ b/lua/nvim-lsp-installer/servers/pylsp/init.lua @@ -11,7 +11,7 @@ return function(name, root_dir) homepage = "https://github.com/python-lsp/python-lsp-server", installer = pip3.packages { "python-lsp-server[all]" }, default_options = { - cmd = { pip3.executable(root_dir, "pylsp") }, + cmd_env = pip3.env(root_dir), commands = { PylspInstall = { function(...) @@ -20,10 +20,11 @@ return function(name, root_dir) local plugins_str = table.concat(plugins, ", ") notify(("Installing %q..."):format(plugins_str)) process.spawn( - pip3.executable(root_dir, "pip"), + "pip", { args = vim.list_extend({ "install", "-U", "--disable-pip-version-check" }, plugins), stdio_sink = process.simple_sink(), + env = process.graft_env(pip3.env(root_dir)), }, vim.schedule_wrap(function(success) if success then diff --git a/lua/nvim-lsp-installer/servers/pyright/init.lua b/lua/nvim-lsp-installer/servers/pyright/init.lua index 00f46605..8bdcaebd 100644 --- a/lua/nvim-lsp-installer/servers/pyright/init.lua +++ b/lua/nvim-lsp-installer/servers/pyright/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) homepage = "https://github.com/microsoft/pyright", installer = npm.packages { "pyright" }, default_options = { - cmd = { npm.executable(root_dir, "pyright-langserver"), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/quick_lint_js/init.lua b/lua/nvim-lsp-installer/servers/quick_lint_js/init.lua index 6b7b6870..4944f8bf 100644 --- a/lua/nvim-lsp-installer/servers/quick_lint_js/init.lua +++ b/lua/nvim-lsp-installer/servers/quick_lint_js/init.lua @@ -5,6 +5,7 @@ local platform = require "nvim-lsp-installer.platform" local installers = require "nvim-lsp-installer.installers" local path = require "nvim-lsp-installer.path" local Data = require "nvim-lsp-installer.data" +local process = require "nvim-lsp-installer.process" local coalesce, when = Data.coalesce, Data.when @@ -56,7 +57,9 @@ return function(name, root_dir) }, }, default_options = { - cmd = { path.concat { root_dir, "bin", "quick-lint-js" }, "--lsp-server" }, + cmd_env = { + PATH = process.extend_path { path.concat { root_dir, "bin" } }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/rome/init.lua b/lua/nvim-lsp-installer/servers/rome/init.lua index d6ed449c..ca1f25bf 100644 --- a/lua/nvim-lsp-installer/servers/rome/init.lua +++ b/lua/nvim-lsp-installer/servers/rome/init.lua @@ -19,7 +19,7 @@ return function(name, root_dir) npm.packages { "rome" }, }, default_options = { - cmd = { npm.executable(root_dir, "rome"), "lsp" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/rust_analyzer/init.lua b/lua/nvim-lsp-installer/servers/rust_analyzer/init.lua index cd9d670e..5611dca3 100644 --- a/lua/nvim-lsp-installer/servers/rust_analyzer/init.lua +++ b/lua/nvim-lsp-installer/servers/rust_analyzer/init.lua @@ -1,5 +1,5 @@ local server = require "nvim-lsp-installer.server" -local path = require "nvim-lsp-installer.path" +local process = require "nvim-lsp-installer.process" local platform = require "nvim-lsp-installer.platform" local std = require "nvim-lsp-installer.installers.std" local context = require "nvim-lsp-installer.installers.context" @@ -48,7 +48,9 @@ return function(name, root_dir) std.chmod("+x", { "rust-analyzer" }), }, default_options = { - cmd = { path.concat { root_dir, "rust-analyzer" } }, + cmd_env = { + PATH = process.extend_path { root_dir }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/serve_d/init.lua b/lua/nvim-lsp-installer/servers/serve_d/init.lua index 238317dc..36dba64a 100644 --- a/lua/nvim-lsp-installer/servers/serve_d/init.lua +++ b/lua/nvim-lsp-installer/servers/serve_d/init.lua @@ -1,9 +1,9 @@ local server = require "nvim-lsp-installer.server" local platform = require "nvim-lsp-installer.platform" -local path = require "nvim-lsp-installer.path" local std = require "nvim-lsp-installer.installers.std" local context = require "nvim-lsp-installer.installers.context" local Data = require "nvim-lsp-installer.data" +local process = require "nvim-lsp-installer.process" return function(name, root_dir) return server.Server:new { @@ -28,7 +28,9 @@ return function(name, root_dir) end), }, default_options = { - cmd = { path.concat { root_dir, "serve-d" } }, + cmd_env = { + PATH = process.extend_path { root_dir }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/solang/init.lua b/lua/nvim-lsp-installer/servers/solang/init.lua index 98458723..794c4edb 100644 --- a/lua/nvim-lsp-installer/servers/solang/init.lua +++ b/lua/nvim-lsp-installer/servers/solang/init.lua @@ -5,6 +5,7 @@ local context = require "nvim-lsp-installer.installers.context" local Data = require "nvim-lsp-installer.data" local platform = require "nvim-lsp-installer.platform" local installers = require "nvim-lsp-installer.installers" +local process = require "nvim-lsp-installer.process" local coalesce, when = Data.coalesce, Data.when @@ -54,9 +55,11 @@ return function(name, root_dir) llvm_installer, }, default_options = { - cmd = { path.concat { root_dir, "solang" }, "--language-server", "--target", "ewasm" }, cmd_env = { - PATH = table.concat({ path.concat { root_dir, "llvm12.0", "bin" }, vim.env.PATH }, platform.path_sep), + PATH = process.extend_path { + path.concat { root_dir }, + path.concat { root_dir, "llvm12.0", "bin" }, + }, }, }, } diff --git a/lua/nvim-lsp-installer/servers/solargraph/init.lua b/lua/nvim-lsp-installer/servers/solargraph/init.lua index d65cb031..d0b44450 100644 --- a/lua/nvim-lsp-installer/servers/solargraph/init.lua +++ b/lua/nvim-lsp-installer/servers/solargraph/init.lua @@ -9,7 +9,6 @@ return function(name, root_dir) homepage = "https://solargraph.org", installer = gem.packages { "solargraph" }, default_options = { - cmd = { gem.executable(root_dir, "solargraph"), "stdio" }, cmd_env = gem.env(root_dir), }, } diff --git a/lua/nvim-lsp-installer/servers/solc/init.lua b/lua/nvim-lsp-installer/servers/solc/init.lua index 8f6c48aa..dd04f592 100644 --- a/lua/nvim-lsp-installer/servers/solc/init.lua +++ b/lua/nvim-lsp-installer/servers/solc/init.lua @@ -3,7 +3,7 @@ local Data = require "nvim-lsp-installer.data" local context = require "nvim-lsp-installer.installers.context" local platform = require "nvim-lsp-installer.platform" local std = require "nvim-lsp-installer.installers.std" -local path = require "nvim-lsp-installer.path" +local process = require "nvim-lsp-installer.process" local coalesce, when = Data.coalesce, Data.when @@ -33,7 +33,9 @@ return function(name, root_dir) std.chmod("+x", { bin_name }), }, default_options = { - cmd = { path.concat { root_dir, bin_name }, "--lsp" }, + cmd_env = { + PATH = process.extend_path { root_dir }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/solidity_ls/init.lua b/lua/nvim-lsp-installer/servers/solidity_ls/init.lua index a90fd6a0..451738f6 100644 --- a/lua/nvim-lsp-installer/servers/solidity_ls/init.lua +++ b/lua/nvim-lsp-installer/servers/solidity_ls/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) homepage = "https://github.com/edag94/vscode-solidity", installer = npm.packages { "solidity-language-server" }, default_options = { - cmd = { npm.executable(root_dir, "solidity-language-server"), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/sorbet/init.lua b/lua/nvim-lsp-installer/servers/sorbet/init.lua index cc0c0e6b..233116ce 100644 --- a/lua/nvim-lsp-installer/servers/sorbet/init.lua +++ b/lua/nvim-lsp-installer/servers/sorbet/init.lua @@ -8,7 +8,6 @@ return function(name, root_dir) languages = { "ruby" }, installer = gem.packages { "sorbet" }, default_options = { - cmd = { gem.executable(root_dir, "srb"), "tc", "--lsp" }, cmd_env = gem.env(root_dir), }, } diff --git a/lua/nvim-lsp-installer/servers/sqlls/init.lua b/lua/nvim-lsp-installer/servers/sqlls/init.lua index a9251874..7e6e0dff 100644 --- a/lua/nvim-lsp-installer/servers/sqlls/init.lua +++ b/lua/nvim-lsp-installer/servers/sqlls/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) homepage = "https://github.com/joe-re/sql-language-server", installer = npm.packages { "sql-language-server" }, default_options = { - cmd = { npm.executable(root_dir, "sql-language-server"), "up", "--method", "stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/sqls/init.lua b/lua/nvim-lsp-installer/servers/sqls/init.lua index e816e3a3..40a11d67 100644 --- a/lua/nvim-lsp-installer/servers/sqls/init.lua +++ b/lua/nvim-lsp-installer/servers/sqls/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) homepage = "https://github.com/lighttiger2505/sqls", installer = go.packages { "github.com/lighttiger2505/sqls" }, default_options = { - cmd = { go.executable(root_dir, "sqls") }, + cmd_env = go.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/stylelint_lsp/init.lua b/lua/nvim-lsp-installer/servers/stylelint_lsp/init.lua index fe2ed2c9..1bfbe7f3 100644 --- a/lua/nvim-lsp-installer/servers/stylelint_lsp/init.lua +++ b/lua/nvim-lsp-installer/servers/stylelint_lsp/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) languages = { "stylelint" }, installer = npm.packages { "stylelint-lsp" }, default_options = { - cmd = { npm.executable(root_dir, "stylelint-lsp"), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/sumneko_lua/init.lua b/lua/nvim-lsp-installer/servers/sumneko_lua/init.lua index 907545be..1d562bb4 100644 --- a/lua/nvim-lsp-installer/servers/sumneko_lua/init.lua +++ b/lua/nvim-lsp-installer/servers/sumneko_lua/init.lua @@ -4,6 +4,7 @@ local platform = require "nvim-lsp-installer.platform" local Data = require "nvim-lsp-installer.data" local std = require "nvim-lsp-installer.installers.std" local context = require "nvim-lsp-installer.installers.context" +local process = require "nvim-lsp-installer.process" local coalesce, when = Data.coalesce, Data.when @@ -40,7 +41,11 @@ return function(name, root_dir) end), }, default_options = { - cmd = { path.concat { root_dir, "extension", "server", "bin", "lua-language-server" } }, + cmd_env = { + PATH = process.extend_path { + path.concat { root_dir, "extension", "server", "bin" }, + }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/svelte/init.lua b/lua/nvim-lsp-installer/servers/svelte/init.lua index 225be747..b14dc247 100644 --- a/lua/nvim-lsp-installer/servers/svelte/init.lua +++ b/lua/nvim-lsp-installer/servers/svelte/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) homepage = "https://github.com/sveltejs/language-tools", installer = npm.packages { "svelte-language-server" }, default_options = { - cmd = { npm.executable(root_dir, "svelteserver"), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/tailwindcss/init.lua b/lua/nvim-lsp-installer/servers/tailwindcss/init.lua index ff3396ad..d62e70bd 100644 --- a/lua/nvim-lsp-installer/servers/tailwindcss/init.lua +++ b/lua/nvim-lsp-installer/servers/tailwindcss/init.lua @@ -8,7 +8,7 @@ return function(name, root_dir) languages = { "tailwind" }, installer = npm.packages { "@tailwindcss/language-server" }, default_options = { - cmd = { npm.executable(root_dir, "tailwindcss-language-server"), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/taplo/init.lua b/lua/nvim-lsp-installer/servers/taplo/init.lua index cb4de20a..c9e405bb 100644 --- a/lua/nvim-lsp-installer/servers/taplo/init.lua +++ b/lua/nvim-lsp-installer/servers/taplo/init.lua @@ -4,7 +4,7 @@ local platform = require "nvim-lsp-installer.platform" local installers = require "nvim-lsp-installer.installers" local Data = require "nvim-lsp-installer.data" local std = require "nvim-lsp-installer.installers.std" -local path = require "nvim-lsp-installer.path" +local process = require "nvim-lsp-installer.process" local coalesce, when = Data.coalesce, Data.when @@ -34,7 +34,9 @@ return function(name, root_dir) end), }, default_options = { - cmd = { path.concat { root_dir, "taplo-lsp" }, "run" }, + cmd_env = { + PATH = process.extend_path { root_dir }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/terraformls/init.lua b/lua/nvim-lsp-installer/servers/terraformls/init.lua index dd20c15d..4e4c5bea 100644 --- a/lua/nvim-lsp-installer/servers/terraformls/init.lua +++ b/lua/nvim-lsp-installer/servers/terraformls/init.lua @@ -1,4 +1,5 @@ local server = require "nvim-lsp-installer.server" +local process = require "nvim-lsp-installer.process" local path = require "nvim-lsp-installer.path" local platform = require "nvim-lsp-installer.platform" local std = require "nvim-lsp-installer.installers.std" @@ -39,7 +40,9 @@ return function(name, root_dir) end), }, default_options = { - cmd = { path.concat { root_dir, "terraform-ls", "terraform-ls" }, "serve" }, + cmd_env = { + PATH = process.extend_path { path.concat { root_dir, "terraform-ls" } }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/texlab/init.lua b/lua/nvim-lsp-installer/servers/texlab/init.lua index 0bac4143..2379c5c0 100644 --- a/lua/nvim-lsp-installer/servers/texlab/init.lua +++ b/lua/nvim-lsp-installer/servers/texlab/init.lua @@ -1,5 +1,5 @@ local server = require "nvim-lsp-installer.server" -local path = require "nvim-lsp-installer.path" +local process = require "nvim-lsp-installer.process" local std = require "nvim-lsp-installer.installers.std" local context = require "nvim-lsp-installer.installers.context" local Data = require "nvim-lsp-installer.data" @@ -31,7 +31,9 @@ return function(name, root_dir) end), }, default_options = { - cmd = { path.concat { root_dir, "texlab" } }, + cmd_env = { + PATH = process.extend_path { root_dir }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/tflint/init.lua b/lua/nvim-lsp-installer/servers/tflint/init.lua index d7fce6b4..8a6f987e 100644 --- a/lua/nvim-lsp-installer/servers/tflint/init.lua +++ b/lua/nvim-lsp-installer/servers/tflint/init.lua @@ -1,24 +1,22 @@ local server = require "nvim-lsp-installer.server" -local notify = require "nvim-lsp-installer.notify" -local path = require "nvim-lsp-installer.path" local Data = require "nvim-lsp-installer.data" local platform = require "nvim-lsp-installer.platform" local std = require "nvim-lsp-installer.installers.std" local context = require "nvim-lsp-installer.installers.context" local process = require "nvim-lsp-installer.process" -local os = Data.coalesce( - Data.when(platform.is_mac, "darwin"), - Data.when(platform.is_linux, "linux"), - Data.when(platform.is_win, "windows") -) +local coalesce, when = Data.coalesce, Data.when -local arch = Data.coalesce(Data.when(platform.arch == "x64", "amd64"), platform.arch) +return function(name, root_dir) + local os = coalesce( + when(platform.is_mac, "darwin"), + when(platform.is_linux, "linux"), + when(platform.is_win, "windows") + ) -local target = ("tflint_%s_%s.zip"):format(os, arch) + local arch = coalesce(when(platform.arch == "x64", "amd64"), platform.arch) -return function(name, root_dir) - local bin_path = path.concat { root_dir, "tflint" } + local target = ("tflint_%s_%s.zip"):format(os, arch) return server.Server:new { name = name, @@ -32,17 +30,26 @@ return function(name, root_dir) end), }, default_options = { - cmd = { bin_path, "--langserver" }, + cmd_env = { + PATH = process.extend_path { root_dir }, + }, commands = { TFLintInit = { function() + local process = require "nvim-lsp-installer.process" + local notify = require "nvim-lsp-installer.notify" + local path = require "nvim-lsp-installer.path" + notify "Installing TFLint plugins…" process.spawn( - bin_path, + "tflint", { args = { "--init" }, cwd = path.cwd(), stdio_sink = process.simple_sink(), + env = process.graft_env { + PATH = process.extend_path { root_dir }, + }, }, vim.schedule_wrap(function(success) if success then diff --git a/lua/nvim-lsp-installer/servers/tsserver/init.lua b/lua/nvim-lsp-installer/servers/tsserver/init.lua index 7bb908b1..5b192475 100644 --- a/lua/nvim-lsp-installer/servers/tsserver/init.lua +++ b/lua/nvim-lsp-installer/servers/tsserver/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) homepage = "https://github.com/typescript-language-server/typescript-language-server", installer = npm.packages { "typescript-language-server", "typescript" }, default_options = { - cmd = { npm.executable(root_dir, "typescript-language-server"), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/vala_ls/init.lua b/lua/nvim-lsp-installer/servers/vala_ls/init.lua index b32a9fc2..8503579e 100644 --- a/lua/nvim-lsp-installer/servers/vala_ls/init.lua +++ b/lua/nvim-lsp-installer/servers/vala_ls/init.lua @@ -43,7 +43,9 @@ return function(name, root_dir) std.rmrf "vala-language-server", }, default_options = { - cmd = { path.concat { root_dir, "bin", "vala-language-server" } }, + cmd_env = { + PATH = process.extend_path { path.concat { root_dir, "bin" } }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/vimls/init.lua b/lua/nvim-lsp-installer/servers/vimls/init.lua index df5e2e31..28c7d26b 100644 --- a/lua/nvim-lsp-installer/servers/vimls/init.lua +++ b/lua/nvim-lsp-installer/servers/vimls/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) homepage = "https://github.com/iamcco/vim-language-server", installer = npm.packages { "vim-language-server" }, default_options = { - cmd = { npm.executable(root_dir, "vim-language-server"), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/volar/init.lua b/lua/nvim-lsp-installer/servers/volar/init.lua index 278c0a4d..25721b6d 100644 --- a/lua/nvim-lsp-installer/servers/volar/init.lua +++ b/lua/nvim-lsp-installer/servers/volar/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) languages = { "vue" }, installer = npm.packages { "@volar/server" }, default_options = { - cmd = { npm.executable(root_dir, "volar-server"), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/vscode-langservers-extracted/init.lua b/lua/nvim-lsp-installer/servers/vscode-langservers-extracted/init.lua index 162cfc41..83493834 100644 --- a/lua/nvim-lsp-installer/servers/vscode-langservers-extracted/init.lua +++ b/lua/nvim-lsp-installer/servers/vscode-langservers-extracted/init.lua @@ -1,9 +1,8 @@ local server = require "nvim-lsp-installer.server" local npm = require "nvim-lsp-installer.installers.npm" ----@param executable string @The vscode-langservers-extracted executable to use for the server. ---@param languages string[] -return function(executable, languages) +return function(languages) return function(name, root_dir) return server.Server:new { name = name, @@ -11,7 +10,7 @@ return function(executable, languages) root_dir = root_dir, installer = npm.packages { "vscode-langservers-extracted" }, default_options = { - cmd = { npm.executable(root_dir, executable), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/vuels/init.lua b/lua/nvim-lsp-installer/servers/vuels/init.lua index aed040fd..19f19faf 100644 --- a/lua/nvim-lsp-installer/servers/vuels/init.lua +++ b/lua/nvim-lsp-installer/servers/vuels/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) homepage = "https://github.com/vuejs/vetur", installer = npm.packages { "vls" }, default_options = { - cmd = { npm.executable(root_dir, "vls"), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/yamlls/init.lua b/lua/nvim-lsp-installer/servers/yamlls/init.lua index 1f49b2b2..648b5a57 100644 --- a/lua/nvim-lsp-installer/servers/yamlls/init.lua +++ b/lua/nvim-lsp-installer/servers/yamlls/init.lua @@ -9,7 +9,7 @@ return function(name, root_dir) homepage = "https://github.com/redhat-developer/yaml-language-server", installer = npm.packages { "yaml-language-server" }, default_options = { - cmd = { npm.executable(root_dir, "yaml-language-server"), "--stdio" }, + cmd_env = npm.env(root_dir), }, } end diff --git a/lua/nvim-lsp-installer/servers/zk/init.lua b/lua/nvim-lsp-installer/servers/zk/init.lua index 2af55646..e8ea645a 100644 --- a/lua/nvim-lsp-installer/servers/zk/init.lua +++ b/lua/nvim-lsp-installer/servers/zk/init.lua @@ -3,7 +3,7 @@ local platform = require "nvim-lsp-installer.platform" local Data = require "nvim-lsp-installer.data" local std = require "nvim-lsp-installer.installers.std" local context = require "nvim-lsp-installer.installers.context" -local path = require "nvim-lsp-installer.path" +local process = require "nvim-lsp-installer.process" local coalesce, when = Data.coalesce, Data.when return function(name, root_dir) @@ -53,7 +53,9 @@ return function(name, root_dir) )), }, default_options = { - cmd = { path.concat { root_dir, "zk" }, "lsp" }, + cmd_env = { + PATH = process.extend_path { root_dir }, + }, }, } end diff --git a/lua/nvim-lsp-installer/servers/zls/init.lua b/lua/nvim-lsp-installer/servers/zls/init.lua index af7d5ecd..98409640 100644 --- a/lua/nvim-lsp-installer/servers/zls/init.lua +++ b/lua/nvim-lsp-installer/servers/zls/init.lua @@ -4,6 +4,7 @@ local platform = require "nvim-lsp-installer.platform" local Data = require "nvim-lsp-installer.data" local context = require "nvim-lsp-installer.installers.context" local std = require "nvim-lsp-installer.installers.std" +local process = require "nvim-lsp-installer.process" local coalesce, when = Data.coalesce, Data.when @@ -34,7 +35,9 @@ return function(name, root_dir) std.chmod("+x", { path.concat { "package", "zls" } }), }, default_options = { - cmd = { path.concat { root_dir, "package", "zls" } }, + cmd_env = { + PATH = process.extend_path { path.concat { root_dir, "package" } }, + }, }, } end |
