Simplify/de-abstract nvim config files

This commit is contained in:
2025-09-16 12:22:58 -05:00
parent c9bad270d2
commit 964db5caf8
21 changed files with 254 additions and 162 deletions

View File

@@ -0,0 +1,51 @@
return {
-- TODO: decide which of these i won't be using, then remove from this file
{
"ellisonleao/gruvbox.nvim",
name = "gruvbox",
-- priority = 1000,
opts = {
terminal_colors = true, -- add neovim terminal colors
undercurl = true,
underline = true,
bold = true,
italic = {
strings = true,
emphasis = true,
comments = true,
operators = false,
folds = true,
},
strikethrough = true,
invert_selection = false,
invert_signs = false,
invert_tabline = false,
inverse = true, -- invert background for search, diffs, statuslines and errors
contrast = "", -- "hard", "soft", or ""
palette_overrides = {},
overrides = {},
dim_inactive = false,
transparent_mode = false,
},
},
{
"rose-pine/neovim",
name = "rose-pine",
},
{
"folke/tokyonight.nvim",
lazy = false,
priority = 1000,
opts = {
style = "night", -- "night", "storm", "moon", "day"
styles = {
functions = {} -- disable italic for functions
},
on_colors = function(colors)
colors.hint = colors.orange
colors.error = "#ff0000"
colors.fg_gutter = "#9098B8"
end
},
}
}

View File

@@ -0,0 +1,18 @@
return {
'stevearc/conform.nvim',
opts = {},
config = function()
require("conform").setup({
formatters_by_ft = {
-- c = { "fill-in" },
-- cpp = { "fill-in" },
go = { "gofmt" },
lua = { "stylua" },
ruby = { "standardrb" },
python = { "black" },
javascript = { "prettier" },
}
})
end
}

View File

@@ -0,0 +1,64 @@
return {
{
"mfussenegger/nvim-dap",
event = "VeryLazy",
dependencies = {
"nvim-neotest/nvim-nio", -- dependency of nvim-dap-ui below
"rcarriga/nvim-dap-ui",
"jay-babu/mason-nvim-dap.nvim", -- requires mason.nvim
"theHamsta/nvim-dap-virtual-text", -- TODO: decide if i want this or not
},
config = function()
local dap = require("dap")
local dap_ui = require("dapui")
local mason_dap = require("mason-nvim-dap")
local dap_virtual_text = require("nvim-dap-virtual-text")
dap_virtual_text.setup()
mason_dap.setup({
ensure_installed = { "cppdbg" }, -- "codelldb", "lldb", "gdb", "cppdbg"
automatic_installation = true,
handlers = {
function(config) require("mason-nvim-dap").default_setup(config) end,
},
})
dap.configurations = {
c = {
{
name = "launch file",
type = "cppdbg",
request = "launch",
cwd = "${workspaceFolder}",
program = function()
return vim.fn.input("path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
MIMode = "lldb",
stopAtEntry = false,
},
{
name = "attach to lldbserver :1234",
type = "cppdbg",
request = "launch",
cwd = "${workspaceFolder}",
program = function()
return vim.fn.input("path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
MIMode = "lldb",
miDebuggerServerAddress = "localhost:1234",
miDebuggerPath = "/usr/bin/lldb",
},
},
}
dap_ui.setup()
vim.fn.sign_define("DapBreakpoint", { text = "🟥" })
dap.listeners.before.attach.dapui_config = function() dap_ui.open() end
dap.listeners.before.launch.dapui_config = function() dap_ui.open() end
dap.listeners.before.event_terminated.dapui_config = function() dap_ui.close() end
dap.listeners.before.event_exited.dapui_config = function() dap_ui.close() end
end,
},
}

View File

@@ -0,0 +1,3 @@
return {
{ "tpope/vim-fugitive" },
}

View File

@@ -0,0 +1,11 @@
return {
{
"ThePrimeagen/harpoon",
branch = "harpoon2", -- https://github.com/ThePrimeagen/harpoon/tree/harpoon2
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
local harpoon = require("harpoon")
harpoon:setup()
end,
},
}

View File

@@ -0,0 +1,124 @@
return {
"neovim/nvim-lspconfig",
dependencies = {
"stevearc/conform.nvim",
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"hrsh7th/nvim-cmp",
-- snippets, using luasnip for now
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
},
config = function()
require("conform").setup({ formatters_by_ft = {} })
local cmp = require('cmp')
local cmp_lsp = require("cmp_nvim_lsp")
local capabilities = vim.tbl_deep_extend(
"force",
{},
vim.lsp.protocol.make_client_capabilities(),
cmp_lsp.default_capabilities()
)
require("mason").setup()
require("mason-lspconfig").setup({
ensure_installed = {
"clangd",
"lua_ls",
"ruby_lsp",
-- "gopls",
-- "tailwindcss",
},
handlers = {
function(server_name) -- default
require("lspconfig")[server_name].setup {
capabilities = capabilities
}
end,
["lua_ls"] = function()
local lspconfig = require("lspconfig")
lspconfig.lua_ls.setup {
capabilities = capabilities,
settings = {
Lua = {
format = {
enable = true,
defaultConfig = { -- NOTE: string values only
indent_style = "space",
indent_size = "2",
},
},
},
},
}
end,
}
})
local cmp_select = { behavior = cmp.SelectBehavior.Select }
cmp.setup({
mapping = cmp.mapping.preset.insert({
["<C-Space>"] = cmp.mapping.complete(),
['<C-y>'] = cmp.mapping.confirm({ select = true }),
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-u>'] = cmp.mapping.scroll_docs(4),
}),
snippet = {
expand = function(args)
-- vim.snippet.expand(args.body) -- TODO: native option, maybe try
require('luasnip').lsp_expand(args.body)
end,
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
}, {
{ name = 'buffer' },
}),
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
performance = {
max_view_entries = 14,
},
})
-- `/` cmdline setup.
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
}),
matching = { disallow_symbol_nonprefix_matching = false }
})
vim.diagnostic.config({
-- update_in_insert = true,
float = {
focusable = false,
style = "minimal",
border = "rounded",
source = "always",
header = "",
prefix = "",
},
})
-- TODO: enables needed? or does neovim/nvim-lspconfig cover by default?
-- vim.lsp.enable('clangd')
-- vim.lsp.enable('ruby_lsp')
-- vim.lsp.enable('standardrb')
-- vim.lsp.enable('herb_ls') -- targets html + ruby (erb files)
end,
}

