Working neovim config

This commit is contained in:
2025-09-07 07:07:50 -04:00
parent 5d95db3480
commit f9e88b17f7
9 changed files with 251 additions and 129 deletions

View File

@@ -1,54 +1,50 @@
return {
-- LSP Configuration
{
"neovim/nvim-lspconfig",
"williamboman/mason.nvim",
config = function()
require("mason").setup()
end,
},
{
"williamboman/mason-lspconfig.nvim",
dependencies = {
-- LSP Management
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
-- Optional but recommended
"hrsh7th/nvim-cmp", -- Completion engine
"hrsh7th/cmp-nvim-lsp", -- LSP source for nvim-cmp
"j-hui/fidget.nvim", -- LSP status updates
"folke/neodev.nvim", -- Additional Lua configuration
"neovim/nvim-lspconfig",
},
config = function()
-- Setup language servers
require("mason-lspconfig").setup({
ensure_installed = {
"lua_ls",
"ts_ls",
"html",
"cssls",
"gopls",
"rust_analyzer",
},
})
end,
},
{
"neovim/nvim-lspconfig",
dependencies = { "williamboman/mason-lspconfig.nvim" },
config = function()
local lspconfig = require("lspconfig")
local capabilities = require("cmp_nvim_lsp").default_capabilities()
-- Configure each language server
lspconfig.lua_ls.setup({
capabilities = capabilities,
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
checkThirdParty = false,
},
telemetry = {
enable = false,
},
},
},
})
local servers = { "lua_ls", "ts_ls", "html", "cssls", "gopls", "rust_analyzer" }
-- Add more language servers
lspconfig.pyright.setup({
capabilities = capabilities,
})
for _, server_name in ipairs(servers) do
lspconfig[server_name].setup({
capabilities = capabilities,
})
end
-- Add keybindings for LSP functions
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
local opts = { buffer = ev.buf, noremap = true, silent = true }
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "<leader>gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts)
@@ -60,33 +56,4 @@ return {
})
end,
},
{
"williamboman/mason.nvim",
config = function()
require("mason").setup()
end,
},
{
"williamboman/mason-lspconfig.nvim",
config = function()
require("mason-lspconfig").setup({
ensure_installed = {
-- Add the language servers you want to auto-install
"lua_ls",
"pyright",
"ts_ls"
},
})
end,
},
-- Optional: Add nvim-cmp and its sources
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
-- Add other sources as needed
},
},
}
}