nix/docs/nvim.md

244 lines
4.8 KiB
Markdown

# Neovim Configuration
Leader key: `<Space>`
## Files & Buffers
| Key | Action |
|-----|--------|
| `<leader>ex` | Toggle file tree |
| `<leader>fs` | Save file |
| `<leader>ff` | Find file |
| `<leader>fr` | Find recent file |
| `<leader>sf` | Search git files |
| `<leader>bb` | List buffers |
| `<leader><leader>` | List buffers |
| `<leader>bd` | Delete buffer |
| `<leader>.` | Scratch buffer |
## Search
| Key | Action |
|-----|--------|
| `<leader>sg` | Search grep |
| `<leader>sw` | Search grep word |
| `<leader>sb` | Buffer lines |
| `<leader>sB` | Grep open buffers |
| `<leader>:` | Command history |
## LSP
| Key | Action |
|-----|--------|
| `gd` | Goto definition |
| `gD` | Goto declaration |
| `gr` | References |
| `gI` | Goto implementation |
| `gy` | Goto type definition |
| `gai` | Incoming calls |
| `gao` | Outgoing calls |
| `K` | Hover documentation |
| `<leader>rn` | Rename symbol |
| `<leader>ca` | Code action |
| `<leader>d` | Show diagnostic |
| `[d` / `]d` | Previous / next diagnostic |
| `<leader>ls` | LSP symbols |
| `<leader>lS` | LSP workspace symbols |
## Git
| Key | Action |
|-----|--------|
| `<leader>gg` | Open Neogit |
| `<leader>gb` | Git branches |
| `<leader>gl` | Git log |
| `<leader>gL` | Git log (file) |
| `<leader>gs` | Git status |
| `<leader>gS` | Git stash |
| `<leader>gd` | Git diff (hunks) |
| `<leader>gi` | GitHub issues (open) |
| `<leader>gI` | GitHub issues (all) |
| `<leader>gp` | GitHub PRs (open) |
| `<leader>gP` | GitHub PRs (all) |
## Grapple (Harpoon-style marks)
| Key | Action |
|-----|--------|
| `<leader>ma` | Toggle tag |
| `<leader>mm` | Tags menu |
| `<leader>m1-4` | Select tag 1-4 |
| `<leader>mn` | Next tag |
| `<leader>mp` | Previous tag |
| `<leader>mga` | Add global tag |
| `<leader>mgm` | Global tags menu |
## Claude Code
| Key | Action |
|-----|--------|
| `<leader>ac` | Toggle Claude |
| `<leader>af` | Focus Claude |
| `<leader>ar` | Resume Claude |
| `<leader>aC` | Continue Claude |
| `<leader>am` | Select Claude model |
| `<leader>ab` | Add current buffer |
| `<leader>as` | Send to Claude (visual) |
| `<leader>aa` | Accept diff |
| `<leader>ad` | Deny diff |
## Code / Config
| Key | Action |
|-----|--------|
| `<leader>cc` | Compile |
| `<leader>cC` | Recompile |
| `<leader>cf` | Format buffer |
| `<leader>cr` | Reload config |
| `<leader>ce` | Edit config |
| `<leader>ch` | Check health |
## Windows
| Key | Action |
|-----|--------|
| `<leader>wh/j/k/l` | Navigate windows |
| `<leader>ws` | Split horizontal |
| `<leader>wv` | Split vertical |
| `<leader>wq` | Close window |
| `<C-h/j/k/l>` | Move to tmux pane |
## Quickfix
| Key | Action |
|-----|--------|
| `<leader>qq` | Open/focus quickfix |
| `<leader>ql` | Toggle loclist |
| `>` | Expand quickfix context |
| `<` | Collapse quickfix context |
## Utilities
| Key | Action |
|-----|--------|
| `<leader>ut` | Toggle undotree |
| `<leader>zz` | Toggle zen mode |
| `<leader>zm` | Toggle zoom |
## R (in R files)
| Key | Action |
|-----|--------|
| `<leader>rs` | Start R |
| `<leader>rq` | Close R |
| `<leader>rl` | Send line to R |
| `<leader>rs` | Send selection to R (visual) |
| `<leader>rf` | Send file to R |
| `<leader>ro` | Show function args |
| `<leader>rh` | R help |
## Treesitter
### Incremental Selection
Select code based on AST nodes - expand or shrink selection intelligently.
| Key | Action |
|-----|--------|
| `vv` | Start treesitter selection |
| `<Tab>` | Expand to larger node |
| `<S-Tab>` | Shrink to smaller node |
| `<C-Tab>` | Expand to full scope |
### Text Objects
Use with operators like `v` (visual), `d` (delete), `c` (change), `y` (yank).
| Key | Description |
|-----|-------------|
| `af` / `if` | Outer / inner function |
| `ac` / `ic` | Outer / inner class |
| `aa` / `ia` | Outer / inner argument |
| `ai` / `ii` | Outer / inner conditional |
| `al` / `il` | Outer / inner loop |
| `ab` / `ib` | Outer / inner block |
Examples:
- `vaf` - select entire function
- `dif` - delete function body
- `caa` - change an argument
- `yic` - yank inner class
### Movement
Jump between functions, classes, and arguments.
| Key | Action |
|-----|--------|
| `]f` / `[f` | Next / previous function start |
| `]F` / `[F` | Next / previous function end |
| `]c` / `[c` | Next / previous class start |
| `]C` / `[C` | Next / previous class end |
| `]a` / `[a` | Next / previous argument |
### Swap
| Key | Action |
|-----|--------|
| `<leader>a` | Swap argument with next |
| `<leader>A` | Swap argument with previous |
## Git Rebase (in gitrebase files)
| Key | Action |
|-----|--------|
| `p` | Pick |
| `r` | Reword |
| `e` | Edit |
| `s` | Squash |
| `f` | Fixup |
| `d` | Drop |
| `x` | Exec |
| `<C-n>` / `<C-j>` | Move line down |
| `<C-p>` / `<C-k>` | Move line up |
## Terminal
| Key | Action |
|-----|--------|
| `<C-q>` | Exit terminal mode |