finalize 0.12.1 config - last touches and doc
This commit is contained in:
@@ -1,141 +1,107 @@
|
||||
# Neovim Configuration
|
||||
|
||||
Keybinds reference for autocompletion, LSP, linting, diagnostics, and AI
|
||||
features. Leader key is `<Space>`.
|
||||
Keybinds reference for window management, file navigation, autocompletion, LSP,
|
||||
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)
|
||||
|
||||
| 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)
|
||||
|
||||
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
|
||||
## LSP & Navigation
|
||||
|
||||
| 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 |
|
||||
| `gd` | Normal | Go to definition |
|
||||
| `gd` | Normal | Go to definition (Fzf-Lua) |
|
||||
| `gD` | Normal | Go to declaration |
|
||||
| `grr` | Normal | Go to references |
|
||||
| `gri` | Normal | Go to implementation |
|
||||
| `grn` | Normal | Rename symbol |
|
||||
| `gr` | Normal | Go to references (Fzf-Lua) |
|
||||
| `gI` | Normal | Go to implementation (Fzf-Lua) |
|
||||
| `<leader>th` | Normal | Toggle Inlay Hints |
|
||||
|
||||
### Inlay Hints
|
||||
|
||||
Inlay hints are enabled automatically for any LSP that supports them.
|
||||
|
||||
## Linting & Diagnostics
|
||||
## Linting, Diagnostics & Code Actions
|
||||
|
||||
| Keybind | Mode | Description |
|
||||
| ------------ | ------------- | ---------------------------------- |
|
||||
| ------------ | ------ | ---------------------------------------- |
|
||||
| `<leader>cf` | Normal | Apply quickfix at cursor |
|
||||
| `<leader>l` | Normal | Trigger linting for current file |
|
||||
| `<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`.
|
||||
|
||||
### Configured Linters
|
||||
|
||||
| Language | Linter |
|
||||
| ---------- | ---------------- |
|
||||
| Lua | luacheck |
|
||||
| Bash / sh | shellcheck |
|
||||
| Terraform | tflint |
|
||||
| Markdown | markdownlint-cli2|
|
||||
| Go | golangci-lint |
|
||||
|
||||
## Formatting
|
||||
|
||||
| Keybind | Mode | Description |
|
||||
| ------------ | ------------- | --------------------------------- |
|
||||
| `<leader>mp` | Normal/Visual | Format file or range |
|
||||
| `<leader>sn` | Normal | Save without formatting |
|
||||
|
||||
Format on save is enabled by default.
|
||||
|
||||
### 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
|
||||
## AI (CodeCompanion)
|
||||
|
||||
| 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 |
|
||||
| ------------ | ------------- | --------------------------------- |
|
||||
| `<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 |
|
||||
|
||||
### 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.
|
||||
Active provider is automatically selected: **Gemini** (if `GEMINI_API_KEY` is set) or **Kiro** (local model).
|
||||
|
||||
@@ -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
|
||||
})
|
||||
|
||||
@@ -81,15 +81,6 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
||||
apply = true,
|
||||
})
|
||||
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,
|
||||
})
|
||||
|
||||
|
||||
@@ -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# ● %*"
|
||||
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
|
||||
if vim.bo.readonly == true then
|
||||
return "%#Error# %*"
|
||||
end
|
||||
return ""
|
||||
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"
|
||||
|
||||
@@ -48,6 +48,13 @@ codecompanion.setup({
|
||||
|
||||
-- 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 })
|
||||
-- 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("packadd blink.cmp")
|
||||
|
||||
Reference in New Issue
Block a user