1
0

finalize 0.12.1 config - last touches and doc

This commit is contained in:
2026-04-08 22:15:47 +02:00
parent ed1cc8eedf
commit 2afffb0488
5 changed files with 233 additions and 153 deletions

View File

@@ -1,141 +1,107 @@
# Neovim Configuration # Neovim Configuration
Keybinds reference for autocompletion, LSP, linting, diagnostics, and AI Keybinds reference for window management, file navigation, autocompletion, LSP,
features. Leader key is `<Space>`. linting, formatting, and AI features. Leader key is `<Space>`. Local leader is `\`.
## General & Window Management
| Keybind | Mode | Description |
| ------------ | ------ | ---------------------------------------- |
| `<leader>sn` | Normal | Save without formatting |
| `<leader>w` | Normal | Toggle line wrapping |
| `<leader>tt` | Normal | Alternate light/dark theme (Themery) |
| `x` | Nor/Vis| Remove char under cursor without yank |
| `p` | Visual | Paste without yanking underlying text |
| `<` / `>` | Visual | Indent left / right |
| `gl` | Normal | Jump to last change |
| `<C-up/down>`| Nor/Vis| Move screen up / down one line |
## Buffer Management
| Keybind | Mode | Description |
| ------------ | ------ | ---------------------------------------- |
| `<Tab>` | Normal | Switch to next buffer |
| `<S-Tab>` | Normal | Switch to previous buffer |
| `<leader>x` | Normal | Close buffer |
| `<leader>b` | Normal | Open new buffer |
## Splits & Navigation (Tmux Integrated)
| Keybind | Mode | Description |
| ------------ | ------ | ---------------------------------------- |
| `<leader>v` | Normal | Split vertical |
| `<leader>h` | Normal | Split horizontal |
| `<leader>xs` | Normal | Close split |
| `<leader>se` | Normal | Reset split sizes |
| `<S-up>` | Normal | Move to split above |
| `<S-down>` | Normal | Move to split below |
| `<S-left>` | Normal | Move to split left |
| `<S-right>` | Normal | Move to split right |
| `<C-\>` | Normal | Move to last active split |
| `<C-Space>` | Normal | Move to next split |
## File Explorer & Fuzzy Finding (Fzf-Lua / Oil)
| Keybind | Mode | Description |
| ---------------- | ------ | ------------------------------------ |
| `<leader>pv` | Normal | Open file explorer (Oil) |
| `<leader>pf` | Normal | Fuzzy find project files |
| `<leader>ps` | Normal | Live grep project text |
| `<leader><space>`| Normal | Fuzzy find open buffers |
| `<leader>gf` | Normal | Fuzzy find tracked Git files |
| `<leader>f` | N/X/O | Jump to label |
## Git Integration
| Keybind | Mode | Description |
| ------------ | ------ | ---------------------------------------- |
| `<leader>gs` | Normal | Open Git status (Fugitive) |
| `<leader>gk` | Normal | Toggle inline Git blame |
## Autocompletion (blink.cmp) ## Autocompletion (blink.cmp)
| Keybind | Mode | Description | | Keybind | Mode | Description |
| --------- | ------- | --------------------------------- | | --------- | ------- | ------------------------------------------ |
| `C-y` | Insert | Accept completion |
| `C-space` | Insert | Open menu or toggle docs |
| `C-n` | Insert | Select next item |
| `C-p` | Insert | Select previous item |
| `C-e` | Insert | Dismiss completion menu |
| `C-k` | Insert | Toggle signature help |
| `Tab` | Command | Show and accept cmdline completion | | `Tab` | Command | Show and accept cmdline completion |
Completion is disabled in Avante's input buffer. Completion is handled natively via Blink and Neovim 0.11+ built-in
`vim.snippet`. CodeCompanion and LSP provide the completion sources.
### Snippets (LuaSnip) ## LSP & Navigation
Snippets are available for Lua, Rust, Bash, Python, and Terraform. Type a
snippet prefix and accept it from the completion menu (`C-y`).
## LSP
### Code Actions & Refactoring
| Keybind | Mode | Description | | Keybind | Mode | Description |
| ------------ | ------ | ---------------------------------------- | | ------------ | ------ | ---------------------------------------- |
| `<leader>ca` | Normal | Code action menu |
| `<leader>ca` | Visual | Code action (quickfix for selection) |
| `<leader>cf` | Normal | Apply quickfix at cursor |
| `<leader>ci` | Normal | Organize imports |
### Navigation (Neovim 0.11+ built-ins)
| Keybind | Mode | Description |
| ------- | ------ | -------------------- |
| `K` | Normal | Hover documentation | | `K` | Normal | Hover documentation |
| `gd` | Normal | Go to definition | | `gd` | Normal | Go to definition (Fzf-Lua) |
| `gD` | Normal | Go to declaration | | `gD` | Normal | Go to declaration |
| `grr` | Normal | Go to references | | `gr` | Normal | Go to references (Fzf-Lua) |
| `gri` | Normal | Go to implementation | | `gI` | Normal | Go to implementation (Fzf-Lua) |
| `grn` | Normal | Rename symbol | | `<leader>th` | Normal | Toggle Inlay Hints |
### Inlay Hints ## Linting, Diagnostics & Code Actions
Inlay hints are enabled automatically for any LSP that supports them.
## Linting & Diagnostics
| Keybind | Mode | Description | | Keybind | Mode | Description |
| ------------ | ------------- | ---------------------------------- | | ------------ | ------ | ---------------------------------------- |
| `<leader>cf` | Normal | Apply quickfix at cursor |
| `<leader>l` | Normal | Trigger linting for current file | | `<leader>l` | Normal | Trigger linting for current file |
| `<leader>d` | Normal | Toggle inline diagnostics | | `<leader>d` | Normal | Toggle inline diagnostics |
| `<leader>sd` | Normal | Search all diagnostics (Telescope) | | `<leader>cd` | Normal | Copy diagnostic to clipboard |
Linting runs automatically on `BufEnter`, `BufWritePost`, and `InsertLeave`. Linting runs automatically on `BufEnter`, `BufWritePost`, and `InsertLeave`.
### Configured Linters
| Language | Linter |
| ---------- | ---------------- |
| Lua | luacheck |
| Bash / sh | shellcheck |
| Terraform | tflint |
| Markdown | markdownlint-cli2|
| Go | golangci-lint |
## Formatting ## Formatting
| Keybind | Mode | Description | | Keybind | Mode | Description |
| ------------ | ------------- | --------------------------------- | | ------------ | ------------- | --------------------------------- |
| `<leader>mp` | Normal/Visual | Format file or range | | `<leader>mp` | Normal/Visual | Format file or range |
| `<leader>sn` | Normal | Save without formatting |
Format on save is enabled by default. ## AI (CodeCompanion)
### Configured Formatters
| Language | Formatter |
| --------------- | --------------- |
| Lua | stylua |
| Rust | rustfmt |
| Go | gofumpt |
| Python | ruff |
| Bash / sh / zsh | shfmt |
| JSON | prettier |
| YAML | yamlfmt |
| Markdown | markdownlint-cli2|
| Terraform | terraform_fmt |
## AI (Avante)
Provider is selected automatically: **Cursor ACP** when `~/.local/bin/agent`
exists, otherwise **Gemini API** (requires `GEMINI_API_KEY`).
All tool calls require explicit approval (`auto_approve_tool_permissions = false`).
### Global Keybinds
| Keybind | Mode | Description | | Keybind | Mode | Description |
| ------------ | ---------------- | --------------------- | | ------------ | ------------- | --------------------------------- |
| `<C-\>` | Normal/Visual/Insert | Toggle Avante sidebar | | `<leader>a` | Normal/Visual | Toggle CodeCompanion Chat |
| `<leader>aa` | Normal | Avante Ask | | `<leader>ca` | Visual | Add visual selection to Chat |
| `<leader>ae` | Normal | Avante Edit | | `<leader>ci` | Normal/Visual | Open inline prompt |
| `<leader>ar` | Normal | Avante Refresh | | `<leader>cp` | Normal/Visual | Open Action Palette |
### Sidebar (defaults) Active provider is automatically selected: **Gemini** (if `GEMINI_API_KEY` is set) or **Kiro** (local model).
| Keybind | Description |
| --------- | ------------------------------- |
| `A` | Apply all suggestions |
| `a` | Apply suggestion at cursor |
| `r` | Retry user request |
| `e` | Edit user request |
| `<Tab>` | Switch windows in sidebar |
| `<S-Tab>` | Reverse switch windows |
| `@` | Add file to context |
| `d` | Remove file from context |
| `q` | Close sidebar |
### Diff Review
When changes are proposed and applied, a conflict-style diff appears in the
buffer. Use these keybinds to accept or reject hunks:
| Keybind | Description |
| ----------- | ------------------------ |
| `co` | Choose ours (original) |
| `ct` | Choose theirs (suggested)|
| `ca` | Accept all theirs |
| `cb` | Choose both |
| `cc` | Choose at cursor |
| `]x` / `[x` | Next / previous diff hunk |
### Input Buffer
The Avante input prompt auto-resizes to fit your text (up to 20 lines) and
shrinks back after sending.

View File

@@ -47,7 +47,6 @@ vim.opt.cursorline = true
vim.opt.splitbelow = true -- open new vertical split bottom vim.opt.splitbelow = true -- open new vertical split bottom
vim.opt.splitright = true -- open new horizontal splits right vim.opt.splitright = true -- open new horizontal splits right
vim.opt.showtabline = 2 -- always show tabs
vim.opt.pumheight = 10 -- pop up menu height vim.opt.pumheight = 10 -- pop up menu height
vim.opt.shortmess:append("c") -- don't give |ins-completion-menu| messages vim.opt.shortmess:append("c") -- don't give |ins-completion-menu| messages
@@ -102,3 +101,44 @@ vim.api.nvim_create_autocmd({ "VimEnter", "VimLeave" }, {
-- --
-- Filetypes to enable spellcheck -- Filetypes to enable spellcheck
local spell_types = { "text", "plaintex", "typst", "gitcommit", "markdown" } local spell_types = { "text", "plaintex", "typst", "gitcommit", "markdown" }
-- add gotmpl filetypes for blueprint repos
-- *.ext.tmpl files use the filetype of ext (e.g. foo.json.tmpl -> json, bar.sh.tmpl -> bash)
vim.filetype.add({
extension = {
gotmpl = "gotmpl",
},
pattern = {
[".*/recipes/.*%.ya?ml"] = "gotmpl",
[".*%.tmpl$"] = function(path)
local name = vim.fn.fnamemodify(path, ":t")
local base = name:match("^(.+)%.tmpl$")
if base then
local ext = base:match("%.(%w+)$")
if ext then
if ext == "sh" then
return "bash"
end
return ext
end
end
return nil
end,
},
})
-- Set global spell option to false initially to disable it for all file types
vim.opt.spell = false
-- Create an augroup for spellcheck to group related autocommands
vim.api.nvim_create_augroup("Spellcheck", { clear = true })
-- Create an autocommand to enable spellcheck for specified file types
vim.api.nvim_create_autocmd({ "FileType" }, {
group = "Spellcheck", -- Grouping the command for easier management
pattern = spell_types, -- Only apply to these file types
callback = function()
vim.opt_local.spell = true -- Enable spellcheck for these file types
end,
desc = "Enable spellcheck for defined filetypes", -- Description for clarity
})

View File

@@ -81,15 +81,6 @@ vim.api.nvim_create_autocmd("LspAttach", {
apply = true, apply = true,
}) })
end, { buffer = bufnr, desc = "Apply fix at cursor" }) end, { buffer = bufnr, desc = "Apply fix at cursor" })
vim.keymap.set("n", "<leader>ci", function()
vim.lsp.buf.code_action({
context = {
only = { "source.organizeImports.rust", "source.organizeImports" },
},
apply = true,
})
end, { buffer = bufnr, desc = "Organize imports" })
end, end,
}) })

View File

@@ -1,26 +1,102 @@
local function tab_info() local mru_bufs = {}
local fname = vim.fn.expand("%:p")
if fname == "" then -- Initialize with currently listed buffers
return "" for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
if vim.bo[bufnr].buflisted then
table.insert(mru_bufs, bufnr)
end end
return "%#WildMenu# " .. fname .. " %*"
end end
--- @return string local augroup = vim.api.nvim_create_augroup("MRU_Buffers", { clear = true })
local function filestatus()
if vim.bo.modified == true then vim.api.nvim_create_autocmd("BufEnter", {
return "%#Error# ● %*" group = augroup,
callback = function(args)
local bufnr = args.buf
if vim.bo[bufnr].buflisted then
for i, b in ipairs(mru_bufs) do
if b == bufnr then
table.remove(mru_bufs, i)
break
end end
if vim.bo.readonly == true then
return "%#Error#  %*"
end end
return "" table.insert(mru_bufs, 1, bufnr)
end end
end,
})
vim.api.nvim_create_autocmd("BufDelete", {
group = augroup,
callback = function(args)
local bufnr = args.buf
for i, b in ipairs(mru_bufs) do
if b == bufnr then
table.remove(mru_bufs, i)
break
end
end
end,
})
function _G.TabLine() function _G.TabLine()
return table.concat({ local current_buf = vim.api.nvim_get_current_buf()
tab_info(), local available_width = vim.o.columns
filestatus(), local used_width = 0
}) local tabline = ""
local ellipsis = "%#TabLineFill# ..."
local valid_bufs = {}
-- 1. Always place the current buffer first
if vim.bo[current_buf].buflisted then
table.insert(valid_bufs, current_buf)
end end
-- 2. Add the rest of the buffers in native ID order (matches :bnext)
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
if bufnr ~= current_buf and vim.api.nvim_buf_is_valid(bufnr) and vim.bo[bufnr].buflisted then
table.insert(valid_bufs, bufnr)
end
end
for _, bufnr in ipairs(valid_bufs) do
local is_current = (bufnr == current_buf)
local name = vim.api.nvim_buf_get_name(bufnr)
if name == "" then
name = "[No Name]"
end
local hl = is_current and "%#WildMenu#" or "%#TabLine#"
local status_raw = ""
local status_hl = ""
if vim.bo[bufnr].modified then
status_raw = status_raw .. ""
status_hl = status_hl .. "%#Error#● " .. hl
end
if vim.bo[bufnr].readonly then
status_raw = status_raw .. ""
status_hl = status_hl .. "%#Error# " .. hl
end
local text_to_measure = string.format(" %s %s", name, status_raw)
local display_width = vim.api.nvim_strwidth(text_to_measure)
if used_width + display_width > available_width - 4 then
tabline = tabline .. ellipsis
break
end
local segment = string.format("%s %s %s", hl, name, status_hl)
tabline = tabline .. segment
used_width = used_width + display_width
end
return tabline .. "%#TabLineFill#"
end
vim.opt.tabline = "%!v:lua.TabLine()" vim.opt.tabline = "%!v:lua.TabLine()"
vim.opt.showtabline = 2 -- always show tabs
-- Adds the buffer name to the top of each window
vim.opt.winbar = " %t %m"

View File

@@ -48,6 +48,13 @@ codecompanion.setup({
-- Optional: Keymaps for CodeCompanion -- Optional: Keymaps for CodeCompanion
vim.keymap.set({ "n", "v" }, "<leader>a", "<cmd>CodeCompanionChat Toggle<cr>", { noremap = true, silent = true }) vim.keymap.set({ "n", "v" }, "<leader>a", "<cmd>CodeCompanionChat Toggle<cr>", { noremap = true, silent = true })
vim.keymap.set({ "n", "v" }, "<leader>a", "<cmd>CodeCompanionChat Toggle<cr>", { noremap = true, silent = true })
-- Inline prompt for buffer modifications (Generates diffs)
vim.keymap.set({ "n", "v" }, "<leader>ci", "<cmd>CodeCompanion <cr>", { noremap = true, silent = true })
-- Add visual selection to chat
vim.keymap.set("v", "<leader>ca", "<cmd>CodeCompanionChat Add<cr>", { noremap = true, silent = true })
-- Action palette (Use this to Accept/Reject inline diffs)
vim.keymap.set({ "n", "v" }, "<leader>cp", "<cmd>CodeCompanionActions<cr>", { noremap = true, silent = true })
vim.cmd([[cab cc CodeCompanion]]) vim.cmd([[cab cc CodeCompanion]])
vim.cmd("packadd blink.cmp") vim.cmd("packadd blink.cmp")