finalize 0.12.1 config - last touches and doc
This commit is contained in:
@@ -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 `\`.
|
||||||
|
|
||||||
## Autocompletion (blink.cmp)
|
## General & Window Management
|
||||||
|
|
||||||
| Keybind | Mode | Description |
|
| Keybind | Mode | Description |
|
||||||
| --------- | ------- | --------------------------------- |
|
| ------------ | ------ | ---------------------------------------- |
|
||||||
| `C-y` | Insert | Accept completion |
|
| `<leader>sn` | Normal | Save without formatting |
|
||||||
| `C-space` | Insert | Open menu or toggle docs |
|
| `<leader>w` | Normal | Toggle line wrapping |
|
||||||
| `C-n` | Insert | Select next item |
|
| `<leader>tt` | Normal | Alternate light/dark theme (Themery) |
|
||||||
| `C-p` | Insert | Select previous item |
|
| `x` | Nor/Vis| Remove char under cursor without yank |
|
||||||
| `C-e` | Insert | Dismiss completion menu |
|
| `p` | Visual | Paste without yanking underlying text |
|
||||||
| `C-k` | Insert | Toggle signature help |
|
| `<` / `>` | Visual | Indent left / right |
|
||||||
| `Tab` | Command | Show and accept cmdline completion|
|
| `gl` | Normal | Jump to last change |
|
||||||
|
| `<C-up/down>`| Nor/Vis| Move screen up / down one line |
|
||||||
Completion is disabled in Avante's input buffer.
|
|
||||||
|
## Buffer Management
|
||||||
### Snippets (LuaSnip)
|
|
||||||
|
| Keybind | Mode | Description |
|
||||||
Snippets are available for Lua, Rust, Bash, Python, and Terraform. Type a
|
| ------------ | ------ | ---------------------------------------- |
|
||||||
snippet prefix and accept it from the completion menu (`C-y`).
|
| `<Tab>` | Normal | Switch to next buffer |
|
||||||
|
| `<S-Tab>` | Normal | Switch to previous buffer |
|
||||||
## LSP
|
| `<leader>x` | Normal | Close buffer |
|
||||||
|
| `<leader>b` | Normal | Open new buffer |
|
||||||
### Code Actions & Refactoring
|
|
||||||
|
## 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)
|
||||||
|
|
||||||
|
| 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) |
|
||||||
|
| `<leader>th` | Normal | Toggle Inlay Hints |
|
||||||
|
|
||||||
|
## Linting, Diagnostics & Code Actions
|
||||||
|
|
||||||
| 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>cf` | Normal | Apply quickfix at cursor |
|
||||||
| `<leader>ci` | Normal | Organize imports |
|
| `<leader>l` | Normal | Trigger linting for current file |
|
||||||
|
| `<leader>d` | Normal | Toggle inline diagnostics |
|
||||||
### Navigation (Neovim 0.11+ built-ins)
|
| `<leader>cd` | Normal | Copy diagnostic to clipboard |
|
||||||
|
|
||||||
| 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 |
|
|
||||||
| ------------ | ------------- | ---------------------------------- |
|
|
||||||
| `<leader>l` | Normal | Trigger linting for current file |
|
|
||||||
| `<leader>d` | Normal | Toggle inline diagnostics |
|
|
||||||
| `<leader>sd` | Normal | Search all diagnostics (Telescope) |
|
|
||||||
|
|
||||||
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
|
| Keybind | Mode | Description |
|
||||||
|
| ------------ | ------------- | --------------------------------- |
|
||||||
|
| `<leader>a` | Normal/Visual | Toggle CodeCompanion Chat |
|
||||||
|
| `<leader>ca` | Visual | Add visual selection to Chat |
|
||||||
|
| `<leader>ci` | Normal/Visual | Open inline prompt |
|
||||||
|
| `<leader>cp` | Normal/Visual | Open Action Palette |
|
||||||
|
|
||||||
| Language | Formatter |
|
Active provider is automatically selected: **Gemini** (if `GEMINI_API_KEY` is set) or **Kiro** (local model).
|
||||||
| --------------- | --------------- |
|
|
||||||
| 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 |
|
|
||||||
| ------------ | ---------------- | --------------------- |
|
|
||||||
| `<C-\>` | Normal/Visual/Insert | Toggle Avante sidebar |
|
|
||||||
| `<leader>aa` | Normal | Avante Ask |
|
|
||||||
| `<leader>ae` | Normal | Avante Edit |
|
|
||||||
| `<leader>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 |
|
|
||||||
| `<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.
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
})
|
||||||
|
|||||||
@@ -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,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
end
|
callback = function(args)
|
||||||
if vim.bo.readonly == true then
|
local bufnr = args.buf
|
||||||
return "%#Error# %*"
|
if vim.bo[bufnr].buflisted then
|
||||||
end
|
for i, b in ipairs(mru_bufs) do
|
||||||
return ""
|
if b == bufnr then
|
||||||
end
|
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()
|
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
|
||||||
|
|
||||||
|
-- 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
|
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"
|
||||||
|
|||||||
@@ -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")
|
||||||
|
|||||||
Reference in New Issue
Block a user