1
0

finalize 0.12.1 config

This commit is contained in:
2026-04-08 20:57:09 +02:00
parent 372f3a7720
commit ed1cc8eedf
37 changed files with 144 additions and 2492 deletions

141
nvim/.config/nvim/README.md Normal file
View File

@@ -0,0 +1,141 @@
# Neovim Configuration
Keybinds reference for autocompletion, LSP, linting, diagnostics, and AI
features. Leader key is `<Space>`.
## 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
| 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 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`.
### 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
| 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.

View File

@@ -9,12 +9,11 @@ return {
loadOutDirsFromCheck = true,
runBuildScripts = true,
},
checkOnSave = {
check = {
command = "clippy",
},
completion = {
autoself = { enable = true },
snippets = { enable = true },
},
diagnostics = {
enable = true,

View File

@@ -19,6 +19,11 @@ vim.lsp.config("*", {
},
})
-- Add rounded borders to diagnostic floating windows
vim.diagnostic.config({
float = { border = "rounded" },
})
-- Consolidate all LSP actions into a single LspAttach autocmd
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", { clear = true }),
@@ -48,6 +53,25 @@ vim.api.nvim_create_autocmd("LspAttach", {
vim.opt_local.foldmethod = "expr"
end
-- [[ NAVIGATION ]]
vim.keymap.set("n", "gd", function()
require("fzf-lua").lsp_definitions()
end, { buffer = bufnr, desc = "Go to definition" })
vim.keymap.set("n", "gr", function()
require("fzf-lua").lsp_references()
end, { buffer = bufnr, desc = "Find references" })
vim.keymap.set("n", "gI", function()
require("fzf-lua").lsp_implementations()
end, { buffer = bufnr, desc = "Go to implementation" })
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { buffer = bufnr, desc = "Go to declaration" })
vim.keymap.set("n", "K", function()
vim.lsp.buf.hover({ border = "rounded", max_width = 120 })
end, { buffer = bufnr, desc = "Show documentation" })
-- [[ CODE ACTIONS ]]
-- Note: Neovim 0.11+ automatically maps 'gra' to code actions natively.

View File

@@ -21,13 +21,13 @@ codecompanion.setup({
gemini = function()
return require("codecompanion.adapters").extend("gemini", {
env = {
-- We read the API key from the environment variable.
-- We read the API key from the environment variable.
-- You can also use "cmd:pass show gemini/api_key" or "cmd:cat ~/.gemini_api_key"
api_key = os.getenv("GEMINI_API_KEY") or "cmd:cat ~/.gemini_api_key",
},
schema = {
model = {
default = "gemini-3.1-pro-preview",
default = "gemini-3.1-pro-preview",
},
},
})
@@ -55,7 +55,10 @@ local blink = require("blink.cmp")
blink.setup({
keymap = { preset = "default" },
appearance = { nerd_font_variant = "mono" },
completion = { documentation = { auto_show = true } },
completion = {
menu = { border = "rounded" },
documentation = { auto_show = true, window = { border = "rounded" } },
},
cmdline = {
keymap = { ["<Tab>"] = { "show", "accept" } },
@@ -88,6 +91,16 @@ blink.setup({
fuzzy = { implementation = "prefer_rust_with_warning" },
})
-- Ensure borders stay colored even after toggling light/dark themes
vim.api.nvim_create_autocmd("ColorScheme", {
pattern = "*",
callback = function()
vim.api.nvim_set_hl(0, "BlinkCmpMenuBorder", { link = "Special" })
vim.api.nvim_set_hl(0, "BlinkCmpDocBorder", { link = "Special" })
vim.api.nvim_set_hl(0, "FloatBorder", { link = "Special" })
end,
})
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = blink.get_lsp_capabilities(capabilities)

View File

@@ -4,6 +4,7 @@ vim.pack.add({
{ src = "https://github.com/stevearc/oil.nvim" },
{ src = "https://github.com/echasnovski/mini.icons" },
{ src = "https://github.com/yorickpeterse/nvim-jump" },
{ src = "https://github.com/ibhagwan/fzf-lua" },
})
require("which-key").setup({
preset = "helix",
@@ -20,3 +21,55 @@ require("oil").setup({
vim.keymap.set("n", "<leader>pv", "<cmd>Oil<cr>", { desc = "Open current directory" })
vim.keymap.set({ "n", "x", "o" }, "<leader>f", require("jump").start, {})
local function get_project_root()
-- 1. Prioritize Terraform or nvim config project root (keeps search local to the TF module)
local tf_root = vim.fs.root(0, { ".terraform", ".terraform.lock.hcl" })
local nvim_root = vim.fs.root(0, { "nvim-pack-lock.json" })
-- 2. Fallback to Git root (prioritizes the top-level repo for Rust/Go/etc.)
local git_root = vim.fs.root(0, ".git")
-- 3. Fallback to language markers if not in a git repo
local lang_root = vim.fs.root(0, {
"Cargo.toml",
"go.mod",
"pyproject.toml",
"requirements.txt",
"pom.xml",
"build.gradle",
".luarc.json",
})
-- Chain them in the exact priority order you want
return tf_root or nvim_root or git_root or lang_root or vim.fn.getcwd()
end
vim.keymap.set("n", "<leader>pf", function()
require("fzf-lua").files({ cwd = get_project_root() })
end, { desc = "Fuzzy find project files" })
vim.keymap.set("n", "<leader>ps", function()
require("fzf-lua").live_grep({ cwd = get_project_root() })
end, { desc = "Live grep project text" })
vim.keymap.set("n", "<leader><space>", function()
require("fzf-lua").buffers()
end, { desc = "Fuzzy find open files" })
vim.keymap.set("n", "<leader>gf", function()
require("fzf-lua").git_files()
end, { desc = "Fuzzy find tracked Git files" })
vim.api.nvim_create_autocmd("BufEnter", {
group = vim.api.nvim_create_augroup("AutoChdirProjectRoot", { clear = true }),
callback = function(args)
-- Only change directory for normal files
if vim.bo[args.buf].buftype == "" and vim.api.nvim_buf_get_name(args.buf) ~= "" then
local root = get_project_root()
if root and root ~= vim.fn.getcwd() then
vim.api.nvim_set_current_dir(root)
end
end
end,
})

View File

@@ -34,8 +34,46 @@ vim.api.nvim_create_autocmd({ "BufReadPre", "BufNewFile" }, {
if vim.diagnostic.config().virtual_lines then
vim.diagnostic.config({ virtual_lines = false })
else
vim.diagnostic.config({ virtual_lines = { current_line = true } })
vim.diagnostic.config({
virtual_lines = {
current_line = true,
format = function(diagnostic)
local max_width = vim.api.nvim_win_get_width(0) - 15
max_width = math.max(max_width, 30)
local wrapped = ""
local current_len = 0
for word in diagnostic.message:gmatch("%S+") do
if current_len + #word + 1 > max_width and current_len > 0 then
wrapped = wrapped .. "\n" .. word
current_len = #word
else
wrapped = wrapped == "" and word or (wrapped .. " " .. word)
current_len = current_len + #word + 1
end
end
return wrapped
end,
},
})
end
end, { desc = "Toggle inline diagnostics" })
vim.keymap.set("n", "<leader>cd", function()
local line = vim.api.nvim_win_get_cursor(0)[1] - 1
local diagnostics = vim.diagnostic.get(0, { lnum = line })
if #diagnostics == 0 then
vim.notify("No diagnostics on current line", vim.log.levels.WARN)
return
end
local messages = {}
for _, diag in ipairs(diagnostics) do
table.insert(messages, diag.message)
end
vim.fn.setreg("+", table.concat(messages, "\n"))
vim.notify("Copied diagnostic(s) to clipboard", vim.log.levels.INFO)
end, { desc = "Copy diagnostic to clipboard" })
end,
})

View File

@@ -7,7 +7,6 @@ vim.opt.cmdheight = 2 -- more space in the neovim command line for displaying me
vim.pack.add({
{ src = "https://github.com/rose-pine/neovim" },
{ src = "https://github.com/zaldih/themery.nvim" },
{ src = "https://github.com/mvllow/modes.nvim", version = "v0.3.0" },
{ src = "https://github.com/brenoprata10/nvim-highlight-colors" },
})
@@ -27,7 +26,6 @@ vim.keymap.set("n", "<leader>tt", function()
end, { noremap = true, desc = "Alternate between light and dark mode" })
require("nvim-highlight-colors").setup()
require("modes").setup()
vim.pack.add({
{ src = "https://github.com/nvim-tree/nvim-web-devicons" },

View File

@@ -13,6 +13,14 @@
"rev": "086a40dc7ed8242c03be9f47fbcee68699cc2395",
"src": "https://github.com/stevearc/conform.nvim"
},
"fidget.nvim": {
"rev": "889e2e96edef4e144965571d46f7a77bcc4d0ddf",
"src": "https://github.com/j-hui/fidget.nvim"
},
"fzf-lua": {
"rev": "9f0432fdd7825ab163520045831a40b6df82ea28",
"src": "https://github.com/ibhagwan/fzf-lua"
},
"git-blame.nvim": {
"rev": "5c536e2d4134d064aa3f41575280bc8a2a0e03d7",
"src": "https://github.com/f-person/git-blame.nvim"

View File

@@ -0,0 +1,3 @@
((text) @injection.content
(#set! injection.language "yaml")
(#set! injection.combined))