lsp: autoconfiguring lsps with mason-lspconfig

This commit is contained in:
kalmenn 2024-01-07 17:37:02 +01:00
parent e1ec85793b
commit 30542b0ab3
Signed by: kalmenn
GPG key ID: F500055C44BC3834
3 changed files with 49 additions and 27 deletions

View file

@ -10,6 +10,8 @@
"feline.nvim": { "branch": "main", "commit": "0f6c531ac928bcff4cccc08b7fff3b5b2657359f" }, "feline.nvim": { "branch": "main", "commit": "0f6c531ac928bcff4cccc08b7fff3b5b2657359f" },
"gitsigns.nvim": { "branch": "main", "commit": "d195f0c35ced5174d3ecce1c4c8ebb3b5bc23fa9" }, "gitsigns.nvim": { "branch": "main", "commit": "d195f0c35ced5174d3ecce1c4c8ebb3b5bc23fa9" },
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "0989bdf4fdf7b5aa4c74131d7ffccc3f399ac788" },
"mason.nvim": { "branch": "main", "commit": "a09da6ac634926a299dd439da08bdb547a8ca011" },
"neo-tree.nvim": { "branch": "v3.x", "commit": "77d9f484b88fd380386b46ed9206e5374d69d9d8" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "77d9f484b88fd380386b46ed9206e5374d69d9d8" },
"nui.nvim": { "branch": "main", "commit": "80445d015d2b5f9af0d9e8bce63d303bc86eda8a" }, "nui.nvim": { "branch": "main", "commit": "80445d015d2b5f9af0d9e8bce63d303bc86eda8a" },
"nvim": { "branch": "main", "commit": "b901cf144573b293b6cefeb1ac8c97d5d239ee7a" }, "nvim": { "branch": "main", "commit": "b901cf144573b293b6cefeb1ac8c97d5d239ee7a" },

View file

@ -41,8 +41,9 @@ return {
"simrat39/rust-tools.nvim", "simrat39/rust-tools.nvim",
dependencies = { dependencies = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
"hrsh7th/cmp-nvim-lsp",
}, },
lazy = false, lazy = true,
config = function() config = function()
local capabilities = require("cmp_nvim_lsp").default_capabilities(); local capabilities = require("cmp_nvim_lsp").default_capabilities();

View file

@ -4,6 +4,14 @@ return {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = {}, opts = {},
}, },
{
"williamboman/mason-lspconfig.nvim",
dependencies = {
"williamboman/mason.nvim",
},
config = function()
end,
},
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
dependencies = { dependencies = {
@ -38,14 +46,22 @@ return {
}) })
end, end,
config = function() config = function()
local lspconfig = require("lspconfig")
local capabilities = require("cmp_nvim_lsp").default_capabilities(); local capabilities = require("cmp_nvim_lsp").default_capabilities();
local lspconfig = require("lspconfig");
lspconfig.pyright.setup({ require("mason-lspconfig").setup({
handlers = {
-- default handler
function(server_name)
lspconfig[server_name].setup {
capabilities = capabilities, capabilities = capabilities,
}) }
end,
-- overrides
["rust_analyzer"] = function()
require("lazy").load { plugins = { "rust-tools.nvim" } };
end,
["lua_ls"] = function()
lspconfig.lua_ls.setup({ lspconfig.lua_ls.setup({
capabilities = capabilities, capabilities = capabilities,
settings = { settings = {
@ -65,6 +81,9 @@ return {
}, },
}, },
}) })
end end,
},
});
end,
}, },
} }