161 lines
3.9 KiB
Lua
161 lines
3.9 KiB
Lua
vim.pack.add({
|
|
{
|
|
src = "https://github.com/mason-org/mason.nvim",
|
|
name = "mason.nvim",
|
|
},
|
|
{
|
|
src = "https://github.com/mason-org/mason-lspconfig.nvim",
|
|
name = "mason-lspconfig.nvim",
|
|
},
|
|
{
|
|
src = "https://github.com/neovim/nvim-lspconfig",
|
|
name = "nvim-lspconfig",
|
|
},
|
|
})
|
|
|
|
local mason_lspconfig = require("mason-lspconfig")
|
|
|
|
local function configure_diagnostics()
|
|
vim.diagnostic.config({
|
|
severity_sort = true,
|
|
signs = true,
|
|
underline = true,
|
|
update_in_insert = false,
|
|
virtual_text = true,
|
|
float = {
|
|
border = "rounded",
|
|
source = "if_many",
|
|
},
|
|
})
|
|
end
|
|
|
|
configure_diagnostics()
|
|
|
|
local capabilities = require("mini.completion").get_lsp_capabilities()
|
|
local dart = require("romanzy.custom.dart")
|
|
local managed_servers = {
|
|
"astro",
|
|
"bashls",
|
|
"basedpyright",
|
|
"clangd",
|
|
"gopls",
|
|
"jsonls",
|
|
"lua_ls",
|
|
"marksman",
|
|
"taplo",
|
|
"yamlls",
|
|
"ts_ls",
|
|
"tailwindcss",
|
|
"eslint",
|
|
"tinymist",
|
|
"ruff",
|
|
}
|
|
local managed_tools = {
|
|
"prettier",
|
|
}
|
|
local servers = {
|
|
-- General
|
|
bashls = {},
|
|
marksman = {},
|
|
yamlls = {},
|
|
jsonls = {},
|
|
taplo = {},
|
|
-- C
|
|
clangd = {},
|
|
-- Go
|
|
gopls = {},
|
|
-- Lua
|
|
lua_ls = {
|
|
settings = {
|
|
Lua = {
|
|
diagnostics = {
|
|
globals = { "vim" },
|
|
},
|
|
runtime = {
|
|
version = "LuaJIT",
|
|
},
|
|
workspace = {
|
|
checkThirdParty = false,
|
|
library = vim.api.nvim_get_runtime_file("", true),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
-- Web dev
|
|
ts_ls = {},
|
|
tailwindcss = {},
|
|
eslint = {},
|
|
astro = {},
|
|
-- Typst
|
|
tinymist = {},
|
|
-- Dart
|
|
dartls = {
|
|
root_dir = function(bufnr, on_dir)
|
|
local root = dart.root(vim.api.nvim_buf_get_name(bufnr))
|
|
if root then on_dir(root) end
|
|
end,
|
|
cmd = function(dispatchers, config)
|
|
return vim.lsp.rpc.start({
|
|
dart.executable(config.root_dir),
|
|
"language-server",
|
|
"--protocol=lsp",
|
|
}, dispatchers, {
|
|
cwd = config.root_dir,
|
|
detached = config.detached,
|
|
})
|
|
end,
|
|
},
|
|
-- Python
|
|
basedpyright = {
|
|
settings = {
|
|
basedpyright = {
|
|
analysis = {
|
|
typeCheckingMode = "strict",
|
|
diagnosticSeverityOverrides = {
|
|
reportUnannotatedClassAttribute = "none",
|
|
reportAny = "none",
|
|
reportExplicitAny = "none",
|
|
reportUnknownVariableType = "none",
|
|
reportImplicitStringConcatenation = "none",
|
|
reportUnusedCallResult = "none"
|
|
},
|
|
},
|
|
},
|
|
}
|
|
},
|
|
ruff = {
|
|
init_options = {
|
|
settings = {
|
|
lineLength = 79,
|
|
lint = {
|
|
extendSelect = { "ANN2" }, -- Missing return annotations.
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
for server_name, config in pairs(servers) do
|
|
config.capabilities = vim.tbl_deep_extend("force", {}, capabilities, config.capabilities or {})
|
|
vim.lsp.config(server_name, config)
|
|
end
|
|
|
|
require("mason").setup()
|
|
|
|
mason_lspconfig.setup({
|
|
ensure_installed = managed_servers,
|
|
automatic_enable = managed_servers,
|
|
})
|
|
|
|
vim.lsp.enable("dartls")
|
|
|
|
local mason_registry = require("mason-registry")
|
|
mason_registry.refresh(vim.schedule_wrap(function()
|
|
for _, tool_name in ipairs(managed_tools) do
|
|
local tool = mason_registry.get_package(tool_name)
|
|
if not tool:is_installed() and not tool:is_installing() then
|
|
tool:install()
|
|
end
|
|
end
|
|
end))
|