├── doc └── .gitignore ├── .gitignore ├── stylua.toml ├── tests ├── README.md ├── core │ ├── functional │ │ ├── table_spec.lua │ │ ├── data_spec.lua │ │ ├── type_spec.lua │ │ ├── string_spec.lua │ │ ├── relation_spec.lua │ │ ├── logic_spec.lua │ │ └── number_spec.lua │ ├── clients │ │ └── eclipse_spec.lua │ ├── fs_spec.lua │ ├── path_spec.lua │ ├── managers │ │ ├── github_client_spec.lua │ │ ├── dotnet_spec.lua │ │ └── opam_spec.lua │ └── optional_spec.lua ├── minimal_init.vim ├── setup │ ├── ensure_installed_spec.lua │ ├── automatic_installation_spec.lua │ └── automatic_installation_exclude_spec.lua ├── ui_status_win_spec.lua ├── dispatcher_spec.lua ├── helpers │ └── lua │ │ └── luassertx.lua ├── minimal_debug_init.lua ├── server_spec.lua └── middleware_spec.lua ├── lua └── nvim-lsp-installer │ ├── servers │ ├── cssls │ │ └── init.lua │ ├── html │ │ └── init.lua │ ├── jsonls │ │ └── init.lua │ ├── eslint │ │ ├── init.lua │ │ └── README.md │ ├── omnisharp │ │ └── README.md │ ├── tailwindcss │ │ └── init.lua │ ├── dartls │ │ └── init.lua │ ├── julials │ │ └── README.md │ ├── sorbet │ │ └── init.lua │ ├── vuels │ │ └── init.lua │ ├── solargraph │ │ └── init.lua │ ├── intelephense │ │ └── init.lua │ ├── emmet_ls │ │ └── init.lua │ ├── fortls │ │ └── init.lua │ ├── pyright │ │ └── init.lua │ ├── sourcery │ │ └── init.lua │ ├── svls │ │ └── init.lua │ ├── esbonio │ │ └── init.lua │ ├── psalm │ │ └── init.lua │ ├── rnix │ │ └── init.lua │ ├── salt_ls │ │ └── init.lua │ ├── efm │ │ └── init.lua │ ├── grammarly │ │ └── init.lua │ ├── jsonnet_ls │ │ └── init.lua │ ├── theme_check │ │ └── init.lua │ ├── gopls │ │ └── init.lua │ ├── ocamllsp │ │ └── init.lua │ ├── sourcekit │ │ └── init.lua │ ├── sqls │ │ └── init.lua │ ├── dotls │ │ └── init.lua │ ├── sqlls │ │ └── init.lua │ ├── stylelint_lsp │ │ └── init.lua │ ├── svelte │ │ └── init.lua │ ├── taplo │ │ └── init.lua │ ├── vimls │ │ └── init.lua │ ├── awk_ls │ │ └── init.lua │ ├── bashls │ │ └── init.lua │ ├── csharp_ls │ │ └── init.lua │ ├── fsautocomplete │ │ └── init.lua │ ├── prismals │ │ └── init.lua │ ├── cmake │ │ └── init.lua │ ├── diagnosticls │ │ └── init.lua │ ├── hoon_ls │ │ └── init.lua │ ├── solidity_ls │ │ └── init.lua │ ├── yamlls │ │ └── init.lua │ ├── ember │ │ └── init.lua │ ├── remark_ls │ │ └── init.lua │ ├── robotframework_ls │ │ └── init.lua │ ├── cssmodules_ls │ │ └── init.lua │ ├── foam_ls │ │ └── init.lua │ ├── svlangserver │ │ └── init.lua │ ├── asm_lsp │ │ └── init.lua │ ├── beancount │ │ └── init.lua │ ├── cucumber_language_server │ │ └── init.lua │ ├── jedi_language_server │ │ └── init.lua │ ├── purescriptls │ │ └── init.lua │ ├── dockerls │ │ └── init.lua │ ├── graphql │ │ └── init.lua │ ├── lelwel_ls │ │ └── init.lua │ ├── tflint │ │ └── README.md │ ├── astro │ │ └── init.lua │ ├── teal_ls │ │ └── init.lua │ ├── elmls │ │ └── init.lua │ ├── flux_lsp │ │ └── init.lua │ ├── tsserver │ │ └── init.lua │ ├── vscode-langservers-extracted │ │ └── init.lua │ ├── wgsl_analyzer │ │ └── init.lua │ ├── golangci_lint_ls │ │ └── init.lua │ ├── ocamlls │ │ └── init.lua │ ├── perlnavigator │ │ └── init.lua │ ├── nimls │ │ └── init.lua │ ├── rome │ │ └── init.lua │ ├── pylsp │ │ └── README.md │ ├── jdtls │ │ └── README.md │ ├── ccls │ │ ├── init.lua │ │ ├── mac.lua │ │ └── common.lua │ ├── nickel_ls │ │ └── init.lua │ ├── rescriptls │ │ └── init.lua │ ├── puppet │ │ └── init.lua │ ├── mm0_ls │ │ └── init.lua │ ├── powershell_es │ │ └── init.lua │ ├── ansiblels │ │ └── init.lua │ ├── phpactor │ │ └── init.lua │ ├── groovyls │ │ └── init.lua │ ├── haxe_language_server │ │ └── init.lua │ ├── kotlin_language_server │ │ └── init.lua │ ├── bsl_ls │ │ └── init.lua │ ├── codeqlls │ │ └── init.lua │ ├── scry │ │ └── init.lua │ ├── clarity_lsp │ │ └── init.lua │ ├── slint_lsp │ │ └── init.lua │ ├── solc │ │ └── init.lua │ ├── elixirls │ │ └── init.lua │ ├── marksman │ │ └── init.lua │ ├── reason_ls │ │ └── init.lua │ ├── bicep │ │ └── init.lua │ ├── prosemd_lsp │ │ └── init.lua │ ├── crystalline │ │ └── init.lua │ ├── denols │ │ └── init.lua │ ├── erlangls │ │ └── init.lua │ ├── volar │ │ └── init.lua │ ├── clojure_lsp │ │ └── init.lua │ ├── clangd │ │ └── init.lua │ ├── texlab │ │ └── init.lua │ ├── opencl_ls │ │ └── init.lua │ ├── angularls │ │ └── init.lua │ ├── zls │ │ └── init.lua │ ├── vls │ │ └── init.lua │ ├── vala_ls │ │ └── init.lua │ ├── apex_ls │ │ └── init.lua │ ├── lemminx │ │ └── init.lua │ ├── serve_d │ │ └── init.lua │ ├── visualforce_ls │ │ └── init.lua │ ├── terraformls │ │ └── init.lua │ ├── quick_lint_js │ │ └── init.lua │ ├── zk │ │ └── init.lua │ ├── sumneko_lua │ │ └── init.lua │ ├── hls │ │ └── init.lua │ └── arduino_language_server │ │ └── init.lua │ ├── core │ ├── functional │ │ ├── table.lua │ │ ├── type.lua │ │ ├── relation.lua │ │ ├── data.lua │ │ ├── number.lua │ │ ├── string.lua │ │ ├── logic.lua │ │ └── function.lua │ ├── managers │ │ ├── cargo │ │ │ └── client.lua │ │ ├── dotnet │ │ │ └── init.lua │ │ ├── powershell │ │ │ └── init.lua │ │ └── opam │ │ │ └── init.lua │ ├── clients │ │ └── eclipse.lua │ ├── ui │ │ └── state.lua │ ├── path.lua │ ├── async │ │ └── uv.lua │ ├── fetch.lua │ └── optional.lua │ ├── notify.lua │ ├── _generated │ ├── schemas │ │ ├── rome.lua │ │ ├── nickel_ls.lua │ │ ├── bashls.lua │ │ ├── rescriptls.lua │ │ ├── r_language_server.lua │ │ ├── jsonls.lua │ │ ├── clangd.lua │ │ ├── stylelint_lsp.lua │ │ ├── elmls.lua │ │ └── yamlls.lua │ └── language_autocomplete_map.lua │ ├── jobs │ ├── outdated-servers │ │ ├── jdtls.lua │ │ └── version-check-result.lua │ └── pool.lua │ ├── dispatcher.lua │ └── ui │ └── server_hints.lua ├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ ├── config.yml │ ├── feature_request.yaml │ └── new_server_request.yaml ├── workflows │ ├── tests.yml │ ├── stylua.yml │ └── metadata-diff.yml └── FUNDING.yml ├── scripts └── autogen_metadata.sh └── Makefile /doc/.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /dependencies 2 | /tests/fixtures/lsp_servers 3 | -------------------------------------------------------------------------------- /stylua.toml: -------------------------------------------------------------------------------- 1 | indent_type = "Spaces" 2 | call_parentheses = "None" 3 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | Refer to https://github.com/williamboman/nvim-lspconfig-test for system tests. 2 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/cssls/init.lua: -------------------------------------------------------------------------------- 1 | return require "nvim-lsp-installer.servers.vscode-langservers-extracted" { "css" } 2 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/html/init.lua: -------------------------------------------------------------------------------- 1 | return require "nvim-lsp-installer.servers.vscode-langservers-extracted" { "html" } 2 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/jsonls/init.lua: -------------------------------------------------------------------------------- 1 | return require "nvim-lsp-installer.servers.vscode-langservers-extracted" { "json" } 2 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/eslint/init.lua: -------------------------------------------------------------------------------- 1 | return require "nvim-lsp-installer.servers.vscode-langservers-extracted" { "eslint", "javascript", "typescript" } 2 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 4 6 | end_of_line = lf 7 | insert_final_newline = true 8 | trim_trailing_whitespace=true 9 | max_line_length = 120 10 | charset = utf-8 11 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/core/functional/table.lua: -------------------------------------------------------------------------------- 1 | local fun = require "nvim-lsp-installer.core.functional.function" 2 | 3 | local _ = {} 4 | 5 | _.prop = fun.curryN(function(index, tbl) 6 | return tbl[index] 7 | end, 2) 8 | 9 | return _ 10 | -------------------------------------------------------------------------------- /tests/core/functional/table_spec.lua: -------------------------------------------------------------------------------- 1 | local _ = require "nvim-lsp-installer.core.functional" 2 | 3 | describe("functional: table", function() 4 | it("retrieves property of table", function() 5 | assert.equals("hello", _.prop("a", { a = "hello" })) 6 | end) 7 | end) 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | contact_links: 2 | - name: Ask a question about nvim-lsp-installer or get support 3 | url: https://github.com/williamboman/nvim-lsp-installer/discussions/new?category=q-a 4 | about: Ask a question or request support for using nvim-lsp-installer 5 | -------------------------------------------------------------------------------- /tests/core/clients/eclipse_spec.lua: -------------------------------------------------------------------------------- 1 | local eclipse = require "nvim-lsp-installer.core.clients.eclipse" 2 | 3 | describe("eclipse client", function() 4 | it("parses jdtls version strings", function() 5 | assert.equal( 6 | "1.8.0-202112170540", 7 | eclipse._parse_jdtls_version_string "jdt-language-server-1.8.0-202112170540.tar.gz" 8 | ) 9 | end) 10 | end) 11 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/core/functional/type.lua: -------------------------------------------------------------------------------- 1 | local fun = require "nvim-lsp-installer.core.functional.function" 2 | local rel = require "nvim-lsp-installer.core.functional.relation" 3 | 4 | local _ = {} 5 | 6 | _.is_nil = rel.equals(nil) 7 | 8 | ---@param typ type 9 | ---@param value any 10 | _.is = fun.curryN(function(typ, value) 11 | return type(value) == typ 12 | end, 2) 13 | 14 | return _ 15 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/omnisharp/README.md: -------------------------------------------------------------------------------- 1 | # omnisharp 2 | 3 | ## How to enable Omnisharp Mono 4 | 5 | By default, the `omnisharp` server will use the `dotnet` (NET6) runtime to run the server. 6 | To run the server using the Mono runtime, set the `use_mono` setting like so: 7 | 8 | ```lua 9 | local lspconfig = require("lspconfig") 10 | 11 | lspconfig.omnisharp.setup { 12 | use_mono = true 13 | } 14 | ``` 15 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/notify.lua: -------------------------------------------------------------------------------- 1 | local TITLE = "nvim-lsp-installer" 2 | 3 | return function(msg, level) 4 | local has_notify_plugin = pcall(require, "notify") 5 | level = level or vim.log.levels.INFO 6 | if has_notify_plugin then 7 | vim.notify(msg, level, { 8 | title = TITLE, 9 | }) 10 | else 11 | vim.notify(("[%s] %s"):format(TITLE, msg), level) 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /scripts/autogen_metadata.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -ex 3 | 4 | declare -x XDG_DATA_HOME="${XDG_DATA_HOME:-"$HOME/.local/share"}" 5 | declare -x NVIM_PACK_DIR="$XDG_DATA_HOME/nvim/site/pack" 6 | 7 | declare -x LSP_CONFIG_DIR="$NVIM_PACK_DIR/packer/start/nvim-lspconfig" 8 | declare -x LSP_INSTALLER_DIR="$PWD" 9 | 10 | nvim -u NONE -E -R --headless \ 11 | --cmd "set rtp+=${LSP_CONFIG_DIR},${LSP_INSTALLER_DIR}" \ 12 | +"luafile scripts/autogen_metadata.lua" +q 13 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: 4 | push: 5 | branches: 6 | - "main" 7 | pull_request: 8 | 9 | jobs: 10 | tests: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | - uses: rhysd/action-setup-vim@v1 15 | with: 16 | neovim: true 17 | version: v0.7.0 18 | - name: Run tests 19 | run: make test 20 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/core/functional/relation.lua: -------------------------------------------------------------------------------- 1 | local fun = require "nvim-lsp-installer.core.functional.function" 2 | 3 | local _ = {} 4 | 5 | _.equals = fun.curryN(function(expected, value) 6 | return value == expected 7 | end, 2) 8 | 9 | _.prop_eq = fun.curryN(function(property, value, tbl) 10 | return tbl[property] == value 11 | end, 3) 12 | 13 | _.prop_satisfies = fun.curryN(function(predicate, property, tbl) 14 | return predicate(tbl[property]) 15 | end, 3) 16 | 17 | return _ 18 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/core/managers/cargo/client.lua: -------------------------------------------------------------------------------- 1 | local fetch = require "nvim-lsp-installer.core.fetch" 2 | 3 | local M = {} 4 | 5 | ---@alias CrateResponse {crate: {id: string, max_stable_version: string, max_version: string, newest_version: string}} 6 | 7 | ---@async 8 | ---@param crate string 9 | ---@return Result @of Crate 10 | function M.fetch_crate(crate) 11 | return fetch(("https://crates.io/api/v1/crates/%s"):format(crate)):map_catching(vim.json.decode) 12 | end 13 | 14 | return M 15 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/tailwindcss/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "tailwind" }, 9 | installer = npm.packages { "@tailwindcss/language-server" }, 10 | default_options = { 11 | cmd_env = npm.env(root_dir), 12 | }, 13 | } 14 | end 15 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/dartls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local std = require "nvim-lsp-installer.core.managers.std" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://github.com/dart-lang/sdk", 9 | languages = { "dart" }, 10 | installer = std.system_executable("dart", { help_url = "https://dart.dev/get-dart" }), 11 | default_options = {}, 12 | } 13 | end 14 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/julials/README.md: -------------------------------------------------------------------------------- 1 | # julials 2 | 3 | ## Configuring the Julia Environment 4 | 5 | The Julia Environment will be identified in the following order: 6 | 7 | 1) user configuration (`lspconfig.julials.setup { julia_env_path = "/my/env" }`) 8 | 2) if the `Project.toml` & `Manifest.toml` (or `JuliaProject.toml` & `JuliaManifest.toml`) files exists in the current project working directory, the current project working directory is used as the environment 9 | 3) the result of `Pkg.Types.Context().env.project_file` 10 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/sorbet/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local gem = require "nvim-lsp-installer.core.managers.gem" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://sorbet.org/", 9 | languages = { "ruby" }, 10 | installer = gem.packages { "sorbet" }, 11 | default_options = { 12 | cmd_env = gem.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/vuels/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "vue" }, 9 | homepage = "https://github.com/vuejs/vetur", 10 | installer = npm.packages { "vls" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/solargraph/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local gem = require "nvim-lsp-installer.core.managers.gem" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "ruby" }, 9 | homepage = "https://solargraph.org", 10 | installer = gem.packages { "solargraph" }, 11 | default_options = { 12 | cmd_env = gem.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/_generated/schemas/rome.lua: -------------------------------------------------------------------------------- 1 | -- THIS FILE IS GENERATED. DO NOT EDIT MANUALLY. 2 | -- stylua: ignore start 3 | return {properties = {["rome.lspBin"] = {default = vim.NIL,markdownDescription = "The rome lsp server executable.",type = { "string", "null" }},["rome_lsp.trace.server"] = {default = "off",description = "Traces the communication between VS Code and the language server.",enum = { "off", "messages", "verbose" },enumDescriptions = { "No traces", "Error only", "Full log" },scope = "window",type = "string"}},title = "Rome",type = "object"} -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/intelephense/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://intelephense.com", 9 | languages = { "php" }, 10 | installer = npm.packages { "intelephense" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/emmet_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://github.com/aca/emmet-ls", 9 | languages = { "emmet" }, 10 | installer = npm.packages { "emmet-ls" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/fortls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local pip3 = require "nvim-lsp-installer.core.managers.pip3" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://github.com/gnikit/fortls", 9 | languages = { "fortran" }, 10 | installer = pip3.packages { "fortls" }, 11 | default_options = { 12 | cmd_env = pip3.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/pyright/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "python" }, 9 | homepage = "https://github.com/microsoft/pyright", 10 | installer = npm.packages { "pyright" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/sourcery/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local pip3 = require "nvim-lsp-installer.core.managers.pip3" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "python" }, 9 | homepage = "https://docs.sourcery.ai/", 10 | installer = pip3.packages { "sourcery-cli" }, 11 | default_options = { 12 | cmd_env = pip3.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/svls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local cargo = require "nvim-lsp-installer.core.managers.cargo" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "systemverilog" }, 9 | homepage = "https://github.com/dalance/svls", 10 | installer = cargo.crate "svls", 11 | default_options = { 12 | cmd_env = cargo.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/esbonio/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local pip3 = require "nvim-lsp-installer.core.managers.pip3" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "sphinx" }, 9 | homepage = "https://pypi.org/project/esbonio/", 10 | installer = pip3.packages { "esbonio" }, 11 | default_options = { 12 | cmd_env = pip3.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/psalm/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local composer = require "nvim-lsp-installer.core.managers.composer" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://psalm.dev/", 9 | languages = { "php" }, 10 | installer = composer.packages { "vimeo/psalm" }, 11 | default_options = { 12 | cmd_env = composer.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/rnix/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local cargo = require "nvim-lsp-installer.core.managers.cargo" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "nix" }, 9 | homepage = "https://github.com/nix-community/rnix-lsp", 10 | installer = cargo.crate "rnix-lsp", 11 | default_options = { 12 | cmd_env = cargo.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/salt_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local pip3 = require "nvim-lsp-installer.core.managers.pip3" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "sls" }, 9 | homepage = "https://github.com/dcermak/salt-lsp", 10 | installer = pip3.packages { "salt-lsp" }, 11 | default_options = { 12 | cmd_env = pip3.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/efm/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local go = require "nvim-lsp-installer.core.managers.go" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://github.com/mattn/efm-langserver", 9 | languages = {}, 10 | installer = go.packages { "github.com/mattn/efm-langserver" }, 11 | default_options = { 12 | cmd_env = go.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/grammarly/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://github.com/znck/grammarly", 9 | languages = {}, 10 | installer = npm.packages { "grammarly-languageserver" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/jsonnet_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local go = require "nvim-lsp-installer.core.managers.go" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://github.com/grafana/jsonnet-language-server", 9 | installer = go.packages { "github.com/grafana/jsonnet-language-server" }, 10 | default_options = { 11 | cmd_env = go.env(root_dir), 12 | }, 13 | } 14 | end 15 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/theme_check/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local gem = require "nvim-lsp-installer.core.managers.gem" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "liquid" }, 9 | homepage = "https://github.com/Shopify/theme-check", 10 | installer = gem.packages { "theme-check" }, 11 | default_options = { 12 | cmd_env = gem.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/gopls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local go = require "nvim-lsp-installer.core.managers.go" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://pkg.go.dev/golang.org/x/tools/gopls", 9 | languages = { "go" }, 10 | installer = go.packages { "golang.org/x/tools/gopls" }, 11 | default_options = { 12 | cmd_env = go.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/ocamllsp/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local opam = require "nvim-lsp-installer.core.managers.opam" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://github.com/ocaml/ocaml-lsp", 9 | languages = { "ocaml" }, 10 | installer = opam.packages { "ocaml-lsp-server" }, 11 | default_options = { 12 | cmd_env = opam.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/sourcekit/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local std = require "nvim-lsp-installer.core.managers.std" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://github.com/apple/sourcekit-lsp", 9 | languages = { "swift" }, 10 | installer = std.system_executable("sourcekit-lsp", { help_url = "https://github.com/apple/sourcekit-lsp" }), 11 | default_options = {}, 12 | } 13 | end 14 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/sqls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local go = require "nvim-lsp-installer.core.managers.go" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "sql" }, 9 | homepage = "https://github.com/lighttiger2505/sqls", 10 | installer = go.packages { "github.com/lighttiger2505/sqls" }, 11 | default_options = { 12 | cmd_env = go.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/dotls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://github.com/nikeee/dot-language-server", 9 | languages = { "dot" }, 10 | installer = npm.packages { "dot-language-server" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/sqlls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "sql" }, 9 | homepage = "https://github.com/joe-re/sql-language-server", 10 | installer = npm.packages { "sql-language-server" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/stylelint_lsp/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://github.com/bmatcuk/stylelint-lsp", 9 | languages = { "stylelint" }, 10 | installer = npm.packages { "stylelint-lsp" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/svelte/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "svelte" }, 9 | homepage = "https://github.com/sveltejs/language-tools", 10 | installer = npm.packages { "svelte-language-server" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/taplo/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local cargo = require "nvim-lsp-installer.core.managers.cargo" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "toml" }, 9 | homepage = "https://taplo.tamasfe.dev/lsp/", 10 | installer = cargo.crate("taplo-cli", { features = "lsp" }), 11 | default_options = { 12 | cmd_env = cargo.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/vimls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "vim" }, 9 | homepage = "https://github.com/iamcco/vim-language-server", 10 | installer = npm.packages { "vim-language-server" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/awk_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "awk" }, 9 | homepage = "https://github.com/Beaglefoot/awk-language-server", 10 | installer = npm.packages { "awk-language-server" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/bashls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "bash" }, 9 | homepage = "https://github.com/bash-lsp/bash-language-server", 10 | installer = npm.packages { "bash-language-server" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/csharp_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local dotnet = require "nvim-lsp-installer.core.managers.dotnet" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "c#" }, 9 | homepage = "https://github.com/razzmatazz/csharp-language-server", 10 | installer = dotnet.package "csharp-ls", 11 | default_options = { 12 | cmd_env = dotnet.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/fsautocomplete/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local dotnet = require "nvim-lsp-installer.core.managers.dotnet" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "f#" }, 9 | homepage = "https://github.com/fsharp/FsAutoComplete", 10 | installer = dotnet.package "fsautocomplete", 11 | default_options = { 12 | cmd_env = dotnet.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/prismals/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "prisma" }, 9 | homepage = "https://github.com/prisma/language-tools", 10 | installer = npm.packages { "@prisma/language-server" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/cmake/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local pip3 = require "nvim-lsp-installer.core.managers.pip3" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://github.com/regen100/cmake-language-server", 9 | languages = { "cmake" }, 10 | installer = pip3.packages { "cmake-language-server" }, 11 | default_options = { 12 | cmd_env = pip3.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/diagnosticls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = {}, 9 | homepage = "https://github.com/iamcco/diagnostic-languageserver", 10 | installer = npm.packages { "diagnostic-languageserver" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/hoon_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "hoon" }, 9 | homepage = "https://github.com/urbit/hoon-language-server", 10 | installer = npm.packages { "@urbit/hoon-language-server" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/solidity_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "solidity" }, 9 | homepage = "https://github.com/edag94/vscode-solidity", 10 | installer = npm.packages { "solidity-language-server" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/yamlls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "yaml" }, 9 | homepage = "https://github.com/redhat-developer/yaml-language-server", 10 | installer = npm.packages { "yaml-language-server" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/ember/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "ember" }, 9 | homepage = "https://github.com/lifeart/ember-language-server", 10 | installer = npm.packages { "@lifeart/ember-language-server" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/remark_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://github.com/remarkjs/remark-language-server", 9 | languages = { "markdown" }, 10 | installer = npm.packages { "remark-language-server" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/robotframework_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local pip3 = require "nvim-lsp-installer.core.managers.pip3" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | installer = pip3.packages { "robotframework-lsp" }, 9 | languages = { "robot" }, 10 | homepage = "https://github.com/robocorp/robotframework-lsp", 11 | default_options = { 12 | cmd_env = pip3.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/cssmodules_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://github.com/antonk52/cssmodules-language-server", 9 | languages = { "css" }, 10 | installer = npm.packages { "cssmodules-language-server" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/foam_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://github.com/FoamScience/foam-language-server", 9 | languages = { "foam", "OpenFOAM" }, 10 | installer = npm.packages { "foam-language-server" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/svlangserver/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://github.com/imc-trading/svlangserver", 9 | languages = { "systemverilog" }, 10 | installer = npm.packages { "@imc-trading/svlangserver" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/_generated/schemas/nickel_ls.lua: -------------------------------------------------------------------------------- 1 | -- THIS FILE IS GENERATED. DO NOT EDIT MANUALLY. 2 | -- stylua: ignore start 3 | return {properties = {["nls.server.debugLog"] = {default = false,description = "Logs the communication between VS Code and the language server.",scope = "window",type = "boolean"},["nls.server.path"] = {default = "nls",description = "Path to nickel language server",scope = "window",type = "string"},["nls.server.trace"] = {description = "Enables performance tracing to the given file",scope = "window",type = "string"}},title = "Nickel Language Server Configuration",type = "object"} -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/asm_lsp/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local cargo = require "nvim-lsp-installer.core.managers.cargo" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "assembly-gas", "assembly-nasm", "assembly-go" }, 9 | homepage = "https://github.com/bergercookie/asm-lsp", 10 | installer = cargo.crate "asm-lsp", 11 | default_options = { 12 | cmd_env = cargo.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/beancount/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local cargo = require "nvim-lsp-installer.core.managers.cargo" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "beancount" }, 9 | homepage = "https://github.com/polarmutex/beancount-language-server", 10 | installer = cargo.crate "beancount-language-server", 11 | default_options = { 12 | cmd_env = cargo.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/cucumber_language_server/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "cucumber" }, 9 | homepage = "https://github.com/cucumber/language-server", 10 | installer = npm.packages { "@cucumber/language-server" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/jedi_language_server/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local pip3 = require "nvim-lsp-installer.core.managers.pip3" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "python" }, 9 | homepage = "https://github.com/pappasam/jedi-language-server", 10 | installer = pip3.packages { "jedi-language-server" }, 11 | default_options = { 12 | cmd_env = pip3.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/purescriptls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "purescript" }, 9 | homepage = "https://github.com/nwolverson/purescript-language-server", 10 | installer = npm.packages { "purescript-language-server" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/dockerls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://github.com/rcjsuen/dockerfile-language-server-nodejs", 9 | languages = { "docker" }, 10 | installer = npm.packages { "dockerfile-language-server-nodejs" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/graphql/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://www.npmjs.com/package/graphql-language-service-cli", 9 | languages = { "graphql" }, 10 | installer = npm.packages { "graphql-language-service-cli", "graphql" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/lelwel_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local cargo = require "nvim-lsp-installer.core.managers.cargo" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "lelwel" }, 9 | homepage = "https://github.com/0x2a-42/lelwel", 10 | installer = cargo.crate("lelwel", { 11 | features = "lsp", 12 | }), 13 | default_options = { 14 | cmd_env = cargo.env(root_dir), 15 | }, 16 | } 17 | end 18 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/tflint/README.md: -------------------------------------------------------------------------------- 1 | # tflint 2 | 3 | ## Installing TFLint plugins 4 | 5 | TFLint has [third party plugins](https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md) which are not installed by default. 6 | 7 | To install TFLint plugins, there's a convenient `:TFLintInit` command that does this for you. It will use Neovim's 8 | current working directory to locate the plugins to install (according to `tflint --init`): 9 | 10 | ``` 11 | :TFLintInit 12 | ``` 13 | 14 | The `:TFLintInit` command will only be available once the `tflint` server has been set up. 15 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/core/clients/eclipse.lua: -------------------------------------------------------------------------------- 1 | local fetch = require "nvim-lsp-installer.core.fetch" 2 | local M = {} 3 | 4 | ---@param version string The version string as found in the latest.txt endpoint. 5 | ---@return string The parsed version number. 6 | function M._parse_jdtls_version_string(version) 7 | return vim.trim(version):gsub("^jdt%-language%-server%-", ""):gsub("%.tar%.gz$", "") 8 | end 9 | 10 | ---@async 11 | function M.fetch_latest_jdtls_version() 12 | return fetch("https://download.eclipse.org/jdtls/snapshots/latest.txt"):map(M._parse_jdtls_version_string) 13 | end 14 | 15 | return M 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/astro/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "astro" }, 9 | homepage = "https://github.com/withastro/language-tools/tree/main/packages/language-server", 10 | installer = npm.packages { "@astrojs/language-server" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/teal_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local luarocks = require "nvim-lsp-installer.core.managers.luarocks" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "teal" }, 9 | homepage = "https://github.com/teal-language/teal-language-server", 10 | installer = luarocks.package("teal-language-server", { dev = true }), 11 | default_options = { 12 | cmd_env = luarocks.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/elmls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://github.com/elm-tooling/elm-language-server", 9 | languages = { "elm" }, 10 | installer = npm.packages { "@elm-tooling/elm-language-server", "elm", "elm-test", "elm-format" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/flux_lsp/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local cargo = require "nvim-lsp-installer.core.managers.cargo" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "flux" }, 9 | homepage = "https://github.com/influxdata/flux-lsp", 10 | installer = cargo.crate("https://github.com/influxdata/flux-lsp", { 11 | git = true, 12 | }), 13 | default_options = { 14 | cmd_env = cargo.env(root_dir), 15 | }, 16 | } 17 | end 18 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/tsserver/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | languages = { "typescript", "javascript" }, 9 | homepage = "https://github.com/typescript-language-server/typescript-language-server", 10 | installer = npm.packages { "typescript-language-server", "typescript" }, 11 | default_options = { 12 | cmd_env = npm.env(root_dir), 13 | }, 14 | } 15 | end 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/vscode-langservers-extracted/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | ---@param languages string[] 5 | return function(languages) 6 | return function(name, root_dir) 7 | return server.Server:new { 8 | name = name, 9 | languages = languages, 10 | root_dir = root_dir, 11 | installer = npm.packages { "vscode-langservers-extracted" }, 12 | default_options = { 13 | cmd_env = npm.env(root_dir), 14 | }, 15 | } 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/jobs/outdated-servers/jdtls.lua: -------------------------------------------------------------------------------- 1 | local eclipse = require "nvim-lsp-installer.core.clients.eclipse" 2 | 3 | ---@async 4 | ---@param receipt InstallReceipt 5 | return function(receipt) 6 | return eclipse.fetch_latest_jdtls_version():map_catching(function(latest_version) 7 | if receipt.primary_source.version ~= latest_version then 8 | return { 9 | name = "jdtls", 10 | current_version = receipt.primary_source.version, 11 | latest_version = latest_version, 12 | } 13 | end 14 | error "Primary package is not outdated." 15 | end) 16 | end 17 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/_generated/schemas/bashls.lua: -------------------------------------------------------------------------------- 1 | -- THIS FILE IS GENERATED. DO NOT EDIT MANUALLY. 2 | -- stylua: ignore start 3 | return {properties = {["bashIde.explainshellEndpoint"] = {default = "",description = "Configure explainshell server in order to get hover documentation on flags and options.",type = "string"},["bashIde.globPattern"] = {default = "**/*@(.sh|.inc|.bash|.command)",description = "Glob pattern for finding and parsing shell script files.",type = "string"},["bashIde.highlightParsingErrors"] = {default = false,description = "Controls if parsing errors will be highlighted as problems.",type = "boolean"}},title = "Bash IDE configuration",type = "object"} -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/wgsl_analyzer/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local cargo = require "nvim-lsp-installer.core.managers.cargo" 3 | 4 | return function(name, root_dir) 5 | local homepage = "https://github.com/wgsl-analyzer/wgsl-analyzer" 6 | 7 | return server.Server:new { 8 | name = name, 9 | root_dir = root_dir, 10 | languages = { "wgsl" }, 11 | homepage = homepage, 12 | installer = cargo.crate("wgsl_analyzer", { 13 | git = homepage, 14 | }), 15 | default_options = { 16 | cmd_env = cargo.env(root_dir), 17 | }, 18 | } 19 | end 20 | -------------------------------------------------------------------------------- /.github/workflows/stylua.yml: -------------------------------------------------------------------------------- 1 | name: Stylua check 2 | 3 | on: 4 | push: 5 | branches: 6 | - "main" 7 | pull_request: 8 | 9 | jobs: 10 | stylua: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | - name: Run Stylua check 15 | uses: JohnnyMorganz/stylua-action@1.0.0 16 | with: 17 | version: 0.13.1 18 | # token is needed because the action allegedly downloads binary from github releases 19 | token: ${{ secrets.GITHUB_TOKEN }} 20 | # CLI arguments 21 | args: --check . 22 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/dispatcher.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | local registered_callbacks = {} 4 | 5 | ---@param server Server 6 | M.dispatch_server_ready = function(server) 7 | for _, callback in pairs(registered_callbacks) do 8 | local ok, err = pcall(callback, server) 9 | if not ok then 10 | vim.notify(tostring(err), vim.log.levels.ERROR) 11 | end 12 | end 13 | end 14 | 15 | ---@param callback fun(server: Server) 16 | function M.register_server_ready_callback(callback) 17 | registered_callbacks[callback] = callback 18 | return function() 19 | registered_callbacks[callback] = nil 20 | end 21 | end 22 | 23 | return M 24 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/core/functional/data.lua: -------------------------------------------------------------------------------- 1 | local _ = {} 2 | 3 | _.table_pack = function(...) 4 | return { n = select("#", ...), ... } 5 | end 6 | 7 | ---@generic T : string 8 | ---@param values T[] 9 | ---@return table 10 | _.enum = function(values) 11 | local result = {} 12 | for i = 1, #values do 13 | local v = values[i] 14 | result[v] = v 15 | end 16 | return result 17 | end 18 | 19 | ---@generic T 20 | ---@param list T[] 21 | ---@return table 22 | _.set_of = function(list) 23 | local set = {} 24 | for i = 1, #list do 25 | set[list[i]] = true 26 | end 27 | return set 28 | end 29 | 30 | return _ 31 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/eslint/README.md: -------------------------------------------------------------------------------- 1 | # eslint 2 | 3 | *NOTE*: You will have to install the [`eslint` package](https://www.npmjs.com/package/eslint) either locally or globally for the server to run successfully. 4 | 5 | ## Eslint in projects that use pnp 6 | 7 | To allow the `eslint` server to resolve eslint and eslint plugins in a project that uses yarn 2/pnp, you need to manually change the 8 | command used to run the server. This is done when setting up the LSP server, like so: 9 | 10 | ```lua 11 | local eslint_config = require("lspconfig.server_configurations.eslint") 12 | lspconfig.eslint.setup { 13 | opts.cmd = { "yarn", "exec", unpack(eslint_config.default_config.cmd) } 14 | } 15 | ``` 16 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/golangci_lint_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local go = require "nvim-lsp-installer.core.managers.go" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | homepage = "https://github.com/nametake/golangci-lint-langserver", 9 | languages = { "go" }, 10 | installer = go.packages { 11 | "github.com/nametake/golangci-lint-langserver", 12 | "github.com/golangci/golangci-lint/cmd/golangci-lint", 13 | }, 14 | default_options = { 15 | cmd_env = go.env(root_dir), 16 | }, 17 | } 18 | end 19 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/ocamlls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | 4 | return function(name, root_dir) 5 | return server.Server:new { 6 | name = name, 7 | root_dir = root_dir, 8 | deprecated = { 9 | message = "ocamlls is deprecated, use ocamllsp instead.", 10 | replace_with = "ocamllsp", 11 | }, 12 | homepage = "https://github.com/ocaml-lsp/ocaml-language-server", 13 | languages = { "ocaml" }, 14 | installer = npm.packages { "ocaml-language-server" }, 15 | default_options = { 16 | cmd_env = npm.env(root_dir), 17 | }, 18 | } 19 | end 20 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/core/ui/state.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | ---@generic T : table 4 | ---@param initial_state T 5 | ---@param subscriber fun(state: T) 6 | function M.create_state_container(initial_state, subscriber) 7 | -- we do deepcopy to make sure instances of state containers doesn't mutate the initial state 8 | local state = vim.deepcopy(initial_state) 9 | local has_unsubscribed = false 10 | 11 | ---@param mutate_fn fun(current_state: table) 12 | return function(mutate_fn) 13 | mutate_fn(state) 14 | if not has_unsubscribed then 15 | subscriber(state) 16 | end 17 | end, function() 18 | return state 19 | end, function(val) 20 | has_unsubscribed = val 21 | end 22 | end 23 | 24 | return M 25 | -------------------------------------------------------------------------------- /tests/core/functional/data_spec.lua: -------------------------------------------------------------------------------- 1 | local _ = require "nvim-lsp-installer.core.functional" 2 | 3 | describe("functional: data", function() 4 | it("creates enums", function() 5 | local colors = _.enum { 6 | "BLUE", 7 | "YELLOW", 8 | } 9 | assert.same({ 10 | ["BLUE"] = "BLUE", 11 | ["YELLOW"] = "YELLOW", 12 | }, colors) 13 | end) 14 | 15 | it("creates sets", function() 16 | local colors = _.set_of { 17 | "BLUE", 18 | "YELLOW", 19 | "BLUE", 20 | "RED", 21 | } 22 | assert.same({ 23 | ["BLUE"] = true, 24 | ["YELLOW"] = true, 25 | ["RED"] = true, 26 | }, colors) 27 | end) 28 | end) 29 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | INSTALL_ROOT_DIR:=$(shell pwd)/tests/fixtures/lsp_servers 2 | NVIM_HEADLESS:=nvim --headless --noplugin -u tests/minimal_init.vim 3 | 4 | dependencies: 5 | git clone --depth 1 https://github.com/nvim-lua/plenary.nvim dependencies/pack/vendor/start/plenary.nvim 6 | git clone --depth 1 https://github.com/neovim/nvim-lspconfig dependencies/pack/vendor/start/nvim-lspconfig 7 | 8 | .PHONY: clean_dependencies 9 | clean_dependencies: 10 | rm -rf dependencies 11 | 12 | .PHONY: clean_fixtures 13 | clean_fixtures: 14 | rm -rf "${INSTALL_ROOT_DIR}" 15 | 16 | .PHONY: clean 17 | clean: clean_fixtures clean_dependencies 18 | 19 | .PHONY: test 20 | test: clean_fixtures dependencies 21 | INSTALL_ROOT_DIR=${INSTALL_ROOT_DIR} $(NVIM_HEADLESS) -c "call RunTests()" 22 | 23 | # vim:noexpandtab 24 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/perlnavigator/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local path = require "nvim-lsp-installer.core.path" 3 | local npm = require "nvim-lsp-installer.core.managers.npm" 4 | 5 | return function(name, root_dir) 6 | return server.Server:new { 7 | name = name, 8 | root_dir = root_dir, 9 | languages = { "perl" }, 10 | homepage = "https://github.com/bscan/PerlNavigator", 11 | installer = npm.packages { "perlnavigator-server" }, 12 | default_options = { 13 | cmd = { 14 | "node", 15 | path.concat { root_dir, "node_modules", "perlnavigator-server", "out", "server.js" }, 16 | "--stdio", 17 | }, 18 | }, 19 | } 20 | end 21 | -------------------------------------------------------------------------------- /tests/minimal_init.vim: -------------------------------------------------------------------------------- 1 | " Avoid neovim/neovim#11362 2 | set display=lastline 3 | set directory="" 4 | set noswapfile 5 | 6 | let $lsp_installer = getcwd() 7 | let $test_helpers = getcwd() .. "/tests/helpers" 8 | let $dependencies = getcwd() .. "/dependencies" 9 | 10 | set rtp+=$lsp_installer,$test_helpers 11 | set packpath=$dependencies 12 | 13 | packloadall 14 | 15 | lua require("luassertx") 16 | lua require("test_helpers") 17 | 18 | lua < number 12 | end, 2) 13 | 14 | _.gte = fun.curryN(function(number, value) 15 | return value >= number 16 | end, 2) 17 | 18 | _.lt = fun.curryN(function(number, value) 19 | return value < number 20 | end, 2) 21 | 22 | _.lte = fun.curryN(function(number, value) 23 | return value <= number 24 | end, 2) 25 | 26 | _.inc = fun.curryN(function(increment, value) 27 | return value + increment 28 | end, 2) 29 | 30 | _.dec = fun.curryN(function(decrement, value) 31 | return value - decrement 32 | end, 2) 33 | 34 | return _ 35 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/core/functional/string.lua: -------------------------------------------------------------------------------- 1 | local fun = require "nvim-lsp-installer.core.functional.function" 2 | 3 | local _ = {} 4 | 5 | ---@param pattern string 6 | ---@param str string 7 | _.matches = fun.curryN(function(pattern, str) 8 | return str:match(pattern) ~= nil 9 | end, 2) 10 | 11 | ---@param template string 12 | ---@param str string 13 | _.format = fun.curryN(function(template, str) 14 | return template:format(str) 15 | end, 2) 16 | 17 | ---@param sep string 18 | ---@param str string 19 | _.split = fun.curryN(function(sep, str) 20 | return vim.split(str, sep) 21 | end, 2) 22 | 23 | ---@param pattern string 24 | ---@param repl string|function|table 25 | ---@param str string 26 | _.gsub = fun.curryN(function(pattern, repl, str) 27 | return string.gsub(str, pattern, repl) 28 | end, 3) 29 | 30 | return _ 31 | -------------------------------------------------------------------------------- /tests/core/fs_spec.lua: -------------------------------------------------------------------------------- 1 | local fs = require "nvim-lsp-installer.core.fs" 2 | local lsp_installer = require "nvim-lsp-installer" 3 | 4 | describe("fs", function() 5 | before_each(function() 6 | lsp_installer.settings { 7 | install_root_dir = "/foo", 8 | } 9 | end) 10 | 11 | it( 12 | "refuses to rmrf paths outside of boundary", 13 | async_test(function() 14 | local e = assert.has.errors(function() 15 | fs.async.rmrf "/thisisa/path" 16 | end) 17 | 18 | assert.equal( 19 | [[Refusing to rmrf "/thisisa/path" which is outside of the allowed boundary "/foo". Please report this error at https://github.com/williamboman/nvim-lsp-installer/issues/new]], 20 | e 21 | ) 22 | end) 23 | ) 24 | end) 25 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/nimls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local process = require "nvim-lsp-installer.core.process" 3 | local git = require "nvim-lsp-installer.core.managers.git" 4 | 5 | return function(name, root_dir) 6 | return server.Server:new { 7 | name = name, 8 | root_dir = root_dir, 9 | homepage = "https://github.com/PMunch/nimlsp", 10 | languages = { "nim" }, 11 | ---@param ctx InstallContext 12 | installer = function(ctx) 13 | git.clone({ "https://github.com/PMunch/nimlsp.git" }).with_receipt() 14 | ctx.spawn.nimble { "build", "-y", "--localdeps" } 15 | end, 16 | default_options = { 17 | cmd_env = { 18 | PATH = process.extend_path { root_dir }, 19 | }, 20 | }, 21 | } 22 | end 23 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [williamboman] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/rome/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local npm = require "nvim-lsp-installer.core.managers.npm" 3 | local Optional = require "nvim-lsp-installer.core.optional" 4 | 5 | return function(name, root_dir) 6 | return server.Server:new { 7 | name = name, 8 | root_dir = root_dir, 9 | languages = { "typescript", "javascript" }, 10 | homepage = "https://rome.tools", 11 | ---@param ctx InstallContext 12 | installer = function(ctx) 13 | ctx.requested_version = ctx.requested_version:or_(function() 14 | return Optional.of "10.0.7-nightly.2021.7.27" 15 | end) 16 | npm.install({ "rome" }).with_receipt() 17 | end, 18 | default_options = { 19 | cmd_env = npm.env(root_dir), 20 | }, 21 | } 22 | end 23 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/pylsp/README.md: -------------------------------------------------------------------------------- 1 | # Pylsp 2 | 3 | ## Installing pylsp plugins 4 | 5 | Pylsp has [third party plugins](https://github.com/python-lsp/python-lsp-server#3rd-party-plugins) which are not installed by default. 6 | 7 | In order for these plugins to work with the `pylsp` server managed by this plugin, they need to be installed in the same [virtual environment](https://docs.python.org/3/library/venv.html) as `pylsp`. For these reasons, there's a convenient `:PylspInstall ` command that does this for you, for example: 8 | 9 | ```vim 10 | :PylspInstall pyls-flake8 pylsp-mypy pyls-isort 11 | ``` 12 | 13 | The `:PylspInstall` command will only be available once the `pylsp` server has been set up. 14 | 15 | **Note that these extra pylsp plugins will not be reinstalled if you update/reinstall the `pylsp` server, you will have to manage 16 | them manually.** 17 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/jdtls/README.md: -------------------------------------------------------------------------------- 1 | # jdtls 2 | 3 | ## Customizing JVM arguments 4 | 5 | It's possible to customize some of the JVM arguments used to launch the server by setting the `vmargs` configuration. 6 | This can for example be used to change the memory configuration. 7 | 8 | Example:: 9 | 10 | ```lua 11 | lspconfig.jdtls.setup { 12 | vmargs = { 13 | "-XX:+UseParallelGC", 14 | "-XX:GCTimeRatio=4", 15 | "-XX:AdaptiveSizePolicyWeight=90", 16 | "-Dsun.zip.disableMemoryMapping=true", 17 | "-Djava.import.generatesMetadataFilesAtProjectRoot=false", 18 | "-Xmx1G", 19 | "-Xms100m", 20 | } 21 | } 22 | ``` 23 | 24 | ## Enable Lombok support 25 | 26 | Lombok support is disabled by default. To enable Lombok support, set the `use_lombok_agent` configuration to `true` 27 | during setup, like so: 28 | 29 | ```lua 30 | lspconfig.jdtls.setup { 31 | use_lombok_agent = true 32 | } 33 | ``` 34 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/ccls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local path = require "nvim-lsp-installer.core.path" 3 | local platform = require "nvim-lsp-installer.core.platform" 4 | local process = require "nvim-lsp-installer.core.process" 5 | 6 | return function(name, root_dir) 7 | return server.Server:new { 8 | name = name, 9 | root_dir = root_dir, 10 | homepage = "https://github.com/MaskRay/ccls", 11 | languages = { "c", "c++", "objective-c" }, 12 | installer = function() 13 | platform.when { 14 | mac = require "nvim-lsp-installer.servers.ccls.mac", 15 | linux = require "nvim-lsp-installer.servers.ccls.linux", 16 | } 17 | end, 18 | default_options = { 19 | cmd_env = { 20 | PATH = process.extend_path { path.concat { root_dir, "bin" } }, 21 | }, 22 | }, 23 | } 24 | end 25 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/nickel_ls/init.lua: -------------------------------------------------------------------------------- 1 | local path = require "nvim-lsp-installer.core.path" 2 | local server = require "nvim-lsp-installer.server" 3 | local cargo = require "nvim-lsp-installer.core.managers.cargo" 4 | local git = require "nvim-lsp-installer.core.managers.git" 5 | 6 | return function(name, root_dir) 7 | return server.Server:new { 8 | name = name, 9 | root_dir = root_dir, 10 | homepage = "https://nickel-lang.org/", 11 | languages = { "nickel" }, 12 | installer = function(ctx) 13 | git.clone({ "https://github.com/tweag/nickel" }).with_receipt() 14 | ctx.spawn.cargo { 15 | "install", 16 | "--root", 17 | ".", 18 | "--path", 19 | path.concat { "lsp", "nls" }, 20 | } 21 | end, 22 | default_options = { 23 | cmd_env = cargo.env(root_dir), 24 | }, 25 | } 26 | end 27 | -------------------------------------------------------------------------------- /tests/core/functional/type_spec.lua: -------------------------------------------------------------------------------- 1 | local _ = require "nvim-lsp-installer.core.functional" 2 | 3 | describe("functional: type", function() 4 | it("should check nil value", function() 5 | assert.is_true(_.is_nil(nil)) 6 | assert.is_false(_.is_nil(1)) 7 | assert.is_false(_.is_nil {}) 8 | assert.is_false(_.is_nil(function() end)) 9 | end) 10 | 11 | it("should check types", function() 12 | local is_fun = _.is "function" 13 | local is_string = _.is "string" 14 | local is_number = _.is "number" 15 | local is_boolean = _.is "boolean" 16 | 17 | assert.is_true(is_fun(function() end)) 18 | assert.is_false(is_fun(1)) 19 | assert.is_true(is_string "") 20 | assert.is_false(is_string(1)) 21 | assert.is_true(is_number(1)) 22 | assert.is_false(is_number "") 23 | assert.is_true(is_boolean(true)) 24 | assert.is_false(is_boolean(1)) 25 | end) 26 | end) 27 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/core/path.lua: -------------------------------------------------------------------------------- 1 | local uv = vim.loop 2 | 3 | local sep = (function() 4 | ---@diagnostic disable-next-line: undefined-global 5 | if jit then 6 | ---@diagnostic disable-next-line: undefined-global 7 | local os = string.lower(jit.os) 8 | if os == "linux" or os == "osx" or os == "bsd" then 9 | return "/" 10 | else 11 | return "\\" 12 | end 13 | else 14 | return package.config:sub(1, 1) 15 | end 16 | end)() 17 | 18 | local M = {} 19 | 20 | function M.cwd() 21 | return uv.fs_realpath "." 22 | end 23 | 24 | ---@param path_components string[] 25 | ---@return string 26 | function M.concat(path_components) 27 | return table.concat(path_components, sep) 28 | end 29 | 30 | ---@path root_path string 31 | ---@path path string 32 | function M.is_subdirectory(root_path, path) 33 | return root_path == path or path:sub(1, #root_path + 1) == root_path .. sep 34 | end 35 | 36 | return M 37 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/rescriptls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local path = require "nvim-lsp-installer.core.path" 3 | local github = require "nvim-lsp-installer.core.managers.github" 4 | 5 | return function(name, root_dir) 6 | return server.Server:new { 7 | name = name, 8 | root_dir = root_dir, 9 | languages = { "rescript" }, 10 | homepage = "https://github.com/rescript-lang/rescript-vscode", 11 | installer = function() 12 | github.unzip_release_file({ 13 | repo = "rescript-lang/rescript-vscode", 14 | asset_file = function(version) 15 | return ("rescript-vscode-%s.vsix"):format(version) 16 | end, 17 | }).with_receipt() 18 | end, 19 | default_options = { 20 | cmd = { "node", path.concat { root_dir, "extension", "server", "out", "server.js" }, "--stdio" }, 21 | }, 22 | } 23 | end 24 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/puppet/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local process = require "nvim-lsp-installer.core.process" 3 | local github = require "nvim-lsp-installer.core.managers.github" 4 | 5 | return function(name, root_dir) 6 | return server.Server:new { 7 | name = name, 8 | root_dir = root_dir, 9 | homepage = "https://github.com/puppetlabs/puppet-editor-services", 10 | languages = { "puppet" }, 11 | installer = function() 12 | github.unzip_release_file({ 13 | repo = "puppetlabs/puppet-editor-services", 14 | asset_file = function(version) 15 | return ("puppet_editor_services_%s.zip"):format(version) 16 | end, 17 | }).with_receipt() 18 | end, 19 | default_options = { 20 | cmd_env = { 21 | PATH = process.extend_path { root_dir }, 22 | }, 23 | }, 24 | } 25 | end 26 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/ccls/mac.lua: -------------------------------------------------------------------------------- 1 | local path = require "nvim-lsp-installer.core.path" 2 | local platform = require "nvim-lsp-installer.core.platform" 3 | local installer = require "nvim-lsp-installer.core.installer" 4 | local fs = require "nvim-lsp-installer.core.fs" 5 | 6 | local ccls_installer = require "nvim-lsp-installer.servers.ccls.common" 7 | 8 | ---@async 9 | return function() 10 | local ctx = installer.context() 11 | local homebrew_prefix = platform.get_homebrew_prefix():get_or_throw() 12 | local llvm_dir = path.concat { homebrew_prefix, "opt", "llvm", "lib", "cmake" } 13 | if not fs.async.dir_exists(llvm_dir) then 14 | ctx.stdio_sink.stderr( 15 | ( 16 | "LLVM does not seem to be installed on this system (looked in %q). Please install LLVM via Homebrew:\n $ brew install llvm\n" 17 | ):format(llvm_dir) 18 | ) 19 | error "Unable to find LLVM." 20 | end 21 | ccls_installer { llvm_dir = llvm_dir } 22 | end 23 | -------------------------------------------------------------------------------- /tests/core/path_spec.lua: -------------------------------------------------------------------------------- 1 | local path = require "nvim-lsp-installer.core.path" 2 | 3 | describe("path", function() 4 | it("concatenates paths", function() 5 | assert.equal("foo/bar/baz/~", path.concat { "foo", "bar", "baz", "~" }) 6 | end) 7 | 8 | it("concatenates paths on Windows", function() 9 | local old_os = jit.os 10 | jit.os = "windows" 11 | package.loaded["nvim-lsp-installer.core.path"] = nil 12 | local path = require "nvim-lsp-installer.core.path" 13 | assert.equal([[foo\bar\baz\~]], path.concat { "foo", "bar", "baz", "~" }) 14 | jit.os = old_os 15 | end) 16 | 17 | it("identifies subdirectories", function() 18 | assert.is_true(path.is_subdirectory("/foo/bar", "/foo/bar/baz")) 19 | assert.is_true(path.is_subdirectory("/foo/bar", "/foo/bar")) 20 | assert.is_false(path.is_subdirectory("/foo/bar", "/foo/bas/baz")) 21 | assert.is_false(path.is_subdirectory("/foo/bar", "/foo/bars/baz")) 22 | end) 23 | end) 24 | -------------------------------------------------------------------------------- /.github/workflows/metadata-diff.yml: -------------------------------------------------------------------------------- 1 | name: Metadata diff checker 2 | 3 | on: 4 | push: 5 | branches: 6 | - "main" 7 | pull_request: 8 | 9 | jobs: 10 | metadata-diff-check: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | - uses: rhysd/action-setup-vim@v1 15 | with: 16 | neovim: true 17 | version: v0.7.0 18 | 19 | - name: Clone dependencies 20 | run: | 21 | mkdir -p ~/.local/share/nvim/site/pack/packer/start 22 | git clone --depth 1 https://github.com/neovim/nvim-lspconfig ~/.local/share/nvim/site/pack/packer/start/nvim-lspconfig 23 | 24 | - name: Run autogen_metadata.sh script 25 | run: ./scripts/autogen_metadata.sh 26 | 27 | - name: Ensure there are no diffs 28 | run: | 29 | git update-index --refresh 30 | git diff-index --quiet HEAD -- 31 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/mm0_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local path = require "nvim-lsp-installer.core.path" 3 | local process = require "nvim-lsp-installer.core.process" 4 | local git = require "nvim-lsp-installer.core.managers.git" 5 | 6 | return function(name, root_dir) 7 | return server.Server:new { 8 | name = name, 9 | root_dir = root_dir, 10 | languages = { "metamath-zero" }, 11 | homepage = "https://github.com/digama0/mm0", 12 | ---@param ctx InstallContext 13 | installer = function(ctx) 14 | git.clone({ "https://github.com/digama0/mm0" }).with_receipt() 15 | ctx:chdir("mm0-rs", function() 16 | ctx.spawn.cargo { "build", "--release" } 17 | end) 18 | end, 19 | default_options = { 20 | cmd_env = { 21 | PATH = process.extend_path { path.concat { root_dir, "mm0-rs", "target", "release" } }, 22 | }, 23 | }, 24 | } 25 | end 26 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/powershell_es/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local path = require "nvim-lsp-installer.core.path" 3 | local std = require "nvim-lsp-installer.core.managers.std" 4 | local github = require "nvim-lsp-installer.core.managers.github" 5 | 6 | return function(name, root_dir) 7 | return server.Server:new { 8 | name = name, 9 | root_dir = root_dir, 10 | homepage = "https://github.com/PowerShell/PowerShellEditorServices", 11 | languages = { "powershell" }, 12 | installer = function() 13 | std.ensure_executable("pwsh", { help_url = "https://github.com/PowerShell/PowerShell#get-powershell" }) 14 | github.unzip_release_file({ 15 | repo = "PowerShell/PowerShellEditorServices", 16 | asset_file = "PowerShellEditorServices.zip", 17 | }).with_receipt() 18 | end, 19 | default_options = { 20 | bundle_path = path.concat { root_dir }, 21 | }, 22 | } 23 | end 24 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/ansiblels/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local path = require "nvim-lsp-installer.core.path" 3 | local npm = require "nvim-lsp-installer.core.managers.npm" 4 | local git = require "nvim-lsp-installer.core.managers.git" 5 | 6 | return function(name, root_dir) 7 | return server.Server:new { 8 | name = name, 9 | root_dir = root_dir, 10 | languages = { "ansible" }, 11 | homepage = "https://github.com/ansible/ansible-language-server", 12 | installer = function() 13 | git.clone({ "https://github.com/ansible/ansible-language-server" }).with_receipt() 14 | -- ansiblels has quite a strict npm version requirement. 15 | -- Install dependencies using the the latest npm version. 16 | npm.exec { "npm@latest", "install" } 17 | npm.run { "compile" } 18 | end, 19 | default_options = { 20 | cmd = { "node", path.concat { root_dir, "out", "server", "src", "server.js" }, "--stdio" }, 21 | }, 22 | } 23 | end 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yaml: -------------------------------------------------------------------------------- 1 | name: Feature request 2 | description: Suggest an idea for this project 3 | labels: 4 | - enhancement 5 | 6 | body: 7 | - type: markdown 8 | attributes: 9 | value: | 10 | 👋! This is not an issue template for questions! If you have questions, please refer to https://github.com/williamboman/nvim-lsp-installer/discussions/categories/q-a :) 11 | 12 | Before filing an issue, make sure that you meet the minimum requirements mentioned in the README. 13 | 14 | - type: textarea 15 | attributes: 16 | label: Is your feature request related to a problem? Please describe. 17 | validations: 18 | required: true 19 | 20 | - type: textarea 21 | attributes: 22 | label: Describe the solution you'd like 23 | validations: 24 | required: true 25 | 26 | - type: textarea 27 | attributes: 28 | label: Describe potential alternatives you've considered 29 | 30 | - type: textarea 31 | attributes: 32 | label: Additional context 33 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/phpactor/init.lua: -------------------------------------------------------------------------------- 1 | local path = require "nvim-lsp-installer.core.path" 2 | local server = require "nvim-lsp-installer.server" 3 | local composer = require "nvim-lsp-installer.core.managers.composer" 4 | local git = require "nvim-lsp-installer.core.managers.git" 5 | local process = require "nvim-lsp-installer.core.process" 6 | local platform = require "nvim-lsp-installer.core.platform" 7 | 8 | return function(name, root_dir) 9 | return server.Server:new { 10 | name = name, 11 | root_dir = root_dir, 12 | homepage = "https://phpactor.readthedocs.io/en/master/", 13 | languages = { "php" }, 14 | installer = function() 15 | assert(platform.is_unix, "Phpactor only supports UNIX environments.") 16 | git.clone({ "https://github.com/phpactor/phpactor.git" }).with_receipt() 17 | composer.install() 18 | end, 19 | default_options = { 20 | cmd_env = { 21 | PATH = process.extend_path { path.concat { root_dir, "bin" } }, 22 | }, 23 | }, 24 | } 25 | end 26 | -------------------------------------------------------------------------------- /tests/core/functional/string_spec.lua: -------------------------------------------------------------------------------- 1 | local _ = require "nvim-lsp-installer.core.functional" 2 | 3 | describe("functional: string", function() 4 | it("matches string patterns", function() 5 | assert.is_true(_.matches("foo", "foo")) 6 | assert.is_true(_.matches("bar", "foobarbaz")) 7 | assert.is_true(_.matches("ba+r", "foobaaaaaaarbaz")) 8 | 9 | assert.is_false(_.matches("ba+r", "foobharbaz")) 10 | assert.is_false(_.matches("bar", "foobaz")) 11 | end) 12 | 13 | it("should format strings", function() 14 | assert.equals("Hello World!", _.format("%s", "Hello World!")) 15 | assert.equals("special manouvers", _.format("%s manouvers", "special")) 16 | end) 17 | 18 | it("should split strings", function() 19 | assert.same({ "This", "is", "a", "sentence" }, _.split("%s", "This is a sentence")) 20 | assert.same({ "This", "is", "a", "sentence" }, _.split("|", "This|is|a|sentence")) 21 | end) 22 | 23 | it("should gsub strings", function() 24 | assert.same("predator", _.gsub("^apex%s*", "", "apex predator")) 25 | end) 26 | end) 27 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/groovyls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local path = require "nvim-lsp-installer.core.path" 3 | local std = require "nvim-lsp-installer.core.managers.std" 4 | local git = require "nvim-lsp-installer.core.managers.git" 5 | 6 | return function(name, root_dir) 7 | return server.Server:new { 8 | name = name, 9 | root_dir = root_dir, 10 | languages = { "groovy" }, 11 | homepage = "https://github.com/GroovyLanguageServer/groovy-language-server", 12 | ---@param ctx InstallContext 13 | installer = function(ctx) 14 | std.ensure_executable "javac" 15 | git.clone({ "https://github.com/GroovyLanguageServer/groovy-language-server" }).with_receipt() 16 | ctx:promote_cwd() 17 | ctx.spawn.gradlew { 18 | "build", 19 | with_paths = { ctx.cwd:get() }, 20 | } 21 | end, 22 | default_options = { 23 | cmd = { "java", "-jar", path.concat { root_dir, "build", "libs", "groovyls-all.jar" } }, 24 | }, 25 | } 26 | end 27 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/haxe_language_server/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local path = require "nvim-lsp-installer.core.path" 3 | local std = require "nvim-lsp-installer.core.managers.std" 4 | local git = require "nvim-lsp-installer.core.managers.git" 5 | local npm = require "nvim-lsp-installer.core.managers.npm" 6 | 7 | return function(name, root_dir) 8 | return server.Server:new { 9 | name = name, 10 | root_dir = root_dir, 11 | homepage = "https://github.com/vshaxe/haxe-language-server", 12 | languages = { "haxe" }, 13 | ---@param ctx InstallContext 14 | installer = function(ctx) 15 | std.ensure_executable("haxelib", { help_url = "https://haxe.org" }) 16 | git.clone({ "https://github.com/vshaxe/haxe-language-server" }).with_receipt() 17 | ctx.spawn.npm { "install" } 18 | npm.exec { "lix", "run", "vshaxe-build", "-t", "language-server" } 19 | end, 20 | default_options = { 21 | cmd = { "node", path.concat { root_dir, "bin", "server.js" } }, 22 | }, 23 | } 24 | end 25 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/kotlin_language_server/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local process = require "nvim-lsp-installer.core.process" 3 | local path = require "nvim-lsp-installer.core.path" 4 | local github = require "nvim-lsp-installer.core.managers.github" 5 | 6 | return function(name, root_dir) 7 | return server.Server:new { 8 | name = name, 9 | root_dir = root_dir, 10 | homepage = "https://github.com/fwcd/kotlin-language-server", 11 | languages = { "kotlin" }, 12 | installer = function() 13 | github.unzip_release_file({ 14 | repo = "fwcd/kotlin-language-server", 15 | asset_file = "server.zip", 16 | }).with_receipt() 17 | end, 18 | default_options = { 19 | cmd_env = { 20 | PATH = process.extend_path { 21 | path.concat { 22 | root_dir, 23 | "server", 24 | "bin", 25 | }, 26 | }, 27 | }, 28 | }, 29 | } 30 | end 31 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/core/async/uv.lua: -------------------------------------------------------------------------------- 1 | local a = require "nvim-lsp-installer.core.async" 2 | 3 | ---@type table 4 | local M = setmetatable({}, { 5 | __index = function(cache, method) 6 | cache[method] = a.promisify(vim.loop[method], true) 7 | return cache[method] 8 | end, 9 | }) 10 | 11 | return M 12 | 13 | ---@alias UvMethod 14 | ---| '"fs_close"' 15 | ---| '"fs_open"' 16 | ---| '"fs_read"' 17 | ---| '"fs_unlink"' 18 | ---| '"fs_write"' 19 | ---| '"fs_mkdir"' 20 | ---| '"fs_mkdtemp"' 21 | ---| '"fs_mkstemp"' 22 | ---| '"fs_rmdir"' 23 | ---| '"fs_scandir"' 24 | ---| '"fs_stat"' 25 | ---| '"fs_fstat"' 26 | ---| '"fs_lstat"' 27 | ---| '"fs_rename"' 28 | ---| '"fs_fsync"' 29 | ---| '"fs_fdatasync"' 30 | ---| '"fs_ftruncate"' 31 | ---| '"fs_sendfile"' 32 | ---| '"fs_access"' 33 | ---| '"fs_chmod"' 34 | ---| '"fs_fchmod"' 35 | ---| '"fs_utime"' 36 | ---| '"fs_futime"' 37 | ---| '"fs_lutime"' 38 | ---| '"fs_link"' 39 | ---| '"fs_symlink"' 40 | ---| '"fs_readlink"' 41 | ---| '"fs_realpath"' 42 | ---| '"fs_chown"' 43 | ---| '"fs_fchown"' 44 | ---| '"fs_lchown"' 45 | ---| '"fs_copyfile"' 46 | ---| '"fs_opendir"' 47 | ---| '"fs_readdir"' 48 | ---| '"fs_closedir"' 49 | ---| '"fs_statfs"' 50 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/bsl_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local path = require "nvim-lsp-installer.core.path" 3 | local github = require "nvim-lsp-installer.core.managers.github" 4 | local std = require "nvim-lsp-installer.core.managers.std" 5 | 6 | return function(name, root_dir) 7 | return server.Server:new { 8 | name = name, 9 | root_dir = root_dir, 10 | homepage = "https://1c-syntax.github.io/bsl-language-server", 11 | languages = { "onescript" }, 12 | installer = function() 13 | std.ensure_executable "java" 14 | github.download_release_file({ 15 | repo = "1c-syntax/bsl-language-server", 16 | out_file = "bsl-lsp.jar", 17 | asset_file = function(release) 18 | local version = release:gsub("^v", "") 19 | return ("bsl-language-server-%s-exec.jar"):format(version) 20 | end, 21 | }).with_receipt() 22 | end, 23 | default_options = { 24 | cmd = { 25 | "java", 26 | "-jar", 27 | path.concat { root_dir, "bsl-lsp.jar" }, 28 | }, 29 | }, 30 | } 31 | end 32 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/core/managers/dotnet/init.lua: -------------------------------------------------------------------------------- 1 | local process = require "nvim-lsp-installer.core.process" 2 | local installer = require "nvim-lsp-installer.core.installer" 3 | 4 | local M = {} 5 | 6 | ---@param package string 7 | local function with_receipt(package) 8 | return function() 9 | local ctx = installer.context() 10 | ctx.receipt:with_primary_source(ctx.receipt.dotnet(package)) 11 | end 12 | end 13 | 14 | ---@async 15 | ---@param package string 16 | function M.package(package) 17 | return function() 18 | return M.install(package).with_receipt() 19 | end 20 | end 21 | 22 | ---@async 23 | ---@param package string 24 | function M.install(package) 25 | local ctx = installer.context() 26 | ctx.spawn.dotnet { 27 | "tool", 28 | "update", 29 | "--tool-path", 30 | ".", 31 | ctx.requested_version 32 | :map(function(version) 33 | return { "--version", version } 34 | end) 35 | :or_else(vim.NIL), 36 | package, 37 | } 38 | 39 | return { 40 | with_receipt = with_receipt(package), 41 | } 42 | end 43 | 44 | function M.env(root_dir) 45 | return { 46 | PATH = process.extend_path { root_dir }, 47 | } 48 | end 49 | 50 | return M 51 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/codeqlls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local functional = require "nvim-lsp-installer.core.functional" 3 | local platform = require "nvim-lsp-installer.core.platform" 4 | local github = require "nvim-lsp-installer.core.managers.github" 5 | local process = require "nvim-lsp-installer.core.process" 6 | local path = require "nvim-lsp-installer.core.path" 7 | 8 | local coalesce, when = functional.coalesce, functional.when 9 | 10 | return function(name, root_dir) 11 | return server.Server:new { 12 | name = name, 13 | root_dir = root_dir, 14 | languages = { "codeql" }, 15 | installer = function() 16 | github.unzip_release_file({ 17 | repo = "github/codeql-cli-binaries", 18 | asset_file = coalesce( 19 | when(platform.is_mac, "codeql-osx64.zip"), 20 | when(platform.is_unix, "codeql-linux64.zip"), 21 | when(platform.is_win, "codeql-win64.zip") 22 | ), 23 | }).with_receipt() 24 | end, 25 | default_options = { 26 | cmd_env = { 27 | PATH = process.extend_path { path.concat { root_dir, "codeql" } }, 28 | }, 29 | }, 30 | } 31 | end 32 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/scry/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local process = require "nvim-lsp-installer.core.process" 3 | local path = require "nvim-lsp-installer.core.path" 4 | local std = require "nvim-lsp-installer.core.managers.std" 5 | local git = require "nvim-lsp-installer.core.managers.git" 6 | 7 | return function(name, root_dir) 8 | return server.Server:new { 9 | name = name, 10 | root_dir = root_dir, 11 | languages = { "crystal" }, 12 | homepage = "https://github.com/crystal-lang-tools/scry", 13 | ---@param ctx InstallContext 14 | installer = function(ctx) 15 | std.ensure_executable("crystal", { 16 | help_url = "https://crystal-lang.org/install/", 17 | }) 18 | std.ensure_executable("shards", { 19 | help_url = "https://crystal-lang.org/install/", 20 | }) 21 | git.clone({ "https://github.com/crystal-lang-tools/scry.git" }).with_receipt() 22 | ctx.spawn.shards { "build", "--verbose", "--release" } 23 | end, 24 | default_options = { 25 | cmd_env = { 26 | PATH = process.extend_path { path.concat { root_dir, "bin" } }, 27 | }, 28 | }, 29 | } 30 | end 31 | -------------------------------------------------------------------------------- /tests/core/functional/relation_spec.lua: -------------------------------------------------------------------------------- 1 | local _ = require "nvim-lsp-installer.core.functional" 2 | 3 | describe("functional: relation", function() 4 | it("should check equality", function() 5 | local tbl = {} 6 | local is_tbl = _.equals(tbl) 7 | local is_a = _.equals "a" 8 | local is_42 = _.equals(42) 9 | 10 | assert.is_true(is_tbl(tbl)) 11 | assert.is_true(is_a "a") 12 | assert.is_true(is_42(42)) 13 | assert.is_false(is_a "b") 14 | assert.is_false(is_42(32)) 15 | end) 16 | 17 | it("should check property equality", function() 18 | local fn_key = function() end 19 | local tbl = { a = "a", b = "b", number = 42, [fn_key] = "fun" } 20 | assert.is_true(_.prop_eq("a", "a", tbl)) 21 | assert.is_true(_.prop_eq(fn_key, "fun", tbl)) 22 | assert.is_true(_.prop_eq(fn_key) "fun"(tbl)) 23 | end) 24 | 25 | it("should check whether property satisfies predicate", function() 26 | local obj = { 27 | low = 0, 28 | med = 10, 29 | high = 15, 30 | } 31 | 32 | assert.is_false(_.prop_satisfies(_.gt(10), "low", obj)) 33 | assert.is_false(_.prop_satisfies(_.gt(10), "med")(obj)) 34 | assert.is_true(_.prop_satisfies(_.gt(10)) "high"(obj)) 35 | end) 36 | end) 37 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/_generated/schemas/rescriptls.lua: -------------------------------------------------------------------------------- 1 | -- THIS FILE IS GENERATED. DO NOT EDIT MANUALLY. 2 | -- stylua: ignore start 3 | return {properties = {["rescript.settings.askToStartBuild"] = {default = true,description = "Whether you want the extension to prompt for autostarting a ReScript build if a project is opened with no build running.",scope = "language-overridable",type = "boolean"},["rescript.settings.autoRunCodeAnalysis"] = {default = false,description = "Automatically start ReScript's code analysis.",type = "boolean"},["rescript.settings.binaryPath"] = {default = vim.NIL,description = "Path to the directory where ReScript binaries are. You can use it if you haven't or don't want to use the installed ReScript from node_modules in your project.",type = { "string", "null" }},["rescript.settings.codeLens"] = {default = false,description = "Enable (experimental) code lens for function definitions.",type = "boolean"},["rescript.settings.inlayHints.enable"] = {default = false,description = "Enable (experimental) inlay hints.",type = "boolean"},["rescript.settings.inlayHints.maxLength"] = {default = 25,markdownDescription = "Maximum length of character for inlay hints. Set to null to have an unlimited length. Inlay hints that exceed the maximum length will not be shown.",minimum = 0,type = { "null", "integer" }}},title = "ReScript",type = "object"} -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/clarity_lsp/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local process = require "nvim-lsp-installer.core.process" 3 | local platform = require "nvim-lsp-installer.core.platform" 4 | local github = require "nvim-lsp-installer.core.managers.github" 5 | local functional = require "nvim-lsp-installer.core.functional" 6 | 7 | local coalesce, when = functional.coalesce, functional.when 8 | 9 | return function(name, root_dir) 10 | return server.Server:new { 11 | name = name, 12 | root_dir = root_dir, 13 | homepage = "https://github.com/hirosystems/clarity-lsp", 14 | languages = { "clarity" }, 15 | installer = function() 16 | github.unzip_release_file({ 17 | repo = "hirosystems/clarity-lsp", 18 | asset_file = coalesce( 19 | when(platform.is_mac, "clarity-lsp-macos-x64.zip"), 20 | when(platform.is_linux and platform.arch == "x64", "clarity-lsp-linux-x64.zip"), 21 | when(platform.is_win and platform.arch == "x64", "clarity-lsp-windows-x64.zip") 22 | ), 23 | }).with_receipt() 24 | end, 25 | default_options = { 26 | cmd_env = { 27 | PATH = process.extend_path { root_dir }, 28 | }, 29 | }, 30 | } 31 | end 32 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/jobs/outdated-servers/version-check-result.lua: -------------------------------------------------------------------------------- 1 | ---@class VersionCheckResult 2 | ---@field public server Server 3 | ---@field public success boolean 4 | ---@field public outdated_packages OutdatedPackage[] 5 | local VersionCheckResult = {} 6 | VersionCheckResult.__index = VersionCheckResult 7 | 8 | ---@alias OutdatedPackage {name: string, current_version: string, latest_version: string} 9 | 10 | ---@param server Server 11 | ---@param outdated_packages OutdatedPackage[] 12 | function VersionCheckResult.new(server, success, outdated_packages) 13 | local self = setmetatable({}, VersionCheckResult) 14 | self.server = server 15 | self.success = success 16 | self.outdated_packages = outdated_packages 17 | return self 18 | end 19 | 20 | ---@param server Server 21 | function VersionCheckResult.fail(server) 22 | return VersionCheckResult.new(server, false) 23 | end 24 | 25 | ---@param server Server 26 | ---@param outdated_packages OutdatedPackage[] 27 | function VersionCheckResult.success(server, outdated_packages) 28 | return VersionCheckResult.new(server, true, outdated_packages) 29 | end 30 | 31 | function VersionCheckResult.empty(server) 32 | return VersionCheckResult.success(server, {}) 33 | end 34 | 35 | function VersionCheckResult:has_outdated_packages() 36 | return #self.outdated_packages > 0 37 | end 38 | 39 | return VersionCheckResult 40 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/jobs/pool.lua: -------------------------------------------------------------------------------- 1 | local log = require "nvim-lsp-installer.log" 2 | 3 | local JobExecutionPool = {} 4 | JobExecutionPool.__index = JobExecutionPool 5 | 6 | function JobExecutionPool:new(opts) 7 | return setmetatable({ 8 | size = opts.size, 9 | _queue = {}, 10 | _supplied_jobs = 0, 11 | _running_jobs = 0, 12 | }, JobExecutionPool) 13 | end 14 | 15 | function JobExecutionPool:supply(fn) 16 | self._supplied_jobs = self._supplied_jobs + 1 17 | self._queue[#self._queue + 1] = setmetatable({ 18 | id = self._supplied_jobs, 19 | }, { 20 | __call = function(_, ...) 21 | fn(...) 22 | end, 23 | }) 24 | self:_dequeue() 25 | end 26 | 27 | function JobExecutionPool:_dequeue() 28 | log.fmt_trace("Dequeuing job running_jobs=%s, size=%s", self._running_jobs, self.size) 29 | if self._running_jobs < self.size and #self._queue > 0 then 30 | local dequeued = table.remove(self._queue, 1) 31 | self._running_jobs = self._running_jobs + 1 32 | log.fmt_trace("Dequeued job job_id=%s, running_jobs=%s, size=%s", dequeued.id, self._running_jobs, self.size) 33 | dequeued(function() 34 | log.fmt_trace("Job finished job_id=%s", dequeued.id) 35 | self._running_jobs = self._running_jobs - 1 36 | self:_dequeue() 37 | end) 38 | end 39 | end 40 | 41 | return JobExecutionPool 42 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/slint_lsp/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local path = require "nvim-lsp-installer.core.path" 3 | local platform = require "nvim-lsp-installer.core.platform" 4 | local process = require "nvim-lsp-installer.core.process" 5 | local github = require "nvim-lsp-installer.core.managers.github" 6 | 7 | return function(name, root_dir) 8 | return server.Server:new { 9 | name = name, 10 | root_dir = root_dir, 11 | homepage = "https://slint-ui.com/", 12 | languages = { "slint" }, 13 | installer = function() 14 | local repo = "slint-ui/slint" 15 | platform.when { 16 | win = function() 17 | github.unzip_release_file({ 18 | repo = repo, 19 | asset_file = "slint-lsp-windows.zip", 20 | }).with_receipt() 21 | end, 22 | linux = function() 23 | github.untargz_release_file({ 24 | repo = repo, 25 | asset_file = "slint-lsp-linux.tar.gz", 26 | }).with_receipt() 27 | end, 28 | } 29 | end, 30 | default_options = { 31 | cmd_env = { 32 | PATH = process.extend_path { path.concat { root_dir, "slint-lsp" } }, 33 | }, 34 | }, 35 | } 36 | end 37 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/core/functional/logic.lua: -------------------------------------------------------------------------------- 1 | local fun = require "nvim-lsp-installer.core.functional.function" 2 | 3 | local _ = {} 4 | 5 | ---@generic T 6 | ---@param predicates (fun(item: T): boolean)[] 7 | ---@return fun(item: T): boolean 8 | _.all_pass = fun.curryN(function(predicates, item) 9 | for i = 1, #predicates do 10 | if not predicates[i](item) then 11 | return false 12 | end 13 | end 14 | return true 15 | end, 2) 16 | 17 | ---@generic T 18 | ---@param predicate fun(item: T): boolean 19 | ---@param a fun(item: T): any 20 | ---@param b fun(item: T): any 21 | ---@param value T 22 | _.if_else = fun.curryN(function(predicate, a, b, value) 23 | if predicate(value) then 24 | return a(value) 25 | else 26 | return b(value) 27 | end 28 | end, 4) 29 | 30 | ---@param value boolean 31 | _.is_not = function(value) 32 | return not value 33 | end 34 | 35 | ---@generic T 36 | ---@param predicate fun(value: T): boolean 37 | ---@param value T 38 | _.complement = fun.curryN(function(predicate, value) 39 | return not predicate(value) 40 | end, 2) 41 | 42 | _.cond = fun.curryN(function(predicate_transformer_pairs, value) 43 | for _, pair in ipairs(predicate_transformer_pairs) do 44 | local predicate, transformer = pair[1], pair[2] 45 | if predicate(value) then 46 | return transformer(value) 47 | end 48 | end 49 | end, 2) 50 | 51 | return _ 52 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/solc/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local functional = require "nvim-lsp-installer.core.functional" 3 | local platform = require "nvim-lsp-installer.core.platform" 4 | local process = require "nvim-lsp-installer.core.process" 5 | local github = require "nvim-lsp-installer.core.managers.github" 6 | local std = require "nvim-lsp-installer.core.managers.std" 7 | 8 | local coalesce, when = functional.coalesce, functional.when 9 | 10 | return function(name, root_dir) 11 | return server.Server:new { 12 | name = name, 13 | root_dir = root_dir, 14 | homepage = "https://github.com/ethereum/solidity", 15 | languages = { "solidity" }, 16 | installer = function() 17 | github.download_release_file({ 18 | repo = "ethereum/solidity", 19 | out_file = platform.is_win and "solc.exe" or "solc", 20 | asset_file = coalesce( 21 | when(platform.is_mac, "solc-macos"), 22 | when(platform.is_linux, "solc-static-linux"), 23 | when(platform.is_win, "solc-windows.exe") 24 | ), 25 | }).with_receipt() 26 | std.chmod("+x", { "solc" }) 27 | end, 28 | default_options = { 29 | cmd_env = { 30 | PATH = process.extend_path { root_dir }, 31 | }, 32 | }, 33 | } 34 | end 35 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/ui/server_hints.lua: -------------------------------------------------------------------------------- 1 | ---@class ServerHints 2 | ---@field server Server 3 | local ServerHints = {} 4 | ServerHints.__index = ServerHints 5 | 6 | function ServerHints.new(server) 7 | return setmetatable({ server = server }, ServerHints) 8 | end 9 | 10 | ---@param language string 11 | ---@return boolean 12 | function ServerHints:is_language_equal(language) 13 | local match_start, match_end = self.server.name:find(language, 1, true) 14 | -- This is somewhat... arbitrary 15 | return match_start ~= nil 16 | and (match_end - match_start) >= 2 -- the match need to be at least 2 in length 17 | -- match needs to start in the beginning - if it's not, then the total string lengths cannot differ too much 18 | and (match_start == 1 or (match_start < 3 and (math.abs(#self.server.name - #language) < 4))) 19 | end 20 | 21 | function ServerHints:get_hints() 22 | local hints = {} 23 | if self.server.languages then 24 | for _, language in ipairs(self.server.languages) do 25 | if not self:is_language_equal(language) then 26 | hints[#hints + 1] = language 27 | end 28 | end 29 | end 30 | return hints 31 | end 32 | 33 | function ServerHints:__tostring() 34 | local hints = self:get_hints() 35 | if #hints == 0 then 36 | return "" 37 | end 38 | return "(" .. table.concat(hints, ", ") .. ")" 39 | end 40 | 41 | return ServerHints 42 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/new_server_request.yaml: -------------------------------------------------------------------------------- 1 | name: New server request 2 | description: Request a new server not currently available 3 | title: "[New server]: " 4 | labels: 5 | - new-server-request 6 | 7 | body: 8 | - type: input 9 | attributes: 10 | label: Server name 11 | description: Which server would you like to request to be added? 12 | validations: 13 | required: true 14 | 15 | - type: input 16 | attributes: 17 | label: Server homepage 18 | description: e.g., a GitHub page 19 | validations: 20 | required: true 21 | 22 | - type: input 23 | attributes: 24 | label: Languages 25 | description: Which languages does this server target? 26 | placeholder: typescript, javascript 27 | validations: 28 | required: true 29 | 30 | - type: checkboxes 31 | attributes: 32 | label: Is this server added in lspconfig? 33 | description: Is there a server configuration for this server in [lspconfig](https://github.com/neovim/nvim-lspconfig)? 34 | options: 35 | - label: "Yes" 36 | - label: "No" 37 | 38 | - type: textarea 39 | attributes: 40 | label: How is this server distributed? 41 | description: Is the server distributed through a standardized channel (such as GitHub release files, npm, pip, etc.)? Leave empty if you don't know. 42 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/elixirls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local path = require "nvim-lsp-installer.core.path" 3 | local platform = require "nvim-lsp-installer.core.platform" 4 | local github = require "nvim-lsp-installer.core.managers.github" 5 | local std = require "nvim-lsp-installer.core.managers.std" 6 | 7 | return function(name, root_dir) 8 | return server.Server:new { 9 | name = name, 10 | root_dir = root_dir, 11 | homepage = "https://github.com/elixir-lsp/elixir-ls", 12 | languages = { "elixir" }, 13 | ---@param ctx InstallContext 14 | installer = function(ctx) 15 | -- We write to the elixir-ls directory for backwards compatibility reasons 16 | ctx.fs:mkdir "elixir-ls" 17 | ctx:chdir("elixir-ls", function() 18 | github.unzip_release_file({ 19 | repo = "elixir-lsp/elixir-ls", 20 | asset_file = "elixir-ls.zip", 21 | }).with_receipt() 22 | std.chmod("+x", { "language_server.sh" }) 23 | end) 24 | end, 25 | default_options = { 26 | cmd = { 27 | path.concat { 28 | root_dir, 29 | "elixir-ls", 30 | platform.is_win and "language_server.bat" or "language_server.sh", 31 | }, 32 | }, 33 | }, 34 | } 35 | end 36 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/_generated/schemas/r_language_server.lua: -------------------------------------------------------------------------------- 1 | -- THIS FILE IS GENERATED. DO NOT EDIT MANUALLY. 2 | -- stylua: ignore start 3 | return {properties = {["r.lsp.args"] = {default = {},description = "The command line arguments to use when launching R Language Server",type = "array"},["r.lsp.debug"] = {default = false,description = "Debug R Language Server",type = "boolean"},["r.lsp.diagnostics"] = {default = true,description = "Enable Diagnostics",type = "boolean"},["r.lsp.lang"] = {default = "",description = "Override default LANG environment variable",type = "string"},["r.lsp.path"] = {default = "",deprecationMessage = "Will be deprecated. Use r.rpath.windows, r.rpath.mac, or r.rpath.linux instead.",description = "Path to R binary for launching Language Server",markdownDeprecationMessage = "Will be deprecated. Use `#r.rpath.windows#`, `#r.rpath.mac#`, or `#r.rpath.linux#` instead.",type = "string"},["r.lsp.use_stdio"] = {default = false,description = "Use STDIO connection instead of TCP. (Unix/macOS users only)",type = "boolean"},["r.rpath.linux"] = {default = "",description = 'Path to an R executable for Linux. Must be "vanilla" R, not radian etc.!',type = "string"},["r.rpath.mac"] = {default = "",description = 'Path to an R executable for macOS. Must be "vanilla" R, not radian etc.!',type = "string"},["r.rpath.windows"] = {default = "",description = 'Path to an R executable for Windows. Must be "vanilla" R, not radian etc.!',type = "string"}},title = "R LSP Client",type = "object"} -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/marksman/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local process = require "nvim-lsp-installer.core.process" 3 | local platform = require "nvim-lsp-installer.core.platform" 4 | local functional = require "nvim-lsp-installer.core.functional" 5 | local github = require "nvim-lsp-installer.core.managers.github" 6 | local std = require "nvim-lsp-installer.core.managers.std" 7 | 8 | local coalesce, when = functional.coalesce, functional.when 9 | 10 | return function(name, root_dir) 11 | return server.Server:new { 12 | name = name, 13 | root_dir = root_dir, 14 | homepage = "https://github.com/artempyanykh/marksman", 15 | languages = { "markdown" }, 16 | installer = function() 17 | github.download_release_file({ 18 | repo = "artempyanykh/marksman", 19 | out_file = platform.is_win and "marksman.exe" or "marksman", 20 | asset_file = coalesce( 21 | when(platform.is.mac, "marksman-macos"), 22 | when(platform.is.linux_x64, "marksman-linux"), 23 | when(platform.is.win_x64, "marksman.exe") 24 | ), 25 | }).with_receipt() 26 | std.chmod("+x", { "marksman" }) 27 | end, 28 | default_options = { 29 | cmd_env = { 30 | PATH = process.extend_path { root_dir }, 31 | }, 32 | }, 33 | } 34 | end 35 | -------------------------------------------------------------------------------- /tests/setup/ensure_installed_spec.lua: -------------------------------------------------------------------------------- 1 | local spy = require "luassert.spy" 2 | local configs = require "lspconfig.configs" 3 | local servers = require "nvim-lsp-installer.servers" 4 | 5 | describe("ensure_installed", function() 6 | it( 7 | "should install servers", 8 | async_test(function() 9 | local server1_installer_spy = spy.new() 10 | local server2_installer_spy = spy.new() 11 | local server1 = ServerGenerator { 12 | name = "ensure_installed1", 13 | installer = function() 14 | server1_installer_spy() 15 | end, 16 | } 17 | local server2 = ServerGenerator { 18 | name = "ensure_installed2", 19 | installer = function() 20 | server2_installer_spy() 21 | end, 22 | } 23 | 24 | servers.register(server1) 25 | servers.register(server2) 26 | 27 | configs[server1.name] = { default_config = {} } 28 | configs[server2.name] = { default_config = {} } 29 | 30 | require("nvim-lsp-installer").setup { 31 | ensure_installed = { server1.name, server2.name }, 32 | } 33 | assert.wait_for(function() 34 | assert.spy(server1_installer_spy).was_called(1) 35 | assert.spy(server2_installer_spy).was_called(1) 36 | end) 37 | end) 38 | ) 39 | end) 40 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/reason_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local platform = require "nvim-lsp-installer.core.platform" 3 | local path = require "nvim-lsp-installer.core.path" 4 | local functional = require "nvim-lsp-installer.core.functional" 5 | local process = require "nvim-lsp-installer.core.process" 6 | local github = require "nvim-lsp-installer.core.managers.github" 7 | 8 | local coalesce, when = functional.coalesce, functional.when 9 | 10 | return function(name, root_dir) 11 | return server.Server:new { 12 | name = name, 13 | root_dir = root_dir, 14 | languages = { "reason" }, 15 | homepage = "https://github.com/jaredly/reason-language-server", 16 | ---@param ctx InstallContext 17 | installer = function(ctx) 18 | local archive_name = coalesce( 19 | when(platform.is_mac, "rls-macos"), 20 | when(platform.is_linux, "rls-linux"), 21 | when(platform.is_win, "rls-windows") 22 | ) 23 | github.unzip_release_file({ 24 | repo = "jaredly/reason-language-server", 25 | asset_file = ("%s.zip"):format(archive_name), 26 | }).with_receipt() 27 | ctx.fs:rename(archive_name, "reason") 28 | end, 29 | default_options = { 30 | cmd_env = { 31 | PATH = process.extend_path { path.concat { root_dir, "reason" } }, 32 | }, 33 | }, 34 | } 35 | end 36 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/bicep/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local path = require "nvim-lsp-installer.core.path" 3 | local std = require "nvim-lsp-installer.core.managers.std" 4 | local github = require "nvim-lsp-installer.core.managers.github" 5 | 6 | return function(name, root_dir) 7 | return server.Server:new { 8 | name = name, 9 | root_dir = root_dir, 10 | languages = { "bicep" }, 11 | homepage = "https://github.com/Azure/bicep", 12 | ---@param ctx InstallContext 13 | installer = function(ctx) 14 | std.ensure_executable("dotnet", { help_url = "https://dotnet.microsoft.com/download" }) 15 | ctx.fs:mkdir "vscode" 16 | ctx:chdir("vscode", function() 17 | -- The bicep-langserver.zip is a bit broken on POSIX systems - so we download it via the VSCode distribution 18 | -- instead. See https://github.com/Azure/bicep/issues/3704. 19 | github.unzip_release_file({ 20 | repo = "Azure/bicep", 21 | asset_file = "vscode-bicep.vsix", 22 | }).with_receipt() 23 | end) 24 | ctx.fs:rename(path.concat { "vscode", "extension", "bicepLanguageServer" }, "langserver") 25 | ctx.fs:rmrf "vscode" 26 | ctx:chdir "langserver" 27 | end, 28 | default_options = { 29 | cmd = { "dotnet", path.concat { root_dir, "Bicep.LangServer.dll" } }, 30 | }, 31 | } 32 | end 33 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/prosemd_lsp/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local process = require "nvim-lsp-installer.core.process" 3 | local platform = require "nvim-lsp-installer.core.platform" 4 | local functional = require "nvim-lsp-installer.core.functional" 5 | local github = require "nvim-lsp-installer.core.managers.github" 6 | local std = require "nvim-lsp-installer.core.managers.std" 7 | 8 | local coalesce, when = functional.coalesce, functional.when 9 | 10 | return function(name, root_dir) 11 | return server.Server:new { 12 | name = name, 13 | root_dir = root_dir, 14 | homepage = "https://github.com/kitten/prosemd-lsp", 15 | languages = { "markdown" }, 16 | installer = function() 17 | github.download_release_file({ 18 | repo = "kitten/prosemd-lsp", 19 | out_file = platform.is_win and "prosemd-lsp.exe" or "prosemd-lsp", 20 | asset_file = coalesce( 21 | when(platform.is_mac, "prosemd-lsp-macos"), 22 | when(platform.is_linux and platform.arch == "x64", "prosemd-lsp-linux"), 23 | when(platform.is_win and platform.arch == "x64", "prosemd-lsp-windows.exe") 24 | ), 25 | }).with_receipt() 26 | std.chmod("+x", { "prosemd-lsp" }) 27 | end, 28 | default_options = { 29 | cmd_env = { 30 | PATH = process.extend_path { root_dir }, 31 | }, 32 | }, 33 | } 34 | end 35 | -------------------------------------------------------------------------------- /tests/core/managers/github_client_spec.lua: -------------------------------------------------------------------------------- 1 | local client = require "nvim-lsp-installer.core.managers.github.client" 2 | 3 | describe("github client", function() 4 | ---@type GitHubRelease 5 | local release = { 6 | tag_name = "v0.1.0", 7 | prerelease = false, 8 | draft = false, 9 | assets = {}, 10 | } 11 | 12 | local function stub_release(mock) 13 | return setmetatable(mock, { __index = release }) 14 | end 15 | 16 | it("should identify stable prerelease", function() 17 | local predicate = client.release_predicate { 18 | include_prerelease = false, 19 | } 20 | 21 | assert.is_false(predicate(stub_release { prerelease = true })) 22 | assert.is_true(predicate(stub_release { prerelease = false })) 23 | end) 24 | 25 | it("should identify stable release with tag name pattern", function() 26 | local predicate = client.release_predicate { 27 | tag_name_pattern = "^lsp%-server.*$", 28 | } 29 | 30 | assert.is_false(predicate(stub_release { tag_name = "v0.1.0" })) 31 | assert.is_true(predicate(stub_release { tag_name = "lsp-server-v0.1.0" })) 32 | end) 33 | 34 | it("should identify stable release", function() 35 | local predicate = client.release_predicate {} 36 | 37 | assert.is_true(predicate(stub_release { tag_name = "v0.1.0" })) 38 | assert.is_false(predicate(stub_release { prerelease = true })) 39 | assert.is_false(predicate(stub_release { draft = true })) 40 | end) 41 | end) 42 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/crystalline/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local process = require "nvim-lsp-installer.core.process" 3 | local platform = require "nvim-lsp-installer.core.platform" 4 | local functional = require "nvim-lsp-installer.core.functional" 5 | local path = require "nvim-lsp-installer.core.path" 6 | local github = require "nvim-lsp-installer.core.managers.github" 7 | local std = require "nvim-lsp-installer.core.managers.std" 8 | 9 | local coalesce, when = functional.coalesce, functional.when 10 | 11 | return function(name, root_dir) 12 | return server.Server:new { 13 | name = name, 14 | root_dir = root_dir, 15 | homepage = "https://github.com/elbywan/crystalline", 16 | languages = { "crystal" }, 17 | installer = function() 18 | github.gunzip_release_file({ 19 | repo = "elbywan/crystalline", 20 | asset_file = coalesce( 21 | when(platform.is_mac and platform.arch == "x64", "crystalline_x86_64-apple-darwin.gz"), 22 | when(platform.is_linux and platform.arch == "x64", "crystalline_x86_64-unknown-linux-gnu.gz") 23 | ), 24 | out_file = "crystalline", 25 | }).with_receipt() 26 | std.chmod("+x", { "crystalline" }) 27 | end, 28 | default_options = { 29 | cmd_env = { 30 | PATH = process.extend_path { root_dir, path.concat { root_dir, "crystal", "bin" } }, 31 | }, 32 | }, 33 | } 34 | end 35 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/denols/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local process = require "nvim-lsp-installer.core.process" 3 | local platform = require "nvim-lsp-installer.core.platform" 4 | local functional = require "nvim-lsp-installer.core.functional" 5 | local github = require "nvim-lsp-installer.core.managers.github" 6 | 7 | local coalesce, when = functional.coalesce, functional.when 8 | 9 | return function(name, root_dir) 10 | return server.Server:new { 11 | name = name, 12 | root_dir = root_dir, 13 | homepage = "https://deno.land/x/deno/cli/lsp", 14 | languages = { "deno" }, 15 | installer = function() 16 | github.unzip_release_file({ 17 | repo = "denoland/deno", 18 | asset_file = coalesce( 19 | when( 20 | platform.is_mac, 21 | coalesce( 22 | when(platform.arch == "arm64", "deno-aarch64-apple-darwin.zip"), 23 | when(platform.arch == "x64", "deno-x86_64-apple-darwin.zip") 24 | ) 25 | ), 26 | when(platform.is_linux, "deno-x86_64-unknown-linux-gnu.zip"), 27 | when(platform.is_win, "deno-x86_64-pc-windows-msvc.zip") 28 | ), 29 | }).with_receipt() 30 | end, 31 | default_options = { 32 | cmd_env = { 33 | PATH = process.extend_path { root_dir }, 34 | }, 35 | }, 36 | } 37 | end 38 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/erlangls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local path = require "nvim-lsp-installer.core.path" 3 | local process = require "nvim-lsp-installer.core.process" 4 | local platform = require "nvim-lsp-installer.core.platform" 5 | local std = require "nvim-lsp-installer.core.managers.std" 6 | local git = require "nvim-lsp-installer.core.managers.git" 7 | local github = require "nvim-lsp-installer.core.managers.github" 8 | local Optional = require "nvim-lsp-installer.core.optional" 9 | 10 | return function(name, root_dir) 11 | local rebar3 = platform.is_win and "rebar3.cmd" or "rebar3" 12 | 13 | return server.Server:new { 14 | name = name, 15 | root_dir = root_dir, 16 | languages = { "erlang" }, 17 | homepage = "https://erlang-ls.github.io/", 18 | ---@param ctx InstallContext 19 | installer = function(ctx) 20 | std.ensure_executable(rebar3, { help_url = "http://rebar3.org/docs/" }) 21 | 22 | local repo = "erlang-ls/erlang_ls" 23 | local source = github.tag { repo = repo } 24 | source.with_receipt() 25 | git.clone { ("https://github.com/%s.git"):format(repo), version = Optional.of(source.tag) } 26 | 27 | ctx.spawn[rebar3] { "escriptize" } 28 | ctx.spawn[rebar3] { "as", "dap", "escriptize" } 29 | end, 30 | default_options = { 31 | cmd_env = { 32 | PATH = process.extend_path { path.concat { root_dir, "_build", "default", "bin" } }, 33 | }, 34 | }, 35 | } 36 | end 37 | -------------------------------------------------------------------------------- /tests/core/managers/dotnet_spec.lua: -------------------------------------------------------------------------------- 1 | local mock = require "luassert.mock" 2 | local Optional = require "nvim-lsp-installer.core.optional" 3 | local installer = require "nvim-lsp-installer.core.installer" 4 | local dotnet = require "nvim-lsp-installer.core.managers.dotnet" 5 | 6 | describe("dotnet manager", function() 7 | ---@type InstallContext 8 | local ctx 9 | before_each(function() 10 | ctx = InstallContextGenerator { 11 | spawn = mock.new { 12 | dotnet = mockx.returns {}, 13 | }, 14 | } 15 | end) 16 | 17 | it( 18 | "should call dotnet tool update", 19 | async_test(function() 20 | ctx.requested_version = Optional.of "42.13.37" 21 | installer.run_installer(ctx, dotnet.package "main-package") 22 | assert.spy(ctx.spawn.dotnet).was_called(1) 23 | assert.spy(ctx.spawn.dotnet).was_called_with { 24 | "tool", 25 | "update", 26 | "--tool-path", 27 | ".", 28 | { "--version", "42.13.37" }, 29 | "main-package", 30 | } 31 | end) 32 | ) 33 | 34 | it( 35 | "should provide receipt information", 36 | async_test(function() 37 | ctx.requested_version = Optional.of "42.13.37" 38 | installer.run_installer(ctx, dotnet.package "main-package") 39 | assert.same({ 40 | type = "dotnet", 41 | package = "main-package", 42 | }, ctx.receipt.primary_source) 43 | end) 44 | ) 45 | end) 46 | -------------------------------------------------------------------------------- /tests/setup/automatic_installation_spec.lua: -------------------------------------------------------------------------------- 1 | local spy = require "luassert.spy" 2 | local lspconfig = require "lspconfig" 3 | local configs = require "lspconfig.configs" 4 | local servers = require "nvim-lsp-installer.servers" 5 | 6 | describe("automatic_installation", function() 7 | it( 8 | "should install servers set up via lspconfig", 9 | async_test(function() 10 | local server1_installer_spy = spy.new() 11 | local server2_installer_spy = spy.new() 12 | local server1 = ServerGenerator { 13 | name = "automatic_installation1", 14 | installer = function() 15 | server1_installer_spy() 16 | end, 17 | } 18 | local server2 = ServerGenerator { 19 | name = "automatic_installation2", 20 | installer = function() 21 | server2_installer_spy() 22 | end, 23 | } 24 | 25 | servers.register(server1) 26 | servers.register(server2) 27 | 28 | configs[server1.name] = { default_config = {} } 29 | configs[server2.name] = { default_config = {} } 30 | 31 | require("nvim-lsp-installer").setup { 32 | automatic_installation = true, 33 | } 34 | 35 | lspconfig[server1.name].setup {} 36 | 37 | assert.wait_for(function() 38 | assert.spy(server1_installer_spy).was_called(1) 39 | assert.spy(server2_installer_spy).was_called(0) 40 | end) 41 | end) 42 | ) 43 | end) 44 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/volar/init.lua: -------------------------------------------------------------------------------- 1 | local a = require "nvim-lsp-installer.core.async" 2 | local path = require "nvim-lsp-installer.core.path" 3 | local server = require "nvim-lsp-installer.server" 4 | local npm = require "nvim-lsp-installer.core.managers.npm" 5 | local fs = require "nvim-lsp-installer.core.fs" 6 | 7 | return function(name, root_dir) 8 | ---@param dir string 9 | local function get_tsserverlib_path(dir) 10 | return path.concat { dir, "node_modules", "typescript", "lib", "tsserverlibrary.js" } 11 | end 12 | 13 | ---@param workspace_dir string|nil 14 | local function get_typescript_server_path(workspace_dir) 15 | local local_tsserverlib = workspace_dir ~= nil and get_tsserverlib_path(workspace_dir) 16 | local vendored_tsserverlib = get_tsserverlib_path(root_dir) 17 | if local_tsserverlib and fs.sync.file_exists(local_tsserverlib) then 18 | return local_tsserverlib 19 | else 20 | return vendored_tsserverlib 21 | end 22 | end 23 | 24 | return server.Server:new { 25 | name = name, 26 | root_dir = root_dir, 27 | homepage = "https://github.com/johnsoncodehk/volar", 28 | languages = { "vue" }, 29 | installer = npm.packages { "@volar/vue-language-server", "typescript" }, 30 | default_options = { 31 | cmd_env = npm.env(root_dir), 32 | on_new_config = function(new_config, new_root_dir) 33 | new_config.init_options.typescript.serverPath = get_typescript_server_path(new_root_dir) 34 | end, 35 | }, 36 | } 37 | end 38 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/clojure_lsp/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local process = require "nvim-lsp-installer.core.process" 3 | local functional = require "nvim-lsp-installer.core.functional" 4 | local platform = require "nvim-lsp-installer.core.platform" 5 | local github = require "nvim-lsp-installer.core.managers.github" 6 | local std = require "nvim-lsp-installer.core.managers.std" 7 | 8 | local coalesce, when = functional.coalesce, functional.when 9 | 10 | return function(name, root_dir) 11 | return server.Server:new { 12 | name = name, 13 | root_dir = root_dir, 14 | homepage = "https://clojure-lsp.io", 15 | languages = { "clojure" }, 16 | installer = function() 17 | github.unzip_release_file({ 18 | repo = "clojure-lsp/clojure-lsp", 19 | asset_file = coalesce( 20 | when(platform.is.mac_arm64, "clojure-lsp-native-macos-aarch64.zip"), 21 | when(platform.is.mac_x64, "clojure-lsp-native-macos-amd64.zip"), 22 | when(platform.is.linux_x64, "clojure-lsp-native-linux-amd64.zip"), 23 | when(platform.is.linux_aarch64, "clojure-lsp-native-linux-aarch64.zip"), 24 | when(platform.is_win, "clojure-lsp-native-windows-amd64.zip") 25 | ), 26 | }).with_receipt() 27 | std.chmod("+x", { "clojure-lsp" }) 28 | end, 29 | default_options = { 30 | cmd_env = { 31 | PATH = process.extend_path { root_dir }, 32 | }, 33 | }, 34 | } 35 | end 36 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/clangd/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local path = require "nvim-lsp-installer.core.path" 3 | local process = require "nvim-lsp-installer.core.process" 4 | local functional = require "nvim-lsp-installer.core.functional" 5 | local platform = require "nvim-lsp-installer.core.platform" 6 | local github = require "nvim-lsp-installer.core.managers.github" 7 | 8 | local coalesce, when = functional.coalesce, functional.when 9 | 10 | return function(name, root_dir) 11 | return server.Server:new { 12 | name = name, 13 | root_dir = root_dir, 14 | homepage = "https://clangd.llvm.org", 15 | languages = { "c", "c++" }, 16 | ---@param ctx InstallContext 17 | installer = function(ctx) 18 | local source = github.unzip_release_file { 19 | repo = "clangd/clangd", 20 | asset_file = function(release) 21 | local target = coalesce( 22 | when(platform.is_mac, "clangd-mac-%s.zip"), 23 | when(platform.is_linux and platform.arch == "x64", "clangd-linux-%s.zip"), 24 | when(platform.is_win, "clangd-windows-%s.zip") 25 | ) 26 | return target and target:format(release) 27 | end, 28 | } 29 | source.with_receipt() 30 | ctx.fs:rename(("clangd_%s"):format(source.release), "clangd") 31 | end, 32 | default_options = { 33 | cmd_env = { 34 | PATH = process.extend_path { path.concat { root_dir, "clangd", "bin" } }, 35 | }, 36 | }, 37 | } 38 | end 39 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/_generated/schemas/jsonls.lua: -------------------------------------------------------------------------------- 1 | -- THIS FILE IS GENERATED. DO NOT EDIT MANUALLY. 2 | -- stylua: ignore start 3 | return {id = "json",order = 20,properties = {["json.colorDecorators.enable"] = {default = true,deprecationMessage = "%json.colorDecorators.enable.deprecationMessage%",description = "%json.colorDecorators.enable.desc%",scope = "window",type = "boolean"},["json.format.enable"] = {default = true,description = "%json.format.enable.desc%",scope = "window",type = "boolean"},["json.format.keepLines"] = {default = false,description = "%json.format.keepLines.desc%",scope = "window",type = "boolean"},["json.maxItemsComputed"] = {default = 5000,description = "%json.maxItemsComputed.desc%",type = "number"},["json.schemaDownload.enable"] = {default = true,description = "%json.enableSchemaDownload.desc%",tags = { "usesOnlineServices" },type = "boolean"},["json.schemas"] = {description = "%json.schemas.desc%",items = {default = {fileMatch = { "/myfile" },url = "schemaURL"},properties = {fileMatch = {description = "%json.schemas.fileMatch.desc%",items = {default = "MyFile.json",description = "%json.schemas.fileMatch.item.desc%",type = "string"},minItems = 1,type = "array"},schema = {["$ref"] = "http://json-schema.org/draft-07/schema#",description = "%json.schemas.schema.desc%"},url = {default = "/user.schema.json",description = "%json.schemas.url.desc%",type = "string"}},type = "object"},scope = "resource",type = "array"},["json.trace.server"] = {default = "off",description = "%json.tracing.desc%",enum = { "off", "messages", "verbose" },scope = "window",type = "string"},["json.validate.enable"] = {default = true,description = "%json.validate.enable.desc%",scope = "window",type = "boolean"}},title = "JSON",type = "object"} -------------------------------------------------------------------------------- /tests/setup/automatic_installation_exclude_spec.lua: -------------------------------------------------------------------------------- 1 | local spy = require "luassert.spy" 2 | local lspconfig = require "lspconfig" 3 | local configs = require "lspconfig.configs" 4 | local servers = require "nvim-lsp-installer.servers" 5 | 6 | describe("automatic_installation_exclude", function() 7 | it( 8 | "should install servers set up via lspconfig", 9 | async_test(function() 10 | local server1_installer_spy = spy.new() 11 | local server2_installer_spy = spy.new() 12 | local server1 = ServerGenerator { 13 | name = "automatic_installation_exclude1", 14 | installer = function() 15 | server1_installer_spy() 16 | end, 17 | } 18 | local server2 = ServerGenerator { 19 | name = "automatic_installation_exclude2", 20 | installer = function() 21 | server2_installer_spy() 22 | end, 23 | } 24 | 25 | servers.register(server1) 26 | servers.register(server2) 27 | 28 | configs[server1.name] = { default_config = {} } 29 | configs[server2.name] = { default_config = {} } 30 | 31 | require("nvim-lsp-installer").setup { 32 | automatic_installation = { exclude = { server2.name } }, 33 | } 34 | 35 | lspconfig[server1.name].setup {} 36 | lspconfig[server2.name].setup {} 37 | 38 | assert.wait_for(function() 39 | assert.spy(server1_installer_spy).was_called(1) 40 | assert.spy(server2_installer_spy).was_called(0) 41 | end) 42 | end) 43 | ) 44 | end) 45 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/core/managers/powershell/init.lua: -------------------------------------------------------------------------------- 1 | local spawn = require "nvim-lsp-installer.core.spawn" 2 | local process = require "nvim-lsp-installer.core.process" 3 | 4 | local M = {} 5 | 6 | local PWSHOPT = { 7 | progress_preference = [[ $ProgressPreference = 'SilentlyContinue'; ]], -- https://stackoverflow.com/a/63301751 8 | security_protocol = [[ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ]], 9 | } 10 | 11 | ---@param script string 12 | ---@param opts JobSpawnOpts 13 | ---@param custom_spawn JobSpawn 14 | function M.script(script, opts, custom_spawn) 15 | opts = opts or {} 16 | ---@type JobSpawn 17 | local spawner = custom_spawn or spawn 18 | return spawner.powershell(vim.tbl_extend("keep", { 19 | "-NoProfile", 20 | on_spawn = function(_, stdio) 21 | local stdin = stdio[1] 22 | stdin:write(PWSHOPT.progress_preference) 23 | stdin:write(PWSHOPT.security_protocol) 24 | stdin:write(script) 25 | stdin:close() 26 | end, 27 | env_raw = process.graft_env(opts.env or {}, { "PSMODULEPATH" }), 28 | }, opts)) 29 | end 30 | 31 | ---@param command string 32 | ---@param opts JobSpawnOpts 33 | ---@param custom_spawn JobSpawn 34 | function M.command(command, opts, custom_spawn) 35 | opts = opts or {} 36 | ---@type JobSpawn 37 | local spawner = custom_spawn or spawn 38 | return spawner.powershell(vim.tbl_extend("keep", { 39 | "-NoProfile", 40 | "-Command", 41 | PWSHOPT.progress_preference .. PWSHOPT.security_protocol .. command, 42 | env_raw = process.graft_env(opts.env or {}, { "PSMODULEPATH" }), 43 | }, opts)) 44 | end 45 | 46 | return M 47 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/_generated/language_autocomplete_map.lua: -------------------------------------------------------------------------------- 1 | -- THIS FILE IS GENERATED. DO NOT EDIT MANUALLY. 2 | -- stylua: ignore start 3 | return { 4 | OpenFOAM = { "foam_ls" }, 5 | R = { "r_language_server" }, 6 | V = { "vls" }, 7 | ["assembly-gas"] = { "asm_lsp" }, 8 | ["assembly-go"] = { "asm_lsp" }, 9 | ["assembly-nasm"] = { "asm_lsp" }, 10 | c = { "ccls", "clangd" }, 11 | ["c#"] = { "csharp_ls", "omnisharp" }, 12 | ["c++"] = { "ccls", "clangd" }, 13 | crystal = { "crystalline", "scry" }, 14 | css = { "cssls", "cssmodules_ls" }, 15 | d = { "serve_d" }, 16 | ["f#"] = { "fsautocomplete" }, 17 | fortran = { "fortls" }, 18 | go = { "golangci_lint_ls", "gopls" }, 19 | haskell = { "hls" }, 20 | java = { "jdtls" }, 21 | javascript = { "eslint", "quick_lint_js", "rome", "tsserver" }, 22 | latex = { "ltex", "texlab" }, 23 | liquid = { "theme_check" }, 24 | lua = { "sumneko_lua" }, 25 | markdown = { "marksman", "prosemd_lsp", "remark_ls", "zk" }, 26 | ["metamath-zero"] = { "mm0_ls" }, 27 | nix = { "rnix" }, 28 | ["objective-c"] = { "ccls" }, 29 | onescript = { "bsl_ls" }, 30 | php = { "intelephense", "phpactor", "psalm" }, 31 | python = { "jedi_language_server", "pylsp", "pyright", "sourcery" }, 32 | ruby = { "solargraph", "sorbet" }, 33 | sls = { "salt_ls" }, 34 | solidity = { "solang", "solc", "solidity_ls" }, 35 | sphinx = { "esbonio" }, 36 | sql = { "sqlls", "sqls" }, 37 | swift = { "sourcekit" }, 38 | systemverilog = { "svlangserver", "svls", "verible" }, 39 | terraform = { "terraformls", "tflint" }, 40 | toml = { "taplo" }, 41 | typescript = { "eslint", "rome", "tsserver" }, 42 | verilog = { "verible" }, 43 | vlang = { "vls" }, 44 | vue = { "volar", "vuels" }, 45 | xml = { "lemminx" }, 46 | zig = { "zls" } 47 | } -------------------------------------------------------------------------------- /tests/core/functional/logic_spec.lua: -------------------------------------------------------------------------------- 1 | local spy = require "luassert.spy" 2 | local _ = require "nvim-lsp-installer.core.functional" 3 | 4 | describe("functional: logic", function() 5 | it("should check that all_pass checks that all predicates pass", function() 6 | local is_waldo = function(i) 7 | return i == "waldo" 8 | end 9 | assert.is_true(_.all_pass { _.T, _.T, is_waldo, _.T } "waldo") 10 | assert.is_false(_.all_pass { _.T, _.T, is_waldo, _.F } "waldo") 11 | assert.is_false(_.all_pass { _.T, _.T, is_waldo, _.T } "waldina") 12 | end) 13 | 14 | it("should branch if_else", function() 15 | local a = spy.new() 16 | local b = spy.new() 17 | _.if_else(_.T, a, b) "a" 18 | _.if_else(_.F, a, b) "b" 19 | assert.spy(a).was_called(1) 20 | assert.spy(a).was_called_with "a" 21 | assert.spy(b).was_called(1) 22 | assert.spy(b).was_called_with "b" 23 | end) 24 | 25 | it("should flip booleans", function() 26 | assert.is_true(_.is_not(false)) 27 | assert.is_false(_.is_not(true)) 28 | end) 29 | 30 | it("should resolve correct cond", function() 31 | local planetary_object = _.cond { 32 | { 33 | _.equals "Moon!", 34 | _.format "to the %s", 35 | }, 36 | { 37 | _.equals "World!", 38 | _.format "Hello %s", 39 | }, 40 | } 41 | assert.equals("Hello World!", planetary_object "World!") 42 | assert.equals("to the Moon!", planetary_object "Moon!") 43 | end) 44 | 45 | it("should give complements", function() 46 | assert.is_true(_.complement(_.is_nil, "not nil")) 47 | assert.is_false(_.complement(_.is_nil, nil)) 48 | end) 49 | end) 50 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/texlab/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local process = require "nvim-lsp-installer.core.process" 3 | local functional = require "nvim-lsp-installer.core.functional" 4 | local platform = require "nvim-lsp-installer.core.platform" 5 | local github = require "nvim-lsp-installer.core.managers.github" 6 | 7 | local coalesce, when = functional.coalesce, functional.when 8 | 9 | return function(name, root_dir) 10 | return server.Server:new { 11 | name = name, 12 | root_dir = root_dir, 13 | homepage = "https://github.com/latex-lsp/texlab", 14 | languages = { "latex" }, 15 | installer = function() 16 | local repo = "latex-lsp/texlab" 17 | platform.when { 18 | unix = function() 19 | github.untargz_release_file({ 20 | repo = repo, 21 | asset_file = coalesce( 22 | when(platform.is.mac_arm64, "texlab-aarch64-macos.tar.gz"), 23 | when(platform.is.mac_x64, "texlab-x86_64-macos.tar.gz"), 24 | when(platform.is.linux_x64, "texlab-x86_64-linux.tar.gz") 25 | ), 26 | }).with_receipt() 27 | end, 28 | win = function() 29 | github.unzip_release_file({ 30 | repo = repo, 31 | asset_file = coalesce(when(platform.arch == "x64", "texlab-x86_64-windows.zip")), 32 | }).with_receipt() 33 | end, 34 | } 35 | end, 36 | default_options = { 37 | cmd_env = { 38 | PATH = process.extend_path { root_dir }, 39 | }, 40 | }, 41 | } 42 | end 43 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/opencl_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local process = require "nvim-lsp-installer.core.process" 3 | local platform = require "nvim-lsp-installer.core.platform" 4 | local functional = require "nvim-lsp-installer.core.functional" 5 | local github = require "nvim-lsp-installer.core.managers.github" 6 | 7 | local coalesce, when = functional.coalesce, functional.when 8 | 9 | return function(name, root_dir) 10 | return server.Server:new { 11 | name = name, 12 | root_dir = root_dir, 13 | homepage = "https://github.com/Galarius/opencl-language-server", 14 | languages = { "opencl" }, 15 | installer = function() 16 | platform.when { 17 | unix = function() 18 | local asset_file = coalesce( 19 | when(platform.is_mac, "opencl-language-server-darwin-x86_64.tar.gz"), 20 | when(platform.is_linux and platform.arch == "x64", "opencl-language-server-linux-x86_64.tar.gz") 21 | ) 22 | github.untargz_release_file({ 23 | repo = "Galarius/opencl-language-server", 24 | asset_file = asset_file, 25 | }).with_receipt() 26 | end, 27 | win = function() 28 | github.unzip_release_file({ 29 | repo = "Galarius/opencl-language-server", 30 | asset_file = "opencl-language-server-win32-x86_64.zip", 31 | }).with_receipt() 32 | end, 33 | } 34 | end, 35 | default_options = { 36 | cmd_env = { 37 | PATH = process.extend_path { root_dir }, 38 | }, 39 | }, 40 | } 41 | end 42 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/angularls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local platform = require "nvim-lsp-installer.core.platform" 3 | local npm = require "nvim-lsp-installer.core.managers.npm" 4 | local _ = require "nvim-lsp-installer.core.functional" 5 | local path = require "nvim-lsp-installer.core.path" 6 | 7 | local append_node_modules = _.map(function(dir) 8 | return path.concat { dir, "node_modules" } 9 | end) 10 | 11 | return function(name, root_dir) 12 | local function get_cmd(workspace_dir) 13 | local cmd = { 14 | "ngserver", 15 | "--stdio", 16 | "--tsProbeLocations", 17 | table.concat(append_node_modules { root_dir, workspace_dir }, ","), 18 | "--ngProbeLocations", 19 | table.concat( 20 | append_node_modules { 21 | path.concat { root_dir, "node_modules", "@angular", "language-server" }, 22 | workspace_dir, 23 | }, 24 | "," 25 | ), 26 | } 27 | if platform.is_win then 28 | table.insert(cmd, 1, "cmd.exe") 29 | table.insert(cmd, 2, "/C") 30 | end 31 | 32 | return cmd 33 | end 34 | 35 | return server.Server:new { 36 | name = name, 37 | root_dir = root_dir, 38 | homepage = "https://angular.io/guide/language-service", 39 | languages = { "angular" }, 40 | installer = npm.packages { "@angular/language-server", "typescript" }, 41 | default_options = { 42 | cmd = get_cmd(path.cwd()), 43 | cmd_env = npm.env(root_dir), 44 | on_new_config = function(new_config, new_root_dir) 45 | new_config.cmd = get_cmd(new_root_dir) 46 | end, 47 | }, 48 | } 49 | end 50 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/core/managers/opam/init.lua: -------------------------------------------------------------------------------- 1 | local functional = require "nvim-lsp-installer.core.functional" 2 | local path = require "nvim-lsp-installer.core.path" 3 | local process = require "nvim-lsp-installer.core.process" 4 | local installer = require "nvim-lsp-installer.core.installer" 5 | 6 | local M = {} 7 | 8 | local list_copy = functional.list_copy 9 | 10 | ---@param packages string[] 11 | local function with_receipt(packages) 12 | return function() 13 | local ctx = installer.context() 14 | ctx.receipt:with_primary_source(ctx.receipt.opam(packages[1])) 15 | for i = 2, #packages do 16 | ctx.receipt:with_secondary_source(ctx.receipt.opam(packages[i])) 17 | end 18 | end 19 | end 20 | 21 | ---@async 22 | ---@param packages string[] @The opam packages to install. The first item in this list will be the recipient of the requested version, if set. 23 | function M.packages(packages) 24 | return function() 25 | return M.install(packages).with_receipt() 26 | end 27 | end 28 | 29 | ---@async 30 | ---@param packages string[] @The opam packages to install. The first item in this list will be the recipient of the requested version, if set. 31 | function M.install(packages) 32 | local ctx = installer.context() 33 | local pkgs = list_copy(packages) 34 | 35 | ctx.requested_version:if_present(function(version) 36 | pkgs[1] = ("%s.%s"):format(pkgs[1], version) 37 | end) 38 | 39 | ctx.spawn.opam { 40 | "install", 41 | "--destdir=.", 42 | "--yes", 43 | "--verbose", 44 | pkgs, 45 | } 46 | 47 | return { 48 | with_receipt = with_receipt(packages), 49 | } 50 | end 51 | 52 | function M.env(root_dir) 53 | return { 54 | PATH = process.extend_path { path.concat { root_dir, "bin" } }, 55 | } 56 | end 57 | 58 | return M 59 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/zls/init.lua: -------------------------------------------------------------------------------- 1 | local path = require "nvim-lsp-installer.core.path" 2 | local server = require "nvim-lsp-installer.server" 3 | local platform = require "nvim-lsp-installer.core.platform" 4 | local functional = require "nvim-lsp-installer.core.functional" 5 | local process = require "nvim-lsp-installer.core.process" 6 | local github = require "nvim-lsp-installer.core.managers.github" 7 | local std = require "nvim-lsp-installer.core.managers.std" 8 | 9 | local coalesce, when = functional.coalesce, functional.when 10 | 11 | return function(name, root_dir) 12 | return server.Server:new { 13 | name = name, 14 | root_dir = root_dir, 15 | homepage = "https://github.com/zigtools/zls", 16 | languages = { "zig" }, 17 | ---@param ctx InstallContext 18 | installer = function(ctx) 19 | local asset_file = coalesce( 20 | when(platform.is_mac, "x86_64-macos.tar.xz"), 21 | when( 22 | platform.is_linux, 23 | coalesce( 24 | when(platform.arch == "x64", "x86_64-linux.tar.xz"), 25 | when(platform.arch == "x86", "i386-linux.tar.xz") 26 | ) 27 | ), 28 | when(platform.is_win and platform.arch == "x64", "x86_64-windows.tar.xz") 29 | ) 30 | github.untarxz_release_file({ 31 | repo = "zigtools/zls", 32 | asset_file = asset_file, 33 | }).with_receipt() 34 | ctx.fs:rename("bin", "package") 35 | std.chmod("+x", { path.concat { "package", "zls" } }) 36 | end, 37 | default_options = { 38 | cmd_env = { 39 | PATH = process.extend_path { path.concat { root_dir, "package" } }, 40 | }, 41 | }, 42 | } 43 | end 44 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/vls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local github = require "nvim-lsp-installer.core.managers.github" 3 | local github_client = require "nvim-lsp-installer.core.managers.github.client" 4 | local std = require "nvim-lsp-installer.core.managers.std" 5 | local functional = require "nvim-lsp-installer.core.functional" 6 | local platform = require "nvim-lsp-installer.core.platform" 7 | local Optional = require "nvim-lsp-installer.core.optional" 8 | local process = require "nvim-lsp-installer.core.process" 9 | 10 | return function(name, root_dir) 11 | return server.Server:new { 12 | name = name, 13 | root_dir = root_dir, 14 | homepage = "https://github.com/vlang/vls", 15 | languages = { "vlang", "V" }, 16 | ---@async 17 | installer = function() 18 | local repo = "vlang/vls" 19 | 20 | ---@type GitHubRelease 21 | local latest_dev_build = 22 | github_client.fetch_latest_release(repo, { include_prerelease = true }):get_or_throw() 23 | 24 | github.download_release_file({ 25 | version = Optional.of(latest_dev_build.tag_name), 26 | repo = repo, 27 | out_file = platform.is.win and "vls.exe" or "vls", 28 | asset_file = functional.coalesce( 29 | functional.when(platform.is.linux_x64, "vls_linux_x64"), 30 | functional.when(platform.is.mac, "vls_macos_x64"), 31 | functional.when(platform.is.win_x64, "vls_windows_x64.exe") 32 | ), 33 | }).with_receipt() 34 | std.chmod("+x", { "vls" }) 35 | end, 36 | default_options = { 37 | cmd_env = { 38 | PATH = process.extend_path { root_dir }, 39 | }, 40 | }, 41 | } 42 | end 43 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/vala_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local path = require "nvim-lsp-installer.core.path" 3 | local std = require "nvim-lsp-installer.core.managers.std" 4 | local github = require "nvim-lsp-installer.core.managers.github" 5 | local process = require "nvim-lsp-installer.core.process" 6 | 7 | return function(name, root_dir) 8 | return server.Server:new { 9 | name = name, 10 | root_dir = root_dir, 11 | homepage = "https://wiki.gnome.org/Projects/Vala", 12 | languages = { "vala" }, 13 | ---@param ctx InstallContext 14 | installer = function(ctx) 15 | std.ensure_executable("meson", { help_url = "https://mesonbuild.com/Getting-meson.html" }) 16 | std.ensure_executable("ninja", { help_url = "https://ninja-build.org/" }) 17 | std.ensure_executable("valac", { help_url = "https://wiki.gnome.org/Projects/Vala" }) 18 | 19 | local release_source = github.untarxz_release_file { 20 | repo = "Prince781/vala-language-server", 21 | asset_file = function(version) 22 | return ("vala-language-server-%s.tar.xz"):format(version) 23 | end, 24 | } 25 | release_source.with_receipt() 26 | 27 | local vala_dirname = ("vala-language-server-%s"):format(release_source.release) 28 | local install_dir = ctx.cwd:get() 29 | ctx:chdir(vala_dirname, function() 30 | ctx.spawn.meson { ("-Dprefix=%s"):format(install_dir), "build" } 31 | ctx.spawn.ninja { "-C", "build", "install" } 32 | end) 33 | ctx.fs:rmrf(vala_dirname) 34 | end, 35 | default_options = { 36 | cmd_env = { 37 | PATH = process.extend_path { path.concat { root_dir, "bin" } }, 38 | }, 39 | }, 40 | } 41 | end 42 | -------------------------------------------------------------------------------- /tests/core/functional/number_spec.lua: -------------------------------------------------------------------------------- 1 | local _ = require "nvim-lsp-installer.core.functional" 2 | 3 | describe("functional: number", function() 4 | it("should negate numbers", function() 5 | assert.equals(-42, _.negate(42)) 6 | assert.equals(42, _.negate(-42)) 7 | end) 8 | 9 | it("should check numbers greater than value", function() 10 | local greater_than_life = _.gt(42) 11 | assert.is_false(greater_than_life(0)) 12 | assert.is_false(greater_than_life(42)) 13 | assert.is_true(greater_than_life(43)) 14 | end) 15 | 16 | it("should check numbers greater or equal than value", function() 17 | local greater_or_equal_to_life = _.gte(42) 18 | assert.is_false(greater_or_equal_to_life(0)) 19 | assert.is_true(greater_or_equal_to_life(42)) 20 | assert.is_true(greater_or_equal_to_life(43)) 21 | end) 22 | 23 | it("should check numbers lower than value", function() 24 | local lesser_than_life = _.lt(42) 25 | assert.is_true(lesser_than_life(0)) 26 | assert.is_false(lesser_than_life(42)) 27 | assert.is_false(lesser_than_life(43)) 28 | end) 29 | 30 | it("should check numbers lower or equal than value", function() 31 | local lesser_or_equal_to_life = _.lte(42) 32 | assert.is_true(lesser_or_equal_to_life(0)) 33 | assert.is_true(lesser_or_equal_to_life(42)) 34 | assert.is_false(lesser_or_equal_to_life(43)) 35 | end) 36 | 37 | it("should increment numbers", function() 38 | local add_5 = _.inc(5) 39 | assert.equals(0, add_5(-5)) 40 | assert.equals(5, add_5(0)) 41 | assert.equals(7, add_5(2)) 42 | end) 43 | 44 | it("should decrement numbers", function() 45 | local subtract_5 = _.dec(5) 46 | assert.equals(5, subtract_5(10)) 47 | assert.equals(-5, subtract_5(0)) 48 | assert.equals(-3, subtract_5(2)) 49 | end) 50 | end) 51 | -------------------------------------------------------------------------------- /tests/ui_status_win_spec.lua: -------------------------------------------------------------------------------- 1 | local ServerHints = require "nvim-lsp-installer.ui.server_hints" 2 | 3 | describe("status win server hints", function() 4 | it("should produce valid server hints", function() 5 | local srv = ServerGenerator { 6 | name = "rust_analyzer", 7 | languages = { "rust", "analyz", "totallynotjavascript" }, 8 | } 9 | local hints = ServerHints.new(srv) 10 | assert.same({ "analyz", "totallynotjavascript" }, hints:get_hints()) 11 | assert.equal("(analyz, totallynotjavascript)", tostring(hints)) 12 | end) 13 | 14 | it("should not produce server hints", function() 15 | local srv = ServerGenerator { 16 | name = "rust_analyzer", 17 | languages = { "rust" }, 18 | } 19 | local srv2 = ServerGenerator { 20 | name = "cssmodules_ls", 21 | languages = { "css" }, 22 | } 23 | local hints = ServerHints.new(srv) 24 | assert.same({}, hints:get_hints()) 25 | assert.equal("", tostring(hints)) 26 | 27 | local hints2 = ServerHints.new(srv2) 28 | assert.same({}, (hints2:get_hints())) 29 | assert.equal("", tostring(hints2)) 30 | end) 31 | 32 | it("should produce server hints even when there's a match if language is short or long", function() 33 | local srv = ServerGenerator { 34 | name = "clangd", 35 | languages = { "c", "c++" }, 36 | } 37 | local srv2 = ServerGenerator { 38 | name = "this_is_a_very_cool_rust_server", 39 | languages = { "rust" }, 40 | } 41 | local hints = ServerHints.new(srv) 42 | assert.same({ "c", "c++" }, hints:get_hints()) 43 | assert.equal("(c, c++)", tostring(hints)) 44 | 45 | local hints2 = ServerHints.new(srv2) 46 | assert.same({ "rust" }, hints2:get_hints()) 47 | assert.equal("(rust)", tostring(hints2)) 48 | end) 49 | end) 50 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/apex_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local github = require "nvim-lsp-installer.core.managers.github" 3 | local github_client = require "nvim-lsp-installer.core.managers.github.client" 4 | local Optional = require "nvim-lsp-installer.core.optional" 5 | local path = require "nvim-lsp-installer.core.path" 6 | local _ = require "nvim-lsp-installer.core.functional" 7 | 8 | return function(name, root_dir) 9 | local JAR_FILE = "apex-jorje-lsp.jar" 10 | 11 | return server.Server:new { 12 | name = name, 13 | root_dir = root_dir, 14 | homepage = "https://github.com/forcedotcom/salesforcedx-vscode", 15 | languages = { "apex" }, 16 | ---@async 17 | ---@param ctx InstallContext 18 | installer = function(ctx) 19 | local repo = "forcedotcom/salesforcedx-vscode" 20 | 21 | -- See https://github.com/forcedotcom/salesforcedx-vscode/issues/4184#issuecomment-1146052086 22 | ---@type GitHubRelease 23 | local release = github_client 24 | .fetch_releases(repo) 25 | :map(_.find_first(_.prop_satisfies(_.compose(_.gt(0), _.length), "assets"))) 26 | :map(Optional.of_nilable) 27 | :get_or_throw() -- Result unwrap 28 | :or_else_throw "Failed to find release with assets." -- Optional unwrap 29 | 30 | github.unzip_release_file({ 31 | version = Optional.of(release.tag_name), 32 | asset_file = _.compose(_.format "salesforcedx-vscode-apex-%s.vsix", _.gsub("^v", "")), 33 | repo = repo, 34 | }).with_receipt() 35 | 36 | ctx.fs:rename(path.concat { "extension", "out", JAR_FILE }, JAR_FILE) 37 | ctx.fs:rmrf "extension" 38 | end, 39 | default_options = { 40 | apex_jar_path = path.concat { root_dir, JAR_FILE }, 41 | }, 42 | } 43 | end 44 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/_generated/schemas/clangd.lua: -------------------------------------------------------------------------------- 1 | -- THIS FILE IS GENERATED. DO NOT EDIT MANUALLY. 2 | -- stylua: ignore start 3 | return {properties = {["clangd.arguments"] = {default = {},description = "Arguments for clangd server.",items = {type = "string"},type = "array"},["clangd.checkUpdates"] = {default = false,description = "Check for language server updates on startup.",type = "boolean"},["clangd.detectExtensionConflicts"] = {default = true,description = "Warn about conflicting extensions and suggest disabling them.",type = "boolean"},["clangd.fallbackFlags"] = {default = {},description = "Extra clang flags used to parse files when no compilation database is found.",items = {type = "string"},type = "array"},["clangd.onConfigChanged"] = {default = "prompt",description = "What to do when clangd configuration files are changed. Ignored for clangd 12+, which can reload such files itself.",enum = { "prompt", "restart", "ignore" },enumDescriptions = { "Prompt the user for restarting the server", "Automatically restart the server", "Do nothing" },type = "string"},["clangd.path"] = {default = "clangd",description = "The path to clangd executable, e.g.: /usr/bin/clangd.",scope = "machine-overridable",type = "string"},["clangd.restartAfterCrash"] = {default = true,description = "Auto restart clangd (up to 4 times) if it crashes.",type = "boolean"},["clangd.semanticHighlighting"] = {default = true,deprecationMessage = "Legacy semanticHighlights is no longer supported. Please use `editor.semanticHighlighting.enabled` instead.",description = "Enable semantic highlighting in clangd.",type = "boolean"},["clangd.serverCompletionRanking"] = {default = true,description = "Always rank completion items on the server as you type. This produces more accurate results at the cost of higher latency than client-side filtering.",type = "boolean"},["clangd.trace"] = {description = "Names a file that clangd should log a performance trace to, in chrome trace-viewer JSON format.",type = "string"}},title = "clangd",type = "object"} -------------------------------------------------------------------------------- /tests/dispatcher_spec.lua: -------------------------------------------------------------------------------- 1 | local dispatcher = require "nvim-lsp-installer.dispatcher" 2 | local spy = require "luassert.spy" 3 | local match = require "luassert.match" 4 | 5 | describe("dispatcher", function() 6 | it("calls registered callbacks", function() 7 | local server = {} 8 | local callback = spy.new() 9 | dispatcher.register_server_ready_callback(callback) 10 | dispatcher.dispatch_server_ready(server) 11 | 12 | assert.spy(callback).was_called(1) 13 | assert.spy(callback).was_called_with(server) 14 | end) 15 | 16 | it("deregisters callbacks", function() 17 | local server = {} 18 | local callback = spy.new() 19 | local deregister = dispatcher.register_server_ready_callback(callback) 20 | deregister() 21 | dispatcher.dispatch_server_ready(server) 22 | 23 | assert.spy(callback).was_not_called() 24 | end) 25 | 26 | it("calls all registers callbacks, even if one errors", function() 27 | local server = {} 28 | local callback1 = spy.new() 29 | local callback2 = spy.new(function() 30 | error "I have an error" 31 | end) 32 | local callback3 = spy.new() 33 | local notify = spy.on(vim, "notify") 34 | dispatcher.register_server_ready_callback(callback1) 35 | dispatcher.register_server_ready_callback(callback2) 36 | dispatcher.register_server_ready_callback(callback3) 37 | dispatcher.dispatch_server_ready(server) 38 | 39 | assert.spy(callback1).was_called(1) 40 | assert.spy(callback1).was_called_with(server) 41 | assert.spy(callback2).was_called(1) 42 | assert.spy(callback2).was_called_with(server) 43 | assert.spy(callback3).was_called(1) 44 | assert.spy(callback3).was_called_with(server) 45 | assert.spy(notify).was_called(1) 46 | assert.spy(notify).was_called_with(match.has_match "^.*I have an error$", vim.log.levels.ERROR) 47 | end) 48 | end) 49 | -------------------------------------------------------------------------------- /tests/helpers/lua/luassertx.lua: -------------------------------------------------------------------------------- 1 | local assert = require "luassert" 2 | local match = require "luassert.match" 3 | local a = require "nvim-lsp-installer.core.async" 4 | 5 | local function wait_for(_, arguments) 6 | ---@type fun() @Function to execute until it does not error. 7 | local assertions_fn = arguments[1] 8 | ---@type number @Timeout in milliseconds. Defaults to 5000. 9 | local timeout = arguments[2] 10 | timeout = timeout or 15000 11 | 12 | local start = vim.loop.hrtime() 13 | local is_ok, err 14 | repeat 15 | is_ok, err = pcall(assertions_fn) 16 | if not is_ok then 17 | a.sleep(math.min(timeout, 100)) 18 | end 19 | until is_ok or ((vim.loop.hrtime() - start) / 1e6) > timeout 20 | 21 | if not is_ok then 22 | error(err) 23 | end 24 | 25 | return is_ok 26 | end 27 | 28 | local function tbl_containing(_, arguments, _) 29 | return function(value) 30 | local expected = arguments[1] 31 | for key, val in pairs(expected) do 32 | if match.is_matcher(val) then 33 | if not val(value[key]) then 34 | return false 35 | end 36 | elseif value[key] ~= val then 37 | return false 38 | end 39 | end 40 | return true 41 | end 42 | end 43 | 44 | local function list_containing(_, arguments, _) 45 | return function(value) 46 | local expected = arguments[1] 47 | for _, val in pairs(value) do 48 | if match.is_matcher(expected) then 49 | if expected(val) then 50 | return true 51 | end 52 | elseif expected == val then 53 | return true 54 | end 55 | end 56 | return false 57 | end 58 | end 59 | 60 | assert:register("matcher", "tbl_containing", tbl_containing) 61 | assert:register("matcher", "list_containing", list_containing) 62 | assert:register("assertion", "wait_for", wait_for) 63 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/lemminx/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local functional = require "nvim-lsp-installer.core.functional" 3 | local platform = require "nvim-lsp-installer.core.platform" 4 | local process = require "nvim-lsp-installer.core.process" 5 | local std = require "nvim-lsp-installer.core.managers.std" 6 | 7 | local coalesce, when = functional.coalesce, functional.when 8 | 9 | return function(name, root_dir) 10 | return server.Server:new { 11 | name = name, 12 | root_dir = root_dir, 13 | languages = { "xml" }, 14 | homepage = "https://github.com/eclipse/lemminx", 15 | ---@param ctx InstallContext 16 | installer = function(ctx) 17 | local unzipped_file = assert( 18 | coalesce( 19 | when(platform.is_mac, "lemminx-osx-x86_64"), 20 | when(platform.is_linux, "lemminx-linux"), 21 | when(platform.is_win, "lemminx-win32") 22 | ), 23 | ("Your operating system or architecture (%q) is not yet supported."):format(platform.arch) 24 | ) 25 | 26 | std.download_file( 27 | ("https://download.jboss.org/jbosstools/vscode/snapshots/lemminx-binary/%s/%s.zip"):format( 28 | ctx.requested_version:or_else "0.19.2-655", -- TODO: resolve latest version dynamically 29 | unzipped_file 30 | ), 31 | "lemminx.zip" 32 | ) 33 | std.unzip("lemminx.zip", ".") 34 | ctx.fs:rename( 35 | platform.is_win and ("%s.exe"):format(unzipped_file) or unzipped_file, 36 | platform.is_win and "lemminx.exe" or "lemminx" 37 | ) 38 | ctx.receipt:with_primary_source(ctx.receipt.unmanaged) 39 | end, 40 | default_options = { 41 | cmd_env = { 42 | PATH = process.extend_path { root_dir }, 43 | }, 44 | }, 45 | } 46 | end 47 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/ccls/common.lua: -------------------------------------------------------------------------------- 1 | local path = require "nvim-lsp-installer.core.path" 2 | local platform = require "nvim-lsp-installer.core.platform" 3 | local installer = require "nvim-lsp-installer.core.installer" 4 | local git = require "nvim-lsp-installer.core.managers.git" 5 | local Optional = require "nvim-lsp-installer.core.optional" 6 | 7 | ---@async 8 | ---@param opts {llvm_dir: string} 9 | return function(opts) 10 | local ctx = installer.context() 11 | local clang_resource_dir = path.concat { ctx.destination_dir, "clang-resource" } 12 | local install_prefix = ctx.cwd:get() 13 | 14 | ctx.fs:mkdir "ccls-git" 15 | ctx:chdir("ccls-git", function() 16 | git.clone { "https://github.com/MaskRay/ccls", recursive = true } 17 | ctx.spawn.cmake { 18 | "-DCMAKE_BUILD_TYPE=Release", 19 | "-DUSE_SYSTEM_RAPIDJSON=OFF", 20 | "-DCMAKE_FIND_FRAMEWORK=LAST", 21 | "-Wno-dev", 22 | ("-DCMAKE_INSTALL_PREFIX=%s"):format(install_prefix), 23 | Optional.of_nilable(opts.llvm_dir) 24 | :map(function(llvm_dir) 25 | return { 26 | ("-DCMAKE_PREFIX_PATH=%s"):format(llvm_dir), 27 | -- On Mac we use Homebrew LLVM which will persist after installation. 28 | -- On Linux, and when a custom llvm_dir is provided, its clang resource dir will be the only 29 | -- artifact persisted after installation, as the locally installed llvm installation will be 30 | -- cleaned up after compilation. 31 | not platform.is_mac and ("-DCLANG_RESOURCE_DIR=%s"):format(clang_resource_dir) or vim.NIL, 32 | } 33 | end) 34 | :or_else(vim.NIL), 35 | platform.is_mac and "-DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" or vim.NIL, 36 | } 37 | 38 | ctx.spawn.make { "install" } 39 | end) 40 | ctx.fs:rmrf "ccls-git" 41 | end 42 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/_generated/schemas/stylelint_lsp.lua: -------------------------------------------------------------------------------- 1 | -- THIS FILE IS GENERATED. DO NOT EDIT MANUALLY. 2 | -- stylua: ignore start 3 | return {properties = {["stylelintplus.autoFixOnFormat"] = {default = false,description = "Auto-fix on format request.",scope = "resource",type = "boolean"},["stylelintplus.autoFixOnSave"] = {default = false,description = "Auto-fix and format on save.",scope = "resource",type = "boolean"},["stylelintplus.config"] = {default = vim.NIL,description = "Stylelint config. If config and configFile are unset, stylelint will automatically look for a config file.",scope = "resource",type = "object"},["stylelintplus.configFile"] = {default = vim.NIL,description = "Stylelint config file. If config and configFile are unset, stylelint will automatically look for a config file.",scope = "resource",type = "string"},["stylelintplus.configOverrides"] = {default = vim.NIL,description = "Stylelint config overrides. These will be applied on top of the config, configFile, or auto-discovered config file loaded by stylelint.",scope = "resource",type = "object"},["stylelintplus.cssInJs"] = {default = false,description = "Run stylelint on javascript/typescript files.",scope = "window",type = "boolean"},["stylelintplus.enable"] = {default = true,description = "If false, stylelint will not validate the file.",scope = "resource",type = "boolean"},["stylelintplus.filetypes"] = {default = { "css", "less", "postcss", "sass", "scss", "sugarss", "vue", "wxss" },description = "Filetypes that coc-stylelintplus will lint.",items = {type = "string"},scope = "window",type = "array"},["stylelintplus.trace.server"] = {default = "off",description = "Capture trace messages from the server.",enum = { "off", "messages", "verbose" },scope = "window",type = "string"},["stylelintplus.validateOnSave"] = {default = false,description = "Validate after saving. Automatically enabled if autoFixOnSave is enabled.",scope = "resource",type = "boolean"},["stylelintplus.validateOnType"] = {default = true,description = "Validate after making changes.",scope = "resource",type = "boolean"}},title = "stylelintplus",type = "object"} -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/core/fetch.lua: -------------------------------------------------------------------------------- 1 | local log = require "nvim-lsp-installer.log" 2 | local platform = require "nvim-lsp-installer.core.platform" 3 | local Result = require "nvim-lsp-installer.core.result" 4 | local spawn = require "nvim-lsp-installer.core.spawn" 5 | local powershell = require "nvim-lsp-installer.core.managers.powershell" 6 | 7 | local USER_AGENT = "nvim-lsp-installer (+https://github.com/williamboman/nvim-lsp-installer)" 8 | 9 | local HEADERS = { 10 | wget = { "--header", ("User-Agent: %s"):format(USER_AGENT) }, 11 | curl = { "-H", ("User-Agent: %s"):format(USER_AGENT) }, 12 | iwr = ("-Headers @{'User-Agent' = '%s'}"):format(USER_AGENT), 13 | } 14 | 15 | ---@alias FetchOpts {out_file:string} 16 | 17 | ---@async 18 | ---@param url string @The url to fetch. 19 | ---@param opts FetchOpts 20 | local function fetch(url, opts) 21 | opts = opts or {} 22 | log.fmt_debug("Fetching URL %s", url) 23 | 24 | local platform_specific = Result.failure() 25 | 26 | if platform.is_win then 27 | if opts.out_file then 28 | platform_specific = powershell.command( 29 | ([[iwr %s -UseBasicParsing -Uri %q -OutFile %q;]]):format(HEADERS.iwr, url, opts.out_file) 30 | ) 31 | else 32 | platform_specific = powershell.command( 33 | ([[Write-Output (iwr %s -UseBasicParsing -Uri %q).Content;]]):format(HEADERS.iwr, url) 34 | ) 35 | end 36 | end 37 | 38 | return platform_specific 39 | :recover_catching(function() 40 | return spawn.wget({ HEADERS.wget, "-nv", "-O", opts.out_file or "-", url }):get_or_throw() 41 | end) 42 | :recover_catching(function() 43 | return spawn.curl({ HEADERS.curl, "-fsSL", opts.out_file and { "-o", opts.out_file } or vim.NIL, url }):get_or_throw() 44 | end) 45 | :map(function(result) 46 | if opts.out_file then 47 | return result 48 | else 49 | return result.stdout 50 | end 51 | end) 52 | end 53 | 54 | return fetch 55 | -------------------------------------------------------------------------------- /tests/minimal_debug_init.lua: -------------------------------------------------------------------------------- 1 | local on_windows = vim.loop.os_uname().version:match "Windows" 2 | 3 | local function join_paths(...) 4 | local path_sep = on_windows and "\\" or "/" 5 | local result = table.concat({ ... }, path_sep) 6 | return result 7 | end 8 | 9 | vim.opt.runtimepath = vim.env.VIMRUNTIME 10 | vim.opt.completeopt = "menu" 11 | 12 | local temp_dir = vim.loop.os_getenv "TEMP" or "/tmp" 13 | 14 | vim.opt.packpath = join_paths(temp_dir, "nvim-lsp-installer-debug", "site") 15 | 16 | local package_root = join_paths(temp_dir, "nvim-lsp-installer-debug", "site", "pack") 17 | local install_path = join_paths(package_root, "packer", "start", "packer.nvim") 18 | local compile_path = join_paths(install_path, "plugin", "packer_compiled.lua") 19 | 20 | local function load_plugins() 21 | require("packer").startup { 22 | { 23 | "wbthomason/packer.nvim", 24 | "neovim/nvim-lspconfig", 25 | "williamboman/nvim-lsp-installer", 26 | }, 27 | config = { 28 | package_root = package_root, 29 | compile_path = compile_path, 30 | }, 31 | } 32 | end 33 | 34 | function _G.load_config() 35 | local lspconfig = require "lspconfig" 36 | 37 | local function on_attach(client, bufnr) 38 | vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") 39 | end 40 | 41 | require("nvim-lsp-installer").setup { 42 | log = vim.log.levels.DEBUG, 43 | } 44 | 45 | -- ================================================== 46 | -- ========= SETUP RELEVANT SERVER(S) HERE! ========= 47 | -- ================================================== 48 | -- 49 | -- lspconfig.sumneko_lua.setup { on_attach = on_attach } 50 | end 51 | 52 | if vim.fn.isdirectory(install_path) == 0 then 53 | vim.fn.system { "git", "clone", "https://github.com/wbthomason/packer.nvim", install_path } 54 | load_plugins() 55 | require("packer").sync() 56 | vim.cmd [[autocmd User PackerComplete ++once lua load_config()]] 57 | else 58 | load_plugins() 59 | require("packer").sync() 60 | _G.load_config() 61 | end 62 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/serve_d/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local platform = require "nvim-lsp-installer.core.platform" 3 | local functional = require "nvim-lsp-installer.core.functional" 4 | local process = require "nvim-lsp-installer.core.process" 5 | local github = require "nvim-lsp-installer.core.managers.github" 6 | 7 | local coalesce, when = functional.coalesce, functional.when 8 | 9 | return function(name, root_dir) 10 | return server.Server:new { 11 | name = name, 12 | root_dir = root_dir, 13 | homepage = "https://github.com/Pure-D/serve-d", 14 | languages = { "d" }, 15 | installer = function() 16 | local repo = "Pure-D/serve-d" 17 | platform.when { 18 | unix = function() 19 | github.untarxz_release_file({ 20 | repo = repo, 21 | asset_file = function(release) 22 | local target = coalesce( 23 | when(platform.is_mac, "serve-d_%s-osx-x86_64.tar.xz"), 24 | when(platform.is_linux and platform.arch == "x64", "serve-d_%s-linux-x86_64.tar.xz") 25 | ) 26 | return target and target:format(release:gsub("^v", "")) 27 | end, 28 | }).with_receipt() 29 | end, 30 | win = function() 31 | github.unzip_release_file({ 32 | repo = repo, 33 | asset_file = function(release) 34 | local target = coalesce(when(platform.arch == "x64"), "serve-d_%s-windows-x86_64.zip") 35 | return target and target:format(release:gsub("^v", "")) 36 | end, 37 | }).with_receipt() 38 | end, 39 | } 40 | end, 41 | default_options = { 42 | cmd_env = { 43 | PATH = process.extend_path { root_dir }, 44 | }, 45 | }, 46 | } 47 | end 48 | -------------------------------------------------------------------------------- /tests/server_spec.lua: -------------------------------------------------------------------------------- 1 | local spy = require "luassert.spy" 2 | local lsp_installer = require "nvim-lsp-installer" 3 | local server = require "nvim-lsp-installer.server" 4 | local a = require "nvim-lsp-installer.core.async" 5 | 6 | local function timestamp() 7 | local seconds, microseconds = vim.loop.gettimeofday() 8 | return (seconds * 1000) + math.floor(microseconds / 1000) 9 | end 10 | 11 | describe("server", function() 12 | it( 13 | "calls registered on_ready handlers upon successful installation", 14 | async_test(function() 15 | local on_ready_handler = spy.new() 16 | local generic_handler = spy.new() 17 | 18 | lsp_installer.on_server_ready(generic_handler) 19 | 20 | local srv = ServerGenerator { 21 | name = "on_ready_fixture", 22 | root_dir = server.get_server_root_path "on_ready_fixture", 23 | } 24 | srv:on_ready(on_ready_handler) 25 | srv:install() 26 | assert.wait_for(function() 27 | assert.spy(on_ready_handler).was_called(1) 28 | assert.spy(generic_handler).was_called(1) 29 | assert.spy(generic_handler).was_called_with(srv) 30 | end) 31 | assert.is_true(srv:is_installed()) 32 | end) 33 | ) 34 | 35 | it( 36 | "doesn't call on_ready handler when server fails installation", 37 | async_test(function() 38 | local on_ready_handler = spy.new() 39 | local generic_handler = spy.new() 40 | 41 | lsp_installer.on_server_ready(generic_handler) 42 | 43 | local srv = FailingServerGenerator { 44 | name = "on_ready_fixture_failing", 45 | root_dir = server.get_server_root_path "on_ready_fixture_failing", 46 | } 47 | srv:on_ready(on_ready_handler) 48 | srv:install() 49 | a.sleep(500) 50 | assert.spy(on_ready_handler).was_not_called() 51 | assert.spy(generic_handler).was_not_called() 52 | assert.is_false(srv:is_installed()) 53 | end) 54 | ) 55 | end) 56 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/visualforce_ls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local github = require "nvim-lsp-installer.core.managers.github" 3 | local github_client = require "nvim-lsp-installer.core.managers.github.client" 4 | local Optional = require "nvim-lsp-installer.core.optional" 5 | local path = require "nvim-lsp-installer.core.path" 6 | local _ = require "nvim-lsp-installer.core.functional" 7 | 8 | return function(name, root_dir) 9 | return server.Server:new { 10 | name = name, 11 | root_dir = root_dir, 12 | homepage = "https://github.com/forcedotcom/salesforcedx-vscode", 13 | languages = { "visualforce" }, 14 | ---@async 15 | installer = function() 16 | local repo = "forcedotcom/salesforcedx-vscode" 17 | 18 | -- See https://github.com/forcedotcom/salesforcedx-vscode/issues/4184#issuecomment-1146052086 19 | ---@type GitHubRelease 20 | local release = github_client 21 | .fetch_releases(repo) 22 | :map(_.find_first(_.prop_satisfies(_.compose(_.gt(0), _.length), "assets"))) 23 | :map(Optional.of_nilable) 24 | :get_or_throw() -- Result unwrap 25 | :or_else_throw "Failed to find release with assets." -- Optional unwrap 26 | 27 | github.unzip_release_file({ 28 | version = Optional.of(release.tag_name), 29 | asset_file = _.compose(_.format "salesforcedx-vscode-visualforce-%s.vsix", _.gsub("^v", "")), 30 | repo = repo, 31 | }).with_receipt() 32 | end, 33 | default_options = { 34 | cmd = { 35 | "node", 36 | path.concat { 37 | root_dir, 38 | "extension", 39 | "node_modules", 40 | "@salesforce", 41 | "salesforcedx-visualforce-language-server", 42 | "out", 43 | "src", 44 | "visualforceServer.js", 45 | }, 46 | "--stdio", 47 | }, 48 | }, 49 | } 50 | end 51 | -------------------------------------------------------------------------------- /tests/core/managers/opam_spec.lua: -------------------------------------------------------------------------------- 1 | local match = require "luassert.match" 2 | local mock = require "luassert.mock" 3 | local Optional = require "nvim-lsp-installer.core.optional" 4 | local installer = require "nvim-lsp-installer.core.installer" 5 | local opam = require "nvim-lsp-installer.core.managers.opam" 6 | 7 | describe("opam manager", function() 8 | ---@type InstallContext 9 | local ctx 10 | before_each(function() 11 | ctx = InstallContextGenerator { 12 | spawn = mock.new { 13 | opam = mockx.returns {}, 14 | }, 15 | } 16 | end) 17 | 18 | it( 19 | "should call opam install", 20 | async_test(function() 21 | ctx.requested_version = Optional.of "42.13.37" 22 | installer.run_installer(ctx, opam.packages { "main-package", "supporting-package", "supporting-package2" }) 23 | assert.spy(ctx.spawn.opam).was_called(1) 24 | assert.spy(ctx.spawn.opam).was_called_with(match.tbl_containing { 25 | "install", 26 | "--destdir=.", 27 | "--yes", 28 | "--verbose", 29 | match.tbl_containing { 30 | "main-package.42.13.37", 31 | "supporting-package", 32 | "supporting-package2", 33 | }, 34 | }) 35 | end) 36 | ) 37 | 38 | it( 39 | "should provide receipt information", 40 | async_test(function() 41 | ctx.requested_version = Optional.of "42.13.37" 42 | installer.run_installer(ctx, opam.packages { "main-package", "supporting-package", "supporting-package2" }) 43 | assert.same({ 44 | type = "opam", 45 | package = "main-package", 46 | }, ctx.receipt.primary_source) 47 | assert.same({ 48 | { 49 | type = "opam", 50 | package = "supporting-package", 51 | }, 52 | { 53 | type = "opam", 54 | package = "supporting-package2", 55 | }, 56 | }, ctx.receipt.secondary_sources) 57 | end) 58 | ) 59 | end) 60 | -------------------------------------------------------------------------------- /tests/core/optional_spec.lua: -------------------------------------------------------------------------------- 1 | local Optional = require "nvim-lsp-installer.core.optional" 2 | local spy = require "luassert.spy" 3 | 4 | describe("Optional.of_nilable", function() 5 | it("should create empty optionals", function() 6 | local empty = Optional.empty() 7 | assert.is_false(empty:is_present()) 8 | end) 9 | 10 | it("should create non-empty optionals", function() 11 | local empty = Optional.of_nilable "value" 12 | assert.is_true(empty:is_present()) 13 | end) 14 | 15 | it("should use memoized empty value", function() 16 | assert.is_true(Optional.empty() == Optional.empty()) 17 | end) 18 | end) 19 | 20 | describe("Optional.get()", function() 21 | it("should map non-empty values", function() 22 | local str = Optional.of_nilable("world!") 23 | :map(function(val) 24 | return "Hello " .. val 25 | end) 26 | :get() 27 | assert.equals("Hello world!", str) 28 | end) 29 | 30 | it("should raise error when getting empty value", function() 31 | local err = assert.has_error(function() 32 | Optional.empty():get() 33 | end) 34 | assert.equals("No value present.", err) 35 | end) 36 | end) 37 | 38 | describe("Optional.or_else()", function() 39 | it("should use .or_else() value if empty", function() 40 | local value = Optional.empty():or_else "Hello!" 41 | assert.equals("Hello!", value) 42 | end) 43 | 44 | it("should not use .or_else() value if not empty", function() 45 | local value = Optional.of_nilable("Good bye!"):or_else "Hello!" 46 | assert.equals("Good bye!", value) 47 | end) 48 | end) 49 | 50 | describe("Optional.if_present()", function() 51 | it("should not call .if_present() if value is empty", function() 52 | local present = spy.new() 53 | Optional.empty():if_present(present) 54 | assert.spy(present).was_not_called() 55 | end) 56 | 57 | it("should call .if_present() if value is not empty", function() 58 | local present = spy.new() 59 | Optional.of_nilable("value"):if_present(present) 60 | assert.spy(present).was_called(1) 61 | assert.spy(present).was_called_with "value" 62 | end) 63 | end) 64 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/terraformls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local process = require "nvim-lsp-installer.core.process" 3 | local platform = require "nvim-lsp-installer.core.platform" 4 | local functional = require "nvim-lsp-installer.core.functional" 5 | local github = require "nvim-lsp-installer.core.managers.github" 6 | 7 | local coalesce, when = functional.coalesce, functional.when 8 | 9 | return function(name, root_dir) 10 | return server.Server:new { 11 | name = name, 12 | root_dir = root_dir, 13 | homepage = "https://github.com/hashicorp/terraform-ls", 14 | languages = { "terraform" }, 15 | installer = function() 16 | github.unzip_release_file({ 17 | repo = "hashicorp/terraform-ls", 18 | asset_file = function(version) 19 | local target = coalesce( 20 | when( 21 | platform.is_mac, 22 | coalesce( 23 | when(platform.arch == "arm64", "terraform-ls_%s_darwin_arm64.zip"), 24 | when(platform.arch == "x64", "terraform-ls_%s_darwin_amd64.zip") 25 | ) 26 | ), 27 | when( 28 | platform.is_linux, 29 | coalesce( 30 | when(platform.arch == "arm64", "terraform-ls_%s_linux_arm64.zip"), 31 | when(platform.arch == "arm", "terraform-ls_%s_linux_arm.zip"), 32 | when(platform.arch == "x64", "terraform-ls_%s_linux_amd64.zip") 33 | ) 34 | ), 35 | when( 36 | platform.is_win, 37 | coalesce(when(platform.arch == "x64", "terraform-ls_%s_windows_amd64.zip")) 38 | ) 39 | ) 40 | return target and target:format(version:gsub("^v", "")) 41 | end, 42 | }).with_receipt() 43 | end, 44 | default_options = { 45 | cmd_env = { 46 | PATH = process.extend_path { root_dir }, 47 | }, 48 | }, 49 | } 50 | end 51 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/_generated/schemas/elmls.lua: -------------------------------------------------------------------------------- 1 | -- THIS FILE IS GENERATED. DO NOT EDIT MANUALLY. 2 | -- stylua: ignore start 3 | return {properties = {["elmLS.disableElmLSDiagnostics"] = {default = false,description = "Disable linting diagnostics from the language server.",scope = "window",type = "boolean"},["elmLS.elmFormatPath"] = {default = "",description = "The path to your elm-format executable. Should be empty by default, in that case it will assume the name and try to first get it from a local npm installation or a global one. If you set it manually it will not try to load from the npm folder.",scope = "window",type = "string"},["elmLS.elmPath"] = {default = "",description = "The path to your elm executable. Should be empty by default, in that case it will assume the name and try to first get it from a local npm installation or a global one. If you set it manually it will not try to load from the npm folder.",scope = "window",type = "string"},["elmLS.elmReviewDiagnostics"] = {default = "off",description = "Set severity or disable linting diagnostics for elm-review.",enum = { "off", "warning", "error" },scope = "window",type = "string"},["elmLS.elmReviewPath"] = {default = "",description = "The path to your elm-review executable. Should be empty by default, in that case it will assume the name and try to first get it from a local npm installation or a global one. If you set it manually it will not try to load from the npm folder.",scope = "window",type = "string"},["elmLS.elmTestPath"] = {default = "",description = "The path to your elm-test executable. Should be empty by default, in that case it will assume the name and try to first get it from a local npm installation or a global one. If you set it manually it will not try to load from the npm folder.",scope = "window",type = "string"},["elmLS.elmTestRunner.showElmTestOutput"] = {description = "Show output of elm-test as terminal task",scope = "resource",type = "boolean"},["elmLS.onlyUpdateDiagnosticsOnSave"] = {default = false,description = "Only update compiler diagnostics on save, not on document change.",scope = "window",type = "boolean"},["elmLS.skipInstallPackageConfirmation"] = {default = false,description = "Skips confirmation for the Install Package code action.",scope = "window",type = "boolean"},["elmLS.trace.server"] = {default = "off",description = "Traces the communication between VS Code and the language server.",enum = { "off", "messages", "verbose" },scope = "window",type = "string"}},title = "Elm",type = "object"} -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/_generated/schemas/yamlls.lua: -------------------------------------------------------------------------------- 1 | -- THIS FILE IS GENERATED. DO NOT EDIT MANUALLY. 2 | -- stylua: ignore start 3 | return {properties = {["redhat.telemetry.enabled"] = {default = vim.NIL,markdownDescription = "Enable usage data and errors to be sent to Red Hat servers. Read our [privacy statement](https://developers.redhat.com/article/tool-data-collection).",scope = "window",type = "boolean"},["yaml.completion"] = {default = true,description = "Enable/disable completion feature",type = "boolean"},["yaml.customTags"] = {default = {},description = "Custom tags for the parser to use",type = "array"},["yaml.disableAdditionalProperties"] = {default = false,description = "Globally set additionalProperties to false for all objects. So if its true, no extra properties are allowed inside yaml.",type = "boolean"},["yaml.format.bracketSpacing"] = {default = true,description = "Print spaces between brackets in objects",type = "boolean"},["yaml.format.enable"] = {default = true,description = "Enable/disable default YAML formatter",type = "boolean"},["yaml.format.printWidth"] = {default = 80,description = "Specify the line length that the printer will wrap on",type = "integer"},["yaml.format.proseWrap"] = {default = "preserve",description = "Always: wrap prose if it exeeds the print width, Never: never wrap the prose, Preserve: wrap prose as-is",enum = { "preserve", "never", "always" },type = "string"},["yaml.format.singleQuote"] = {default = false,description = "Use single quotes instead of double quotes",type = "boolean"},["yaml.hover"] = {default = true,description = "Enable/disable hover feature",type = "boolean"},["yaml.maxItemsComputed"] = {default = 5000,description = "The maximum number of outline symbols and folding regions computed (limited for performance reasons).",type = "integer"},["yaml.schemaStore.enable"] = {default = true,description = "Automatically pull available YAML schemas from JSON Schema Store",type = "boolean"},["yaml.schemaStore.url"] = {default = "https://www.schemastore.org/api/json/catalog.json",description = "URL of schema store catalog to use",type = "string"},["yaml.schemas"] = {default = vim.empty_dict(),description = "Associate schemas to YAML files in the current workspace",type = "object"},["yaml.trace.server"] = {default = "off",description = "Traces the communication between VSCode and the YAML language service.",enum = { "off", "messages", "verbose" },type = "string"},["yaml.validate"] = {default = true,description = "Enable/disable validation feature",type = "boolean"}}} -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/quick_lint_js/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local platform = require "nvim-lsp-installer.core.platform" 3 | local path = require "nvim-lsp-installer.core.path" 4 | local functional = require "nvim-lsp-installer.core.functional" 5 | local process = require "nvim-lsp-installer.core.process" 6 | local std = require "nvim-lsp-installer.core.managers.std" 7 | local github = require "nvim-lsp-installer.core.managers.github" 8 | 9 | local coalesce, when = functional.coalesce, functional.when 10 | 11 | return function(name, root_dir) 12 | return server.Server:new { 13 | name = name, 14 | root_dir = root_dir, 15 | homepage = "https://quick-lint-js.com/", 16 | languages = { "javascript" }, 17 | ---@async 18 | installer = function() 19 | local repo = "quick-lint/quick-lint-js" 20 | local release_file = assert( 21 | coalesce( 22 | when(platform.is.mac_x64, "macos.tar.gz"), 23 | when(platform.is.mac_arm64, "macos-aarch64.tar.gz"), 24 | when(platform.is.linux_x64, "linux.tar.gz"), 25 | when(platform.is.linux_arm64, "linux-aarch64.tar.gz"), 26 | when(platform.is.linux_arm, "linux-armhf.tar.gz"), 27 | when(platform.is.win_x64, "windows.zip"), 28 | when(platform.is.win_arm64, "windows-arm64.zip"), 29 | when(platform.is.win_arm, "windows-arm.zip") 30 | ), 31 | "Current platform is not supported." 32 | ) 33 | 34 | local source = github.tag { repo = repo } 35 | source.with_receipt() 36 | 37 | local url = ("https://c.quick-lint-js.com/releases/%s/manual/%s"):format(source.tag, release_file) 38 | platform.when { 39 | unix = function() 40 | std.download_file(url, "archive.tar.gz") 41 | std.untar("archive.tar.gz", { strip_components = 1 }) 42 | end, 43 | win = function() 44 | std.download_file(url, "archive.zip") 45 | std.unzip("archive.zip", ".") 46 | end, 47 | } 48 | end, 49 | default_options = { 50 | cmd_env = { 51 | PATH = process.extend_path { path.concat { root_dir, "bin" } }, 52 | }, 53 | }, 54 | } 55 | end 56 | -------------------------------------------------------------------------------- /tests/middleware_spec.lua: -------------------------------------------------------------------------------- 1 | local util = require "lspconfig.util" 2 | local servers = require "nvim-lsp-installer.servers" 3 | local middleware = require "nvim-lsp-installer.middleware" 4 | 5 | describe("middleware", function() 6 | local server 7 | before_each(function() 8 | -- 1. setup dummy server 9 | local default_options = { 10 | cmd = { "dummy-lsp" }, 11 | cmd_env = { PATH = "/keep/my/path/out/your/f/mouth" }, 12 | } 13 | server = ServerGenerator { 14 | default_options = default_options, 15 | } 16 | servers.register(server) 17 | 18 | -- 2. register hook 19 | middleware.register_lspconfig_hook() 20 | end) 21 | 22 | after_each(function() 23 | -- reset hook 24 | util.on_setup = nil 25 | end) 26 | 27 | it( 28 | "should apply config changes to installed servers", 29 | async_test(function() 30 | server:install() 31 | assert.wait_for(function() 32 | assert.is_true(server:is_installed()) 33 | end) 34 | local config = { 35 | name = "dummy", 36 | cmd = { "should", "be", "overwritten" }, 37 | custom = "setting", 38 | cmd_env = { SOME_DEFAULT_ENV = "important" }, 39 | } 40 | util.on_setup(config) 41 | assert.same({ 42 | cmd = { "dummy-lsp" }, 43 | name = "dummy", 44 | custom = "setting", 45 | cmd_env = { 46 | PATH = "/keep/my/path/out/your/f/mouth", 47 | SOME_DEFAULT_ENV = "important", 48 | }, 49 | }, config) 50 | end) 51 | ) 52 | 53 | it( 54 | "should not apply config changes to uninstalled servers", 55 | async_test(function() 56 | local config = { 57 | name = "uninstalled_dummy", 58 | cmd = { "should", "not", "be", "overwritten" }, 59 | custom = "setting", 60 | cmd_env = { SOME_DEFAULT_ENV = "important" }, 61 | } 62 | util.on_setup(config) 63 | assert.same({ 64 | name = "uninstalled_dummy", 65 | cmd = { "should", "not", "be", "overwritten" }, 66 | custom = "setting", 67 | cmd_env = { SOME_DEFAULT_ENV = "important" }, 68 | }, config) 69 | end) 70 | ) 71 | end) 72 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/core/optional.lua: -------------------------------------------------------------------------------- 1 | ---@class Optional 2 | ---@field private _value unknown 3 | local Optional = {} 4 | Optional.__index = Optional 5 | 6 | ---@param value any 7 | function Optional.new(value) 8 | return setmetatable({ _value = value }, Optional) 9 | end 10 | 11 | local EMPTY = Optional.new(nil) 12 | 13 | ---@param value any 14 | function Optional.of_nilable(value) 15 | if value == nil then 16 | return EMPTY 17 | else 18 | return Optional.new(value) 19 | end 20 | end 21 | 22 | function Optional.empty() 23 | return EMPTY 24 | end 25 | 26 | ---@param value any 27 | function Optional.of(value) 28 | return Optional.new(value) 29 | end 30 | 31 | ---@param mapper_fn fun(value: any): any 32 | function Optional:map(mapper_fn) 33 | if self:is_present() then 34 | return Optional.of_nilable(mapper_fn(self._value)) 35 | else 36 | return EMPTY 37 | end 38 | end 39 | 40 | function Optional:get() 41 | if not self:is_present() then 42 | error("No value present.", 2) 43 | end 44 | return self._value 45 | end 46 | 47 | ---@param value any 48 | function Optional:or_else(value) 49 | if self:is_present() then 50 | return self._value 51 | else 52 | return value 53 | end 54 | end 55 | 56 | ---@param supplier fun(): any 57 | function Optional:or_else_get(supplier) 58 | if self:is_present() then 59 | return self._value 60 | else 61 | return supplier() 62 | end 63 | end 64 | 65 | ---@param supplier fun(): Optional 66 | ---@return Optional 67 | function Optional:or_(supplier) 68 | if self:is_present() then 69 | return self 70 | else 71 | return supplier() 72 | end 73 | end 74 | 75 | ---@param exception any @(optional) The exception to throw if the result is a failure. 76 | function Optional:or_else_throw(exception) 77 | if self:is_present() then 78 | return self._value 79 | else 80 | if exception then 81 | error(exception, 2) 82 | else 83 | error("No value present.", 2) 84 | end 85 | end 86 | end 87 | 88 | ---@param fn fun(value: any) 89 | function Optional:if_present(fn) 90 | if self:is_present() then 91 | fn(self._value) 92 | end 93 | return self 94 | end 95 | 96 | function Optional:is_present() 97 | return self._value ~= nil 98 | end 99 | 100 | return Optional 101 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/zk/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local platform = require "nvim-lsp-installer.core.platform" 3 | local functional = require "nvim-lsp-installer.core.functional" 4 | local process = require "nvim-lsp-installer.core.process" 5 | local github = require "nvim-lsp-installer.core.managers.github" 6 | 7 | local coalesce, when = functional.coalesce, functional.when 8 | return function(name, root_dir) 9 | return server.Server:new { 10 | name = name, 11 | root_dir = root_dir, 12 | homepage = "https://github.com/mickael-menu/zk", 13 | languages = { "markdown" }, 14 | installer = function() 15 | local repo = "mickael-menu/zk" 16 | platform.when { 17 | mac = function() 18 | github.unzip_release_file({ 19 | repo = repo, 20 | asset_file = coalesce( 21 | when(platform.arch == "arm64", function(version) 22 | return ("zk-%s-macos-arm64.zip"):format(version) 23 | end), 24 | when(platform.arch == "x64", function(version) 25 | return ("zk-%s-macos-x86_64.zip"):format(version) 26 | end) 27 | ), 28 | }):with_receipt() 29 | end, 30 | linux = function() 31 | github.untargz_release_file({ 32 | repo = repo, 33 | asset_file = coalesce( 34 | when(platform.arch == "arm64", function(version) 35 | return ("zk-%s-linux-arm64.tar.gz"):format(version) 36 | end), 37 | when(platform.arch == "x64", function(version) 38 | return ("zk-%s-linux-amd64.tar.gz"):format(version) 39 | end), 40 | when(platform.arch == "x86", function(version) 41 | return ("zk-%s-linux-i386.tar.gz"):format(version) 42 | end) 43 | ), 44 | }).with_receipt() 45 | end, 46 | } 47 | end, 48 | default_options = { 49 | cmd_env = { 50 | PATH = process.extend_path { root_dir }, 51 | }, 52 | }, 53 | } 54 | end 55 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/sumneko_lua/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local path = require "nvim-lsp-installer.core.path" 3 | local platform = require "nvim-lsp-installer.core.platform" 4 | local functional = require "nvim-lsp-installer.core.functional" 5 | local process = require "nvim-lsp-installer.core.process" 6 | local github = require "nvim-lsp-installer.core.managers.github" 7 | 8 | local coalesce, when = functional.coalesce, functional.when 9 | 10 | return function(name, root_dir) 11 | return server.Server:new { 12 | name = name, 13 | root_dir = root_dir, 14 | languages = { "lua" }, 15 | homepage = "https://github.com/sumneko/lua-language-server", 16 | installer = function() 17 | github.unzip_release_file({ 18 | repo = "sumneko/vscode-lua", 19 | asset_file = function(version) 20 | local target = coalesce( 21 | when( 22 | platform.is_mac, 23 | coalesce( 24 | when(platform.arch == "x64", "vscode-lua-%s-darwin-x64.vsix"), 25 | when(platform.arch == "arm64", "vscode-lua-%s-darwin-arm64.vsix") 26 | ) 27 | ), 28 | when( 29 | platform.is_linux, 30 | coalesce( 31 | when(platform.arch == "x64", "vscode-lua-%s-linux-x64.vsix"), 32 | when(platform.arch == "arm64", "vscode-lua-%s-linux-arm64.vsix") 33 | ) 34 | ), 35 | when( 36 | platform.is_win, 37 | coalesce( 38 | when(platform.arch == "x64", "vscode-lua-%s-win32-x64.vsix"), 39 | when(platform.arch == "x86", "vscode-lua-%s-win32-ia32.vsix") 40 | ) 41 | ) 42 | ) 43 | 44 | return target and target:format(version) 45 | end, 46 | }).with_receipt() 47 | end, 48 | default_options = { 49 | cmd_env = { 50 | PATH = process.extend_path { 51 | path.concat { root_dir, "extension", "server", "bin" }, 52 | }, 53 | }, 54 | }, 55 | } 56 | end 57 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/hls/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local platform = require "nvim-lsp-installer.core.platform" 3 | local process = require "nvim-lsp-installer.core.process" 4 | local std = require "nvim-lsp-installer.core.managers.std" 5 | local github_client = require "nvim-lsp-installer.core.managers.github.client" 6 | local path = require "nvim-lsp-installer.core.path" 7 | 8 | return function(name, root_dir) 9 | return server.Server:new { 10 | name = name, 11 | root_dir = root_dir, 12 | homepage = "https://haskell-language-server.readthedocs.io/en/latest/", 13 | languages = { "haskell" }, 14 | ---@param ctx InstallContext 15 | installer = function(ctx) 16 | local repo = "haskell/haskell-language-server" 17 | local release = ctx.requested_version:or_else_get(function() 18 | return github_client.fetch_latest_release(repo) 19 | :map( 20 | ---@param release GitHubRelease 21 | function(release) 22 | return release.tag_name 23 | end 24 | ) 25 | :get_or_throw() 26 | end) 27 | 28 | std.ensure_executable("ghcup", { help_url = "https://www.haskell.org/ghcup/" }) 29 | ctx:promote_cwd() 30 | ctx.spawn.ghcup { "install", "hls", release, "-i", ctx.cwd:get() } 31 | 32 | ctx.receipt:with_primary_source(ctx.receipt.github_release(repo, release)) 33 | end, 34 | default_options = { 35 | lspinfo = function(cfg) 36 | local extra = {} 37 | local function on_stdout(_, data, _) 38 | local version = data[1] 39 | table.insert(extra, "version: " .. version) 40 | end 41 | 42 | local opts = { 43 | cwd = cfg.cwd, 44 | stdout_buffered = true, 45 | on_stdout = on_stdout, 46 | } 47 | local chanid = vim.fn.jobstart({ path.concat { root_dir, "bin", cfg.cmd[1] }, "--version" }, opts) 48 | vim.fn.jobwait { chanid } 49 | return extra 50 | end, 51 | cmd_env = { 52 | PATH = process.extend_path { 53 | platform.is_win and root_dir or path.concat { root_dir, "bin" }, 54 | }, 55 | }, 56 | }, 57 | } 58 | end 59 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/servers/arduino_language_server/init.lua: -------------------------------------------------------------------------------- 1 | local server = require "nvim-lsp-installer.server" 2 | local platform = require "nvim-lsp-installer.core.platform" 3 | local functional = require "nvim-lsp-installer.core.functional" 4 | local github = require "nvim-lsp-installer.core.managers.github" 5 | local process = require "nvim-lsp-installer.core.process" 6 | 7 | local coalesce, when = functional.coalesce, functional.when 8 | 9 | return function(name, root_dir) 10 | return server.Server:new { 11 | name = name, 12 | root_dir = root_dir, 13 | homepage = "https://github.com/arduino/arduino-language-server", 14 | languages = { "arduino" }, 15 | installer = function() 16 | local opts = { 17 | repo = "arduino/arduino-language-server", 18 | asset_file = function(release) 19 | local target = coalesce( 20 | when(platform.is_mac, "arduino-language-server_%s_macOS_64bit.tar.gz"), 21 | when( 22 | platform.is_linux and platform.arch == "x64", 23 | "arduino-language-server_%s_Linux_64bit.tar.gz" 24 | ), 25 | when( 26 | platform.is_linux and platform.arch == "x86", 27 | "arduino-language-server_%s_Linux_32bit.tar.gz" 28 | ), 29 | when( 30 | platform.is_linux and platform.arch == "arm64", 31 | "arduino-language-server_%s_Linux_ARM64.tar.gz" 32 | ), 33 | when(platform.is_win and platform.arch == "x64", "arduino-language-server_%s_Windows_64bit.zip"), 34 | when(platform.is_win and platform.arch == "x86", "arduino-language-server_%s_Windows_32bit.zip") 35 | ) 36 | 37 | return target and target:format(release) 38 | end, 39 | } 40 | 41 | platform.when { 42 | unix = function() 43 | github.untargz_release_file(opts).with_receipt() 44 | end, 45 | win = function() 46 | github.unzip_release_file(opts).with_receipt() 47 | end, 48 | } 49 | end, 50 | default_options = { 51 | cmd_env = { 52 | PATH = process.extend_path { root_dir }, 53 | }, 54 | }, 55 | } 56 | end 57 | -------------------------------------------------------------------------------- /lua/nvim-lsp-installer/core/functional/function.lua: -------------------------------------------------------------------------------- 1 | local data = require "nvim-lsp-installer.core.functional.data" 2 | 3 | local _ = {} 4 | 5 | ---@generic T : fun(...) 6 | ---@param fn T 7 | ---@param arity integer 8 | ---@return T 9 | _.curryN = function(fn, arity) 10 | return function(...) 11 | local args = data.table_pack(...) 12 | if args.n >= arity then 13 | return fn(unpack(args, 1, arity)) 14 | else 15 | return _.curryN(_.partial(fn, unpack(args, 1, args.n)), arity - args.n) 16 | end 17 | end 18 | end 19 | 20 | _.compose = function(...) 21 | local functions = data.table_pack(...) 22 | assert(functions.n > 0, "compose requires at least one function") 23 | return function(...) 24 | local result = data.table_pack(...) 25 | for i = functions.n, 1, -1 do 26 | result = data.table_pack(functions[i](unpack(result, 1, result.n))) 27 | end 28 | return unpack(result, 1, result.n) 29 | end 30 | end 31 | 32 | ---@generic T 33 | ---@param fn fun(...): T 34 | ---@return fun(...): T 35 | _.partial = function(fn, ...) 36 | local bound_args = data.table_pack(...) 37 | return function(...) 38 | local args = data.table_pack(...) 39 | local merged_args = {} 40 | for i = 1, bound_args.n do 41 | merged_args[i] = bound_args[i] 42 | end 43 | for i = 1, args.n do 44 | merged_args[bound_args.n + i] = args[i] 45 | end 46 | return fn(unpack(merged_args, 1, bound_args.n + args.n)) 47 | end 48 | end 49 | 50 | _.identity = function(a) 51 | return a 52 | end 53 | 54 | _.always = function(a) 55 | return function() 56 | return a 57 | end 58 | end 59 | 60 | _.T = _.always(true) 61 | _.F = _.always(false) 62 | 63 | ---@generic T : fun(...) 64 | ---@param fn T 65 | ---@param cache_key_generator (fun(...): string | nil)|nil 66 | ---@return T 67 | _.memoize = function(fn, cache_key_generator) 68 | cache_key_generator = cache_key_generator or _.identity 69 | local cache = {} 70 | return function(...) 71 | local key = cache_key_generator(...) 72 | if not cache[key] then 73 | cache[key] = data.table_pack(fn(...)) 74 | end 75 | return unpack(cache[key], 1, cache[key].n) 76 | end 77 | end 78 | 79 | ---@generic T 80 | ---@param fn fun(): T 81 | ---@return fun(): T 82 | _.lazy = function(fn) 83 | local memoized = _.memoize(fn, _.always "lazyval") 84 | return function() 85 | return memoized() 86 | end 87 | end 88 | 89 | return _ 90 | --------------------------------------------------------------------------------