aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-07-20 00:00:55 +0200
committerGitHub <noreply@github.com>2022-07-19 22:00:55 +0000
commit619e52abec0175620a6b8af4e18ed4cfb4857825 (patch)
tree31c662409a88cd9e35b372f90e07136cfa586a29 /lua
parentchore: update generated code (#99) (diff)
downloadmason-619e52abec0175620a6b8af4e18ed4cfb4857825.tar
mason-619e52abec0175620a6b8af4e18ed4cfb4857825.tar.gz
mason-619e52abec0175620a6b8af4e18ed4cfb4857825.tar.bz2
mason-619e52abec0175620a6b8af4e18ed4cfb4857825.tar.lz
mason-619e52abec0175620a6b8af4e18ed4cfb4857825.tar.xz
mason-619e52abec0175620a6b8af4e18ed4cfb4857825.tar.zst
mason-619e52abec0175620a6b8af4e18ed4cfb4857825.zip
fix(mason-lspconfig): patch some server's cmd on Windows (#100)
Diffstat (limited to 'lua')
-rw-r--r--lua/mason-core/EventEmitter.lua2
-rw-r--r--lua/mason-lspconfig/init.lua13
-rw-r--r--lua/mason-lspconfig/mappings/filetype.lua10
-rw-r--r--lua/mason-lspconfig/mappings/server.lua3
-rw-r--r--lua/mason-lspconfig/server_configurations/kotlin_language_server/init.lua5
-rw-r--r--lua/mason-lspconfig/server_configurations/ltex/init.lua5
-rw-r--r--lua/mason-lspconfig/server_configurations/psalm/init.lua5
-rw-r--r--lua/mason-lspconfig/win-exepath-compat.lua81
-rw-r--r--lua/mason-registry/init.lua2
9 files changed, 116 insertions, 10 deletions
diff --git a/lua/mason-core/EventEmitter.lua b/lua/mason-core/EventEmitter.lua
index 672c1778..ad739cfb 100644
--- a/lua/mason-core/EventEmitter.lua
+++ b/lua/mason-core/EventEmitter.lua
@@ -38,7 +38,7 @@ function EventEmitter:on(event, handler)
end
---@param event any
----@parma handler fun(payload: any)
+---@param handler fun(payload: any)
function EventEmitter:once(event, handler)
if not self.__event_handlers_once[event] then
self.__event_handlers_once[event] = {}
diff --git a/lua/mason-lspconfig/init.lua b/lua/mason-lspconfig/init.lua
index 659825ad..fcc9b5cc 100644
--- a/lua/mason-lspconfig/init.lua
+++ b/lua/mason-lspconfig/init.lua
@@ -7,6 +7,7 @@ local server_mapping = require "mason-lspconfig.mappings.server"
local path = require "mason-core.path"
local registry = require "mason-registry"
local notify = require "mason-core.notify"
+local platform = require "mason-core.platform"
local M = {}
@@ -61,6 +62,8 @@ end
local function setup_lspconfig_hook()
local util = require "lspconfig.util"
+ local win_exepath_compat = platform.is.win and require "mason-lspconfig.win-exepath-compat"
+
util.on_setup = util.add_hook_before(util.on_setup, function(config)
local pkg_name = server_mapping.lspconfig_to_package[config.name]
if not pkg_name then
@@ -69,7 +72,15 @@ local function setup_lspconfig_hook()
if registry.is_installed(pkg_name) then
resolve_server_config_factory(config.name):if_present(function(config_factory)
- merge_in_place(config, config_factory(path.package_prefix(pkg_name)))
+ merge_in_place(config, config_factory({ install_dir = path.package_prefix(pkg_name) }, config))
+ if win_exepath_compat and win_exepath_compat[config.name] and config.cmd and config.cmd[1] then
+ local exepath = vim.fn.exepath(config.cmd[1])
+ if exepath ~= "" then
+ config.cmd[1] = exepath
+ else
+ log.error("Failed to expand cmd path", config.name, config.cmd)
+ end
+ end
end)
else
if should_auto_install(config.name) then
diff --git a/lua/mason-lspconfig/mappings/filetype.lua b/lua/mason-lspconfig/mappings/filetype.lua
index 577bfe86..fc84277b 100644
--- a/lua/mason-lspconfig/mappings/filetype.lua
+++ b/lua/mason-lspconfig/mappings/filetype.lua
@@ -15,13 +15,13 @@ return {
bicep = { "bicep" },
blade = { "tailwindcss" },
bsl = { "bsl_ls" },
- c = { "ccls", "clangd" },
+ c = { "clangd" },
clar = { "clarity_lsp" },
clarity = { "clarity_lsp" },
clojure = { "clojure_lsp" },
cmake = { "cmake" },
- cpp = { "ccls", "clangd" },
- crystal = { "crystalline", "scry" },
+ cpp = { "clangd" },
+ crystal = { "crystalline" },
cs = { "csharp_ls", "omnisharp" },
css = { "cssls", "emmet_ls", "stylelint_lsp", "tailwindcss" },
cucumber = { "cucumber_language_server" },
@@ -91,8 +91,8 @@ return {
nix = { "rnix" },
njk = { "tailwindcss" },
nunjucks = { "tailwindcss" },
- objc = { "ccls", "clangd" },
- objcpp = { "ccls", "clangd" },
+ objc = { "clangd" },
+ objcpp = { "clangd" },
ocaml = { "ocamllsp" },
["ocaml.interface"] = { "ocamllsp" },
["ocaml.menhir"] = { "ocamllsp" },
diff --git a/lua/mason-lspconfig/mappings/server.lua b/lua/mason-lspconfig/mappings/server.lua
index 582963f4..f8d389e0 100644
--- a/lua/mason-lspconfig/mappings/server.lua
+++ b/lua/mason-lspconfig/mappings/server.lua
@@ -3,7 +3,6 @@ local _ = require "mason-core.functional"
local M = {}
---Maps lspconfig server config name to its corresponding package name.
--- TODO go through these.. fun times
M.lspconfig_to_package = {
["angularls"] = "angular-language-server",
["ansiblels"] = "ansible-language-server",
@@ -16,7 +15,6 @@ M.lspconfig_to_package = {
["beancount"] = "beancount-language-server",
["bicep"] = "bicep-lsp",
["bsl_ls"] = "bsl-language-server",
- ["ccls"] = "ccls",
["clangd"] = "clangd",
["clarity_lsp"] = "clarity-lsp",
["clojure_lsp"] = "clojure-lsp",
@@ -90,7 +88,6 @@ M.lspconfig_to_package = {
["rome"] = "rome",
["rust_analyzer"] = "rust-analyzer",
["salt_ls"] = "salt-lsp",
- ["scry"] = "scry",
["serve_d"] = "serve-d",
["slint_lsp"] = "slint-lsp",
["solang"] = "solang",
diff --git a/lua/mason-lspconfig/server_configurations/kotlin_language_server/init.lua b/lua/mason-lspconfig/server_configurations/kotlin_language_server/init.lua
new file mode 100644
index 00000000..585797fc
--- /dev/null
+++ b/lua/mason-lspconfig/server_configurations/kotlin_language_server/init.lua
@@ -0,0 +1,5 @@
+return function()
+ return {
+ cmd = { "kotlin-language-server" },
+ }
+end
diff --git a/lua/mason-lspconfig/server_configurations/ltex/init.lua b/lua/mason-lspconfig/server_configurations/ltex/init.lua
new file mode 100644
index 00000000..f24d86f7
--- /dev/null
+++ b/lua/mason-lspconfig/server_configurations/ltex/init.lua
@@ -0,0 +1,5 @@
+return function()
+ return {
+ cmd = { "ltex-ls" },
+ }
+end
diff --git a/lua/mason-lspconfig/server_configurations/psalm/init.lua b/lua/mason-lspconfig/server_configurations/psalm/init.lua
new file mode 100644
index 00000000..8dd3645a
--- /dev/null
+++ b/lua/mason-lspconfig/server_configurations/psalm/init.lua
@@ -0,0 +1,5 @@
+return function()
+ return {
+ cmd = { "psalm-language-server" },
+ }
+end
diff --git a/lua/mason-lspconfig/win-exepath-compat.lua b/lua/mason-lspconfig/win-exepath-compat.lua
new file mode 100644
index 00000000..c8743d62
--- /dev/null
+++ b/lua/mason-lspconfig/win-exepath-compat.lua
@@ -0,0 +1,81 @@
+---On Windows, Mason will link executables as .cmd wrapper scripts in Mason's bin/ directory.
+---Some utilities, libuv in particular (which neovim's RPC client, among others, uses), have problems finding .cmd
+---executables in PATH.
+---The following is a table of lspconfig servers whose cmd will need to be expanded with |exepath()| in order to be
+---successfully located and started with lspconfig.
+return {
+ ["angularls"] = true,
+ ["arduino_language_server"] = true,
+ ["asm_lsp"] = true,
+ ["beancount"] = true,
+ ["bicep"] = true,
+ ["bsl_ls"] = true,
+ ["ccls"] = true,
+ ["clangd"] = true,
+ ["clarity_lsp"] = true,
+ ["clojure_lsp"] = true,
+ ["cmake"] = true,
+ ["codeqlls"] = true,
+ ["crystalline"] = true,
+ ["csharp_ls"] = true,
+ ["cssls"] = true,
+ ["denols"] = true,
+ ["dhall_lsp_server"] = true,
+ ["efm"] = true,
+ ["elixirls"] = true,
+ ["esbonio"] = true,
+ ["flux_lsp"] = true,
+ ["fortls"] = true,
+ ["fsautocomplete"] = true,
+ ["golangci_lint_ls"] = true,
+ ["gopls"] = true,
+ ["groovyls"] = true,
+ ["haxe_language_server"] = true,
+ ["hls"] = true,
+ ["jdtls"] = true,
+ ["jedi_language_server"] = true,
+ ["jsonnet_ls"] = true,
+ ["kotlin_language_server"] = true,
+ ["lelwel_ls"] = true,
+ ["lemminx"] = true,
+ ["ltex"] = true,
+ ["mm0_ls"] = true,
+ ["nickel_ls"] = true,
+ ["nimls"] = true,
+ ["ocamllsp"] = true,
+ ["perlnavigator"] = true,
+ ["phpactor"] = true,
+ ["prosemd_lsp"] = true,
+ ["psalm"] = true,
+ ["puppet"] = true,
+ ["pylsp"] = true,
+ ["quick_lint_js"] = true,
+ ["reason_ls"] = true,
+ ["rescriptls"] = true,
+ ["rnix"] = true,
+ ["robotframework_ls"] = true,
+ ["rust_analyzer"] = true,
+ ["salt_ls"] = true,
+ ["scry"] = true,
+ ["serve_d"] = true,
+ ["slint_lsp"] = true,
+ ["solang"] = true,
+ ["sorbet"] = true,
+ ["sourcery"] = true,
+ ["sqlls"] = true,
+ ["sqls"] = true,
+ ["sumneko_lua"] = true,
+ ["svls"] = true,
+ ["taplo"] = true,
+ ["teal_ls"] = true,
+ ["terraformls"] = true,
+ ["texlab"] = true,
+ ["tflint"] = true,
+ ["theme_check"] = true,
+ ["vala_ls"] = true,
+ ["verible"] = true,
+ ["visualforce_ls"] = true,
+ ["vls"] = true,
+ ["zk"] = true,
+ ["zls"] = true,
+}
diff --git a/lua/mason-registry/init.lua b/lua/mason-registry/init.lua
index ed56512c..20b8a311 100644
--- a/lua/mason-registry/init.lua
+++ b/lua/mason-registry/init.lua
@@ -7,6 +7,8 @@ local EventEmitter = require "mason-core.EventEmitter"
local index = require "mason-registry.index"
+---@class MasonRegistry : EventEmitter
+---@diagnostic disable-next-line: assign-type-mismatch
local M = setmetatable({}, { __index = EventEmitter })
EventEmitter.init(M)