114 lines
3.1 KiB
Lua
114 lines
3.1 KiB
Lua
-- Automatically install LSPs and related tools to stdpath for neovim
|
|
return {
|
|
"williamboman/mason.nvim",
|
|
dependencies = {
|
|
"neovim/nvim-lspconfig",
|
|
"williamboman/mason-lspconfig.nvim",
|
|
},
|
|
config = function()
|
|
local servers = {
|
|
harper_ls = {
|
|
settings = {
|
|
["harper-ls"] = {
|
|
userDictPath = vim.fn.stdpath("config") .. "/spell/en.utf-8.add",
|
|
},
|
|
},
|
|
},
|
|
marksman = {},
|
|
vtsls = {
|
|
settings = {
|
|
complete_function_calls = true,
|
|
vtsls = {
|
|
enableMoveToFileCodeAction = true,
|
|
autoUseWorkspaceTsdk = true,
|
|
experimental = {
|
|
completion = {
|
|
enableServerSideFuzzyMatch = true,
|
|
},
|
|
},
|
|
},
|
|
javascript = {
|
|
updateImportsOnFileMove = { enabled = "always" },
|
|
suggest = {
|
|
completeFunctionCalls = true,
|
|
},
|
|
inlayHints = {
|
|
enumMemberValues = { enabled = true },
|
|
functionLikeReturnTypes = { enabled = true },
|
|
parameterNames = { enabled = "literals" },
|
|
parameterTypes = { enabled = true },
|
|
propertyDeclarationTypes = { enabled = true },
|
|
variableTypes = { enabled = false },
|
|
},
|
|
},
|
|
typescript = {
|
|
updateImportsOnFileMove = { enabled = "always" },
|
|
suggest = {
|
|
completeFunctionCalls = true,
|
|
},
|
|
inlayHints = {
|
|
enumMemberValues = { enabled = true },
|
|
functionLikeReturnTypes = { enabled = true },
|
|
parameterNames = { enabled = "literals" },
|
|
parameterTypes = { enabled = true },
|
|
propertyDeclarationTypes = { enabled = true },
|
|
variableTypes = { enabled = false },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
lua_ls = {
|
|
settings = {
|
|
Lua = {
|
|
telemetry = { enable = false },
|
|
-- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings
|
|
diagnostics = { disable = { "missing-fields" } },
|
|
hint = { enable = true },
|
|
},
|
|
},
|
|
},
|
|
tailwindcss = {},
|
|
html = {},
|
|
cssls = {},
|
|
emmet_language_server = {},
|
|
}
|
|
|
|
-- Special formatted fields cannot be set above
|
|
-- servers.vtsls.settings["js/ts"] = { implicitProjectConfig = { checkJs = true } }
|
|
|
|
local ensure_installed = vim.tbl_keys(servers or {})
|
|
|
|
require("mason").setup()
|
|
|
|
require("mason-lspconfig").setup({
|
|
ensure_installed = ensure_installed,
|
|
automatic_installation = false,
|
|
handlers = {
|
|
function(server_name)
|
|
local server = servers[server_name] or {}
|
|
-- This handles overriding only values explicitly passed
|
|
-- by the server configuration above. Useful when disabling
|
|
-- certain features of an LSP (for example, turning off formatting for ts_ls)
|
|
server.capabilities = vim.tbl_deep_extend("force", {}, server.capabilities or {})
|
|
require("lspconfig")[server_name].setup(server)
|
|
end,
|
|
},
|
|
})
|
|
|
|
-- TODO: move to native lsp configs when
|
|
-- lspconfig plugin will be merged into core
|
|
-- for server, settings in pairs(servers) do
|
|
-- vim.lsp.config(server, settings)
|
|
-- vim.lsp.enable(server)
|
|
-- end
|
|
|
|
-- Linters
|
|
local linters = { "stylua", "biome" }
|
|
|
|
for _, linter in ipairs(linters) do
|
|
if not require("mason-registry").is_installed(linter) then
|
|
vim.cmd("MasonInstall " .. linter)
|
|
end
|
|
end
|
|
end,
|
|
}
|