aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2025-04-28 01:03:45 +0200
committerWilliam Boman <william@redwill.se>2025-04-28 01:04:53 +0200
commita3f07c36b24136d4e238f58c196daf5bed5e70be (patch)
tree3f936591336dc39b3cee824a5e03757c0d773d36 /lua
parentfix: enable servers outside of registry.refresh() and vim.schedule() callbacks (diff)
downloadmason-lspconfig-a3f07c36b24136d4e238f58c196daf5bed5e70be.tar
mason-lspconfig-a3f07c36b24136d4e238f58c196daf5bed5e70be.tar.gz
mason-lspconfig-a3f07c36b24136d4e238f58c196daf5bed5e70be.tar.bz2
mason-lspconfig-a3f07c36b24136d4e238f58c196daf5bed5e70be.tar.lz
mason-lspconfig-a3f07c36b24136d4e238f58c196daf5bed5e70be.tar.xz
mason-lspconfig-a3f07c36b24136d4e238f58c196daf5bed5e70be.tar.zst
mason-lspconfig-a3f07c36b24136d4e238f58c196daf5bed5e70be.zip
chore: migrate more configs to new style
Diffstat (limited to 'lua')
-rw-r--r--lua/mason-lspconfig/lsp/astro.lua11
-rw-r--r--lua/mason-lspconfig/lsp/julials.lua39
-rw-r--r--lua/mason-lspconfig/lsp/powershell_es.lua3
-rw-r--r--lua/mason-lspconfig/lsp/pylsp.lua61
-rw-r--r--lua/mason-lspconfig/lsp/volar.lua11
-rw-r--r--lua/mason-lspconfig/server_configurations/angularls/init.lua39
-rw-r--r--lua/mason-lspconfig/server_configurations/astro/init.lua11
-rw-r--r--lua/mason-lspconfig/server_configurations/julials/init.lua42
-rw-r--r--lua/mason-lspconfig/server_configurations/powershell_es/init.lua6
-rw-r--r--lua/mason-lspconfig/server_configurations/pylsp/init.lua56
-rw-r--r--lua/mason-lspconfig/server_configurations/solang/init.lua15
-rw-r--r--lua/mason-lspconfig/server_configurations/volar/init.lua12
12 files changed, 125 insertions, 181 deletions
diff --git a/lua/mason-lspconfig/lsp/astro.lua b/lua/mason-lspconfig/lsp/astro.lua
new file mode 100644
index 0000000..6b99d85
--- /dev/null
+++ b/lua/mason-lspconfig/lsp/astro.lua
@@ -0,0 +1,11 @@
+return {
+ before_init = function(_, config)
+ -- This replaces nvim-lspconfig's before_init by also looking for typescript that is bundled with the package
+ -- via Mason
+ local typescript = require "mason-lspconfig.typescript"
+ local install_dir = vim.fn.expand "$MASON/packages/astro-language-server"
+
+ config.init_options.typescript.serverPath = typescript.resolve_tsserver(install_dir, config.root_dir)
+ config.init_options.typescript.tsdk = typescript.resolve_tsdk(install_dir, config.root_dir)
+ end,
+}
diff --git a/lua/mason-lspconfig/lsp/julials.lua b/lua/mason-lspconfig/lsp/julials.lua
new file mode 100644
index 0000000..ee2d1f0
--- /dev/null
+++ b/lua/mason-lspconfig/lsp/julials.lua
@@ -0,0 +1,39 @@
+return {
+ cmd = { "julia-lsp" },
+ before_init = function(_, config)
+ local _ = require "mason-core.functional"
+ local path = require "mason-core.path"
+ local fs = require "mason-core.fs"
+ local workspace_dir = config.root_dir
+
+ local env_path = config.julia_env_path and vim.fn.expand(config.julia_env_path)
+ if not env_path then
+ local file_exists = _.compose(fs.sync.file_exists, path.concat, _.concat { workspace_dir })
+ if
+ (file_exists { "Project.toml" } and file_exists { "Manifest.toml" })
+ or (file_exists { "JuliaProject.toml" } and file_exists { "JuliaManifest.toml" })
+ then
+ env_path = workspace_dir
+ end
+ end
+
+ if not env_path then
+ local ok, env = pcall(vim.fn.system, {
+ "julia",
+ "--startup-file=no",
+ "--history-file=no",
+ "-e",
+ "using Pkg; print(dirname(Pkg.Types.Context().env.project_file))",
+ })
+ if ok then
+ env_path = env
+ end
+ end
+
+ config.cmd = { "julia-lsp", env_path }
+ config.cmd_env = vim.tbl_extend("keep", config.cmd_env or {}, {
+ SYMBOL_SERVER = config.symbol_server,
+ SYMBOL_CACHE_DOWNLOAD = (config.symbol_cache_download == false) and "0" or "1",
+ })
+ end,
+}
diff --git a/lua/mason-lspconfig/lsp/powershell_es.lua b/lua/mason-lspconfig/lsp/powershell_es.lua
new file mode 100644
index 0000000..82c5a72
--- /dev/null
+++ b/lua/mason-lspconfig/lsp/powershell_es.lua
@@ -0,0 +1,3 @@
+return {
+ bundle_path = vim.fn.expand "$MASON/packages/powershell-editor-services",
+}
diff --git a/lua/mason-lspconfig/lsp/pylsp.lua b/lua/mason-lspconfig/lsp/pylsp.lua
new file mode 100644
index 0000000..556e75e
--- /dev/null
+++ b/lua/mason-lspconfig/lsp/pylsp.lua
@@ -0,0 +1,61 @@
+local pylsp = vim.lsp.config.pylsp
+local old_before_init = pylsp and pylsp.before_init
+
+return {
+ before_init = function(init, config)
+ local a = require "mason-core.async"
+ local _ = require "mason-core.functional"
+
+ vim.api.nvim_create_user_command(
+ "PylspInstall",
+ a.scope(function(opts)
+ local notify = require "mason-lspconfig.notify"
+ local pypi = require "mason-core.installer.managers.pypi"
+ local process = require "mason-core.process"
+ local spawn = require "mason-core.spawn"
+
+ local plugins = opts.fargs
+ local plugins_str = table.concat(plugins, ", ")
+ notify(("Installing %s..."):format(plugins_str))
+ local result = spawn.pip {
+ "install",
+ "-U",
+ "--disable-pip-version-check",
+ plugins,
+ stdio_sink = process.StdioSink:new {
+ stdout = vim.schedule_wrap(vim.api.nvim_out_write),
+ stderr = vim.schedule_wrap(vim.api.nvim_err_write),
+ },
+ with_paths = { pypi.venv_path(vim.fn.expand "$MASON/packages/python-lsp-server") },
+ }
+ if vim.in_fast_event() then
+ a.scheduler()
+ end
+ result
+ :on_success(function()
+ notify(("Successfully installed pylsp plugins %s"):format(plugins_str))
+ end)
+ :on_failure(function()
+ notify("Failed to install requested pylsp plugins.", vim.log.levels.ERROR)
+ end)
+ end),
+ {
+ desc = "[mason-lspconfig.nvim] Installs the provided packages in the same venv as pylsp.",
+ nargs = "+",
+ complete = _.always {
+ "pyls-flake8",
+ "pyls-isort",
+ "pyls-memestra",
+ "pyls-spyder",
+ "pylsp-mypy",
+ "pylsp-rope",
+ "python-lsp-black",
+ "python-lsp-ruff",
+ },
+ }
+ )
+ if old_before_init then
+ old_before_init(init, config)
+ end
+ end,
+}
diff --git a/lua/mason-lspconfig/lsp/volar.lua b/lua/mason-lspconfig/lsp/volar.lua
new file mode 100644
index 0000000..eb21dc6
--- /dev/null
+++ b/lua/mason-lspconfig/lsp/volar.lua
@@ -0,0 +1,11 @@
+return {
+ before_init = function(_, config)
+ -- This replaces nvim-lspconfig's before_init by also looking for typescript that is bundled with the package
+ -- via Mason
+ local typescript = require "mason-lspconfig.typescript"
+ local install_dir = vim.fn.expand "$MASON/packages/vue-language-server"
+
+ config.init_options.typescript.serverPath = typescript.resolve_tsserver(install_dir, config.root_dir)
+ config.init_options.typescript.tsdk = typescript.resolve_tsdk(install_dir, config.root_dir)
+ end,
+}
diff --git a/lua/mason-lspconfig/server_configurations/angularls/init.lua b/lua/mason-lspconfig/server_configurations/angularls/init.lua
deleted file mode 100644
index 6316dd0..0000000
--- a/lua/mason-lspconfig/server_configurations/angularls/init.lua
+++ /dev/null
@@ -1,39 +0,0 @@
-local _ = require "mason-core.functional"
-local path = require "mason-core.path"
-local platform = require "mason-core.platform"
-
----@param install_dir string
-return function(install_dir)
- local append_node_modules = _.map(function(dir)
- return path.concat { dir, "node_modules" }
- end)
-
- local function get_cmd(workspace_dir)
- local cmd = {
- "ngserver",
- "--stdio",
- "--tsProbeLocations",
- table.concat(append_node_modules { install_dir, workspace_dir }, ","),
- "--ngProbeLocations",
- table.concat(
- append_node_modules {
- path.concat { install_dir, "node_modules", "@angular", "language-server" },
- workspace_dir,
- },
- ","
- ),
- }
- if platform.is.win then
- cmd[1] = vim.fn.exepath(cmd[1])
- end
-
- return cmd
- end
-
- return {
- cmd = get_cmd(vim.loop.cwd()),
- on_new_config = function(new_config, root_dir)
- new_config.cmd = get_cmd(root_dir)
- end,
- }
-end
diff --git a/lua/mason-lspconfig/server_configurations/astro/init.lua b/lua/mason-lspconfig/server_configurations/astro/init.lua
deleted file mode 100644
index 3ef9cff..0000000
--- a/lua/mason-lspconfig/server_configurations/astro/init.lua
+++ /dev/null
@@ -1,11 +0,0 @@
----@param install_dir string
-return function(install_dir)
- return {
- on_new_config = function(new_config, workspace_dir)
- local typescript = require "mason-lspconfig.typescript"
-
- new_config.init_options.typescript.serverPath = typescript.resolve_tsserver(install_dir, workspace_dir)
- new_config.init_options.typescript.tsdk = typescript.resolve_tsdk(install_dir, workspace_dir)
- end,
- }
-end
diff --git a/lua/mason-lspconfig/server_configurations/julials/init.lua b/lua/mason-lspconfig/server_configurations/julials/init.lua
deleted file mode 100644
index 5a48413..0000000
--- a/lua/mason-lspconfig/server_configurations/julials/init.lua
+++ /dev/null
@@ -1,42 +0,0 @@
-local _ = require "mason-core.functional"
-local fs = require "mason-core.fs"
-local path = require "mason-core.path"
-
-return function()
- return {
- on_new_config = function(config, workspace_dir)
- local env_path = config.julia_env_path and vim.fn.expand(config.julia_env_path)
- if not env_path then
- local file_exists = _.compose(fs.sync.file_exists, path.concat, _.concat { workspace_dir })
- if
- (file_exists { "Project.toml" } and file_exists { "Manifest.toml" })
- or (file_exists { "JuliaProject.toml" } and file_exists { "JuliaManifest.toml" })
- then
- env_path = workspace_dir
- end
- end
-
- if not env_path then
- local ok, env = pcall(vim.fn.system, {
- "julia",
- "--startup-file=no",
- "--history-file=no",
- "-e",
- "using Pkg; print(dirname(Pkg.Types.Context().env.project_file))",
- })
- if ok then
- env_path = env
- end
- end
-
- config.cmd = {
- vim.fn.exepath "julia-lsp",
- env_path,
- }
- config.cmd_env = vim.tbl_extend("keep", config.cmd_env or {}, {
- SYMBOL_SERVER = config.symbol_server,
- SYMBOL_CACHE_DOWNLOAD = (config.symbol_cache_download == false) and "0" or "1",
- })
- end,
- }
-end
diff --git a/lua/mason-lspconfig/server_configurations/powershell_es/init.lua b/lua/mason-lspconfig/server_configurations/powershell_es/init.lua
deleted file mode 100644
index d36a580..0000000
--- a/lua/mason-lspconfig/server_configurations/powershell_es/init.lua
+++ /dev/null
@@ -1,6 +0,0 @@
----@param install_dir string
-return function(install_dir)
- return {
- bundle_path = install_dir,
- }
-end
diff --git a/lua/mason-lspconfig/server_configurations/pylsp/init.lua b/lua/mason-lspconfig/server_configurations/pylsp/init.lua
deleted file mode 100644
index 8a683ec..0000000
--- a/lua/mason-lspconfig/server_configurations/pylsp/init.lua
+++ /dev/null
@@ -1,56 +0,0 @@
-local _ = require "mason-core.functional"
-local a = require "mason-core.async"
-
----@param install_dir string
-return function(install_dir)
- vim.api.nvim_create_user_command(
- "PylspInstall",
- a.scope(function(opts)
- local notify = require "mason-lspconfig.notify"
- local pypw = require "mason-core.installer.managers.pypi"
- local process = require "mason-core.process"
- local spawn = require "mason-core.spawn"
-
- local plugins = opts.fargs
- local plugins_str = table.concat(plugins, ", ")
- notify(("Installing %s..."):format(plugins_str))
- local result = spawn.pip {
- "install",
- "-U",
- "--disable-pip-version-check",
- plugins,
- stdio_sink = process.StdioSink:new {
- stdout = vim.schedule_wrap(vim.api.nvim_out_write),
- stderr = vim.schedule_wrap(vim.api.nvim_err_write),
- },
- with_paths = { pypw.venv_path(install_dir) },
- }
- if vim.in_fast_event() then
- a.scheduler()
- end
- result
- :on_success(function()
- notify(("Successfully installed pylsp plugins %s"):format(plugins_str))
- end)
- :on_failure(function()
- notify("Failed to install requested pylsp plugins.", vim.log.levels.ERROR)
- end)
- end),
- {
- desc = "[mason-lspconfig.nvim] Installs the provided packages in the same venv as pylsp.",
- nargs = "+",
- complete = _.always {
- "pyls-flake8",
- "pyls-isort",
- "pyls-memestra",
- "pyls-spyder",
- "pylsp-mypy",
- "pylsp-rope",
- "python-lsp-black",
- "python-lsp-ruff",
- },
- }
- )
-
- return {}
-end
diff --git a/lua/mason-lspconfig/server_configurations/solang/init.lua b/lua/mason-lspconfig/server_configurations/solang/init.lua
deleted file mode 100644
index 6dcc7a1..0000000
--- a/lua/mason-lspconfig/server_configurations/solang/init.lua
+++ /dev/null
@@ -1,15 +0,0 @@
-local path = require "mason-core.path"
-local process = require "mason-core.process"
-
----@param install_dir string
-return function(install_dir)
- local llvm_bins = { vim.fn.expand(path.concat { install_dir, "llvm*", "bin" }, true, true)[1] }
- if vim.env.MASON then
- table.insert(llvm_bins, vim.fn.expand "$MASON/opt/solang/llvm15.0/bin")
- end
- return {
- cmd_env = {
- PATH = process.extend_path(llvm_bins),
- },
- }
-end
diff --git a/lua/mason-lspconfig/server_configurations/volar/init.lua b/lua/mason-lspconfig/server_configurations/volar/init.lua
deleted file mode 100644
index 21148dd..0000000
--- a/lua/mason-lspconfig/server_configurations/volar/init.lua
+++ /dev/null
@@ -1,12 +0,0 @@
----@param install_dir string
-return function(install_dir)
- return {
- on_new_config = function(new_config, workspace_dir)
- local typescript = require "mason-lspconfig.typescript"
-
- local tsdk = typescript.resolve_tsdk(install_dir, workspace_dir)
- new_config.init_options.typescript.serverPath = tsdk
- new_config.init_options.typescript.tsdk = tsdk
- end,
- }
-end