-- Install and configure mason.nvim which will install automatically the needed -- LSP return { "williamboman/mason.nvim", dependencies = { "williamboman/mason-lspconfig.nvim", -- Needed for the jsonls LSP -- But it shouldn't be there, because it's always loaded "b0o/schemastore.nvim", }, config = function() -- Import mason local mason = require("mason") -- Import mason-lspconfig local mason_lspconfig = require("mason-lspconfig") -- Import lspconfig local lspconfig = require("lspconfig") -- Activate mason and set icones mason.setup({ ui = { icons = { package_installed = "✓", package_pending = "➜", package_uninstalled = "✗", }, }, }) 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", "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() lspconfig.lua_ls.setup({ settings = { json = { schemas = require("schemastore").json.schemas(), validate = { enable = true }, } } }) end }, }) end, }