View File

@@ -0,0 +1,41 @@
local glob_patterns_find_files = {
"-g", "!**/.git/**",
"-g", "!**/build/**",
"-g", "!**/node_modules/**",
}
local glob_patterns_live_grep = {
unpack(glob_patterns_find_files), -- same for now
}
return {
"nvim-telescope/telescope.nvim",
tag = "0.1.8",
dependencies = { "nvim-lua/plenary.nvim" },
opts = {
defaults = {
layout_strategy = "horizontal",
layout_config = {
horizontal = {
width = 0.98,
height = 0.98,
preview_width = 0.45,
},
},
path_display = { "truncate", },
},
pickers = {
find_files = {
find_command = {
"rg", "--no-ignore", "--hidden", "--files",
unpack(glob_patterns_find_files),
},
},
live_grep = {
additional_args = {
"--no-ignore", "--hidden",
unpack(glob_patterns_live_grep),
}
},
},
},
}

View File

@@ -0,0 +1,73 @@
return {
{
"nvim-treesitter/nvim-treesitter",
branch = 'master',
lazy = false,
build = ":TSUpdate",
config = function()
require("nvim-treesitter.configs").setup({
ensure_installed = {
"vimdoc", "bash", "lua", "c", "cpp", "go", "python", "ruby",
"html", "css", "javascript", "jsdoc", "sql", "json", "yaml",
"markdown", "markdown_inline",
-- "odin", "zig", "ocaml", "java", "typescript",
},
sync_install = false, -- install `ensure_installed` parsers synchronously
auto_install = true, -- install missing on BufEnter, requires tree-sitter CLI
ignore_install = {},
-- indent = { enable = true }, -- TODO: do i want this?
highlight = {
enable = true, -- `false` will disable the whole extension
disable = function(lang, buf)
for i, v in ipairs({ "html", }) do
if lang == v then
print("treesitter disabled for this language")
return true
end
end
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > (100 * 1024) then -- 100 KB
vim.notify(
"larger file, treesitter disabled for performance",
vim.log.levels.WARN,
{title = "Treesitter"}
)
return true
end
end,
-- true, false, or list of langs; may cause slowness or duplicate highlights
additional_vim_regex_highlighting = { "markdown" },
},
})
-- TODO: decide if needed/wanted
-- local treesitter_parser_config = require("nvim-treesitter.parsers").get_parser_configs()
-- treesitter_parser_config.templ = {
-- install_info = {
-- url = "https://github.com/vrischmann/tree-sitter-templ.git",
-- files = {"src/parser.c", "src/scanner.c"},
-- branch = "master",
-- },
-- }
-- vim.treesitter.language.register("templ", "templ")
end
},
{
"nvim-treesitter/nvim-treesitter-context",
after = "nvim-treesitter",
opts = {
enable = false, -- can enable/disable via manual command
multiwindow = false,
max_lines = 0, -- lines the window should span; x <= 0 means no limit
min_window_height = 10, -- min window height to enable; x <= 0 means no limit
line_numbers = true,
multiline_threshold = 40, -- max lines to show for a single context
trim_scope = 'outer', -- 'inner', 'outer'; discard lines if max_lines exceeded
mode = 'cursor', -- 'cursor', 'topline'; line used to calculate context
separator = "-", -- 1 char, like '-'; only shown when >= 2 lines above
zindex = 20, -- z-index of the context window
on_attach = nil, -- (fun(buf: integer): boolean); return false to disable attaching
},
},
}

View File

@@ -0,0 +1,3 @@
return {
"mbbill/undotree",
}