Skip to content

Commit

Permalink
nvim: add nushell language server and allow for lsps that don't have …
Browse files Browse the repository at this point in the history
…a mason installer
  • Loading branch information
chris468 committed Jul 2, 2024
1 parent 26d4edf commit 791a141
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local config = require("chris468.config")
--- @field config? (table | fun():table?)
--- @field register_server? table | fun():table?
--- @field package_name? string
--- @field install? boolean

--- @class (exact) chris468.config.lang.Config
--- @field lsp { [string]: false | chris468.config.lang.Lsp }
Expand Down Expand Up @@ -36,6 +37,12 @@ M.lsp = {
lua_ls = {},
mesonlsp = {},
nil_ls = {}, -- nix
nushell = {
install = false,
config = {
filetypes = { "nu" },
},
},
omnisharp = require("chris468.config.lang.omnisharp"),
powershell_es = {},
pyright = require("chris468.config.lang.pyright"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ return {
local mappings = require("mason-lspconfig.mappings.server").lspconfig_to_package
local tool = {
package_name = lsp.package_name or mappings[server] or server,
install = lsp.install,
on_complete = register_lsp(opts.capabilities),
data = {
name = server,
Expand Down
23 changes: 11 additions & 12 deletions dotfiles/private_dot_config/nvim/lua/chris468/util/mason.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ local M = {}

--- @class (exact) chris468.util.mason.Tool
--- @field package_name string
--- @field install boolean?
--- @field on_complete fun(tool: chris468.util.mason.Tool)?
--- @field data any?
--- @field data any?

--- @alias chris468.util.mason.ToolsForFiletype { [string]: (string|chris468.util.mason.Tool)[] }

Expand Down Expand Up @@ -35,19 +36,17 @@ function M.install_tools(tools)
tool = { package_name = tool }
end
local on_complete = tool.on_complete or noop
if registry.is_installed(tool.package_name) then
if tool.install == false or registry.is_installed(tool.package_name) then
on_complete(tool)
return
end

local pkg = registry.get_package(tool.package_name)
if not pkg then
vim.notify("Package " .. tool .. " not found", vim.log.levels.ERROR)
on_complete(tool)
return
else
local pkg = registry.get_package(tool.package_name)
if pkg then
install_tool(pkg, on_complete, tool)
else
vim.notify("Package " .. tool .. " not found", vim.log.levels.ERROR)
on_complete(tool)
end
end

install_tool(pkg, on_complete, tool)
end
end

Expand Down

0 comments on commit 791a141

Please sign in to comment.