Initial neovim config
Lazy.nvim plugin manager, LSP (rust-analyzer, clangd, ts_ls, zls), treesitter, telescope, bufferline, neo-tree, gitsigns, lazygit, alabaster theme, persistence sessions, nvim-cmp, lualine, which-key. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
35
lua/config/autocmds.lua
Normal file
35
lua/config/autocmds.lua
Normal file
@@ -0,0 +1,35 @@
|
||||
local augroup = vim.api.nvim_create_augroup
|
||||
local autocmd = vim.api.nvim_create_autocmd
|
||||
|
||||
-- Highlight on yank
|
||||
autocmd("TextYankPost", {
|
||||
group = augroup("highlight_yank", { clear = true }),
|
||||
callback = function()
|
||||
vim.highlight.on_yank({ timeout = 200 })
|
||||
end,
|
||||
})
|
||||
|
||||
-- Remove trailing whitespace on save
|
||||
autocmd("BufWritePre", {
|
||||
group = augroup("trim_whitespace", { clear = true }),
|
||||
pattern = "*",
|
||||
command = "%s/\\s\\+$//e",
|
||||
})
|
||||
|
||||
-- Restore cursor position
|
||||
autocmd("BufReadPost", {
|
||||
group = augroup("restore_cursor", { clear = true }),
|
||||
callback = function()
|
||||
local mark = vim.api.nvim_buf_get_mark(0, '"')
|
||||
local lcount = vim.api.nvim_buf_line_count(0)
|
||||
if mark[1] > 0 and mark[1] <= lcount then
|
||||
pcall(vim.api.nvim_win_set_cursor, 0, mark)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Auto-resize splits on window resize
|
||||
autocmd("VimResized", {
|
||||
group = augroup("auto_resize", { clear = true }),
|
||||
command = "tabdo wincmd =",
|
||||
})
|
||||
47
lua/config/keymaps.lua
Normal file
47
lua/config/keymaps.lua
Normal file
@@ -0,0 +1,47 @@
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = " "
|
||||
|
||||
local map = vim.keymap.set
|
||||
|
||||
-- Better window navigation
|
||||
map("n", "<C-h>", "<C-w>h", { desc = "Go to left window" })
|
||||
map("n", "<C-j>", "<C-w>j", { desc = "Go to lower window" })
|
||||
map("n", "<C-k>", "<C-w>k", { desc = "Go to upper window" })
|
||||
map("n", "<C-l>", "<C-w>l", { desc = "Go to right window" })
|
||||
|
||||
-- Resize windows
|
||||
map("n", "<C-Up>", ":resize +2<CR>", { desc = "Increase window height" })
|
||||
map("n", "<C-Down>", ":resize -2<CR>", { desc = "Decrease window height" })
|
||||
map("n", "<C-Left>", ":vertical resize -2<CR>", { desc = "Decrease window width" })
|
||||
map("n", "<C-Right>", ":vertical resize +2<CR>", { desc = "Increase window width" })
|
||||
|
||||
-- Buffers
|
||||
map("n", "<S-l>", ":bnext<CR>", { desc = "Next buffer" })
|
||||
map("n", "<S-h>", ":bprevious<CR>", { desc = "Previous buffer" })
|
||||
map("n", "<leader>bd", ":bdelete<CR>", { desc = "Delete buffer" })
|
||||
|
||||
-- Move lines up/down in visual mode
|
||||
map("v", "J", ":m '>+1<CR>gv=gv", { desc = "Move selection down" })
|
||||
map("v", "K", ":m '<-2<CR>gv=gv", { desc = "Move selection up" })
|
||||
|
||||
-- Keep cursor centered when scrolling
|
||||
map("n", "<C-d>", "<C-d>zz")
|
||||
map("n", "<C-u>", "<C-u>zz")
|
||||
|
||||
-- Keep cursor centered on search results
|
||||
map("n", "n", "nzzzv")
|
||||
map("n", "N", "Nzzzv")
|
||||
|
||||
-- Clear search highlight
|
||||
map("n", "<Esc>", ":nohlsearch<CR>", { desc = "Clear search highlight" })
|
||||
|
||||
-- Better paste (don't override register)
|
||||
map("x", "<leader>p", '"_dP', { desc = "Paste without overwriting register" })
|
||||
|
||||
-- Save file
|
||||
map("n", "<C-s>", ":w<CR>", { desc = "Save file" })
|
||||
|
||||
-- Diagnostic navigation
|
||||
map("n", "[d", vim.diagnostic.goto_prev, { desc = "Previous diagnostic" })
|
||||
map("n", "]d", vim.diagnostic.goto_next, { desc = "Next diagnostic" })
|
||||
map("n", "<leader>e", vim.diagnostic.open_float, { desc = "Show diagnostic" })
|
||||
49
lua/config/options.lua
Normal file
49
lua/config/options.lua
Normal file
@@ -0,0 +1,49 @@
|
||||
local opt = vim.opt
|
||||
|
||||
-- Line numbers
|
||||
opt.number = true
|
||||
opt.relativenumber = true
|
||||
|
||||
-- Tabs & indentation
|
||||
opt.tabstop = 4
|
||||
opt.shiftwidth = 4
|
||||
opt.expandtab = true
|
||||
opt.smartindent = true
|
||||
|
||||
-- Search
|
||||
opt.ignorecase = true
|
||||
opt.smartcase = true
|
||||
opt.hlsearch = true
|
||||
opt.incsearch = true
|
||||
|
||||
-- Appearance
|
||||
opt.termguicolors = true
|
||||
opt.signcolumn = "yes"
|
||||
opt.cursorline = true
|
||||
opt.scrolloff = 8
|
||||
opt.sidescrolloff = 8
|
||||
|
||||
-- Line wrapping
|
||||
opt.wrap = false
|
||||
|
||||
-- Clipboard
|
||||
opt.clipboard = "unnamedplus"
|
||||
|
||||
-- Split behavior
|
||||
opt.splitright = true
|
||||
opt.splitbelow = true
|
||||
|
||||
-- Undo / swap
|
||||
opt.undofile = true
|
||||
opt.swapfile = false
|
||||
opt.backup = false
|
||||
|
||||
-- Performance
|
||||
opt.updatetime = 250
|
||||
opt.timeoutlen = 300
|
||||
|
||||
-- Completion menu
|
||||
opt.completeopt = "menuone,noselect"
|
||||
|
||||
-- File encoding
|
||||
opt.fileencoding = "utf-8"
|
||||
Reference in New Issue
Block a user