Port the live ~/.config/nvim working tree (bcherb2/nvim master plus its uncommitted git.lua and minimap.lua edits): adds claudecode, eslint, lsp, typescript, meow-yarn and refactoring-fix specs, drops the files the live repo deleted, and takes live for everything else. Kept from public: lazy.lua with luarocks disabled, the ai_assist cond guard (nvim-ai-assist is not anonymously clonable, so a fresh box only gets it from the private clone list), and the scrubbed endpoint comment in place of live's LAN address.
193 lines
11 KiB
Markdown
193 lines
11 KiB
Markdown
# Neovim Cheatsheet
|
||
|
||
What this LazyVim config adds or changes. `<leader>` is Space. Everything else is stock LazyVim:
|
||
`<leader>sk` searches all keymaps, `<leader>?` shows the current buffer's keymaps.
|
||
|
||
---
|
||
|
||
## Markdown (md-render.nvim, `lua/plugins/image.lua`)
|
||
|
||
Opening a `.md` file shows the **rendered view** (a separate read-only buffer, images and
|
||
mermaid/PlantUML diagrams drawn inline). The source buffer is what you edit.
|
||
|
||
| Key / command | What it does |
|
||
|---|---|
|
||
| `i` `I` `a` `A` `o` `O` | Jump to the source line and start inserting; leaving Insert re-renders. Fast typing keeps its order; a count works (`3o`) |
|
||
| `dd` `x` `p` `u` `<C-r>` `.` `J` `>` `gUU` `gq` … | Editing keys jump to the matching source line and run there |
|
||
| (wait ~200 ms) | After a normal-mode edit, the view returns to rendered once Neovim is idle |
|
||
| `yy`, Visual `y` / `Y` | Copy the **markdown source** behind the rows (linewise); the view stays rendered. A charwise selection inside one row is a normal yank |
|
||
| `v` / `V` | Jump to source and start Visual there. For a selection *in* the rendered view use a mouse drag, `<C-v>` or `gv` |
|
||
| `<leader>mr` | Render ⇄ source in place (mapped in the markdown source buffer) |
|
||
| `<leader>mp` / `<leader>mt` / `<leader>ms` | Preview in a wide float / a tab / a source+render split (source buffer) |
|
||
| `<leader>md` | md-render demo |
|
||
| `:MdRender toggle\|split\|tab\|float\|auto on\|off` | Same from the command line (works in the rendered view too) |
|
||
|
||
- **Diagram guard:** a destructive key (`dd`, `x`, `J`, `gUU`, …) on a rendered diagram does *not*
|
||
edit. It jumps to the diagram's opening fence and says so; edit the block there.
|
||
- A changed diagram re-renders in the background; you briefly see "Rendering mermaid diagram...".
|
||
- **Limits:** `dd` on a reflowed paragraph deletes only its first source line; `i`/`a` on a
|
||
diagram row insert at the closing fence.
|
||
- **Turn off return-to-render:** `vim.g.md_render_hop_return = false` (e.g. in `options.lua`).
|
||
- **render-markdown.nvim** only decorates floats (LSP hover, completion docs). Source buffers stay
|
||
plain; `:RenderMarkdown buf_toggle` turns it on for one buffer.
|
||
- No linters for markdown / mdx (`markdown.lua`); marksman diagnostics are muted.
|
||
|
||
---
|
||
|
||
## Clipboard and selections
|
||
|
||
`clipboard=unnamedplus` everywhere, so `y`/`p` use the system clipboard.
|
||
|
||
| Where nvim runs | Copy (`y`) | Paste (`p`) |
|
||
|---|---|---|
|
||
| **Inside tmux** | tmux buffer (`load-buffer -w`: also the outer terminal if tmux's `set-clipboard` allows) | tmux buffer; first asks the outer terminal (`refresh-client -l`), which may prompt (Ghostty) or not answer (Warp) |
|
||
| **SSH / herdr** (no tmux) | One OSC 52 copy to your Mac's clipboard | The last yank from **any nvim on this host** (`~/.local/state/nvim/clipboard/last`, mode 0600, survives reboots). Never reads the Mac clipboard |
|
||
| **Local macOS** | `pbcopy` | `pbpaste` |
|
||
|
||
- **Mac → nvim over SSH:** paste with the terminal, **Cmd-V** (works in every mode). There is no
|
||
runtime hint for this.
|
||
- Over 512 KiB a yank warns that the terminal may drop the OSC 52 payload; over 8 MiB it is not
|
||
shared with other instances.
|
||
|
||
| Selection | How you get it | Keys |
|
||
|---|---|---|
|
||
| **Select mode** | Shift+arrows | Typing replaces the selection at once (Space too). `<C-c>` copy, `<C-x>` cut, `<C-g>` switch to Visual |
|
||
| **Visual mode** | Mouse drag, `v`, `V`, `<C-v>` | `y` `d` `p` as usual; `<C-c>` also copies (`<C-x>` stays decrement) |
|
||
|
||
- `<leader>p` yank history (yanky). Over SSH the yank ring doesn't sync with the clipboard.
|
||
Yanks from the md-render view don't enter the ring.
|
||
- `<leader>cy` / `<leader>cY` copy the file's relative / absolute path.
|
||
|
||
---
|
||
|
||
## Search and replace (`lua/plugins/search.lua`)
|
||
|
||
| Key | What it does |
|
||
|---|---|
|
||
| `n` / `N` | Next / previous match, **always forward / backward** (even after `?`), opens folds, shows the hlslens `[i/n]` lens |
|
||
| `*` `#` `g*` `g#` | Word search with the lens |
|
||
| `<leader>Rs` (Visual) / `<leader>Ro` / `<leader>Rw` / `<leader>RW` / `<leader>Re` / `<leader>Rf` | search-replace.nvim, current buffer: selection / prompt / word / WORD / expression / filename |
|
||
| `<leader>Rbs` (Visual) / `<leader>Rbo` / `<leader>Rbw` / `<leader>RbW` / `<leader>Rbe` / `<leader>Rbf` | Same across all buffers |
|
||
| `<leader>sr` | LazyVim's grug-far search and replace (project-wide) |
|
||
| `<leader>rs` | Refactoring menu (LazyVim refactoring extra; `<leader>rf` extract function, `<leader>rx` extract variable, `<leader>ri` inline variable) |
|
||
|
||
- refactoring.nvim is pinned to `8bcf893` while Neovim is older than 0.12.5
|
||
(`lua/plugins/refactoring-fix.lua`). Newer commits call `vim.range`/`vim.pos` with the 0.12.5
|
||
signature and every refactor fails with `E5108 … vim/range.lua:98` on 0.12.1. After upgrading
|
||
Neovim, delete that file and run `:Lazy update refactoring.nvim`.
|
||
|
||
---
|
||
|
||
## Completion and AI
|
||
|
||
| Item | State |
|
||
|---|---|
|
||
| blink.cmp | On; sources LSP, path, snippets (no buffer words). Markdown: LSP + path only. friendly-snippets' global snippets (dates, lorem) off |
|
||
| `<leader>uk` | Toggle all insert-mode completion on/off (global) |
|
||
| Inline ghost text | **Off** (`vim.g.ai_cmp = false` in `options.lua`). Command-line ghost text is still on (not AI) |
|
||
| nvim_ai_assist (`:AI`) | **Disabled** (see below) |
|
||
| Claude Code (LazyVim extra) | `<leader>ac` toggle, `<leader>af` focus, `<leader>ar` resume, `<leader>aC` continue, `<leader>ab` add buffer, `<leader>as` send selection (Visual) / add file (neo-tree), `<leader>aa` / `<leader>ad` accept / deny diff |
|
||
|
||
---
|
||
|
||
## Git
|
||
|
||
| Key / command | What it does |
|
||
|---|---|
|
||
| git-blame.nvim | Blame as virtual text at column 80; `:GitBlameToggle`, `:GitBlameCopySHA`, `:GitBlameOpenCommitURL` |
|
||
| `<leader>gd` / `<leader>gh` / `<leader>gH` | Diffview: changes / file history / repo history |
|
||
| `<leader>dv` / `<leader>ds` / `<leader>dh` / `<leader>dH` | Diffview: open / staged / file history / all history |
|
||
| `<leader>go` / `<leader>uG` | mini.diff overlay / signs |
|
||
| `<leader>gb` / `<leader>gg` | Blame line / lazygit (LazyVim) |
|
||
|
||
In Diffview: `]c` `[c` hunks, `<Tab>` `<S-Tab>` files, `q` close (`:DiffviewClose`).
|
||
|
||
---
|
||
|
||
## UI
|
||
|
||
| Key | What it does |
|
||
|---|---|
|
||
| `<leader>um` / `<leader>uM` | Minimap (neominimap, on at start; shows diagnostics, mini.diff changes, search) toggle / focus |
|
||
| `<leader>uf` | LazyVim's auto-format toggle (global) |
|
||
| `<leader>ut` | Twilight (dim inactive code). Hides LazyVim's treesitter-context toggle: use `:TSContext toggle` |
|
||
| `<leader>uT` | Themery theme picker (`:Themery`). Hides LazyVim's treesitter-highlight toggle: use `:lua Snacks.toggle.treesitter():toggle()`. `<leader>uC` is LazyVim's colorscheme picker |
|
||
| `<leader>ug` | Indent guides (snacks.indent) |
|
||
|
||
Always on: hlargs (argument colours), smear-cursor, treesitter-context.
|
||
|
||
---
|
||
|
||
## Files and navigation
|
||
|
||
| Key | What it does |
|
||
|---|---|
|
||
| `<leader>e` / `<leader>E` | neo-tree (root / cwd); shows dotfiles, gitignored files and `*.log` |
|
||
| `<leader>ff` / `<leader><space>` | Find files (Telescope; includes hidden and gitignored files) |
|
||
| `<leader>/` / `<leader>sg` | Grep (includes gitignored files) |
|
||
| `<leader>fg` / `<leader>fb` / `<leader>fr` | Git files / buffers / recent |
|
||
| `<leader>sh` / `<leader>sk` | Help / keymaps |
|
||
| `<leader>H` / `<leader>h` / `<leader>1`–`<leader>9` | Harpoon: add file / menu / jump |
|
||
| `<leader>cs` / `<leader>ss` | Aerial outline / symbol search |
|
||
| `<leader>fp` | Projects |
|
||
| `<leader>cv` | CSV/TSV aligned view (in `.csv` / `.tsv` buffers) |
|
||
| `<leader>t…` | Tests (neotest, incl. vitest) |
|
||
| `<leader>sz` | chezmoi files |
|
||
|
||
TypeScript uses the `tsc` LSP from the lang.typescript.tsc extra (project-local TypeScript 7 when present).
|
||
|
||
---
|
||
|
||
## Disabled on purpose (and how to undo)
|
||
|
||
| Plugin / feature | Why | Re-enable |
|
||
|---|---|---|
|
||
| nvim-tree | neo-tree is the explorer; both fought over `<leader>e` | Delete `enabled = false` in `lua/plugins/nvim-tree.lua` |
|
||
| indent-blankline | snacks.indent already draws guides | Delete `enabled = false` in `lua/plugins/indent.lua` |
|
||
| nvim_ai_assist (`:AI`) | AI off | Delete `enabled = false` in `lua/plugins/ai_assist.lua` |
|
||
| noice.nvim | Caused treesitter errors | Delete `lua/plugins/noice-fix.lua` |
|
||
| Inline AI ghost text | AI off | `vim.g.ai_cmp = true` in `lua/config/options.lua` |
|
||
| md-render return-to-render | — (on) | `vim.g.md_render_hop_return = false` turns it off |
|
||
| render-markdown in source buffers | md-render owns the rendered view | Remove the `overrides` line in `ui-enhancements.lua`, or `:RenderMarkdown buf_toggle` |
|
||
| refactoring.nvim updates | Pinned to `8bcf893`: newer commits need Neovim 0.12.5 | Upgrade Neovim, delete `lua/plugins/refactoring-fix.lua`, `:Lazy update refactoring.nvim` |
|
||
|
||
---
|
||
|
||
## Files
|
||
|
||
```
|
||
~/.config/nvim/
|
||
├── init.lua # loads config.lazy
|
||
├── lazyvim.json # enabled LazyVim extras
|
||
├── lazy-lock.json # plugin versions
|
||
└── lua/
|
||
├── config/
|
||
│ ├── options.lua # ai_cmp off, clipboard providers, Select/Visual setup
|
||
│ ├── keymaps.lua # <leader>cy/cY, <C-c>/<C-x> copy/cut
|
||
│ ├── autocmds.lua # (empty)
|
||
│ └── lazy.lua # lazy.nvim bootstrap
|
||
└── plugins/
|
||
├── image.lua # md-render: auto render, hop keys, yank, mermaid, image transport
|
||
├── ui-enhancements.lua # render-markdown (floats only), hlargs, twilight, themery
|
||
├── themes.lua # colorscheme plugins for themery
|
||
├── search.lua # hlslens n/N, search-replace (<leader>R)
|
||
├── git.lua # git-blame, diffview (options + <leader>g keys)
|
||
├── diffview.lua # diffview <leader>d keys
|
||
├── minimap.lua # neominimap (<leader>um / <leader>uM)
|
||
├── blink.lua # completion sources, <leader>uk
|
||
├── claudecode.lua # Claude Code selection maps in Visual only
|
||
├── ai_assist.lua # nvim_ai_assist (disabled)
|
||
├── yanky.lua # no ring/clipboard sync over SSH
|
||
├── telescope.lua # show hidden + ignored files
|
||
├── neo-tree-extras.lua # show dotfiles / gitignored / *.log
|
||
├── filetypes.lua # csvview
|
||
├── markdown.lua # no markdown linting / marksman diagnostics
|
||
├── lsp.lua # gD only where the server supports it
|
||
├── refactoring-fix.lua # pin refactoring.nvim on Neovim < 0.12.5
|
||
├── typescript.lua # neotest-vitest
|
||
├── smear_cursor.lua # smear-cursor options
|
||
├── indent.lua # indent-blankline (disabled)
|
||
├── nvim-tree.lua # nvim-tree (disabled)
|
||
└── noice-fix.lua # noice (disabled)
|
||
```
|