--[ -- This plugin is responsible of having external tools correctly installed. --] return { -- NOTE: mason is a dependencie of mason-lspconfig. Not the other way around. "williamboman/mason-lspconfig.nvim", enabled = true, dependencies = { "williamboman/mason.nvim", "WhoIsSethDaniel/mason-tool-installer.nvim", "mfussenegger/nvim-dap", "jay-babu/mason-nvim-dap.nvim", "neovim/nvim-lspconfig", }, config = function() local mason_lspconfig = require("mason-lspconfig") local mason_tool_installer = require("mason-tool-installer") local mason_dap = require("mason-nvim-dap") local lspconfig = require("lspconfig") local capabilities = require("cmp_nvim_lsp").default_capabilities() mason_dap.setup({ automatic_installation = true, ensure_installed = { "codelldb", }, --[[ handlers = { -- cette première fonction est le "gestionnaire par défaut" -- elle s'applique à chaque serveur linguistique sans "gestionnaire personnalisé" function(server_name) require("lspconfig")[server_name].setup({}) end, }, --]] }) mason_lspconfig.setup({ lazy = false, automatic_installation = true, automatic_enable = { exclude = { "harper_ls" }, }, ensure_installed = { "html", "cssls", -- "harper_ls", "ltex", "svelte", "lua_ls", "pyright", "ruff", "rust_analyzer", }, handlers = { -- default handler for installed servers function(server_name) lspconfig[server_name].setup({ capabilities = capabilities, }) end, ["svelte"] = function() -- Configuration specific to svelte LSP server lspconfig["svelte"].setup({ capabilities = capabilities, on_attach = function(client, _) vim.api.nvim_create_autocmd("BufWritePost", { pattern = { "*.js", "*.mjs", "*.svelte" }, callback = function(ctx) -- Here use ctx.match instead of ctx.file client.notify("$/onDidChangeTsOrJsFile", { uri = ctx.match }) end, }) end, }) end, ["ltex"] = function() lspconfig["ltex"].setup({ filetypes = { "latex", "typst", "typ", "bib", "markdown", "plaintex", "tex" }, settings = { ltex = { enabled = { "latex", "typst", "typ", "bib", "markdown", "plaintex", "tex" }, language = { "en-GB", "fr-FR" }, setenceCacheSize = 2000, additionalRules = { enablePickyRules = true, motherTongue = "fr-FR", }, checkFrequency = "edit", }, }, }) end, ["lua_ls"] = function() lspconfig["lua_ls"].setup({ capabilities = capabilities, settings = { Lua = { -- Make the language server recognize the "vim" global variable diagnostics = { globals = { "vim" }, }, completion = { callSnippet = "Replace", }, }, }, }) end, ["harper_ls"] = function() lspconfig["harper_ls"].setup({ settings = { ["harper-ls"] = { markdown = { IgnoreLinkTitle = true, }, linters = { SpellCheck = true, SpelledNumbers = true, AnA = true, SentenceCapitalization = true, UnclosedQuotes = true, WrongQuotes = false, LongSentences = true, RepeatedWords = true, Spaces = true, Matcher = true, CorrectNumberSuffix = true, }, isolateEnglish = true, }, }, }) end, ["pyright"] = function() lspconfig["pyright"].setup({ capabilities = capabilities, settings = { python = { pythonPath = "/usr/bin/python", }, }, }) end, }, }) mason_tool_installer.setup({ ensure_installed = { "prettier", -- Web related formatter "stylua", -- Lua formater -- "isort", -- Python formater -- "black", -- Python formater too "ruff", -- Python linter "eslint_d", -- JavaScript linter "llm-ls", "shfmt", }, }) lspconfig["svelte"].setup({ -- capabilities = capabilities, on_attach = function(client, _) vim.api.nvim_create_autocmd("BufWritePost", { pattern = { "*.js", "*.mjs", "*.svelte" }, callback = function(ctx) -- Here use ctx.match instead of ctx.file client.notify("$/onDidChangeTsOrJsFile", { uri = ctx.match }) end, }) end, }) lspconfig["lua_ls"].setup({ -- capabilities = capabilities, settings = { Lua = { -- Make the language server recognize the "vim" global variable diagnostics = { globals = { "vim" }, }, completion = { callSnippet = "Replace", }, }, }, }) lspconfig["harper_ls"].setup({ filetypes = { "latex", "typst", "typ", "bib", "markdown", "plaintex", "tex" }, settings = { ["harper-ls"] = { markdown = { IgnoreLinkTitle = true, }, linters = { SpellCheck = true, SpelledNumbers = false, AnA = true, SentenceCapitalization = true, UnclosedQuotes = false, WrongQuotes = false, LongSentences = true, RepeatedWords = true, Spaces = true, Matcher = false, CorrectNumberSuffix = true, }, isolateEnglish = true, }, }, }) lspconfig["pyright"].setup({ -- capabilities = capabilities, settings = { python = { pythonPath = "/usr/bin/python", }, }, }) lspconfig["ltex"].setup({ filetypes = { "latex", "typst", "typ", "bib", "markdown", "plaintex", "tex" }, settings = { ltex = { enabled = { "latex", "typst", "typ", "bib", "markdown", "plaintex", "tex" }, language = { "en-GB", "fr-FR" }, setenceCacheSize = 2000, additionalRules = { enablePickyRules = true, motherTongue = "fr-FR", }, checkFrequency = "edit", }, }, }) end, }