2024-08-06 16:35:29 +02:00
|
|
|
-- Install and configure mason.nvim which will install automatically the needed
|
|
|
|
-- LSP
|
|
|
|
|
|
|
|
return {
|
|
|
|
"williamboman/mason.nvim",
|
|
|
|
dependencies = {
|
|
|
|
"williamboman/mason-lspconfig.nvim",
|
|
|
|
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
|
|
|
},
|
|
|
|
config = function()
|
|
|
|
-- Import mason
|
|
|
|
local mason = require("mason")
|
|
|
|
|
|
|
|
-- Import mason-lspconfig
|
|
|
|
local mason_lspconfig = require("mason-lspconfig")
|
|
|
|
|
|
|
|
-- Import lspconfig
|
|
|
|
local lspconfig = require("lspconfig")
|
|
|
|
|
2024-10-04 13:56:39 +02:00
|
|
|
local util = require("lspconfig.util")
|
|
|
|
|
2024-08-06 16:35:29 +02:00
|
|
|
-- Import mason-tool-installer
|
|
|
|
local mason_tool_installer = require("mason-tool-installer")
|
|
|
|
|
|
|
|
-- Activate mason and set icones
|
|
|
|
mason.setup({
|
|
|
|
ui = {
|
|
|
|
icons = {
|
|
|
|
package_installed = "✓",
|
|
|
|
package_pending = "➜",
|
|
|
|
package_uninstalled = "✗",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
mason_tool_installer.setup({
|
|
|
|
ensure_installed = {
|
|
|
|
"black",
|
|
|
|
"isort",
|
|
|
|
"prettier",
|
|
|
|
"stylua",
|
|
|
|
"tree-sitter-cli",
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
mason_lspconfig.setup({
|
|
|
|
-- LSP to be installed by default
|
|
|
|
-- Available LSP: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
|
|
|
-- LSP can be installed with :Mason
|
|
|
|
-- But installing LSP through the following list is better
|
|
|
|
ensure_installed = {
|
|
|
|
"cssls",
|
|
|
|
"html",
|
|
|
|
"jsonls",
|
|
|
|
"lua_ls",
|
2024-10-04 13:56:39 +02:00
|
|
|
"marksman",
|
2024-08-06 16:35:29 +02:00
|
|
|
"pylsp",
|
|
|
|
"yamlls",
|
|
|
|
},
|
|
|
|
handlers = {
|
|
|
|
-- Function called for each LSP from the ensure_installed list loaded
|
|
|
|
function(server_name)
|
|
|
|
-- Activate all LSP from the ensure_installed list with its default
|
|
|
|
-- configuration
|
|
|
|
lspconfig[server_name].setup({})
|
|
|
|
end,
|
|
|
|
|
|
|
|
-- Then, configure each LSP as needed
|
|
|
|
-- See https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
|
|
|
--
|
|
|
|
-- To deactivate a LSP:
|
|
|
|
-- lsp_name = require("lsp-zero").noop,
|
|
|
|
|
|
|
|
-- The LSP name before`= function()` has to be the same than after
|
|
|
|
-- `lspconfig.`
|
|
|
|
-- The first one is the mason_lspconfig key, the seconde one is the
|
|
|
|
-- lspconfig key. They are identical to the ensure_installed entries.
|
|
|
|
|
|
|
|
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#pylsp
|
|
|
|
pylsp = function()
|
|
|
|
lspconfig.pylsp.setup({
|
|
|
|
settings = {
|
|
|
|
pylsp = {
|
|
|
|
plugins = {
|
|
|
|
pyflakes = { enabled = false },
|
|
|
|
pycodestyle = {
|
|
|
|
enabled = true,
|
|
|
|
ignore = { "E501" },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
|
|
|
|
lua_ls = function()
|
|
|
|
lspconfig.lua_ls.setup({
|
|
|
|
settings = {
|
|
|
|
Lua = {
|
|
|
|
diagnostics = {
|
|
|
|
-- Force LSP to recognize global variable `vim`.
|
|
|
|
globals = { "vim" },
|
|
|
|
disable = { "missing-fields" },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
|
|
|
|
jsonls = function()
|
2024-10-04 13:56:39 +02:00
|
|
|
lspconfig.jsonls.setup({
|
2024-08-06 16:35:29 +02:00
|
|
|
settings = {
|
|
|
|
json = {
|
|
|
|
schemas = require("schemastore").json.schemas(),
|
|
|
|
validate = { enable = true },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2024-10-04 13:56:39 +02:00
|
|
|
end,
|
|
|
|
|
|
|
|
marksman = function()
|
|
|
|
lspconfig.marksman.setup({
|
|
|
|
setting = {
|
|
|
|
filetypes = {
|
|
|
|
"markdown",
|
|
|
|
"quarto",
|
|
|
|
},
|
|
|
|
root_dir = util.root_pattern(
|
|
|
|
'.git',
|
|
|
|
'.marksman.toml',
|
|
|
|
'_quarto.yml'
|
|
|
|
),
|
|
|
|
}
|
|
|
|
})
|
2024-08-06 16:35:29 +02:00
|
|
|
end
|
|
|
|
},
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
}
|