nvim/lua/plugins/lsp.lua
2025-07-29 23:25:16 +02:00

68 lines
1.4 KiB
Lua

return {
{
"williamboman/mason-lspconfig.nvim",
dependencies = { "williamboman/mason.nvim", "neovim/nvim-lspconfig" },
event = { "BufReadPre", "BufNewFile" },
opts = {
ensure_installed = { "lua_ls" },
},
},
{
"williamboman/mason.nvim",
lazy = true,
cmd = "Mason",
keys = { { "<Leader>cm", "<cmd>Mason<cr>" } },
opts = {
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
},
},
},
{
"neovim/nvim-lspconfig",
lazy = true,
cmd = { "LspInfo", "LspInstall", "LspUninstall" },
config = function()
-- Keybinds
vim.keymap.set("n", "gd", vim.lsp.buf.definition)
vim.keymap.set("n", "<leader>cr", vim.lsp.buf.rename)
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action)
-- Diagnostics
vim.diagnostic.config({
underline = true,
update_in_insert = false,
virtual_text = {
spacing = 4,
source = "if_many",
prefix = "",
},
severity_sort = true,
signs = {
text = {
[vim.diagnostic.severity.ERROR] = "󰅚",
[vim.diagnostic.severity.WARN] = "󰀪",
[vim.diagnostic.severity.HINT] = "󰌶",
[vim.diagnostic.severity.INFO] = "",
},
},
})
-- Add `vim` to globals
vim.lsp.config("lua_ls", {
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
},
},
})
end,
},
}