This commit is contained in:
2026-02-09 12:58:05 -06:00
parent 3f2c2ce65f
commit d0e94ed5a7
2 changed files with 88 additions and 0 deletions

View File

@@ -28,3 +28,33 @@ map("n", "<S-Tab>", "<cmd>BufferLineCyclePrev<cr>", { desc = "Previous buffer" }
map("n", "<leader>ba", "<cmd>BufferLineCloseOthers<CR>", { desc = "Close other buffers" })
map("n", "<leader>x", "<cmd>BufferLinePickClose<CR>", { desc = "Close buffer" })
map("n", "<leader>bc", "<cmd>BufferLinePick<CR>", { desc = "Close buffer" })
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(ev)
local bufnr = ev.buf
local opts = function(desc)
return { buffer = bufnr, silent = true, desc = desc }
end
map("n", "gd", vim.lsp.buf.definition, opts "LSP: Go to definition")
map("n", "gD", vim.lsp.buf.declaration, opts "LSP: Go to declaration")
map("n", "gi", vim.lsp.buf.implementation, opts "LSP: Go to implementation")
map("n", "gr", vim.lsp.buf.references, opts "LSP: References")
map("n", "K", vim.lsp.buf.hover, opts "LSP: Hover")
map("n", "<leader>rn", vim.lsp.buf.rename, opts "LSP: Rename")
map("n", "<leader>ca", vim.lsp.buf.code_action, opts "LSP: Code action")
map("n", "[d", function()
vim.diagnostic.jump { count = -1, float = true }
end, opts "Diag: Prev")
map("n", "]d", function()
vim.diagnostic.jump { count = 1, float = true }
end, opts "Diag: Next")
map("n", "<leader>dd", vim.diagnostic.open_float, opts "Diag: Line diagnostics")
map("n", "<leader>lf", function()
vim.lsp.buf.format { async = true }
end, opts "LSP: Format (server)")
end,
})

58
lua/plugins/lsp.lua Normal file
View File

@@ -0,0 +1,58 @@
return {
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"L3MON4D3/LuaSnip",
},
config = function()
local cmp = require "cmp"
cmp.setup {
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert {
["<CR>"] = cmp.mapping.confirm { select = true },
["<C-Space>"] = cmp.mapping.complete(),
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
},
}
end,
},
{
"neovim/nvim-lspconfig",
dependencies = {
{ "hrsh7th/nvim-cmp" },
{ "j-hui/fidget.nvim", opts = {} },
},
config = function()
local caps = vim.lsp.protocol.make_client_capabilities()
caps = require("cmp_nvim_lsp").default_capabilities(caps)
vim.lsp.config("*", { capabilities = caps })
vim.lsp.config("lua_ls", {
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
workspace = {
checkThirdParty = false,
},
telemetry = { enable = false },
},
},
})
vim.lsp.enable {
"lua_ls",
}
end,
},
}