From 2afffb04887c698a1a456c80624978c6407c39f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Dom=C3=ADnguez=20Ochoa?= Date: Wed, 8 Apr 2026 22:15:47 +0200 Subject: [PATCH] finalize 0.12.1 config - last touches and doc --- nvim/.config/nvim/README.md | 214 +++++++++------------- nvim/.config/nvim/lua/ink/init.lua | 42 ++++- nvim/.config/nvim/lua/ink/lsp.lua | 9 - nvim/.config/nvim/lua/ink/tabline.lua | 114 ++++++++++-- nvim/.config/nvim/lua/plugins/ai/init.lua | 7 + 5 files changed, 233 insertions(+), 153 deletions(-) diff --git a/nvim/.config/nvim/README.md b/nvim/.config/nvim/README.md index c2a8364..ad4e961 100644 --- a/nvim/.config/nvim/README.md +++ b/nvim/.config/nvim/README.md @@ -1,141 +1,107 @@ # Neovim Configuration -Keybinds reference for autocompletion, LSP, linting, diagnostics, and AI -features. Leader key is ``. +Keybinds reference for window management, file navigation, autocompletion, LSP, +linting, formatting, and AI features. Leader key is ``. Local leader is `\`. -## Autocompletion (blink.cmp) - -| 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| - -Completion is disabled in Avante's input buffer. - -### Snippets (LuaSnip) - -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 +## General & Window Management + +| Keybind | Mode | Description | +| ------------ | ------ | ---------------------------------------- | +| `sn` | Normal | Save without formatting | +| `w` | Normal | Toggle line wrapping | +| `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 | +| ``| Nor/Vis| Move screen up / down one line | + +## Buffer Management + +| Keybind | Mode | Description | +| ------------ | ------ | ---------------------------------------- | +| `` | Normal | Switch to next buffer | +| `` | Normal | Switch to previous buffer | +| `x` | Normal | Close buffer | +| `b` | Normal | Open new buffer | + +## Splits & Navigation (Tmux Integrated) + +| Keybind | Mode | Description | +| ------------ | ------ | ---------------------------------------- | +| `v` | Normal | Split vertical | +| `h` | Normal | Split horizontal | +| `xs` | Normal | Close split | +| `se` | Normal | Reset split sizes | +| `` | Normal | Move to split above | +| `` | Normal | Move to split below | +| `` | Normal | Move to split left | +| `` | Normal | Move to split right | +| `` | Normal | Move to last active split | +| `` | Normal | Move to next split | + +## File Explorer & Fuzzy Finding (Fzf-Lua / Oil) + +| Keybind | Mode | Description | +| ---------------- | ------ | ------------------------------------ | +| `pv` | Normal | Open file explorer (Oil) | +| `pf` | Normal | Fuzzy find project files | +| `ps` | Normal | Live grep project text | +| ``| Normal | Fuzzy find open buffers | +| `gf` | Normal | Fuzzy find tracked Git files | +| `f` | N/X/O | Jump to label | + +## Git Integration + +| Keybind | Mode | Description | +| ------------ | ------ | ---------------------------------------- | +| `gs` | Normal | Open Git status (Fugitive) | +| `gk` | Normal | Toggle inline Git blame | + +## Autocompletion (blink.cmp) + +| Keybind | Mode | Description | +| --------- | ------- | ------------------------------------------ | +| `Tab` | Command | Show and accept cmdline completion | + +Completion is handled natively via Blink and Neovim 0.11+ built-in +`vim.snippet`. CodeCompanion and LSP provide the completion sources. + +## LSP & Navigation + +| Keybind | Mode | Description | +| ------------ | ------ | ---------------------------------------- | +| `K` | Normal | Hover documentation | +| `gd` | Normal | Go to definition (Fzf-Lua) | +| `gD` | Normal | Go to declaration | +| `gr` | Normal | Go to references (Fzf-Lua) | +| `gI` | Normal | Go to implementation (Fzf-Lua) | +| `th` | Normal | Toggle Inlay Hints | + +## Linting, Diagnostics & Code Actions | Keybind | Mode | Description | | ------------ | ------ | ---------------------------------------- | -| `ca` | Normal | Code action menu | -| `ca` | Visual | Code action (quickfix for selection) | | `cf` | Normal | Apply quickfix at cursor | -| `ci` | Normal | Organize imports | - -### Navigation (Neovim 0.11+ built-ins) - -| Keybind | Mode | Description | -| ------- | ------ | -------------------- | -| `K` | Normal | Hover documentation | -| `gd` | Normal | Go to definition | -| `gD` | Normal | Go to declaration | -| `grr` | Normal | Go to references | -| `gri` | Normal | Go to implementation | -| `grn` | Normal | Rename symbol | - -### Inlay Hints - -Inlay hints are enabled automatically for any LSP that supports them. - -## Linting & Diagnostics - -| Keybind | Mode | Description | -| ------------ | ------------- | ---------------------------------- | -| `l` | Normal | Trigger linting for current file | -| `d` | Normal | Toggle inline diagnostics | -| `sd` | Normal | Search all diagnostics (Telescope) | +| `l` | Normal | Trigger linting for current file | +| `d` | Normal | Toggle inline diagnostics | +| `cd` | Normal | Copy diagnostic to clipboard | 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 | Keybind | Mode | Description | | ------------ | ------------- | --------------------------------- | -| `mp` | Normal/Visual | Format file or range | -| `sn` | Normal | Save without formatting | +| `mp` | Normal/Visual | Format file or range | -Format on save is enabled by default. +## AI (CodeCompanion) -### Configured Formatters +| Keybind | Mode | Description | +| ------------ | ------------- | --------------------------------- | +| `a` | Normal/Visual | Toggle CodeCompanion Chat | +| `ca` | Visual | Add visual selection to Chat | +| `ci` | Normal/Visual | Open inline prompt | +| `cp` | Normal/Visual | Open Action Palette | -| 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 | -| ------------ | ---------------- | --------------------- | -| `` | Normal/Visual/Insert | Toggle Avante sidebar | -| `aa` | Normal | Avante Ask | -| `ae` | Normal | Avante Edit | -| `ar` | Normal | Avante Refresh | - -### Sidebar (defaults) - -| Keybind | Description | -| --------- | ------------------------------- | -| `A` | Apply all suggestions | -| `a` | Apply suggestion at cursor | -| `r` | Retry user request | -| `e` | Edit user request | -| `` | Switch windows in sidebar | -| `` | 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. +Active provider is automatically selected: **Gemini** (if `GEMINI_API_KEY` is set) or **Kiro** (local model). diff --git a/nvim/.config/nvim/lua/ink/init.lua b/nvim/.config/nvim/lua/ink/init.lua index aba6199..c73cf02 100644 --- a/nvim/.config/nvim/lua/ink/init.lua +++ b/nvim/.config/nvim/lua/ink/init.lua @@ -47,7 +47,6 @@ vim.opt.cursorline = true vim.opt.splitbelow = true -- open new vertical split bottom 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.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 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 +}) diff --git a/nvim/.config/nvim/lua/ink/lsp.lua b/nvim/.config/nvim/lua/ink/lsp.lua index ef037c2..da21f7f 100644 --- a/nvim/.config/nvim/lua/ink/lsp.lua +++ b/nvim/.config/nvim/lua/ink/lsp.lua @@ -81,15 +81,6 @@ vim.api.nvim_create_autocmd("LspAttach", { apply = true, }) end, { buffer = bufnr, desc = "Apply fix at cursor" }) - - vim.keymap.set("n", "ci", function() - vim.lsp.buf.code_action({ - context = { - only = { "source.organizeImports.rust", "source.organizeImports" }, - }, - apply = true, - }) - end, { buffer = bufnr, desc = "Organize imports" }) end, }) diff --git a/nvim/.config/nvim/lua/ink/tabline.lua b/nvim/.config/nvim/lua/ink/tabline.lua index 8011dce..a6ae584 100644 --- a/nvim/.config/nvim/lua/ink/tabline.lua +++ b/nvim/.config/nvim/lua/ink/tabline.lua @@ -1,26 +1,102 @@ -local function tab_info() - local fname = vim.fn.expand("%:p") - if fname == "" then - return "" +local mru_bufs = {} + +-- Initialize with currently listed buffers +for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do + if vim.bo[bufnr].buflisted then + table.insert(mru_bufs, bufnr) end - return "%#WildMenu# " .. fname .. " %*" end ---- @return string -local function filestatus() - if vim.bo.modified == true then - return "%#Error# ● %*" - end - if vim.bo.readonly == true then - return "%#Error#  %*" - end - return "" -end +local augroup = vim.api.nvim_create_augroup("MRU_Buffers", { clear = true }) + +vim.api.nvim_create_autocmd("BufEnter", { + 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 + table.insert(mru_bufs, 1, bufnr) + 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() - return table.concat({ - tab_info(), - filestatus(), - }) + local current_buf = vim.api.nvim_get_current_buf() + local available_width = vim.o.columns + 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 + + -- 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.showtabline = 2 -- always show tabs + +-- Adds the buffer name to the top of each window +vim.opt.winbar = " %t %m" diff --git a/nvim/.config/nvim/lua/plugins/ai/init.lua b/nvim/.config/nvim/lua/plugins/ai/init.lua index e4fc947..7f9c5e4 100644 --- a/nvim/.config/nvim/lua/plugins/ai/init.lua +++ b/nvim/.config/nvim/lua/plugins/ai/init.lua @@ -48,6 +48,13 @@ codecompanion.setup({ -- Optional: Keymaps for CodeCompanion vim.keymap.set({ "n", "v" }, "a", "CodeCompanionChat Toggle", { noremap = true, silent = true }) +vim.keymap.set({ "n", "v" }, "a", "CodeCompanionChat Toggle", { noremap = true, silent = true }) +-- Inline prompt for buffer modifications (Generates diffs) +vim.keymap.set({ "n", "v" }, "ci", "CodeCompanion ", { noremap = true, silent = true }) +-- Add visual selection to chat +vim.keymap.set("v", "ca", "CodeCompanionChat Add", { noremap = true, silent = true }) +-- Action palette (Use this to Accept/Reject inline diffs) +vim.keymap.set({ "n", "v" }, "cp", "CodeCompanionActions", { noremap = true, silent = true }) vim.cmd([[cab cc CodeCompanion]]) vim.cmd("packadd blink.cmp")