diff options
36 files changed, 87 insertions, 1275 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2a0ce137..5904893f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,14 +77,9 @@ Example: ## Auto-install -Configs may optionally provide `install()` and `install_info()` functions which -are discovered by `:LspInstall` and `:LspInstallInfo`. Function -`util.npm_installer()` can be used for`npm`-installable language servers. See -`elmls.lua`, `tsserver.lua`, `bashls.lua` for examples. - -Note **we are considering removing the auto-install concept** +Note **we have removed auto installers from the nvim-lspconfig repo** ([#334](https://github.com/neovim/nvim-lspconfig/issues/334)). Instead, each -config should _document_ key installation details: +config _documents_ key installation details: - URL to download the server - URL to documentation explaining how to install the server @@ -154,18 +154,6 @@ lspconfig.util.default_config = vim.tbl_extend( ) ``` -### Installing a language server - -Configs may provide an `install()` function. Then you can use -`:LspInstall {name}` to install the required language server. -For example, to install the Elm language server: - - :LspInstall elmls - -Use `:LspInstallInfo` to see install info. - - :LspInstallInfo - ## setup() function The `setup()` interface: diff --git a/lua/lspconfig.lua b/lua/lspconfig.lua index cc9b38bc..b6909f2a 100644 --- a/lua/lspconfig.lua +++ b/lua/lspconfig.lua @@ -4,71 +4,10 @@ local M = { util = require 'lspconfig/util'; } -function M.available_servers() - return vim.tbl_keys(configs) -end - -function M.installable_servers() - local res = {} - for k, v in pairs(configs) do - if v.install then table.insert(res, k) end - end - return res -end - M._root = {} --- Called from plugin/lspconfig.vim because it requires knowing that the last --- script in scriptnames to be executed is lspconfig. -function M._root._setup() - M._root.commands = { - LspInstall = { - function(name) - if configs[name] == nil then - pcall(require('lspconfig/'..name)) - end - local config = configs[name] - if not config then - return print("Invalid server name:", name) - end - if not config.install then - return print(name, "can't be automatically installed (yet)") - end - if config.install_info().is_installed then - return print(name, "is already installed") - end - config.install() - end; - "-nargs=1"; - "-complete=custom,v:lua.lsp_complete_installable_servers"; - description = '`:LspInstall {name}` installs a server under stdpath("cache")/lspconfig/{name}'; - }; - LspInstallInfo = { - function(name) - if name == nil then - local res = {} - for k, v in pairs(configs) do - if v.install_info then - res[k] = v.install_info() - end - end - return print(vim.inspect(res)) - end - if configs[name] == nil then - pcall(require('lspconfig/'..name)) - end - local config = configs[name] - if not config then - return print("Invalid server name:", name) - end - return print(vim.inspect(config.install_info())) - end; - "-nargs=?"; - "-complete=custom,v:lua.lsp_complete_servers"; - description = 'Print installation info for {name} if one is specified, or all installable servers.'; - }; - }; - M.util.create_module_commands("_root", M._root.commands) +function M.available_servers() + return vim.tbl_keys(configs) end local mt = {} diff --git a/lua/lspconfig/als.lua b/lua/lspconfig/als.lua index c5c4a116..dd0138b1 100644 --- a/lua/lspconfig/als.lua +++ b/lua/lspconfig/als.lua @@ -7,62 +7,6 @@ if vim.fn.has('win32') == 1 then bin_name = 'ada_language_server.exe' end -local function make_installer() - local install_dir = util.path.join{util.base_install_dir, server_name} - - local url = 'https://dl.bintray.com/reznikmm/ada-language-server/linux-latest.tar.gz' - local download_target = util.path.join{install_dir, "als.tar.gz"} - local extracted_dir = "linux" - local extract_cmd = string.format("tar -xzf '%s' --one-top-level='%s'", download_target, install_dir) - - if vim.fn.has('win32') == 1 then - url = 'https://dl.bintray.com/reznikmm/ada-language-server/win32-latest.zip' - download_target = util.path.join{install_dir, 'win32-latest.zip'} - extracted_dir = 'win32' - extract_cmd = string.format("unzip -o '%s' -d '%s'", download_target, install_dir) - elseif vim.fn.has('mac') == 1 then - url = 'https://dl.bintray.com/reznikmm/ada-language-server/darwin-latest.tar.gz' - download_target = util.path.join{install_dir, 'darwin-latest.tar.gz'} - extracted_dir = 'darwin' - extract_cmd = string.format("tar -xzf '%s' --one-top-level='%s'", download_target, install_dir) - end - - local download_cmd = string.format('curl -fLo "%s" --create-dirs "%s"', download_target, url) - - local bin_path = util.path.join{install_dir, extracted_dir, bin_name} - local X = {} - function X.install() - local install_info = X.info() - if install_info.is_installed then - print(server_name, "is already installed") - return - end - if not (util.has_bins("curl")) then - error('Need "curl" to install this.') - return - end - vim.fn.mkdir(install_dir, 'p') - vim.fn.system(download_cmd) - vim.fn.system(extract_cmd) - end - function X.info() - return { - is_installed = util.path.exists(bin_path); - install_dir = install_dir; - cmd = { bin_path }; - } - end - function X.configure(config) - local install_info = X.info() - if install_info.is_installed then - config.cmd = install_info.cmd - end - end - return X -end - -local installer = make_installer() - configs[server_name] = { default_config = { cmd = {bin_name}; @@ -70,15 +14,12 @@ configs[server_name] = { -- *.gpr and *.adc would be nice to have here root_dir = util.root_pattern("Makefile", ".git"); }; - on_new_config = function(config) - installer.configure(config) - end; docs = { package_json = "https://raw.githubusercontent.com/AdaCore/ada_language_server/master/integration/vscode/ada/package.json"; description = [[ https://github.com/AdaCore/ada_language_server -Ada language server. Use `LspInstall als` to install it. +Installation instructions can be found [here](https://github.com/AdaCore/ada_language_server#Install). Can be configured by passing a "settings" object to `als.setup{}`: @@ -99,6 +40,4 @@ require('lspconfig').als.setup{ }; }; -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/angularls.lua b/lua/lspconfig/angularls.lua index f579909f..c714b310 100644 --- a/lua/lspconfig/angularls.lua +++ b/lua/lspconfig/angularls.lua @@ -2,20 +2,6 @@ local configs = require 'lspconfig/configs' local util = require 'lspconfig/util' local server_name = 'angularls' -local bin_name = server_name -local install_loc = util.base_install_dir .. '/' .. server_name -local script_loc = install_loc .. '/node_modules/@angular/language-server/index.js' -local bin_loc = install_loc .. '/node_modules/.bin/angularls' - -local installer = util.npm_installer { - server_name = server_name; - packages = { '@angular/language-server' }; - binaries = { bin_name }; - -- angular-language-service doesn't expose a binary, so we create an execution wrapper. - post_install_script = - 'echo "#! /bin/sh\n' .. 'node ' .. script_loc .. ' \\$*' .. '" > ' .. bin_loc .. '\n' .. - 'chmod +x ' .. bin_loc; -} -- Angular requires a node_modules directory to probe for @angular/language-service and typescript -- in order to use your projects configured versions. @@ -31,7 +17,7 @@ local default_probe_dir = get_probe_dir(vim.fn.getcwd()) configs[server_name] = { default_config = { cmd = { - bin_loc, + 'angularls', '--stdio', '--tsProbeLocations', default_probe_dir, '--ngProbeLocations', default_probe_dir @@ -47,7 +33,7 @@ configs[server_name] = { -- We need to check our probe directories because they may have changed. new_config.cmd = { - bin_loc, + 'angularls', '--stdio', '--tsProbeLocations', new_probe_dir, '--ngProbeLocations', new_probe_dir @@ -57,16 +43,11 @@ configs[server_name] = { description = [[ https://github.com/angular/vscode-ng-language-service -`angular-language-server` can be installed via `:LspInstall angularls` - -If you prefer to install this yourself you can through npm `npm install @angular/language-server`. -Be aware there is no global binary and must be run via `node_modules/@angular/language-server/index.js` +`angular-language-server` can be installed via npm `npm install @angular/language-server`. +Be aware there is no global binary and must be run via `node_modules/@angular/language-server/index.js` which can be added as the default cmd. ]]; default_config = { root_dir = [[root_pattern("angular.json", ".git")]]; }; } } - -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info diff --git a/lua/lspconfig/bashls.lua b/lua/lspconfig/bashls.lua index 59b21079..7be7aad3 100644 --- a/lua/lspconfig/bashls.lua +++ b/lua/lspconfig/bashls.lua @@ -2,13 +2,6 @@ local configs = require 'lspconfig/configs' local util = require 'lspconfig/util' local server_name = "bashls" -local bin_name = "bash-language-server" - -local installer = util.npm_installer { - server_name = server_name; - packages = { "bash-language-server" }; - binaries = {bin_name}; -} configs[server_name] = { default_config = { @@ -16,17 +9,6 @@ configs[server_name] = { filetypes = {"sh"}; root_dir = util.path.dirname; }; - on_new_config = function(new_config) - local install_info = installer.info() - if install_info.is_installed then - if type(new_config.cmd) == 'table' then - -- Try to preserve any additional args from upstream changes. - new_config.cmd[1] = install_info.binaries[bin_name] - else - new_config.cmd = {install_info.binaries[bin_name]} - end - end - end; docs = { description = [[ https://github.com/mads-hartmann/bash-language-server @@ -39,6 +21,4 @@ Language server for bash, written using tree sitter in typescript. }; }; -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/cssls.lua b/lua/lspconfig/cssls.lua index 7b50950a..25e6e857 100644 --- a/lua/lspconfig/cssls.lua +++ b/lua/lspconfig/cssls.lua @@ -4,12 +4,6 @@ local util = require 'lspconfig/util' local server_name = "cssls" local bin_name = "css-languageserver" -local installer = util.npm_installer { - server_name = server_name; - packages = { "vscode-css-languageserver-bin" }; - binaries = {bin_name}; -} - local root_pattern = util.root_pattern("package.json") configs[server_name] = { @@ -25,22 +19,11 @@ configs[server_name] = { less = { validate = true } }; }; - on_new_config = function(new_config) - local install_info = installer.info() - if install_info.is_installed then - if type(new_config.cmd) == 'table' then - -- Try to preserve any additional args from upstream changes. - new_config.cmd[1] = install_info.binaries[bin_name] - else - new_config.cmd = {install_info.binaries[bin_name]} - end - end - end; docs = { description = [[ https://github.com/vscode-langservers/vscode-css-languageserver-bin -`css-languageserver` can be installed via `:LspInstall cssls` or by yourself with `npm`: +`css-languageserver` can be installed via `npm`: ```sh npm install -g vscode-css-languageserver-bin ``` @@ -51,6 +34,4 @@ npm install -g vscode-css-languageserver-bin }; } -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/diagnosticls.lua b/lua/lspconfig/diagnosticls.lua index c4f26220..b82a5f90 100644 --- a/lua/lspconfig/diagnosticls.lua +++ b/lua/lspconfig/diagnosticls.lua @@ -4,29 +4,12 @@ local util = require 'lspconfig/util' local server_name = "diagnosticls" local bin_name = "diagnostic-languageserver" -local installer = util.npm_installer { - server_name = server_name; - packages = { bin_name }; - binaries = { bin_name }; -} - configs[server_name] = { default_config = { cmd = {bin_name, "--stdio"}, filetypes = {}, root_dir = util.path.dirname, }, - on_new_config = function(new_config) - local install_info = installer.info() - if install_info.is_installed then - if type(new_config.cmd) == 'table' then - -- Try to preserve any additional args from upstream changes. - new_config.cmd[1] = install_info.binaries[bin_name] - else - new_config.cmd = {install_info.binaries[bin_name], "--stdio"} - end - end - end; docs = { description = [[ https://github.com/iamcco/diagnostic-languageserver @@ -40,6 +23,3 @@ Diagnostic language server integrate with linters. }; }; } - -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info diff --git a/lua/lspconfig/dockerls.lua b/lua/lspconfig/dockerls.lua index 572e4701..feb5e105 100644 --- a/lua/lspconfig/dockerls.lua +++ b/lua/lspconfig/dockerls.lua @@ -4,34 +4,17 @@ local util = require 'lspconfig/util' local server_name = "dockerls" local bin_name = "docker-langserver" -local installer = util.npm_installer { - server_name = server_name; - packages = { "dockerfile-language-server-nodejs" }; - binaries = {bin_name}; -} - configs[server_name] = { default_config = { cmd = {bin_name, "--stdio"}; filetypes = {"Dockerfile", "dockerfile"}; root_dir = util.root_pattern("Dockerfile"); }; - on_new_config = function(new_config) - local install_info = installer.info() - if install_info.is_installed then - if type(new_config.cmd) == 'table' then - -- Try to preserve any additional args from upstream changes. - new_config.cmd[1] = install_info.binaries[bin_name] - else - new_config.cmd = {install_info.binaries[bin_name]} - end - end - end; docs = { description = [[ https://github.com/rcjsuen/dockerfile-language-server-nodejs -`docker-langserver` can be installed via `:LspInstall dockerls` or by yourself with `npm`: +`docker-langserver` can be installed via `npm`: ```sh npm install -g dockerfile-language-server-nodejs ``` @@ -42,6 +25,4 @@ npm install -g dockerfile-language-server-nodejs }; }; -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/elixirls.lua b/lua/lspconfig/elixirls.lua index fcd91a04..c7580e07 100644 --- a/lua/lspconfig/elixirls.lua +++ b/lua/lspconfig/elixirls.lua @@ -2,99 +2,35 @@ local configs = require 'lspconfig/configs' local util = require 'lspconfig/util' local server_name = "elixirls" -local bin_name = "elixir-ls" -local cmd = "language_server" - -if vim.fn.has('mac') == 1 or vim.fn.has('unix') == 1 then - cmd = cmd..".sh" -elseif vim.fn.has('win32') == 1 or vim.fn.has('win64') == 1 then - cmd = cmd..".bat" -else - error("System is not supported, try to install manually.") - return -end - -local function make_installer() - local P = util.path.join - local install_dir = P{util.base_install_dir, server_name} - local cmd_path = P{install_dir, bin_name, "release", cmd} - - local X = {} - function X.install() - local install_info = X.info() - if install_info.is_installed then - print(server_name, "is already installed.") - return - end - - if not (util.has_bins("elixir") and util.has_bins("erl")) then - error("Need elixir and erl to install this") - return - end - - local script = [=[ - set -e - - # clone project - git clone https://github.com/elixir-lsp/elixir-ls - cd elixir-ls - - # fetch dependencies and compile - mix deps.get && mix compile - - # install executable - mix elixir_ls.release -o release - ]=] - vim.fn.mkdir(install_info.install_dir, "p") - util.sh(script, install_info.install_dir) - end - - function X.info() - return { - is_installed = util.path.exists(cmd_path); - install_dir = install_dir; - cmd = { cmd_path }; - } - end - - function X.configure(config) - local install_info = X.info() - if install_info.is_installed then - config.cmd = install_info.cmd - end - end - return X -end - -local installer = make_installer() - configs[server_name] = { default_config = { - cmd = { cmd }; filetypes = {"elixir", "eelixir"}; root_dir = function(fname) return util.root_pattern("mix.exs", ".git")(fname) or vim.loop.os_homedir() end; }; - on_new_config = function(config) - installer.configure(config) - end; docs = { package_json = "https://raw.githubusercontent.com/JakeBecker/vscode-elixir-ls/master/package.json"; description = [[ https://github.com/elixir-lsp/elixir-ls -`elixir-ls` can be installed via `:LspInstall elixirls` or by yourself by following the instructions [here](https://github.com/elixir-lsp/elixir-ls#building-and-running). +`elixir-ls` can be installed by following the instructions [here](https://github.com/elixir-lsp/elixir-ls#building-and-running). + +```bash +curl -fLO https://github.com/elixir-lsp/elixir-ls/releases/latest/download/elixir-ls.zip +unzip elixir-ls.zip -d /path/to/elixir-ls +# Unix +chmod +x /path/to/elixir-ls/language_server.sh +``` -This language server does not provide a global binary, but must be installed manually. The command `:LspInstaller elixirls` makes an attempt at installing the binary by -Fetching the elixir-ls repository from GitHub, compiling it and then installing it. +**By default, elixir-ls doesn't have a `cmd` set.** This is because nvim-lspconfig does not make assumptions about your path. You must add the following to your init.vim or init.lua to set `cmd` to the absolute path ($HOME and ~ are not expanded) of you unzipped elixir-ls. ```lua require'lspconfig'.elixirls.setup{ -- Unix - cmd = { "path/to/language_server.sh" }; + cmd = { "/path/to/elixir-ls/language_server.sh" }; -- Windows - cmd = { "path/to/language_server.bat" }; + cmd = { "/path/to/elixir-ls/language_server.bat" }; ... } ``` @@ -105,6 +41,4 @@ require'lspconfig'.elixirls.setup{ }; } -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/elmls.lua b/lua/lspconfig/elmls.lua index c35824c4..9e692353 100644 --- a/lua/lspconfig/elmls.lua +++ b/lua/lspconfig/elmls.lua @@ -6,12 +6,6 @@ local api = vim.api local server_name = "elmls" local bin_name = "elm-language-server" -local installer = util.npm_installer { - server_name = server_name; - packages = { "elm", "elm-test", "elm-format", "@elm-tooling/elm-language-server" }; - binaries = {bin_name, "elm", "elm-format", "elm-test"}; -} - local default_capabilities = lsp.protocol.make_client_capabilities() default_capabilities.offsetEncoding = {"utf-8", "utf-16"} local elm_root_pattern = util.root_pattern("elm.json") @@ -34,22 +28,6 @@ configs[server_name] = { elmAnalyseTrigger = "change", }; }; - on_new_config = function(new_config) - local install_info = installer.info() - if install_info.is_installed then - if type(new_config.cmd) == 'table' then - -- Try to preserve any additional args from upstream changes. - new_config.cmd[1] = install_info.binaries[bin_name] - else - new_config.cmd = {install_info.binaries[bin_name]} - end - new_config.init_options = util.tbl_deep_extend('force', new_config.init_options, { - elmPath = install_info.binaries["elm"]; - elmFormatPath = install_info.binaries["elm-format"]; - elmTestPath = install_info.binaries["elm-test"]; - }) - end - end; docs = { package_json = "https://raw.githubusercontent.com/elm-tooling/elm-language-client-vscode/master/package.json"; description = [[ @@ -66,7 +44,5 @@ npm install -g elm elm-test elm-format @elm-tooling/elm-language-server }; } -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/groovyls.lua b/lua/lspconfig/groovyls.lua index 576c7e6c..34e913cf 100644 --- a/lua/lspconfig/groovyls.lua +++ b/lua/lspconfig/groovyls.lua @@ -4,62 +4,6 @@ local util = require 'lspconfig/util' local name = "groovyls" local bin_name = "groovy-language-server-all.jar" -local function make_installer() - local X = {} - local P = util.path.join - local install_dir = P{util.base_install_dir, name} - local bin_path = P{install_dir, "groovy-language-server", "build", "libs", bin_name} - local cmd = { - "java", "-jar", bin_path, - }; - - function X.install() - local install_info = X.info() - if install_info.is_installed then - print(name, "is already installed.") - return - end - if not (util.has_bins("curl")) then - error('Need "curl" to install this.') - return - end - if not (util.has_bins("java")) then - error('Need "Java 11+" to install this.') - return - end - - local script = [=[ -set -e -# clone project -git clone https://github.com/prominic/groovy-language-server.git -cd groovy-language-server - -# build -./gradlew build - ]=] - vim.fn.mkdir(install_info.install_dir, "p") - util.sh(script, install_info.install_dir) - end - - function X.info() - return { - is_installed = util.path.exists(bin_path); - install_dir = install_dir; - cmd = cmd - } - end - - function X.configure(config) - local install_info = X.info() - if install_info.is_installed then - config.cmd = install_info.cmd - end - end - return X -end - -local installer = make_installer() - configs[name] = { default_config = { cmd = { @@ -68,9 +12,6 @@ configs[name] = { filetypes = {"groovy"}; root_dir = util.root_pattern(".git") or vim.loop.os_homedir(); }; - on_new_config = function(config) - installer.configure(config) - end; docs = { description = [[ https://github.com/prominic/groovy-language-server.git @@ -79,12 +20,9 @@ Requirements: - Linux/macOS (for now) - Java 11+ -`groovyls` can be installed via `:LspInstall groovyls` or by yourself by following the instructions [here](https://github.com/prominic/groovy-language-server.git#build). - -The command `:LspInstall groovyls` makes an attempt at installing the binary by -Fetching the groovyls repository from GitHub, compiling it and then expose a binary. +`groovyls` can be installed by following the instructions [here](https://github.com/prominic/groovy-language-server.git#build). -If you installed groovy language server by yourself, you can set the `cmd` custom path as follow: +If you have installed groovy language server, you can set the `cmd` custom path as follow: ```lua require'lspconfig'.groovyls.setup{ @@ -104,6 +42,4 @@ require'lspconfig'.groovyls.setup{ }; } -configs[name].install = installer.install -configs[name].install_info = installer.info -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/health.lua b/lua/lspconfig/health.lua index 3abab080..ae7bfac3 100644 --- a/lua/lspconfig/health.lua +++ b/lua/lspconfig/health.lua @@ -3,8 +3,7 @@ function M.check_health() local configs = require 'lspconfig/configs' for _, top_level_config in pairs(configs) do - -- If users execute `:LspInstall` or `:LspInstallInfo`, - -- a config is required but is not added make_config function. + -- Only check configs that have a make_config function. if not (top_level_config.make_config == nil) then -- the folder needs to exist local config = top_level_config.make_config(".") diff --git a/lua/lspconfig/html.lua b/lua/lspconfig/html.lua index a9636222..23cdcb88 100644 --- a/lua/lspconfig/html.lua +++ b/lua/lspconfig/html.lua @@ -4,12 +4,6 @@ local util = require 'lspconfig/util' local server_name = "html" local bin_name = "html-languageserver" -local installer = util.npm_installer { - server_name = server_name; - packages = { "vscode-html-languageserver-bin" }; - binaries = {bin_name}; -} - local root_pattern = util.root_pattern("package.json") configs[server_name] = { @@ -26,22 +20,11 @@ configs[server_name] = { } }; - on_new_config = function(new_config) - local install_info = installer.info() - if install_info.is_installed then - if type(new_config.cmd) == 'table' then - -- Try to preserve any additional args from upstream changes. - new_config.cmd[1] = install_info.binaries[bin_name] - else - new_config.cmd = {install_info.binaries[bin_name]} - end - end - end; docs = { description = [[ https://github.com/vscode-langservers/vscode-html-languageserver-bin -`html-languageserver` can be installed via `:LspInstall html` or by yourself with `npm`: +`html-languageserver` can be installed via `npm`: ```sh npm install -g vscode-html-languageserver-bin ``` @@ -49,6 +32,4 @@ npm install -g vscode-html-languageserver-bin }; } -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/intelephense.lua b/lua/lspconfig/intelephense.lua index 7e381349..08861d5d 100644 --- a/lua/lspconfig/intelephense.lua +++ b/lua/lspconfig/intelephense.lua @@ -4,12 +4,6 @@ local util = require 'lspconfig/util' local server_name = "intelephense" local bin_name = "intelephense" -local installer = util.npm_installer { - server_name = server_name; - packages = { "intelephense" }; - binaries = {bin_name}; -} - configs[server_name] = { default_config = { cmd = {bin_name, "--stdio"}; @@ -22,22 +16,11 @@ configs[server_name] = { return util.path.is_descendant(cwd, root) and cwd or root; end; }; - on_new_config = function(new_config) - local install_info = installer.info() - if install_info.is_installed then - if type(new_config.cmd) == 'table' then - -- Try to preserve any additional args from upstream changes. - new_config.cmd[1] = install_info.binaries[bin_name] - else - new_config.cmd = {install_info.binaries[bin_name]} - end - end - end; docs = { description = [[ https://intelephense.com/ -`intelephense` can be installed via `:LspInstall intelephense` or by yourself with `npm`: +`intelephense` can be installed via `npm`: ```sh npm install -g intelephense ``` @@ -63,6 +46,4 @@ npm install -g intelephense }; } -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/jdtls.lua b/lua/lspconfig/jdtls.lua index 0c900593..85440946 100644 --- a/lua/lspconfig/jdtls.lua +++ b/lua/lspconfig/jdtls.lua @@ -5,93 +5,6 @@ local path = util.path local server_name = "jdtls" -local function make_installer() - local install_dir = path.join { util.base_install_dir, server_name } - local tar_name = "jdt-language-server-latest.tar.gz" - local script = string.format([[ - curl -LO http://download.eclipse.org/jdtls/snapshots/%s > %s - tar xf %s - ]], tar_name, tar_name, tar_name) - local launcher_ls = "ls " .. path.join { install_dir, "plugins", "org.eclipse.equinox.launcher_*.jar" } - - local X = {} - - function X.install() - if not util.has_bins("curl", "tar") then - error('Need the binaries "curl", "tar" to install this.') - return - end - - vim.fn.mkdir(install_dir, "p") - util.sh(script, install_dir) - end - - function X.info() - return { - is_installed = util.path.exists(install_dir, 'features') ~= false; - install_dir = install_dir; - } - end - - function X.get_os_config() - if vim.fn.has("osx") == 1 then - return "config_mac" - elseif vim.fn.has("unix") == 1 then - return "config_linux" - else - return "config_win" - end - end - - function X.get_launcher() - local file = io.popen(launcher_ls) - local results = {} - - for line in file:lines() do - table.insert(results, line) - end - - if #results == 1 then - return results[1] - end - - error("Could not find launcher for jdtls.") - end - - function X.configure(config) - local install_info = X.info() - local launcher_path = X.get_launcher() - - if install_info.is_installed then - config.cmd = vim.list_extend( - vim.list_extend( - { - "java", - "-Declipse.application=org.eclipse.jdt.ls.core.id1", - "-Dosgi.bundles.defaultStartLevel=4", - "-Declipse.product=org.eclipse.jdt.ls.core.product", - "-Dlog.level=ALL", - "-noverify", - "-Xmx1G", - }, - config.init_options.jvm_args), - { - "-jar", launcher_path, - "-configuration", path.join { install_dir, config.init_options.os_config or X.get_os_config() }, - "-data", config.init_options.workspace, - -- TODO: Handle Java versions 8 and under. This may just work... - "--add-modules=ALL-SYSTEM", - "--add-opens", "java.base/java.util=ALL-UNNAMED", - "--add-opens", "java.base/java.lang=ALL-UNNAMED" - }) - end - end - - return X -end - -local installer = make_installer() - configs[server_name] = { default_config = { filetypes = { "java" }; @@ -127,22 +40,16 @@ configs[server_name] = { end }; }; - on_new_config = function(config) - installer.configure(config) - end; docs = { description = [[ https://projects.eclipse.org/projects/eclipse.jdt.ls -Language server can be installed with `:LspInstall jdtls` - Language server for Java. + +See project page for installation instructions. ]]; default_config = { root_dir = [[root_pattern(".git")]]; }; }; } - -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info diff --git a/lua/lspconfig/jsonls.lua b/lua/lspconfig/jsonls.lua index 616a0bbe..9db3cb7b 100644 --- a/lua/lspconfig/jsonls.lua +++ b/lua/lspconfig/jsonls.lua @@ -4,29 +4,12 @@ local util = require 'lspconfig/util' local server_name = "jsonls" local bin_name = "vscode-json-languageserver" -local installer = util.npm_installer { - server_name = server_name; - packages = {bin_name}; - binaries = {bin_name}; -} - configs[server_name] = { default_config = { cmd = {bin_name, "--stdio"}; filetypes = {"json"}; root_dir = util.root_pattern(".git", vim.fn.getcwd()); }; - on_new_config = function(new_config) - local install_info = installer.info() - if install_info.is_installed then - if type(new_config.cmd) == 'table' then - -- Try to preserve any additional args from upstream changes. - new_config.cmd[1] = install_info.binaries[bin_name] - else - new_config.cmd = {install_info.binaries[bin_name]} - end - end - end; docs = { -- this language server config is in VSCode built-in package.json package_json = "https://raw.githubusercontent.com/microsoft/vscode/master/extensions/json-language-features/package.json"; @@ -35,7 +18,7 @@ https://github.com/vscode-langservers/vscode-json-languageserver vscode-json-languageserver, a language server for JSON and JSON schema -`vscode-json-languageserver` can be installed via `:LspInstall jsonls` or by yourself with `npm`: +`vscode-json-languageserver` can be installed via `npm`: ```sh npm install -g vscode-json-languageserver ``` @@ -46,6 +29,4 @@ npm install -g vscode-json-languageserver }; } -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/julials.lua b/lua/lspconfig/julials.lua index f74ce7b7..81b11d4f 100644 --- a/lua/lspconfig/julials.lua +++ b/lua/lspconfig/julials.lua @@ -30,7 +30,7 @@ configs.julials = { package_json = "https://raw.githubusercontent.com/julia-vscode/julia-vscode/master/package.json"; description = [[ https://github.com/julia-vscode/julia-vscode -`LanguageServer.jl` can be installed via `:LspInstall julials` or by yourself the `julia` and `Pkg`: +`LanguageServer.jl` can be installed with `julia` and `Pkg`: ```sh julia --project=]] .. environment_directory .. [[ -e 'using Pkg; Pkg.add("LanguageServer"); Pkg.add("SymbolServer")' ``` @@ -42,25 +42,4 @@ If you want to install the LanguageServer manually, you will have to ensure that }; } -configs.julials.install = function() - - local script = [[ - julia --project=]] .. environment_directory .. [[ -e 'using Pkg; Pkg.add("LanguageServer"); Pkg.add("SymbolServer")' - ]] - - util.sh(script, vim.loop.os_homedir()) -end - -configs.julials.install_info = function() - local script = [[ - julia --project=]] .. environment_directory .. [[ -e 'using LanguageServer; using SymbolServer' - ]] - - local status = pcall(vim.fn.system, script) - - return { - is_installed = status and vim.v.shell_error == 0; - } -end - --- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/metals.lua b/lua/lspconfig/metals.lua index 12e244bb..eacb1954 100644 --- a/lua/lspconfig/metals.lua +++ b/lua/lspconfig/metals.lua @@ -3,68 +3,6 @@ local util = require 'lspconfig/util' local server_name = "metals" local bin_name = "metals" -local function make_installer() - local install_dir = util.path.join{util.base_install_dir, server_name} - local metals_bin = util.path.join{install_dir, bin_name} - local server_version - if (vim.g.metals_server_version) then - server_version = vim.g.metals_server_version - else - server_version = 'latest.release' - end - local X = {} - function X.install() - local install_info = X.info() - if install_info.is_installed then - print(server_name, "is already installed") - return - end - if not (util.has_bins("curl")) then - error('Need "curl" to install this.') - return - end - if not (util.has_bins("java")) then - error('Need "JDK" to install this.') - return - end - - local coursier_exe = nil - if util.has_bins("cs") then - coursier_exe = "cs" - elseif util.has_bins("coursier") then - coursier_exe = "coursier" - end - if not coursier_exe then - coursier_exe = install_dir .. "/coursier" - local download_cmd = string.format("curl -fLo %s --create-dirs https://git.io/coursier-cli", coursier_exe) - local chmod_cmd = string.format("chmod +x %s", coursier_exe) - vim.fn.system(download_cmd) - vim.fn.system(chmod_cmd) - else - os.execute("mkdir -p " .. install_dir) - end - - local install_cmd = string.format("%s bootstrap --java-opt -Xss4m --java-opt -Xms100m org.scalameta:metals_2.12:%s -r bintray:scalacenter/releases -r sonatype:snapshots -o %s -f", coursier_exe, server_version, metals_bin) - vim.fn.system(install_cmd) - end - function X.info() - return { - is_installed = util.path.exists(metals_bin); - install_dir = install_dir; - cmd = { metals_bin }; - } - end - function X.configure(config) - local install_info = X.info() - if install_info.is_installed then - config.cmd = install_info.cmd - end - end - return X -end - -local installer = make_installer() - configs[server_name] = { default_config = { cmd = {bin_name}; @@ -79,28 +17,33 @@ configs[server_name] = { } }; }; - on_new_config = function(config) - installer.configure(config) - end; docs = { package_json = "https://raw.githubusercontent.com/scalameta/metals-vscode/master/package.json"; description = [[ https://scalameta.org/metals/ -To target a specific version on Metals, set the following. -If nothing is set, the latest stable will be used. -```vim -let g:metals_server_version = '0.8.4+106-5f2b9350-SNAPSHOT' -``` - Scala language server with rich IDE features. -`metals` can be installed via `:LspInstall metals`. + +See full instructions in the Metals documentation: + +https://scalameta.org/metals/docs/editors/vim.html#using-an-alternative-lsp-client + +Note: that if you're using [nvim-metals](https://github.com/scalameta/nvim-metals), that plugin fully handles the setup and installation of Metals, and you shouldn't set up Metals both with it and this plugin. + +To install Metals, make sure to have [coursier](https://get-coursier.io/docs/cli-installation) installed, and once you do you can install the latest Metals with `cs install metals`. You can also manually bootstrap Metals with the following command. + +```bash +cs bootstrap \ + --java-opt -Xss4m \ + --java-opt -Xms100m \ + org.scalameta:metals_2.12:<enter-version-here> \ + -r bintray:scalacenter/releases \ + -r sonatype:snapshots \ + -o /usr/local/bin/metals -f +``` ]]; default_config = { root_dir = [[util.root_pattern("build.sbt", "build.sc", "build.gradle", "pom.xml")]]; }; }; }; - -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info diff --git a/lua/lspconfig/nimls.lua b/lua/lspconfig/nimls.lua index f71c60f9..cc80dae8 100644 --- a/lua/lspconfig/nimls.lua +++ b/lua/lspconfig/nimls.lua @@ -13,7 +13,7 @@ configs.nimls = { package_json = "https://raw.githubusercontent.com/pragmagic/vscode-nim/master/package.json"; description = [[ https://github.com/PMunch/nimlsp -`nimlsp` can be installed via `:LspInstall nimls` or by yourself the `nimble` package manager: +`nimlsp` can be installed via the `nimble` package manager: ```sh nimble install nimlsp ``` @@ -23,23 +23,3 @@ nimble install nimlsp }; }; } - -configs.nimls.install = function() - local script = [[ - nimble install nimlsp - ]] - - util.sh(script, vim.loop.os_homedir()) -end - -configs.nimls.install_info = function() - local script = [[ - nimlsp --version - ]] - - local status = pcall(vim.fn.system, script) - - return { - is_installed = status and vim.v.shell_error == 0; - } -end diff --git a/lua/lspconfig/ocamlls.lua b/lua/lspconfig/ocamlls.lua index 05e71992..d01f7622 100644 --- a/lua/lspconfig/ocamlls.lua +++ b/lua/lspconfig/ocamlls.lua @@ -4,33 +4,17 @@ local util = require 'lspconfig/util' local server_name = "ocamlls" local bin_name = "ocaml-language-server" -local installer = util.npm_installer { - server_name = server_name; - packages = { "ocaml-language-server" }; - binaries = { bin_name }; -} - configs[server_name] = { default_config = { cmd = { bin_name, "--stdio" }; filetypes = { "ocaml", "reason" }; root_dir = util.root_pattern(".merlin", "package.json"); }; - on_new_config = function(new_config) - local install_info = installer.info() - if install_info.is_installed then - if type(new_config.cmd) == 'table' then - new_config.cmd[1] = install_info.binaries[bin_name] - else - new_config.cmd = {install_info.binaries[bin_name]} - end - end - end; docs = { description = [[ https://github.com/ocaml-lsp/ocaml-language-server -`ocaml-language-server` can be installed via `:LspInstall ocamlls` or by yourself with `npm` +`ocaml-language-server` can be installed via `npm` ```sh npm install -g ocaml-langauge-server ``` @@ -40,6 +24,4 @@ npm install -g ocaml-langauge-server }; }; }; -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/omnisharp.lua b/lua/lspconfig/omnisharp.lua index 8c6866d6..5f2f2c46 100644 --- a/lua/lspconfig/omnisharp.lua +++ b/lua/lspconfig/omnisharp.lua @@ -1,68 +1,11 @@ local configs = require 'lspconfig/configs' local util = require 'lspconfig/util' local server_name = 'omnisharp' -local bin_name = 'run' - -local function make_installer() - local install_dir = util.path.join{util.base_install_dir, server_name} - local pid = vim.fn.getpid() - local url = 'linux-x64' - - if vim.fn.has('win32') == 1 then - url = 'win-x64' - bin_name = 'Omnisharp.exe' - elseif vim.fn.has('mac') == 1 then - url = 'osx' - end - local bin_path = util.path.join{install_dir, bin_name} - - local download_target = util.path.join{install_dir, string.format("omnisharp-%s.zip", url)} - local extract_cmd = string.format("unzip '%s' -d '%s'", download_target, install_dir) - local download_cmd = string.format('curl -fLo "%s" --create-dirs "https://github.com/OmniSharp/omnisharp-roslyn/releases/latest/download/omnisharp-%s.zip"', download_target, url) - local make_executable_cmd = string.format("chmod u+x '%s'", bin_path) - - local X = {} - function X.install() - local install_info = X.info() - if install_info.is_installed then - print(server_name, "is already installed") - return - end - if not (util.has_bins("curl")) then - error('Need "curl" to install this.') - return - end - vim.fn.mkdir(install_dir, 'p') - vim.fn.system(download_cmd) - vim.fn.system(extract_cmd) - vim.fn.system(make_executable_cmd) - end - function X.info() - return { - is_installed = util.path.exists(bin_path); - install_dir = install_dir; - cmd = { bin_path, "--languageserver" , "--hostPID", tostring(pid)}; - } - end - function X.configure(config) - local install_info = X.info() - if install_info.is_installed then - config.cmd = install_info.cmd - end - end - return X -end - -local installer = make_installer() configs[server_name] = { default_config = { - cmd = installer.info().cmd; filetypes = {"cs", "vb"}; root_dir = util.root_pattern("*.csproj", "*.sln"); - on_new_config = function(config) - installer.configure(config) - end; init_options = { }; }; @@ -72,6 +15,22 @@ configs[server_name] = { description = [[ https://github.com/omnisharp/omnisharp-roslyn OmniSharp server based on Roslyn workspaces + +`omnisharp-roslyn` can be installed by downloading and extracting a release from [here](https://github.com/OmniSharp/omnisharp-roslyn/releases). +Omnisharp can also be built from source by following the instructions [here](https://github.com/omnisharp/omnisharp-roslyn#downloading-omnisharp). + +**By default, omnisharp-roslyn doesn't have a `cmd` set.** This is because nvim-lspconfig does not make assumptions about your path. You must add the following to your init.vim or init.lua to set `cmd` to the absolute path ($HOME and ~ are not expanded) of you unzipped . + +```lua +local pid = vim.fn.getpid() +local omnisharp_bin = "/path/to/omnisharp/OmniSharp" +-- on Windows +-- local omnisharp_bin = "/path/to/omnisharp/OmniSharp.exe" +require'lspconfig'.omnisharp.setup{ + cmd = { omnisharp_bin, "--languageserver" , "--hostPID", tostring(pid) }; + ... +} +``` ]]; default_config = { root_dir = [[root_pattern(".csproj", ".sln")]]; @@ -79,6 +38,4 @@ OmniSharp server based on Roslyn workspaces }; } -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/purescriptls.lua b/lua/lspconfig/purescriptls.lua index 6bd9d5d3..b8a4745c 100644 --- a/lua/lspconfig/purescriptls.lua +++ b/lua/lspconfig/purescriptls.lua @@ -7,33 +7,17 @@ if vim.fn.has('win32') == 1 then bin_name = bin_name..'.cmd' end -local installer = util.npm_installer { - server_name = server_name; - packages = { "purescript", "purescript-language-server" }; - binaries = {bin_name, "purs"}; -} - configs[server_name] = { default_config = { cmd = {bin_name, "--stdio"}; filetypes = {"purescript"}; root_dir = util.root_pattern("spago.dhall", "bower.json"); }; - on_new_config = function(new_config) - local install_info = installer.info() - if install_info.is_installed then - if type(new_config.cmd) == 'table' then - new_config.cmd[1] = install_info.binaries[bin_name] - else - new_config.cmd = {install_info.binaries[bin_name]} - end - end - end; docs = { package_json = "https://raw.githubusercontent.com/nwolverson/vscode-ide-purescript/master/package.json"; description = [[ https://github.com/nwolverson/purescript-language-server -`purescript-language-server` can be installed via `:LspInstall purescriptls` or by yourself with `npm` +`purescript-language-server` can be installed via `npm` ```sh npm install -g purescript-language-server ``` @@ -43,7 +27,4 @@ npm install -g purescript-language-server }; }; }; -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info - -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/pyls_ms.lua b/lua/lspconfig/pyls_ms.lua index 517aede1..e30fc681 100644 --- a/lua/lspconfig/pyls_ms.lua +++ b/lua/lspconfig/pyls_ms.lua @@ -3,87 +3,6 @@ local util = require 'lspconfig/util' local name = "pyls_ms" -local function get_latest_pyls() - local f = io.popen("curl -k --silent 'https://pvsc.blob.core.windows.net/python-language-server-stable?restype=container&comp=list&prefix=Python-Language-Server-osx-x64'") - local l = f:read("*a") - f:close() - local version - for w in string.gmatch (l, "x64%.(.-).nupkg") do - version = w - end - return version -end - -local function make_installer() - local P = util.path.join - local install_dir = P{util.base_install_dir, name} - - local bin = P{install_dir, "Microsoft.Python.LanguageServer.dll"} - local cmd = {"dotnet", "exec", bin} - - local X = {} - function X.install() - local install_info = X.info() - if install_info.is_installed then - print(name, "is already installed") - return - end - if not (util.has_bins("curl")) then - error('Need "curl" to install this.') - return - end - if not (util.has_bins("dotnet")) then - error('Need ".NET Core" to install this.') - return - end - if not (util.has_bins("unzip")) and (vim.fn.has('mac') == 1 or vim.fn.has('unix') == 1) then - error('Need "unzip" to install this.') - return - end - - local system - if vim.fn.has('mac') == 1 then - system = 'osx' - elseif vim.fn.has('unix') == 1 then - system = 'linux' - elseif vim.fn.has('win32') == 1 then - system = 'win' - else - error('Unable to identify host operating system') - end - - local version = get_latest_pyls() - local url = string.format("https://pvsc.azureedge.net/python-language-server-stable/Python-Language-Server-%s-x64.%s.nupkg", string.lower(system), version) - local download_cmd = string.format('curl -fLo %s --create-dirs %s', install_info.install_dir .. "/pyls.nupkg", url) - local install_cmd = '' - - if vim.fn.has('mac') == 1 or vim.fn.has('unix') == 1 then - install_cmd = "unzip " .. install_info.install_dir .. "/pyls.nupkg -d " .. install_info.install_dir - elseif vim.fn.has('win32') == 1 then - install_cmd = "Expand-Archive -Force " .. install_info.install_dir .. "/pyls.nupkg -d " .. install_info.install_dir - end - - vim.fn.system(download_cmd) - vim.fn.system(install_cmd) - end - function X.info() - return { - is_installed = util.path.exists(bin); - install_dir = install_dir; - cmd = cmd; - } - end - function X.configure(config) - local install_info = X.info() - if install_info.is_installed then - config.cmd = cmd - end - end - return X -end - -local installer = make_installer() - configs[name] = { default_config = { @@ -100,9 +19,6 @@ configs[name] = { }; }; }; - on_new_config = function(config) - installer.configure(config) - end; init_options = { interpreter = { properties = @@ -128,9 +44,9 @@ Requires [.NET Core](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-i curl -L https://dot.net/v1/dotnet-install.sh | sh ``` -`python-language-server` can be installed via `:LspInstall pyls_ms` or you can [build](https://github.com/microsoft/python-language-server/blob/master/CONTRIBUTING.md#setup) your own. +`python-language-server` can be installed via [build](https://github.com/microsoft/python-language-server/blob/master/CONTRIBUTING.md#setup). -If you want to use your own build, set cmd to point to `Microsoft.Python.languageServer.dll`. +Set cmd to point to `Microsoft.Python.languageServer.dll`. ```lua cmd = { "dotnet", "exec", "path/to/Microsoft.Python.languageServer.dll" }; @@ -152,6 +68,4 @@ This server accepts configuration via the `settings` key. }; }; -configs[name].install = installer.install -configs[name].install_info = installer.info -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/pyright.lua b/lua/lspconfig/pyright.lua index d9552bfc..6559fc1b 100644 --- a/lua/lspconfig/pyright.lua +++ b/lua/lspconfig/pyright.lua @@ -7,12 +7,6 @@ if vim.fn.has('win32') == 1 then bin_name = bin_name..".cmd" end -local installer = util.npm_installer { - server_name = server_name; - packages = {server_name}; - binaries = {bin_name}; -} - configs[server_name] = { default_config = { cmd = {bin_name, "--stdio"}; @@ -36,6 +30,4 @@ https://github.com/microsoft/pyright }; } -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/rnix.lua b/lua/lspconfig/rnix.lua index deaeac98..ab879a75 100644 --- a/lua/lspconfig/rnix.lua +++ b/lua/lspconfig/rnix.lua @@ -3,47 +3,6 @@ local util = require 'lspconfig/util' local name = "rnix" -local function make_installer() - local P = util.path.join - local install_dir = P{util.base_install_dir, name} - - local bin = P{install_dir, "bin", "rnix-lsp"} - local cmd = {bin} - - local X = {} - function X.install() - local install_info = X.info() - if install_info.is_installed then - print(name, "is already installed") - return - end - if not (util.has_bins("cargo")) then - error('Need "cargo" to install this.') - return - end - - local install_cmd = "cargo install rnix-lsp --root=" .. install_info.install_dir .. " rnix-lsp" - - vim.fn.system(install_cmd) - end - function X.info() - return { - is_installed = util.path.exists(bin); - install_dir = install_dir; - cmd = cmd; - } - end - function X.configure(config) - local install_info = X.info() - if install_info.is_installed then - config.cmd = cmd - end - end - return X -end - -local installer = make_installer() - configs[name] = { default_config = { @@ -54,9 +13,6 @@ configs[name] = { end; settings = { }; - on_new_config = function(config) - installer.configure(config) - end; init_options = { }; }; @@ -76,6 +32,3 @@ This server accepts configuration via the `settings` key. }; }; }; - -configs[name].install = installer.install -configs[name].install_info = installer.info diff --git a/lua/lspconfig/sqlls.lua b/lua/lspconfig/sqlls.lua index aced4e02..6e0734d6 100644 --- a/lua/lspconfig/sqlls.lua +++ b/lua/lspconfig/sqlls.lua @@ -2,13 +2,6 @@ local configs = require 'lspconfig/configs' local util = require 'lspconfig/util' local server_name = "sqlls" -local bin_name = "sql-language-server" - -local installer = util.npm_installer { - server_name = server_name; - packages = { "sql-language-server" }; - binaries = {bin_name}; -} local root_pattern = util.root_pattern(".sqllsrc.json") @@ -20,19 +13,11 @@ configs[server_name] = { end; settings = {}; }; - on_new_config = function(config) - local install_info = installer.info(); - local P = util.path.join - if install_info.is_installed then - local bin_ex = P{install_info.bin_dir, bin_name} - config.cmd = {bin_ex, "up", "--method", "stdio"} - end - end; docs = { description = [[ https://github.com/joe-re/sql-language-server -`cmd` value is **not set** by default. An installer is provided via the `:LspInstall` command that uses the *nvm_lsp node_modules* directory to find the sql-language-server executable. The `cmd` value can be overriden in the `setup` table; +`cmd` value is **not set** by default. The `cmd` value can be overriden in the `setup` table; ```lua require'lspconfig'.sqlls.setup{ @@ -41,12 +26,10 @@ require'lspconfig'.sqlls.setup{ } ``` -This LSP can be installed via `:LspInstall sqlls` or with `npm`. If using LspInstall, run `:LspInstallInfo sqlls` to view installation paths. Find further instructions on manual installation of the sql-language-server at [joe-re/sql-language-server](https://github.com/joe-re/sql-language-server). +This LSP can be installed via `npm`. Find further instructions on manual installation of the sql-language-server at [joe-re/sql-language-server](https://github.com/joe-re/sql-language-server). <br> ]]; }; } -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/sumneko_lua.lua b/lua/lspconfig/sumneko_lua.lua index 2b821766..640243ac 100644 --- a/lua/lspconfig/sumneko_lua.lua +++ b/lua/lspconfig/sumneko_lua.lua @@ -2,94 +2,6 @@ local configs = require 'lspconfig/configs' local util = require 'lspconfig/util' local name = "sumneko_lua" -local bin_name = "lua-language-server" - -local function make_installer() - local P = util.path.join - local install_dir = P{util.base_install_dir, name} - local git_dir = P{install_dir, bin_name} - local os, bin, ninja_zip, build_file - - if vim.fn.has('osx') == 1 then - os = 'macOS' - bin = P{git_dir, "bin", "macOS", bin_name} - ninja_zip = "ninja-mac.zip" - build_file = "macos.ninja" - elseif vim.fn.has('unix') == 1 then - os = 'Linux' - bin = P{git_dir, "bin", "Linux", bin_name} - ninja_zip = "ninja-linux.zip" - build_file = "linux.ninja" - end - local main_file = P{git_dir, "main.lua"} - local cmd = {bin, '-E', main_file} - - local X = {} - function X.install() - if os == nil then - error("This installer supports Linux and macOS only") - return - end - local install_info = X.info() - if install_info.is_installed then - print(name, "is already installed") - return - end - if not (util.has_bins("ninja") or util.has_bins("curl")) then - error('Need either "ninja" or "curl" (to download ninja) to install this.') - return - end - if not util.has_bins("sh", "chmod", "unzip", "clang") then - error('Need the binaries "sh", "chmod", "unzip", "clang" to install this') - return - end - local script = [=[ -set -e -bin_name=]=]..bin_name..'\n'..[=[ -ninja_zip=]=]..ninja_zip..'\n'..[=[ -build_file=]=]..build_file..'\n'..[=[ - -# Install ninja if not available. -which ninja >/dev/null || { - test -x ninja || { - curl -LO https://github.com/ninja-build/ninja/releases/download/v1.9.0/$ninja_zip - unzip $ninja_zip - chmod +x ninja - } - export PATH="$PWD:$PATH" -} - -# clone project -git clone https://github.com/sumneko/$bin_name -cd $bin_name -git submodule update --init --recursive - -# build -cd 3rd/luamake -ninja -f ninja/$build_file -cd ../.. -./3rd/luamake/luamake rebuild - ]=] - vim.fn.mkdir(install_info.install_dir, "p") - util.sh(script, install_info.install_dir) - end - function X.info() - return { - is_installed = util.has_bins(bin); - install_dir = install_dir; - cmd = cmd; - } - end - function X.configure(config) - local install_info = X.info() - if install_info.is_installed then - config.cmd = cmd - end - end - return X -end - -local installer = make_installer() configs[name] = { default_config = { @@ -99,34 +11,21 @@ configs[name] = { end; log_level = vim.lsp.protocol.MessageType.Warning; }; - on_new_config = function(config) - installer.configure(config) - end; docs = { package_json = "https://raw.githubusercontent.com/sumneko/vscode-lua/master/package.json"; description = [[ https://github.com/sumneko/lua-language-server -Lua language server. **By default, this doesn't have a `cmd` set.** This is -because it doesn't provide a global binary. We provide an installer for Linux -and macOS using `:LspInstall`. If you wish to install it yourself, [here is a -guide](https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone)). -So you should set `cmd` yourself like this. - -```lua -require'lspconfig'.sumneko_lua.setup{ - cmd = {"path", "to", "cmd"}; - ... -} -``` +Lua language server. -If you install via our installer, if you execute `:LspInstallInfo sumneko_lua`, you can know `cmd` value. +`lua-language-server` can be installed by following the instructions [here](https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone)). -The settings of the language server can also be overridden. This is especially useful -when developing on the lua components of neovim. Some recommended settings are as follows: +**By default, lua-language-server doesn't have a `cmd` set.** This is because nvim-lspconfig does not make assumptions about your path. You must add the following to your init.vim or init.lua to set `cmd` to the absolute path ($HOME and ~ are not expanded) of you unzipped and compiled lua-language-server. ```lua +local sumneko_root_path = "/path/to/lua-language-server" require'lspconfig'.sumneko_lua.setup { + cmd = {sumneko_root_path .. "/bin/{linux,macOS}/lua-language-server", "-E", sumneko_root_path .. "/main.lua"}; settings = { Lua = { runtime = { @@ -156,7 +55,4 @@ require'lspconfig'.sumneko_lua.setup { }; }; } - -configs[name].install = installer.install -configs[name].install_info = installer.info -- vim:et ts=2 diff --git a/lua/lspconfig/svelte.lua b/lua/lspconfig/svelte.lua index 6c16226a..07a9eded 100644 --- a/lua/lspconfig/svelte.lua +++ b/lua/lspconfig/svelte.lua @@ -4,33 +4,17 @@ local util = require 'lspconfig/util' local server_name = 'svelte' local bin_name = 'svelteserver' -local installer = util.npm_installer { - server_name = server_name; - packages = { "svelte-language-server" }; - binaries = { bin_name }; -} - configs[server_name] = { default_config = { cmd = {bin_name, '--stdio'}; filetypes = {'svelte'}; root_dir = util.root_pattern("package.json", ".git"); }; - on_new_config = function(new_config) - local install_info = installer.info() - if install_info.is_installed then - if type(new_config.cmd) == 'table' then - new_config.cmd[1] = install_info.binaries[bin_name] - else - new_config.cmd = {install_info.binaries[bin_name]} - end - end - end; docs = { description = [[ https://github.com/sveltejs/language-tools/tree/master/packages/language-server -`svelte-language-server` can be installed via `:LspInstall svelte` or by yourself with `npm`: +`svelte-language-server` can be installed via `npm`: ```sh npm install -g svelte-language-server ``` @@ -41,6 +25,4 @@ npm install -g svelte-language-server } } -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/tsserver.lua b/lua/lspconfig/tsserver.lua index c642bb50..99d8e173 100644 --- a/lua/lspconfig/tsserver.lua +++ b/lua/lspconfig/tsserver.lua @@ -7,34 +7,17 @@ if vim.fn.has('win32') == 1 then bin_name = bin_name..".cmd" end -local installer = util.npm_installer { - server_name = server_name; - packages = { "typescript-language-server" }; - binaries = {bin_name}; -} - configs[server_name] = { default_config = { cmd = {bin_name, "--stdio"}; filetypes = {"javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx"}; root_dir = util.root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"); }; - on_new_config = function(new_config) - local install_info = installer.info() - if install_info.is_installed then - if type(new_config.cmd) == 'table' then - -- Try to preserve any additional args from upstream changes. - new_config.cmd[1] = install_info.binaries[bin_name] - else - new_config.cmd = {install_info.binaries[bin_name]} - end - end - end; docs = { description = [[ https://github.com/theia-ide/typescript-language-server -`typescript-language-server` can be installed via `:LspInstall tsserver` or by yourself with `npm`: +`typescript-language-server` can be installed via `npm`: ```sh npm install -g typescript-language-server ``` @@ -45,6 +28,4 @@ npm install -g typescript-language-server }; } -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index 0bf591ae..d218b25d 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -255,6 +255,11 @@ function M.server_per_root_dir_manager(_make_config) local client_id = clients[root_dir] if not client_id then local new_config = _make_config(root_dir) + --TODO:mjlbach -- this current isn't printing + if not new_config.cmd then + print(string.format("Error, cmd not defined for [%q]. You must manually define a cmd for the default config for this server. See server documentation.", new_config.name)) + return + end new_config.on_exit = M.add_hook_before(new_config.on_exit, function() clients[root_dir] = nil end) @@ -321,115 +326,6 @@ function M.find_package_json_ancestor(startpath) end) end -local function validate_string_list(t) - for _, v in ipairs(t) do - if type(v) ~= 'string' then - return false - end - end - return true -end - -local function map_list(t, func) - local res = {} - for i, v in ipairs(t) do table.insert(res, func(v, i)) end - return res -end - -local function zip_lists_to_map(a, b) - assert(#a == #b) - local res = {} - for i = 1, #a do res[a[i]] = b[i] end - return res -end - -local base_install_dir = M.path.join(fn.stdpath("cache"), "lspconfig") -M.base_install_dir = base_install_dir -function M.npm_installer(config) - validate { - server_name = {config.server_name, 's'}; - packages = {config.packages, validate_string_list, 'List of npm package names'}; - binaries = {config.binaries, validate_string_list, 'List of binary names'}; - post_install_script = {config.post_install_script, 's', true}; - } - - local install_dir = M.path.join(base_install_dir, config.server_name) - local bin_dir = M.path.join(install_dir, "node_modules", ".bin") - local function bin_path(name) - return M.path.join(bin_dir, name) - end - - local binary_paths = map_list(config.binaries, bin_path) - - local function get_install_info() - return { - bin_dir = bin_dir; - install_dir = install_dir; - binaries = zip_lists_to_map(config.binaries, binary_paths); - is_installed = M.has_bins(unpack(binary_paths)); - } - end - - local function install() - -- TODO(ashkan) need all binaries or just the first? - if M.has_bins(unpack(config.binaries)) then - return print(config.server_name, "is already installed (not by Nvim)") - end - if not M.has_bins("sh", "npm", "mkdir") then - api.nvim_err_writeln('Installation requires "sh", "npm", "mkdir"') - return - end - if get_install_info().is_installed then - return print(config.server_name, "is already installed") - end - local install_params = { - packages = table.concat(config.packages, ' '); - install_dir = install_dir; - post_install_script = config.post_install_script or ''; - } - local cmd = io.popen("sh", "w") - local install_script = ([[ - set -e - mkdir -p "{{install_dir}}" - cd "{{install_dir}}" - [ ! -f package.json ] && npm init -y - npm install {{packages}} --no-package-lock --no-save --production - {{post_install_script}} - ]]):gsub("{{(%S+)}}", install_params) - cmd:write(install_script) - cmd:close() - if not get_install_info().is_installed then - api.nvim_err_writeln('Installation of ' .. config.server_name .. ' failed') - end - end - - return { - install = install; - info = get_install_info; - } -end - -function M.sh(script, cwd) - assert(cwd and M.path.is_dir(cwd), "sh: Invalid directory") - -- switching to insert mode makes the buffer scroll as new output is added - -- and makes it easy and intuitive to cancel the operation with Ctrl-C - api.nvim_command("10new | startinsert") - local bufnr = api.nvim_get_current_buf() - local function on_exit(job_id, code, event_type) - if code == 0 then - api.nvim_command("silent bwipeout! "..bufnr) - end - end - fn.termopen({"sh", "-c", script}, {cwd = cwd, on_exit = on_exit}) -end - -function M.format_vspackage_url(extension_name) - local org, package = unpack(vim.split(extension_name, ".", true)) - assert(org and package) - return string.format("https://marketplace.visualstudio.com/_apis/public/gallery/publishers/%s/vsextensions/%s/latest/vspackage", org, package) -end - - function M.utf8_config(config) config.capabilities = config.capabilities or lsp.protocol.make_client_capabilities() config.capabilities.offsetEncoding = {"utf-8", "utf-16"} diff --git a/lua/lspconfig/vimls.lua b/lua/lspconfig/vimls.lua index 15e5fed1..a4a913d4 100644 --- a/lua/lspconfig/vimls.lua +++ b/lua/lspconfig/vimls.lua @@ -7,12 +7,6 @@ if vim.fn.has('win32') == 1 then bin_name = bin_name..".cmd" end -local installer = util.npm_installer { - server_name = server_name, - packages = {"vim-language-server"}, - binaries = {bin_name} -} - configs[server_name] = { default_config = { cmd = {bin_name, "--stdio"}, @@ -33,22 +27,11 @@ configs[server_name] = { }, suggest = {fromVimruntime = true, fromRuntimepath = true} }, - on_new_config = function(new_config) - local install_info = installer.info() - if install_info.is_installed then - if type(new_config.cmd) == "table" then - -- Try to preserve any additional args from upstream changes. - new_config.cmd[1] = install_info.binaries[bin_name] - else - new_config.cmd = {install_info.binaries[bin_name]} - end - end - end, docs = { description = [[ https://github.com/iamcco/vim-language-server -If you don't want to use Nvim to install it, then you can use: +You can install vim-language-server via npm: ```sh npm install -g vim-language-server ``` @@ -57,7 +40,4 @@ npm install -g vim-language-server } } -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info - -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/vuels.lua b/lua/lspconfig/vuels.lua index 4a8774bd..146387e1 100644 --- a/lua/lspconfig/vuels.lua +++ b/lua/lspconfig/vuels.lua @@ -4,12 +4,6 @@ local util = require 'lspconfig/util' local server_name = "vuels" local bin_name = "vls" -local installer = util.npm_installer { - server_name = server_name; - packages = { "vls" }; - binaries = {bin_name}; -} - configs[server_name] = { default_config = { cmd = {bin_name}; @@ -54,24 +48,13 @@ configs[server_name] = { }; }; }; - on_new_config = function(new_config) - local install_info = installer.info() - if install_info.is_installed then - if type(new_config.cmd) == 'table' then - -- Try to preserve any additional args from upstream changes. - new_config.cmd[1] = install_info.binaries[bin_name] - else - new_config.cmd = {install_info.binaries[bin_name]} - end - end - end; docs = { package_json = "https://raw.githubusercontent.com/vuejs/vetur/master/package.json"; description = [[ https://github.com/vuejs/vetur/tree/master/server Vue language server(vls) -`vue-language-server` can be installed via `:LspInstall vuels` or by yourself with `npm`: +`vue-language-server` can be installed via `npm`: ```sh npm install -g vls ``` @@ -120,6 +103,4 @@ npm install -g vls }; } -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info -- vim:et ts=2 sw=2 diff --git a/lua/lspconfig/yamlls.lua b/lua/lspconfig/yamlls.lua index 787e8df3..fcbd9b59 100644 --- a/lua/lspconfig/yamlls.lua +++ b/lua/lspconfig/yamlls.lua @@ -4,34 +4,18 @@ local util = require 'lspconfig/util' local server_name = "yamlls" local bin_name = "yaml-language-server" -local installer = util.npm_installer { - server_name = server_name; - packages = {bin_name}; - binaries = {bin_name}; -} - configs[server_name] = { default_config = { cmd = {bin_name, "--stdio"}; filetypes = {"yaml"}; root_dir = util.root_pattern(".git", vim.fn.getcwd()); }; - on_new_config = function(new_config) - local install_info = installer.info() - if install_info.is_installed then - if type(new_config.cmd) == 'table' then - new_config.cmd[1] = install_info.binaries[bin_name] - else - new_config.cmd = {install_info.binaries[bin_name]} - end - end - end; docs = { package_json = "https://raw.githubusercontent.com/redhat-developer/vscode-yaml/master/package.json"; description = [[ https://github.com/redhat-developer/yaml-language-server -`yaml-language-server` can be installed via `:LspInstall yamlls` or by yourself with `npm`: +`yaml-language-server` can be installed via `npm`: ```sh npm install -g yaml-language-server ``` @@ -42,6 +26,4 @@ npm install -g yaml-language-server }; } -configs[server_name].install = installer.install -configs[server_name].install_info = installer.info -- vim:et ts=2 sw=2 diff --git a/plugin/lspconfig.vim b/plugin/lspconfig.vim index bcefbc39..d9826031 100644 --- a/plugin/lspconfig.vim +++ b/plugin/lspconfig.vim @@ -7,8 +7,4 @@ lua << EOF lsp_complete_installable_servers = function() return table.concat(require'lspconfig'.available_servers(), '\n') end -lsp_complete_servers = function() - return table.concat(require'lspconfig'.installable_servers(), '\n') -end -require'lspconfig'._root._setup() EOF diff --git a/scripts/docgen.lua b/scripts/docgen.lua index e27249c8..35ab6b73 100644 --- a/scripts/docgen.lua +++ b/scripts/docgen.lua @@ -130,11 +130,6 @@ local function make_lsp_sections() end end; function() - if template_object.install then - return string.format("Can be installed in Nvim with `:LspInstall %s`", template_name) - end - end; - function() local package_json_name = util.path.join(tempdir, template_name..'.package.json'); if docs.package_json then if not util.path.is_file(package_json_name) then |
