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" },
"gitsigns.nvim": { "branch": "main", "commit": "d195f0c35ced5174d3ecce1c4c8ebb3b5bc23fa9" },
"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" },
"nui.nvim": { "branch": "main", "commit": "80445d015d2b5f9af0d9e8bce63d303bc86eda8a" },
"nvim": { "branch": "main", "commit": "b901cf144573b293b6cefeb1ac8c97d5d239ee7a" },
@ -23,4 +25,4 @@
"telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" },
"undotree": { "branch": "master", "commit": "36ff7abb6b60980338344982ad4cdf03f7961ecd" },
"vim-fugitive": { "branch": "master", "commit": "59659093581aad2afacedc81f009ed6a4bfad275" }
}
}

View file

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

View file

@ -4,6 +4,14 @@ return {
"williamboman/mason.nvim",
opts = {},
},
{
"williamboman/mason-lspconfig.nvim",
dependencies = {
"williamboman/mason.nvim",
},
config = function()
end,
},
{
"neovim/nvim-lspconfig",
dependencies = {
@ -38,33 +46,44 @@ return {
})
end,
config = function()
local lspconfig = require("lspconfig")
local capabilities = require("cmp_nvim_lsp").default_capabilities();
local lspconfig = require("lspconfig");
lspconfig.pyright.setup({
capabilities = capabilities,
})
lspconfig.lua_ls.setup({
capabilities = capabilities,
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true),
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false,
},
},
require("mason-lspconfig").setup({
handlers = {
-- default handler
function(server_name)
lspconfig[server_name].setup {
capabilities = capabilities,
}
end,
-- overrides
["rust_analyzer"] = function()
require("lazy").load { plugins = { "rust-tools.nvim" } };
end,
["lua_ls"] = function()
lspconfig.lua_ls.setup({
capabilities = capabilities,
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true),
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false,
},
},
},
})
end,
},
})
end
});
end,
},
}