Initial Commit - Add nvim config
Signed-off-by: Daniel Henry <iamdanhenry@gmail.com>
This commit is contained in:
40
.config/nvim/lua/core/config.lua
Normal file
40
.config/nvim/lua/core/config.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
local o = vim.opt
|
||||
|
||||
-- Numbers/UI
|
||||
o.number = true
|
||||
o.relativenumber = true
|
||||
o.signcolumn = "yes"
|
||||
o.termguicolors = true
|
||||
o.updatetime = 300
|
||||
|
||||
-- Indentation: 2 spaces, never tabs
|
||||
o.expandtab = true -- insert spaces when you press <Tab>
|
||||
o.shiftwidth = 2 -- >> and << shift by 2
|
||||
o.tabstop = 2 -- a <Tab> displays as 2 spaces
|
||||
o.softtabstop = 2 -- <BS> unindents by 2 in insert mode
|
||||
o.smartindent = true -- basic smart indenting for code
|
||||
|
||||
o.clipboard = "unnamedplus"
|
||||
|
||||
-- Diagnostics: right-side virtual text + nice floats + sorted severity
|
||||
vim.diagnostic.config({
|
||||
virtual_text = {
|
||||
spacing = 2,
|
||||
prefix = "●", -- small dot; try "▎" or "" if you like
|
||||
},
|
||||
severity_sort = true,
|
||||
underline = true,
|
||||
update_in_insert = false, -- don’t distract while typing
|
||||
float = {
|
||||
border = "rounded",
|
||||
source = "if_many",
|
||||
header = "",
|
||||
prefix = "",
|
||||
},
|
||||
})
|
||||
|
||||
-- Pretty signs in the gutter (left)
|
||||
for type, icon in pairs({ Error="", Warn="", Hint="", Info="" }) do
|
||||
local hl = "DiagnosticSign" .. type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
|
||||
end
|
||||
58
.config/nvim/lua/core/keybindings.lua
Normal file
58
.config/nvim/lua/core/keybindings.lua
Normal file
@@ -0,0 +1,58 @@
|
||||
-- Global/editor keymaps live here.
|
||||
-- Tip: keep them conservative so they don't surprise language buffers.
|
||||
|
||||
-- Global/editor keymaps only (language-specific go in e.g. c/keybindings.lua)
|
||||
local map = vim.keymap.set
|
||||
|
||||
-- Save / quit (kept from earlier)
|
||||
-- map("n", "<leader>w", "<cmd>write<CR>", { desc = "Write file" })
|
||||
map("n", "<leader>q", "<cmd>quit<CR>", { desc = "Quit window" })
|
||||
|
||||
-- File explorer (loads Neo-tree on demand)
|
||||
map("n", "<leader>ee", "<cmd>Neotree toggle<CR>", { desc = "Explorer: toggle" })
|
||||
map("n", "<leader>er", "<cmd>Neotree reveal<CR>", { desc = "Explorer: reveal current file" })
|
||||
map("n", "<leader>ef", "<cmd>Neotree focus<CR>", { desc = "Explorer: focus" })
|
||||
|
||||
-- === Splits ===
|
||||
-- Horizontal split (under your left hand)
|
||||
map("n", "<leader>-", "<cmd>split<CR>", { desc = "Split: horizontal" })
|
||||
-- Vertical split (pipe looks like a vertical divider)
|
||||
map("n", "<leader>|", "<cmd>vsplit<CR>", { desc = "Split: vertical" })
|
||||
|
||||
-- === Window navigation (hjkl with Ctrl) ===
|
||||
-- These mirror Vim's native <C-w> h/j/k/l but are faster to type
|
||||
map("n", "<C-h>", "<C-w>h", { desc = "Window left" })
|
||||
map("n", "<C-j>", "<C-w>j", { desc = "Window down" })
|
||||
map("n", "<C-k>", "<C-w>k", { desc = "Window up" })
|
||||
map("n", "<C-l>", "<C-w>l", { desc = "Window right" })
|
||||
|
||||
-- which-key groups (v3 list-style spec)
|
||||
local ok, wk = pcall(require, "which-key") -- this will load the plugin if needed
|
||||
if ok then
|
||||
wk.add({
|
||||
{ "<leader>e", group = "Explorer" },
|
||||
{ "<leader>f", group = "Find" },
|
||||
{ "<leader>g", group = "Git" },
|
||||
{ "<leader>w", group = "Write/Windows" }, -- optional grouping for your own keys
|
||||
})
|
||||
end
|
||||
|
||||
-- Find group (which-key already labels <leader>f as "Find")
|
||||
map("n", "<leader>ff", "<cmd>Telescope find_files<CR>", { desc = "Find files" })
|
||||
map("n", "<leader>fg", "<cmd>Telescope live_grep<CR>", { desc = "Grep project" })
|
||||
map("n", "<leader>fb", "<cmd>Telescope buffers<CR>", { desc = "Switch buffer" })
|
||||
map("n", "<leader>fh", "<cmd>Telescope help_tags<CR>", { desc = "Help tags" })
|
||||
map("n", "<leader>fr", "<cmd>Telescope oldfiles<CR>", { desc = "Recent files" })
|
||||
map("n", "<leader>fs", "<cmd>Telescope grep_string<CR>", { desc = "Grep word under cursor" })
|
||||
local tb = require("telescope.builtin")
|
||||
map("n", "<leader>fs", tb.lsp_workspace_symbols, { desc = "Find: workspace symbols (LSP fuzzy)" })
|
||||
map("n", "<leader>fd", tb.lsp_document_symbols, { desc = "Find: document symbols (LSP fuzzy)" })
|
||||
|
||||
-- Open a small hover with all diagnostics at the cursor
|
||||
map("n", "<leader>xx", "<cmd>Trouble diagnostics toggle<CR>", { desc="Diagnostics: Trouble list" })
|
||||
|
||||
-- Toggle right-side virtual text on/off (sometimes nice to declutter)
|
||||
map("n", "<leader>xt", function()
|
||||
local cfg = vim.diagnostic.config()
|
||||
vim.diagnostic.config({ virtual_text = not cfg.virtual_text })
|
||||
end, { desc = "Diagnostics: toggle virtual text" })
|
||||
231
.config/nvim/lua/core/plugins.lua
Normal file
231
.config/nvim/lua/core/plugins.lua
Normal file
@@ -0,0 +1,231 @@
|
||||
-- All generic/global plugins live in this list.
|
||||
return {
|
||||
{
|
||||
"rose-pine/neovim",
|
||||
name = "rose-pine",
|
||||
lazy = false, -- load at startup
|
||||
priority = 1000, -- ensure theme loads before others
|
||||
config = function()
|
||||
require("rose-pine").setup({
|
||||
-- Variants: "auto" | "main" | "moon" | "dawn"
|
||||
variant = "auto",
|
||||
styles = { transparency = false },
|
||||
})
|
||||
vim.cmd.colorscheme("rose-pine")
|
||||
end,
|
||||
},
|
||||
-- Subtle indent guides
|
||||
{
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
main = "ibl",
|
||||
event = { "BufReadPost", "BufNewFile" },
|
||||
opts = {
|
||||
indent = { char = "│", tab_char = "│" }, -- faint vertical guides; theme controls color
|
||||
scope = { enabled = false }, -- keep it subtle (no current-scope highlight)
|
||||
exclude = {
|
||||
filetypes = { "help", "neo-tree", "Trouble", "lazy", "mason", "dashboard" },
|
||||
buftypes = { "terminal", "nofile", "quickfix", "prompt" },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Keybinding helper (shows hints as you type <leader>…)
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
plugins = { spelling = true },
|
||||
win = { border = "rounded" },
|
||||
delay = 300, -- ms before popup; tweak if it feels slow/fast
|
||||
},
|
||||
},
|
||||
|
||||
-- Statusline
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
options = {
|
||||
theme = "rose-pine", -- or "auto"
|
||||
icons_enabled = true,
|
||||
globalstatus = true,
|
||||
component_separators = { left = "│", right = "│" },
|
||||
section_separators = { left = " ", right = " " },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- File explorer (choose Neo-tree; single source of truth lives here)
|
||||
{
|
||||
"nvim-neo-tree/neo-tree.nvim",
|
||||
cmd = "Neotree", -- lazy-load on command or the keymap below
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-tree/nvim-web-devicons", -- optional, but nice
|
||||
"MunifTanjim/nui.nvim",
|
||||
},
|
||||
opts = {
|
||||
sources = { "filesystem", "buffers", "git_status" },
|
||||
filesystem = {
|
||||
follow_current_file = { enabled = true },
|
||||
hijack_netrw_behavior = "open_default",
|
||||
filtered_items = { hide_gitignored = false },
|
||||
},
|
||||
window = { width = 32 },
|
||||
},
|
||||
},
|
||||
-- Telescope core
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
cmd = "Telescope", -- lazy-load on :Telescope (used by your keymaps)
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
opts = {
|
||||
defaults = {
|
||||
-- small QoL tweaks; change anytime
|
||||
sorting_strategy = "ascending",
|
||||
layout_config = { prompt_position = "top" },
|
||||
mappings = { i = { ["<C-u>"] = false, ["<C-d>"] = false } },
|
||||
},
|
||||
pickers = {
|
||||
find_files = { hidden = true }, -- show dotfiles; respects .gitignore
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Faster sorting (native fzf) — optional but great
|
||||
{
|
||||
"nvim-telescope/telescope-fzf-native.nvim",
|
||||
build = "make",
|
||||
cond = function() return vim.fn.executable("make") == 1 end,
|
||||
config = function()
|
||||
pcall(function() require("telescope").load_extension("fzf") end)
|
||||
end,
|
||||
},
|
||||
|
||||
-- Nicer UI for vim.ui.select/inputs (optional)
|
||||
{
|
||||
"nvim-telescope/telescope-ui-select.nvim",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
pcall(function() require("telescope").load_extension("ui-select") end)
|
||||
end,
|
||||
},
|
||||
-- Completion engine
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
event = "InsertEnter", -- load when you start typing
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp", -- LSP source for cmp
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
{
|
||||
"L3MON4D3/LuaSnip", -- snippet engine (needed for LSP snippet expansion)
|
||||
config = function()
|
||||
|
||||
pcall(require, "c.snippets")
|
||||
|
||||
end
|
||||
|
||||
}
|
||||
},
|
||||
opts = function()
|
||||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
return {
|
||||
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-Space>"] = cmp.mapping.complete(), -- manually trigger
|
||||
["<CR>"] = cmp.mapping.confirm({ select = false }), -- confirm selected (don’t auto-pick)
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||
["<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 = {
|
||||
{ name = "nvim_lsp" }, -- LSP completions (clangd, etc.)
|
||||
{ name = "luasnip" },
|
||||
-- you can add { name = "path" }, { name = "buffer" } later if you want
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
-- Auto-close (), {}, [], "", '' and more
|
||||
{
|
||||
"windwp/nvim-autopairs",
|
||||
event = "InsertEnter",
|
||||
opts = {
|
||||
check_ts = true, -- respects treesitter contexts if you have it
|
||||
disable_filetype = { "TelescopePrompt", "neo-tree" },
|
||||
fast_wrap = {}, -- enables <M-e> fast wrap (optional)
|
||||
},
|
||||
config = function(_, opts)
|
||||
local npairs = require("nvim-autopairs")
|
||||
npairs.setup(opts)
|
||||
|
||||
-- Integrate with nvim-cmp so confirming a function adds () and places cursor inside
|
||||
local ok_cmp, cmp = pcall(require, "cmp")
|
||||
if ok_cmp then
|
||||
local cmp_ap = require("nvim-autopairs.completion.cmp")
|
||||
cmp.event:on("confirm_done", cmp_ap.on_confirm_done())
|
||||
end
|
||||
|
||||
-- OPTIONAL (C quality-of-life):
|
||||
-- Pair < > only when typing #include <...>
|
||||
-- (By default, we *don't* pair < > in C to avoid accidental inserts.)
|
||||
local Rule = require("nvim-autopairs.rule")
|
||||
npairs.add_rules({
|
||||
Rule("<", ">", "c")
|
||||
:with_pair(function(ctx)
|
||||
local line = ctx.line:sub(1, ctx.col - 1)
|
||||
return line:match("^%s*#%s*include%s*$") ~= nil
|
||||
end),
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
build = ":TSUpdate",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
opts = {
|
||||
ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "bash", "make" },
|
||||
highlight = { enable = true },
|
||||
indent = { enable = false }, -- keep off; clang-format handles indent on save
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "gnn", -- start selection
|
||||
node_incremental = "grn", -- grow to next node
|
||||
node_decremental = "grm", -- shrink
|
||||
scope_incremental = "grc", -- grow to scope
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("nvim-treesitter.configs").setup(opts)
|
||||
end,
|
||||
},
|
||||
{ "folke/trouble.nvim", cmd = { "Trouble", "TroubleToggle" }, opts = {} }
|
||||
}
|
||||
Reference in New Issue
Block a user