# 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.
