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

@@ -0,0 +1,62 @@
return {
-- Enhanced LSP UI
{
"j-hui/fidget.nvim",
opts = {},
},
-- Improved diagnostics display
{
"folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
opts = {},
cmd = "Trouble",
keys = {
{
"<leader>xx",
"<cmd>Trouble diagnostics toggle<cr>",
desc = "Diagnostics (Trouble)",
},
{
"<leader>xX",
"<cmd>Trouble diagnostics toggle filter.buf=0<cr>",
desc = "Buffer Diagnostics (Trouble)",
},
{
"<leader>cs",
"<cmd>Trouble symbols toggle focus=false<cr>",
desc = "Symbols (Trouble)",
},
{
"<leader>cl",
"<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
desc = "LSP Definitions / references / ... (Trouble)",
},
{
"<leader>xL",
"<cmd>Trouble loclist toggle<cr>",
desc = "Location List (Trouble)",
},
{
"<leader>xQ",
"<cmd>Trouble qflist toggle<cr>",
desc = "Quickfix List (Trouble)",
},
},
},
-- Signature help
{
"ray-x/lsp_signature.nvim",
event = "VeryLazy",
opts = {},
config = function(_, opts) require'lsp_signature'.setup(opts) end
},
-- Lightbulb for code actions
{
"kosayoda/nvim-lightbulb",
config = function()
require("nvim-lightbulb").setup({
autocmd = { enabled = true }
})
end,
},
}

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
},
},
}
}

View File

@@ -1,38 +0,0 @@
return {
{
"williamboman/mason.nvim",
config = function()
require("mason").setup({
ui = {
border = "rounded", -- Nice UI borders
},
})
end,
},
{
"williamboman/mason-lspconfig.nvim",
dependencies = {
"williamboman/mason.nvim",
"neovim/nvim-lspconfig",
},
config = function()
local mason_lspconfig = require("mason-lspconfig")
mason_lspconfig.setup({
ensure_installed = {
-- "ts_ls", -- Typescript
-- "html", -- HTML
-- "cssls", -- CSS
-- "gopls", -- Go
-- "clangd", -- C++/C
-- "lua_ls", -- Lua
},
automatic_installation = true,
})
end,
},
{
"neovim/nvim-lspconfig", -- Core LSP config
dependencies = { "williamboman/mason.nvim" },
},
}

View File

@@ -1,20 +0,0 @@
return {
-- -- In the config function of nvim-cmp
-- config = function()
-- local cmp = require("cmp")
--
-- cmp.setup({
-- mapping = cmp.mapping.preset.insert({
-- ["<C-Space>"] = cmp.mapping.complete(),
-- ["<CR>"] = cmp.mapping.confirm({ select = true }),
-- ["<C-n>"] = cmp.mapping.select_next_item(),
-- ["<C-p>"] = cmp.mapping.select_prev_item(),
-- }),
-- sources = cmp.config.sources({
-- { name = "nvim_lsp" },
-- { name = "buffer" },
-- { name = "path" },
-- }),
-- })
-- end
}

View File

@@ -0,0 +1,88 @@
return {
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
"onsails/lspkind.nvim",
},
config = function()
local cmp = require("cmp")
local luasnip = require("luasnip")
local lspkind = require("lspkind")
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" },
}, {
{ name = "buffer" },
{ name = "path" },
}),
formatting = {
format = lspkind.cmp_format({
mode = "symbol_text",
maxwidth = 50,
ellipsis_char = "...",
}),
},
})
-- Use buffer source for `/` and `?`
cmp.setup.cmdline({ "/", "?" }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = "buffer" }
}
})
-- Use cmdline & path source for `:`
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = "path" }
}, {
{ name = "cmdline" }
})
})
end,
}
}

View File

@@ -0,0 +1,49 @@
return {
{
"mfussenegger/nvim-dap",
dependencies = {
"rcarriga/nvim-dap-ui",
"theHamsta/nvim-dap-virtual-text",
},
config = function() end,
},
{
"rcarriga/nvim-dap-ui",
dependencies = { "mfussenegger/nvim-dap" },
config = function() end,
},
{
"mxsdev/nvim-dap-vscode-js",
dependencies = { "mfussenegger/nvim-dap" },
config = function()
require('dap-vscode-js').setup({
debugger_path = vim.fn.stdpath("data") .. "/lazy/vscode-js-debug",
adapters = { 'pwa-node', 'pwa-chrome', 'pwa-msedge', 'node-terminal', 'pwa-extensionHost' },
})
for _, language in ipairs({ "typescript", "javascript" }) do
require("dap").configurations[language] = {
{
type = "pwa-node",
request = "launch",
name = "Launch file",
program = "${file}",
cwd = "${workspaceFolder}",
},
}
end
end,
},
{
"mfussenegger/nvim-dap",
keys = {
{ "<leader>db", function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint" },
{ "<leader>dc", function() require("dap").continue() end, desc = "Continue" },
{ "<leader>di", function() require("dap").step_into() end, desc = "Step Into" },
{ "<leader>do", function() require("dap").step_over() end, desc = "Step Over" },
{ "<leader>dO", function() require("dap").step_out() end, desc = "Step Out" },
{ "<leader>dr", function() require("dap").repl.open() end, desc = "Open Repl" },
{ "<leader>dl", function() require("dap").run_last() end, desc = "Run Last" },
},
},
}