From 0aaaf514211200b451f6719d69e9199aca822ac5 Mon Sep 17 00:00:00 2001 From: bcherb2 Date: Wed, 18 Nov 2026 01:32:57 -0500 Subject: [PATCH] feat: nvim config tracks the live tree 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. --- private_dot_config/nvim/PLUGIN_CHEATSHEET.md | 308 ++++++------- private_dot_config/nvim/lazyvim.json | 6 +- .../nvim/lua/config/keymaps.lua | 24 + .../nvim/lua/config/options.lua | 114 ++++- .../nvim/lua/custom/keymaps.lua | 37 -- .../nvim/lua/plugins/ai_assist.lua | 2 +- private_dot_config/nvim/lua/plugins/blink.lua | 24 +- .../nvim/lua/plugins/claudecode.lua | 30 ++ .../nvim/lua/plugins/diffview.lua | 6 +- .../nvim/lua/plugins/eslint.lua | 27 ++ .../nvim/lua/plugins/example.lua | 197 --------- private_dot_config/nvim/lua/plugins/git.lua | 69 ++- private_dot_config/nvim/lua/plugins/image.lua | 412 +++++++++++++++++- .../nvim/lua/plugins/indent.lua | 4 + private_dot_config/nvim/lua/plugins/lsp.lua | 36 ++ .../nvim/lua/plugins/markdown-no-lint.lua | 12 - .../nvim/lua/plugins/markdown.lua | 1 + .../nvim/lua/plugins/meow-yarn.lua | 28 ++ .../nvim/lua/plugins/minimap.lua | 6 +- .../nvim/lua/plugins/minuet.lua | 115 ----- .../nvim/lua/plugins/navigation.lua | 3 - .../nvim/lua/plugins/neo-tree-extras.lua | 4 + .../nvim/lua/plugins/nvim-tree.lua | 4 + .../nvim/lua/plugins/refactoring-fix.lua | 21 + .../nvim/lua/plugins/refactoring.lua | 14 - .../nvim/lua/plugins/search.lua | 44 +- .../nvim/lua/plugins/typescript.lua | 59 +++ .../nvim/lua/plugins/ui-enhancements.lua | 5 + 28 files changed, 1001 insertions(+), 611 deletions(-) delete mode 100644 private_dot_config/nvim/lua/custom/keymaps.lua create mode 100644 private_dot_config/nvim/lua/plugins/claudecode.lua create mode 100644 private_dot_config/nvim/lua/plugins/eslint.lua delete mode 100644 private_dot_config/nvim/lua/plugins/example.lua create mode 100644 private_dot_config/nvim/lua/plugins/lsp.lua delete mode 100644 private_dot_config/nvim/lua/plugins/markdown-no-lint.lua create mode 100644 private_dot_config/nvim/lua/plugins/meow-yarn.lua delete mode 100644 private_dot_config/nvim/lua/plugins/minuet.lua delete mode 100644 private_dot_config/nvim/lua/plugins/navigation.lua create mode 100644 private_dot_config/nvim/lua/plugins/refactoring-fix.lua delete mode 100644 private_dot_config/nvim/lua/plugins/refactoring.lua create mode 100644 private_dot_config/nvim/lua/plugins/typescript.lua diff --git a/private_dot_config/nvim/PLUGIN_CHEATSHEET.md b/private_dot_config/nvim/PLUGIN_CHEATSHEET.md index 97ae31f..7690cf7 100644 --- a/private_dot_config/nvim/PLUGIN_CHEATSHEET.md +++ b/private_dot_config/nvim/PLUGIN_CHEATSHEET.md @@ -1,210 +1,192 @@ -# LazyVim Plugin Cheatsheet +# Neovim Cheatsheet -Quick reference for the custom plugins in your configuration. +What this LazyVim config adds or changes. `` is Space. Everything else is stock LazyVim: +`sk` searches all keymaps, `?` shows the current buffer's keymaps. --- -## Git Tools (`lua/plugins/git.lua`) +## Markdown (md-render.nvim, `lua/plugins/image.lua`) -### git-blame.nvim -Shows git blame information at the end of each line. +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. -**Commands:** -- `:GitBlameToggle` - Toggle git blame on/off -- `:GitBlameEnable` - Enable git blame -- `:GitBlameDisable` - Disable git blame -- `:GitBlameOpenCommitURL` - Open commit in browser -- `:GitBlameCopySHA` - Copy commit SHA to clipboard +| 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` `` `.` `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, `` or `gv` | +| `mr` | Render ⇄ source in place (mapped in the markdown source buffer) | +| `mp` / `mt` / `ms` | Preview in a wide float / a tab / a source+render split (source buffer) | +| `md` | md-render demo | +| `:MdRender toggle\|split\|tab\|float\|auto on\|off` | Same from the command line (works in the rendered view too) | -**Default:** Enabled on startup +- **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. --- -### diffview.nvim -Advanced git diff and history viewer. +## Clipboard and selections -**Key Bindings:** -- `gd` - Open diff view of current changes -- `gh` - View current file's git history -- `gH` - View entire repo's git history +`clipboard=unnamedplus` everywhere, so `y`/`p` use the system clipboard. -**Commands:** -- `:DiffviewOpen` - Open diff view -- `:DiffviewClose` - Close diff view -- `:DiffviewFileHistory` - View repo history -- `:DiffviewFileHistory %` - View current file history -- `:DiffviewRefresh` - Refresh the diff view +| 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` | -**In Diffview:** -- `]c` / `[c` - Jump to next/previous change -- `` / `` - Select next/previous file -- `gf` - Open file in new tab -- `q` - Close diffview +- **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). `` copy, `` cut, `` switch to Visual | +| **Visual mode** | Mouse drag, `v`, `V`, `` | `y` `d` `p` as usual; `` also copies (`` stays decrement) | + +- `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. +- `cy` / `cY` copy the file's relative / absolute path. --- -## UI Enhancements (`lua/plugins/ui-enhancements.lua`) +## Search and replace (`lua/plugins/search.lua`) -### render-markdown.nvim -Renders markdown with better formatting while editing. +| 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 | +| `Rs` (Visual) / `Ro` / `Rw` / `RW` / `Re` / `Rf` | search-replace.nvim, current buffer: selection / prompt / word / WORD / expression / filename | +| `Rbs` (Visual) / `Rbo` / `Rbw` / `RbW` / `Rbe` / `Rbf` | Same across all buffers | +| `sr` | LazyVim's grug-far search and replace (project-wide) | +| `rs` | Refactoring menu (LazyVim refactoring extra; `rf` extract function, `rx` extract variable, `ri` inline variable) | -**Features:** -- Automatically styles headers, lists, code blocks -- Works only in markdown files -- No commands needed - always active in `.md` files - -**Toggle:** Disable by setting `enabled = false` in config +- 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`. --- -### hlargs.nvim -Highlights function arguments with different colors. +## Completion and AI -**Features:** -- Automatically highlights function parameters -- Helps distinguish arguments visually -- Works across all supported languages - -**No commands needed** - always active +| Item | State | +|---|---| +| blink.cmp | On; sources LSP, path, snippets (no buffer words). Markdown: LSP + path only. friendly-snippets' global snippets (dates, lorem) off | +| `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) | `ac` toggle, `af` focus, `ar` resume, `aC` continue, `ab` add buffer, `as` send selection (Visual) / add file (neo-tree), `aa` / `ad` accept / deny diff | --- -### twilight.nvim -Dims inactive code to focus on current block. +## Git -**Key Bindings:** -- `ut` - Toggle Twilight mode +| Key / command | What it does | +|---|---| +| git-blame.nvim | Blame as virtual text at column 80; `:GitBlameToggle`, `:GitBlameCopySHA`, `:GitBlameOpenCommitURL` | +| `gd` / `gh` / `gH` | Diffview: changes / file history / repo history | +| `dv` / `ds` / `dh` / `dH` | Diffview: open / staged / file history / all history | +| `go` / `uG` | mini.diff overlay / signs | +| `gb` / `gg` | Blame line / lazygit (LazyVim) | -**Commands:** -- `:Twilight` - Toggle twilight -- `:TwilightEnable` - Enable twilight -- `:TwilightDisable` - Disable twilight - -**Best for:** Focusing on specific functions or code blocks +In Diffview: `]c` `[c` hunks, `` `` files, `q` close (`:DiffviewClose`). --- -### theme-hub.nvim -Browse and switch colorschemes with live preview. +## UI -**Key Bindings:** -- `uT` - Open Theme Hub +| Key | What it does | +|---|---| +| `um` / `uM` | Minimap (neominimap, on at start; shows diagnostics, mini.diff changes, search) toggle / focus | +| `uf` | LazyVim's auto-format toggle (global) | +| `ut` | Twilight (dim inactive code). Hides LazyVim's treesitter-context toggle: use `:TSContext toggle` | +| `uT` | Themery theme picker (`:Themery`). Hides LazyVim's treesitter-highlight toggle: use `:lua Snacks.toggle.treesitter():toggle()`. `uC` is LazyVim's colorscheme picker | +| `ug` | Indent guides (snacks.indent) | -**Commands:** -- `:ThemeHub` - Open theme browser - -**In Theme Hub:** -- `j` / `k` - Navigate themes -- `` - Apply selected theme -- `` / `q` - Close without applying +Always on: hlargs (argument colours), smear-cursor, treesitter-context. --- -## Search Tools (`lua/plugins/search.lua`) +## Files and navigation -### nvim-hlslens -Enhanced search highlighting with match counts. +| Key | What it does | +|---|---| +| `e` / `E` | neo-tree (root / cwd); shows dotfiles, gitignored files and `*.log` | +| `ff` / `` | Find files (Telescope; includes hidden and gitignored files) | +| `/` / `sg` | Grep (includes gitignored files) | +| `fg` / `fb` / `fr` | Git files / buffers / recent | +| `sh` / `sk` | Help / keymaps | +| `H` / `h` / `1`–`9` | Harpoon: add file / menu / jump | +| `cs` / `ss` | Aerial outline / symbol search | +| `fp` | Projects | +| `cv` | CSV/TSV aligned view (in `.csv` / `.tsv` buffers) | +| `t…` | Tests (neotest, incl. vitest) | +| `sz` | chezmoi files | -**Key Bindings:** -- `n` - Next search result (enhanced) -- `N` - Previous search result (enhanced) -- `*` - Search word under cursor (enhanced) -- `#` - Search word backward (enhanced) -- `g*` / `g#` - Search without word boundaries - -**Features:** -- Shows match count (e.g., "3/15") -- Floating window near cursor -- Automatically clears after cursor movement +TypeScript uses the `tsc` LSP from the lang.typescript.tsc extra (project-local TypeScript 7 when present). --- -### search-replace.nvim -Advanced multi-buffer search and replace. +## Disabled on purpose (and how to undo) -**Single Buffer Operations:** -- `rs` - Search/replace in visual selection -- `ro` - Search/replace (open prompt) -- `rw` - Search/replace word under cursor -- `rW` - Search/replace WORD under cursor -- `re` - Search/replace expression -- `rf` - Search/replace filename - -**Multi-Buffer Operations:** -- `rbs` - Search/replace selections (all buffers) -- `rbo` - Search/replace open (all buffers) -- `rbw` - Search/replace word (all buffers) -- `rbW` - Search/replace WORD (all buffers) -- `rbe` - Search/replace expression (all buffers) -- `rbf` - Search/replace filename (all buffers) - -**Commands:** -- `:SearchReplaceSingleBuffer` - Single buffer mode -- `:SearchReplaceMultiBuffer` - Multi-buffer mode -- `:SearchReplaceWithinVisualSelection` - Within selection +| Plugin / feature | Why | Re-enable | +|---|---|---| +| nvim-tree | neo-tree is the explorer; both fought over `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` | --- -## File Type Tools (`lua/plugins/filetypes.lua`) - -### csvview.nvim -Formats and aligns CSV/TSV files for better readability. - -**Key Bindings:** -- `cv` - Toggle CSV view (only in CSV/TSV files) - -**Commands:** -- `:CsvViewEnable` - Enable CSV formatting -- `:CsvViewDisable` - Disable CSV formatting -- `:CsvViewToggle` - Toggle CSV view - -**File Types:** Automatically works with `.csv` and `.tsv` files - ---- - -## Built-in LazyVim Extras - -These are enabled via `lazyvim.json` and have their own keybindings: - -### Telescope -- `ff` - Find files -- `fg` - Live grep -- `fb` - Browse buffers -- `fh` - Help tags - -### Neo-tree -- `e` - Toggle file explorer -- `E` - Toggle file explorer (current file) - -### Harpoon2 -- `h` - Harpoon menu -- `a` - Add file to harpoon - -### Aerial (Code Outline) -- `cs` - Open symbols outline - -### Project Management -- `fp` - Find project - ---- - -## Tips - -1. **Enable/Disable Plugins:** Edit the respective file in `lua/plugins/` and set `enabled = false` -2. **View All Keymaps:** Press `sk` (search keymaps) in Telescope -3. **Check Plugin Status:** Run `:Lazy` to see installed plugins -4. **Update Plugins:** Run `:Lazy update` -5. **View Help:** Most plugins have `:help ` documentation - ---- - -## Plugin Files Location +## Files ``` -~/.config/nvim/lua/plugins/ -├── git.lua # Git blame & diffview -├── ui-enhancements.lua # Render-markdown, hlargs, twilight, theme-hub -├── search.lua # Hlslens, search-replace -├── filetypes.lua # CSV viewer -└── markdown.lua # Markdown-specific config +~/.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 # cy/cY, / 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 (R) + ├── git.lua # git-blame, diffview (options + g keys) + ├── diffview.lua # diffview d keys + ├── minimap.lua # neominimap (um / uM) + ├── blink.lua # completion sources, 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) ``` diff --git a/private_dot_config/nvim/lazyvim.json b/private_dot_config/nvim/lazyvim.json index 67fe419..016afe8 100644 --- a/private_dot_config/nvim/lazyvim.json +++ b/private_dot_config/nvim/lazyvim.json @@ -4,8 +4,6 @@ "lazyvim.plugins.extras.coding.yanky", "lazyvim.plugins.extras.editor.aerial", "lazyvim.plugins.extras.editor.harpoon2", - "lazyvim.plugins.extras.editor.illuminate", - "lazyvim.plugins.extras.editor.mini-diff", "lazyvim.plugins.extras.editor.neo-tree", "lazyvim.plugins.extras.editor.refactoring", "lazyvim.plugins.extras.editor.telescope", @@ -13,7 +11,9 @@ "lazyvim.plugins.extras.lang.go", "lazyvim.plugins.extras.lang.json", "lazyvim.plugins.extras.lang.python", + "lazyvim.plugins.extras.lang.typescript.tsc", "lazyvim.plugins.extras.lang.yaml", + "lazyvim.plugins.extras.test.core", "lazyvim.plugins.extras.ui.smear-cursor", "lazyvim.plugins.extras.ui.treesitter-context", "lazyvim.plugins.extras.util.chezmoi", @@ -25,4 +25,4 @@ "NEWS.md": "11866" }, "version": 8 -} \ No newline at end of file +} diff --git a/private_dot_config/nvim/lua/config/keymaps.lua b/private_dot_config/nvim/lua/config/keymaps.lua index e0598a9..edb68cc 100644 --- a/private_dot_config/nvim/lua/config/keymaps.lua +++ b/private_dot_config/nvim/lua/config/keymaps.lua @@ -13,3 +13,27 @@ vim.keymap.set("n", "cY", function() vim.fn.setreg("+", vim.fn.expand("%:p")) print("Copied absolute path: " .. vim.fn.expand("%:p")) end, { desc = "Copy absolute path" }) + +-- Select mode (Shift+arrows) replaces the selection with what you type, so `y` +-- types a "y". Conventional copy/cut instead ( switches to Visual first). +-- The `y`/`d` is fed remappable so buffer maps still apply (md-render's render +-- view copies markdown source); `"+` is fed noremap so which-key's `"` trigger +-- stays out. Both go to the front of typeahead, in this order. +local function clipboard_op(prefix, op) + return function() + vim.api.nvim_feedkeys(op, "mi", false) + vim.api.nvim_feedkeys(vim.keycode(prefix) .. '"+', "ni", false) + end +end +vim.keymap.set("s", "", clipboard_op("", "y"), { desc = "Copy selection to clipboard" }) +vim.keymap.set("s", "", clipboard_op("", "d"), { desc = "Cut selection to clipboard" }) +vim.keymap.set("x", "", clipboard_op("", "y"), { desc = "Copy selection to clipboard" }) + +-- VS Code's terminal toggle (Ctrl+`, the ~ key), mirroring LazyVim's . +-- Only reaches nvim when the terminal sends CSI u / kitty keys; the legacy +-- encoding of Ctrl+` is NUL, which is (flash) and is left alone. +local function toggle_terminal() + Snacks.terminal.focus(nil, { cwd = LazyVim.root() }) +end +vim.keymap.set({ "n", "t" }, "", toggle_terminal, { desc = "Terminal (Root Dir)" }) +vim.keymap.set({ "n", "t" }, "", toggle_terminal, { desc = "which_key_ignore" }) diff --git a/private_dot_config/nvim/lua/config/options.lua b/private_dot_config/nvim/lua/config/options.lua index 861dc80..238d448 100644 --- a/private_dot_config/nvim/lua/config/options.lua +++ b/private_dot_config/nvim/lua/config/options.lua @@ -2,10 +2,16 @@ -- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua -- Add any additional options here +-- No AI/inline completion: LazyVim's blink extra sets +-- completion.ghost_text.enabled = vim.g.ai_cmp (grey inline preview of the top +-- item). Must be set here, before LazyVim imports its extras. +vim.g.ai_cmp = false + -- Clipboard provider. LazyVim disables `clipboard=unnamedplus` under SSH, so -- select the right provider and explicitly re-enable clipboard-linked yanks: --- * tmux -> tmux's own clipboard buffer (readable) --- * SSH/remote -> OSC 52 copy-only (see note below) +-- * tmux -> tmux buffer (p first asks the outer terminal via +-- `refresh-client -l`; only works if it allows OSC 52 reads) +-- * SSH/remote -> OSC 52 copy + host-local paste cache (see below) -- * local macOS -> native pbcopy/pbpaste. -- Do NOT use OSC 52 locally: yanky's `sync_with_ring` reads the system -- clipboard, and OSC 52 reads depend on the terminal answering a query, which @@ -17,34 +23,97 @@ elseif vim.env.SSH_CONNECTION then -- Remote session (bare SSH, or a multiplexer like herdr that exports no env -- var of its own). Copy via OSC 52 so yanks reach the OUTER terminal's -- clipboard, but NEVER read the clipboard back: OSC 52 reads require the - -- terminal to answer a query, which Warp/herdr don't, so a read returns stale - -- data (or hangs) and blows up yanky's ring sync. Trade-off: pasting FROM the - -- local host INTO nvim over SSH won't work here -- use the terminal's own - -- paste in insert mode. + -- terminal to answer a query, which Warp/herdr/Ghostty don't, and the runtime + -- reader then blocks for up to 10 s. Pasting FROM the Mac INTO nvim is the + -- terminal's own paste (Cmd-V, bracketed paste; works in every mode). + -- + -- `p` returns the last copy made by ANY nvim on this host: copy() also writes + -- {regtype, lines...} to stdpath("state")/clipboard/last (dir 0700, file 0600, + -- atomic rename; writefile/readfile "b" keep NUL bytes and trailing empty + -- lines), so a yank in one herdr pane pastes in another. Falls back to this + -- instance's last copy. Over 8 MiB the shared file is removed, not left stale. + -- No "nothing to paste" hint: yanky reads "+ when it loads, so paste() can't + -- tell a user's `p` from a plugin's read. -- -- The paste function below must NOT call vim.fn.getreg('"')/'*'/'+' itself: -- Neovim's clipboard provider (autoload/provider/clipboard.vim) guards -- against re-entrant provider calls (`s:here`, see nvim#7184), so a getreg() -- of a clipboard-linked register issued from *inside* a registered paste() -- callback is swallowed and silently returns empty -- not the register's - -- real content. Cache what copy() was last given instead, and have paste() - -- return that cached value directly. - local osc52 = require("vim.ui.clipboard.osc52") - local last = { lines = {}, regtype = "" } - local function make_copy(reg) - local osc52_copy = osc52.copy(reg) - return function(lines, regtype) - last.lines, last.regtype = lines, regtype - osc52_copy(lines, regtype) + -- real content. It reads the shared file or what copy() was last given. + -- Neither function may throw: an error would land in the middle of a yank. + local osc52_send = require("vim.ui.clipboard.osc52").copy("+") + local share_dir = vim.fn.stdpath("state") .. "/clipboard" + local share_file = share_dir .. "/last" + local SHARE_MAX, OSC52_WARN = 8 * 1024 * 1024, 512 * 1024 + local last, dir_mode_set = { lines = {}, regtype = "v" }, false + local stale -- identity of a shared file we failed to replace or remove + local function file_id() + local st = vim.uv.fs_stat(share_file) + return st and ("%d:%d.%d:%d"):format(st.ino, st.mtime.sec, st.mtime.nsec, st.size) + end + local function share(lines, regtype, size) + local tmp = ("%s.%d.tmp"):format(share_file, vim.uv.os_getpid()) + local ok = pcall(function() + if size > SHARE_MAX then error("too large to share") end + if vim.fn.isdirectory(share_dir) == 0 then + vim.fn.mkdir(share_dir, "p", tonumber("700", 8)) + dir_mode_set = false + end + if not dir_mode_set then -- once per process, also for a pre-existing dir + dir_mode_set = true + vim.uv.fs_chmod(share_dir, tonumber("700", 8)) + end + local data = { regtype } + vim.list_extend(data, lines) + if vim.fn.writefile(data, tmp, "bS") ~= 0 then error("write failed") end + assert(vim.uv.fs_chmod(tmp, tonumber("600", 8))) + assert(vim.uv.fs_rename(tmp, share_file)) + end) + stale = nil + if not ok then -- never serve a stale shared copy + pcall(os.remove, tmp) + pcall(os.remove, share_file) + stale = file_id() -- still there (read-only dir): ignore it until replaced end end - local function paste_from_cache() + local function remember(lines, regtype) + last.lines, last.regtype = lines, regtype + local size = 0 + for _, l in ipairs(lines) do size = size + #l + 1 end + share(lines, regtype, size) + return size + end + local function copy_plus(lines, regtype) + local size = remember(lines, regtype) + pcall(osc52_send, lines, regtype) + if size > OSC52_WARN then + vim.schedule(function() + vim.notify(("Copied %d KiB via OSC 52; the terminal may drop payloads this large (nvim `p` on this host still has it)."):format(math.floor(size / 1024)), vim.log.levels.WARN) + end) + end + end + -- OSC 52 'p' (primary selection) means nothing on the Mac, so "* only updates + -- the paste cache. A yank that fans out to "+ AND "* (provider: + -- s:copy['*'] != s:copy['+'], i.e. 'clipboard' has unnamed) still sends + -- exactly one OSC 52 sequence. + local function copy_star(lines, regtype) + remember(lines, regtype) + end + local function paste() + if vim.fn.filereadable(share_file) == 1 and (not stale or file_id() ~= stale) then + local ok, data = pcall(vim.fn.readfile, share_file, "b") + if ok and type(data) == "table" and #data > 0 and data[1]:match("^[vVb]$") then + local regtype = table.remove(data, 1) + return { data, regtype } + end + end return { last.lines, last.regtype } end vim.g.clipboard = { name = "osc52-copyonly", - copy = { ["+"] = make_copy("+"), ["*"] = make_copy("*") }, - paste = { ["+"] = paste_from_cache, ["*"] = paste_from_cache }, + copy = { ["+"] = copy_plus, ["*"] = copy_star }, + paste = { ["+"] = paste, ["*"] = paste }, cache_enabled = 0, } elseif vim.fn.has("mac") == 1 then @@ -76,7 +145,10 @@ vim.opt.scrolloff = 8 -- Keep 8 lines visible above/below cursor vim.opt.sidescrolloff = 8 -- Keep 8 columns visible left/right vim.opt.smoothscroll = true -- Smooth scrolling --- Make Shift+movement and mouse selections behave like a conventional editor. --- Keep `cmd` out of selectmode so v/V continue to enter Vim's Visual mode. +-- Shift+arrows start Select mode like a conventional editor: typing replaces +-- the selection; / copy/cut it to the clipboard (keymaps.lua). +-- Mouse drags start Visual mode so y/d/p work as usual (over SSH with +-- mouse=a the terminal can't copy a drag itself). Keep `cmd` out of +-- selectmode so v/V continue to enter Vim's Visual mode. vim.opt.keymodel = { "startsel", "stopsel" } -vim.opt.selectmode = { "key", "mouse" } +vim.opt.selectmode = { "key" } diff --git a/private_dot_config/nvim/lua/custom/keymaps.lua b/private_dot_config/nvim/lua/custom/keymaps.lua deleted file mode 100644 index d08a0dd..0000000 --- a/private_dot_config/nvim/lua/custom/keymaps.lua +++ /dev/null @@ -1,37 +0,0 @@ -local completion_state = { - enabled = true, -- current state - backup = { -- store the original values so we can restore them - omnifunc = nil, - completefunc = nil, - completeopt = nil, - }, -} - -vim.keymap.set("n", "co", function() - if completion_state.enabled then - -- ----- DISABLE ----- - completion_state.backup.omnifunc = vim.opt_local.omnifunc:get() - completion_state.backup.completefunc = vim.opt_local.completefunc:get() - completion_state.backup.completeopt = vim.opt_local.completeopt:get() - - -- Clear the sources - vim.opt_local.omnifunc = "" - vim.opt_local.completefunc = "" - - -- Hide the menu even if something tries to show it - vim.opt_local.completeopt = { "noinsert", "noselect" } - - completion_state.enabled = false - print("⛔ Autocompletion disabled") - else - -- ----- ENABLE ----- - vim.opt_local.omnifunc = completion_state.backup.omnifunc - vim.opt_local.completefunc = completion_state.backup.completefunc - - -- Restore the previous `completeopt` (or a safe default) - vim.opt_local.completeopt = completion_state.backup.completeopt or { "menu", "preview", "noinsert", "noselect" } - - completion_state.enabled = true - print("✅ Autocompletion re‑enabled") - end -end, { desc = "Toggle all autocompletion (omnifunc, completefunc, menu)" }) diff --git a/private_dot_config/nvim/lua/plugins/ai_assist.lua b/private_dot_config/nvim/lua/plugins/ai_assist.lua index 2b066d4..d7e5681 100644 --- a/private_dot_config/nvim/lua/plugins/ai_assist.lua +++ b/private_dot_config/nvim/lua/plugins/ai_assist.lua @@ -15,7 +15,7 @@ return { require("nvim_ai_assist").setup({ -- Active: Z.AI Coding Plan (uses ZAI_API_KEY from env) provider = "zai-coding", - model = "glm-4.7", + model = "glm-5-turbo", max_tokens = 300, temperature = 0.05, debug = true, -- writes request/response to ~/.cache/nvim/nvim_ai_assist.log; :AILog to view diff --git a/private_dot_config/nvim/lua/plugins/blink.lua b/private_dot_config/nvim/lua/plugins/blink.lua index f8a1f3d..8d2df0a 100644 --- a/private_dot_config/nvim/lua/plugins/blink.lua +++ b/private_dot_config/nvim/lua/plugins/blink.lua @@ -2,7 +2,7 @@ -- * drop the `buffer` (next-word) source everywhere -- * markdown/md-render buffers use LSP+path only (no snippet callout noise) -- * disable friendly-snippets' global snippets (datetime/dateMDY/lorem/...) --- Inline AI suggestions are handled by minuet instead (see minuet.lua). +-- Inline LLM ghost-text (minuet-ai.nvim) was removed; blink is the only completion source. return { "saghen/blink.cmp", opts = function(_, opts) @@ -28,5 +28,27 @@ return { opts.sources.providers.snippets = opts.sources.providers.snippets or {} opts.sources.providers.snippets.opts = opts.sources.providers.snippets.opts or {} opts.sources.providers.snippets.opts.global_snippets = {} + + -- Global on/off switch for completion (uk below). While it's on, + -- blink's own `enabled` check still applies. + local prev = opts.enabled + opts.enabled = function() + if vim.g.thembones_completion == false then return false end + if type(prev) == "function" then return prev() end + return true + end end, + keys = { + { + "uk", + function() + vim.g.thembones_completion = vim.g.thembones_completion == false + if not vim.g.thembones_completion then + pcall(function() require("blink.cmp").hide() end) + end + vim.notify("Completion " .. (vim.g.thembones_completion and "on" or "off")) + end, + desc = "Toggle Completion (global)", + }, + }, } diff --git a/private_dot_config/nvim/lua/plugins/claudecode.lua b/private_dot_config/nvim/lua/plugins/claudecode.lua new file mode 100644 index 0000000..cd1238f --- /dev/null +++ b/private_dot_config/nvim/lua/plugins/claudecode.lua @@ -0,0 +1,30 @@ +-- LazyVim's ai.claudecode extra maps "a" (group) and "as" (Send to +-- Claude) with mode "v", which also covers Select mode. A space typed over a +-- Shift+arrow selection (selectmode=key) then waits 'timeoutlen' for the rest of +-- a map instead of replacing the selection at once. Keep those maps in +-- Visual mode only ("x"); Visual as behaves exactly as before. +return { + { + "coder/claudecode.nvim", + optional = true, + keys = function(_, keys) + local function visual_only(mode) + if mode == "v" then + return "x" + end + if type(mode) == "table" then + return vim.tbl_map(function(m) + return m == "v" and "x" or m + end, mode) + end + return mode + end + return vim.tbl_map(function(k) + if type(k) ~= "table" or k.mode == nil then + return k + end + return vim.tbl_extend("force", k, { mode = visual_only(k.mode) }) + end, keys) + end, + }, +} diff --git a/private_dot_config/nvim/lua/plugins/diffview.lua b/private_dot_config/nvim/lua/plugins/diffview.lua index ce78ed9..cffdc2e 100644 --- a/private_dot_config/nvim/lua/plugins/diffview.lua +++ b/private_dot_config/nvim/lua/plugins/diffview.lua @@ -7,8 +7,6 @@ return { { "dh", "DiffviewFileHistory %", desc = "File history (current)" }, { "dH", "DiffviewFileHistory", desc = "File history (all)" }, }, - config = function() - require("diffview").setup({}) - -- removed the vim.keymap.set lines from here - end, + -- No `config` here: lazy calls require("diffview").setup(opts) with the + -- options from lua/plugins/git.lua (a setup({}) here discarded them). } \ No newline at end of file diff --git a/private_dot_config/nvim/lua/plugins/eslint.lua b/private_dot_config/nvim/lua/plugins/eslint.lua new file mode 100644 index 0000000..23802c9 --- /dev/null +++ b/private_dot_config/nvim/lua/plugins/eslint.lua @@ -0,0 +1,27 @@ +-- In-editor ESLint diagnostics via the eslint language server (Mason: eslint-lsp, +-- i.e. vscode-eslint-language-server). Added 2026-10-23 for the TS code-walkthrough prep. +-- +-- Diagnostics only, NO format/fix on save: eslint attaches and shows lint squiggles +-- inline, but will not silently rewrite the buffer when you save (which would bury your +-- real diff in a walkthrough). Fix manually with ca (code action -> "Fix all +-- ESLint problems") or :EslintFixAll when you actually want it. +-- +-- Note: eslint runs the project's own eslint + typescript-eslint. typescript-eslint does +-- not yet support TypeScript 7, so on a TS 7 project the server errors out — that is the +-- project's toolchain, not this config. Projects pinned to TS 5.x work normally. +return { + { + "neovim/nvim-lspconfig", + opts = { + servers = { + eslint = { + settings = { + -- find eslint config even when it lives in a subfolder, not the cwd root + workingDirectories = { mode = "auto" }, + format = false, + }, + }, + }, + }, + }, +} diff --git a/private_dot_config/nvim/lua/plugins/example.lua b/private_dot_config/nvim/lua/plugins/example.lua deleted file mode 100644 index 17f53d6..0000000 --- a/private_dot_config/nvim/lua/plugins/example.lua +++ /dev/null @@ -1,197 +0,0 @@ --- since this is just an example spec, don't actually load anything here and return an empty spec --- stylua: ignore -if true then return {} end - --- every spec file under the "plugins" directory will be loaded automatically by lazy.nvim --- --- In your plugin files, you can: --- * add extra plugins --- * disable/enabled LazyVim plugins --- * override the configuration of LazyVim plugins -return { - -- add gruvbox - { "ellisonleao/gruvbox.nvim" }, - - -- Configure LazyVim to load gruvbox - { - "LazyVim/LazyVim", - opts = { - colorscheme = "gruvbox", - }, - }, - - -- change trouble config - { - "folke/trouble.nvim", - -- opts will be merged with the parent spec - opts = { use_diagnostic_signs = true }, - }, - - -- disable trouble - { "folke/trouble.nvim", enabled = false }, - - -- override nvim-cmp and add cmp-emoji - { - "hrsh7th/nvim-cmp", - dependencies = { "hrsh7th/cmp-emoji" }, - ---@param opts cmp.ConfigSchema - opts = function(_, opts) - table.insert(opts.sources, { name = "emoji" }) - end, - }, - - -- change some telescope options and a keymap to browse plugin files - { - "nvim-telescope/telescope.nvim", - keys = { - -- add a keymap to browse plugin files - -- stylua: ignore - { - "fp", - function() require("telescope.builtin").find_files({ cwd = require("lazy.core.config").options.root }) end, - desc = "Find Plugin File", - }, - }, - -- change some options - opts = { - defaults = { - layout_strategy = "horizontal", - layout_config = { prompt_position = "top" }, - sorting_strategy = "ascending", - winblend = 0, - }, - }, - }, - - -- add pyright to lspconfig - { - "neovim/nvim-lspconfig", - ---@class PluginLspOpts - opts = { - ---@type lspconfig.options - servers = { - -- pyright will be automatically installed with mason and loaded with lspconfig - pyright = {}, - }, - }, - }, - - -- add tsserver and setup with typescript.nvim instead of lspconfig - { - "neovim/nvim-lspconfig", - dependencies = { - "jose-elias-alvarez/typescript.nvim", - init = function() - require("lazyvim.util").lsp.on_attach(function(_, buffer) - -- stylua: ignore - vim.keymap.set( "n", "co", "TypescriptOrganizeImports", { buffer = buffer, desc = "Organize Imports" }) - vim.keymap.set("n", "cR", "TypescriptRenameFile", { desc = "Rename File", buffer = buffer }) - end) - end, - }, - ---@class PluginLspOpts - opts = { - ---@type lspconfig.options - servers = { - -- tsserver will be automatically installed with mason and loaded with lspconfig - tsserver = {}, - }, - -- you can do any additional lsp server setup here - -- return true if you don't want this server to be setup with lspconfig - ---@type table - setup = { - -- example to setup with typescript.nvim - tsserver = function(_, opts) - require("typescript").setup({ server = opts }) - return true - end, - -- Specify * to use this function as a fallback for any server - -- ["*"] = function(server, opts) end, - }, - }, - }, - - -- for typescript, LazyVim also includes extra specs to properly setup lspconfig, - -- treesitter, mason and typescript.nvim. So instead of the above, you can use: - { import = "lazyvim.plugins.extras.lang.typescript" }, - - -- add more treesitter parsers - { - "nvim-treesitter/nvim-treesitter", - opts = { - ensure_installed = { - "bash", - "html", - "javascript", - "json", - "lua", - "markdown", - "markdown_inline", - "python", - "query", - "regex", - "tsx", - "typescript", - "vim", - "yaml", - }, - }, - }, - - -- since `vim.tbl_deep_extend`, can only merge tables and not lists, the code above - -- would overwrite `ensure_installed` with the new value. - -- If you'd rather extend the default config, use the code below instead: - { - "nvim-treesitter/nvim-treesitter", - opts = function(_, opts) - -- add tsx and treesitter - vim.list_extend(opts.ensure_installed, { - "tsx", - "typescript", - }) - end, - }, - - -- the opts function can also be used to change the default opts: - { - "nvim-lualine/lualine.nvim", - event = "VeryLazy", - opts = function(_, opts) - table.insert(opts.sections.lualine_x, { - function() - return "😄" - end, - }) - end, - }, - - -- or you can return new options to override all the defaults - { - "nvim-lualine/lualine.nvim", - event = "VeryLazy", - opts = function() - return { - --[[add your custom lualine config here]] - } - end, - }, - - -- use mini.starter instead of alpha - { import = "lazyvim.plugins.extras.ui.mini-starter" }, - - -- add jsonls and schemastore packages, and setup treesitter for json, json5 and jsonc - { import = "lazyvim.plugins.extras.lang.json" }, - - -- add any tools you want to have installed below - { - "williamboman/mason.nvim", - opts = { - ensure_installed = { - "stylua", - "shellcheck", - "shfmt", - "flake8", - }, - }, - }, -} diff --git a/private_dot_config/nvim/lua/plugins/git.lua b/private_dot_config/nvim/lua/plugins/git.lua index 33b394d..c00c260 100644 --- a/private_dot_config/nvim/lua/plugins/git.lua +++ b/private_dot_config/nvim/lua/plugins/git.lua @@ -1,16 +1,67 @@ -- Git enhancement plugins +-- +-- Change markers and blame both come from gitsigns.nvim (LazyVim's default; the +-- editor.mini-diff extra is off in lazyvim.json because it disables gitsigns). +local MIN_BLAME_ROOM = 12 -- columns needed before the summary is worth showing +local blame_hl = "GitSignsCurrentLineBlame" + +-- Current-line blame that fits the window: "author, 3 days ago · summary". The +-- summary is cut to the room left after the line's text, and dropped when the +-- line nearly fills the window, so the annotation never runs off screen. +local function blame_formatter(_, info) + if info.author == "Not Committed Yet" then + return { { " ● Uncommitted change", "GitSignsChange" } } + end + local util = require("gitsigns.util") + local head = (" %s, %s"):format(info.author, util.get_relative_time(tonumber(info.author_time))) + + local win = vim.api.nvim_get_current_win() + local textoff = vim.fn.getwininfo(win)[1].textoff + local room = vim.api.nvim_win_get_width(win) - textoff + - vim.api.nvim_strwidth(vim.api.nvim_get_current_line()) - vim.api.nvim_strwidth(head) - 4 + if room < MIN_BLAME_ROOM then + return { { head, blame_hl } } + end + local summary = info.summary or "" + if vim.api.nvim_strwidth(summary) > room then + summary = vim.fn.strcharpart(summary, 0, room - 1) .. "…" + end + return { { head, blame_hl }, { " · " .. summary, blame_hl } } +end + return { - -- Git blame annotations in virtual text - -- Shows git blame info at the end of each line - -- Toggle with :GitBlameToggle { - "f-person/git-blame.nvim", - event = "VeryLazy", + "lewis6991/gitsigns.nvim", opts = { - enabled = true, -- Start enabled - message_template = " • • ", - date_format = "%r", - virtual_text_column = 80, + -- Heavy bars in the sign column, VS Code style. Unstaged changes use + -- GitSignsAdd/Change/Delete; staged ones get gitsigns' dimmer variants. + signs = { + add = { text = "┃" }, + change = { text = "┃" }, + delete = { text = "▁" }, + topdelete = { text = "▔" }, + changedelete = { text = "┃" }, + untracked = { text = "┆" }, + }, + signs_staged = { + add = { text = "┃" }, + change = { text = "┃" }, + delete = { text = "▁" }, + topdelete = { text = "▔" }, + changedelete = { text = "┃" }, + }, + numhl = true, -- also color the line number of every changed line + attach_to_untracked = true, + current_line_blame = true, + current_line_blame_opts = { virt_text_pos = "eol", delay = 300, ignore_whitespace = true }, + current_line_blame_formatter = blame_formatter, + current_line_blame_formatter_nc = blame_formatter, + }, + keys = { + { "gb", "Gitsigns blame", desc = "Blame panel (every line)" }, + { "gL", function() require("gitsigns").blame_line({ full = true }) end, desc = "Blame line (full commit)" }, + { "uB", "Gitsigns toggle_current_line_blame", desc = "Toggle inline blame" }, + { "uN", "Gitsigns toggle_numhl", desc = "Toggle git line-number colors" }, }, }, diff --git a/private_dot_config/nvim/lua/plugins/image.lua b/private_dot_config/nvim/lua/plugins/image.lua index 6daa1e2..6557580 100644 --- a/private_dot_config/nvim/lua/plugins/image.lua +++ b/private_dot_config/nvim/lua/plugins/image.lua @@ -23,6 +23,22 @@ local function image_debug(message) vim.fn.writefile({ line }, path, "a") end +-- Rendered mermaid/PlantUML rows all map to the block's CLOSING fence. If +-- `lnum` is the closing fence of such a block, return the opening-fence line, +-- else nil. +local DIAGRAM_LANGS = { mermaid = true, plantuml = true, puml = true } +local function diagram_open_fence(buf, lnum) + local function get(l) return vim.api.nvim_buf_get_lines(buf, l - 1, l, false)[1] or "" end + if not get(lnum):match("^%s*[`~][`~][`~]+%s*$") then return nil end + for l = lnum - 1, math.max(1, lnum - 5000), -1 do + local fence, info = get(l):match("^%s*([`~][`~][`~]+)%s*(%S*)") + if fence then + local lang = (info:match("^{?%.?([%w_-]+)") or ""):lower() + return DIAGRAM_LANGS[lang] and l or nil + end + end +end + return { { "delphinus/md-render.nvim", @@ -32,6 +48,10 @@ return { { "nvim-tree/nvim-web-devicons", version = "*" }, }, init = function() + -- Rendered width: follows the window, capped at this many columns. A + -- per-call `max_width` would pin it instead and overflow narrow windows. + vim.g.md_render_max_width = 100 + -- Ghostty does not normally forward TERM_PROGRAM / -- GHOSTTY_RESOURCES_DIR into the remote shell. Neovim 0.12 therefore -- cannot prove Kitty graphics support from the remote side on its own. @@ -40,7 +60,9 @@ return { -- -- Keep the terminal identity as Ghostty. md-render uses that identity to -- avoid Ghostty's flaky stored-image re-placement path during redraws. - if use_direct_kitty_bytes() and not vim.env.TERM_PROGRAM then + -- herdr >= 0.9.5 sets TERM_PROGRAM=herdr, which md-render doesn't know, + -- so supports_kitty() went false and mermaid fell back to code blocks. + if use_direct_kitty_bytes() and (not vim.env.TERM_PROGRAM or vim.env.TERM_PROGRAM == "herdr") then vim.env.TERM_PROGRAM = "ghostty" end @@ -57,8 +79,21 @@ return { -- drops to source on the right line and performs the edit. (Pure-motion -- keys h/j/k/w/G/… are deliberately NOT mapped, so you can still navigate -- the render freely.) Yank keys stay in the read-only render buffer so - -- copying text does not dismiss rendered diagrams. Visual-entry keys hop - -- to source so the resulting selection can be changed safely. + -- copying text does not dismiss rendered diagrams, but yy and linewise / + -- multi-line Visual y/Y copy the markdown SOURCE behind those rows (see + -- MdRenderSourceYank below). Visual-entry keys hop to source so the + -- resulting selection can be changed safely. Redo, + -- case, increment, filter and format keys ( U ~ & ! + -- gu gU g~ g? gq gw gJ gp gP) hop too; on the render buffer they would + -- only fail with E21. + -- + -- Diagram guard: every row of a rendered mermaid/PlantUML image maps to + -- the block's closing fence, so a destructive key there (dd, x, J, …) + -- would delete/alter that fence and the unbalanced fence would swallow + -- the rest of the document. For those keys (DIAGRAM_UNSAFE) we hop to + -- the OPENING fence instead and don't replay, so you can edit the + -- diagram source deliberately. p/gp (paste below the fence), u//U + -- and v/V are still replayed. -- NOTE: the plugin sets the render buffer's filetype under -- `eventignore=all` (preview.lua, so markdown ftplugins/treesitter don't -- clobber the pre-rendered content), so a `FileType md-render` autocmd @@ -68,7 +103,46 @@ return { local HOP_KEYS = { "d", "D", "c", "C", "x", "X", "s", "S", "r", "R", "p", "P", "J", ">", "<", "=", "u", "v", "V", ".", + "", "U", "~", "", "", "&", "!", + "gu", "gU", "g~", "g?", "gq", "gw", "gJ", "gp", "gP", } + local DIAGRAM_UNSAFE = {} + for _, key in ipairs({ + "d", "D", "c", "C", "x", "X", "s", "S", "r", "R", "J", ">", "<", "=", + ".", "~", "", "", "&", "!", + "gu", "gU", "g~", "g?", "gq", "gw", "gJ", "P", "gP", + }) do + DIAGRAM_UNSAFE[key] = true + end + + -- Auto mode only returns to render on InsertLeave, so a normal-mode hop + -- (dd, x, u, p, V…d, .) used to strand you in raw source ("images + -- disappear after editing"). After a hop, go back to render the next + -- time Neovim is idle in Normal mode (CursorHold; LazyVim 'updatetime' + -- = 200ms). Disable with: vim.g.md_render_hop_return = false + local function arm_return_to_render(src_buf) + if vim.g.md_render_hop_return == false then return end + local group = vim.api.nvim_create_augroup("MdRenderHopReturn" .. src_buf, { clear = true }) + local function disarm() pcall(vim.api.nvim_del_augroup_by_id, group) end + vim.api.nvim_create_autocmd("CursorHold", { + group = group, + buffer = src_buf, + callback = function() + if vim.api.nvim_get_mode().mode ~= "n" then return end -- e.g. still in Visual + disarm() + local preview = require("md-render").preview + if type(preview._schedule_auto_transition) == "function" then + preview._schedule_auto_transition(src_buf, "render") -- no-op unless auto mode is on + elseif vim.b[src_buf].md_render_auto and vim.api.nvim_get_current_buf() == src_buf then + preview.toggle() + end + end, + }) + -- Insert-entering hops (c/s/C/S/R) return via md-render's own + -- InsertLeave; leaving the buffer cancels. + vim.api.nvim_create_autocmd({ "InsertEnter", "BufLeave" }, { group = group, buffer = src_buf, callback = disarm }) + end + local hop_group = vim.api.nvim_create_augroup("MdRenderEditHop", { clear = true }) vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, { group = hop_group, @@ -93,10 +167,23 @@ return { -- before any follow-up keystroke. That keeps multi-key operators -- in order — `d` becomes operator-pending and your next key (e.g. -- the second `d`, or `w`, `ip`) completes it natively in source. - -- (The plugin schedules its insert-entry hop because those are - -- single keys that immediately switch to Insert mode; operators - -- need the ordering guarantee a sync feed provides.) + -- (md-render's own insert-entry hop scheduled its feed and lost + -- keys typed in the same burst; patch_auto_insert_hop in + -- `config` makes it feed the same way as this.) require("md-render").preview.toggle() + local src_buf = vim.api.nvim_get_current_buf() + if vim.bo[src_buf].filetype == "md-render" then return end -- toggle refused + + if DIAGRAM_UNSAFE[key] then + local fence = diagram_open_fence(src_buf, vim.api.nvim_win_get_cursor(0)[1]) + if fence then + vim.api.nvim_win_set_cursor(0, { fence, 0 }) + vim.notify(("md-render: '%s' not applied to a rendered diagram; jumped to its source fence. " + .. "Edit here (mr, or leaving Insert mode, re-renders)."):format(key), vim.log.levels.INFO) + return + end + end + if key == "v" or key == "V" then -- Enter Visual mode before the user's next queued key arrives. -- feedkeys() would put v/V behind that key, turning `Vd` into @@ -104,8 +191,13 @@ return { local visual_count = count > 0 and tostring(count) or "" vim.cmd("normal! " .. visual_count .. key) else - vim.api.nvim_feedkeys(prefix .. key, "n", false) + -- vim.keycode: // must be fed as keys, not text. + -- "i" inserts at the FRONT of the typeahead: when the rest of + -- the command is already queued (fast typing, `gUU`, `dw`), an + -- appended replay would run after it (`gUU` became `U` + `gU`). + vim.api.nvim_feedkeys(vim.keycode(prefix .. key), "ni", false) end + arm_return_to_render(src_buf) end, { buffer = ev.buf, noremap = true, @@ -115,29 +207,114 @@ return { end end, }) + + -- Yanking in the render buffer used to copy the decorated text (icons, + -- padding, reflowed paragraphs), which pastes as garbage into markdown. + -- yy and Visual y/Y (except a charwise selection within one rendered + -- line, which keeps the native yank) copy the SOURCE lines behind the + -- rendered rows instead, linewise; the view stays rendered. A rendered + -- diagram yanks its whole fenced block. These yanks are set with + -- setreg(), so they don't fire TextYankPost / enter yanky's ring. + local yank_ns = vim.api.nvim_create_namespace("md_render_source_yank") + + local function render_ctx() + local ok, state = pcall(vim.api.nvim_win_get_var, 0, "md_render_state") + if not ok or type(state) ~= "table" or state.mode ~= "render" then return nil end + local session = require("md-render").preview._toggle_sessions[state.source_buf] + if not session or session.buf ~= vim.api.nvim_get_current_buf() then return nil end + local map = session.content and session.content.source_line_map + if type(map) ~= "table" or #map == 0 or not vim.api.nvim_buf_is_valid(state.source_buf) then return nil end + return map, state.source_buf + end + + local function source_lines_for(map, src_buf, r1, r2) + r1 = math.max(1, math.min(r1, #map)) + r2 = math.max(r1, math.min(r2, #map)) + local total = vim.api.nvim_buf_line_count(src_buf) + local s1 = math.max(1, math.min(map[r1], total)) + s1 = diagram_open_fence(src_buf, s1) or s1 + -- The last row's block ends right before the next row that maps to a + -- later source line (covers joined paragraph lines and fences). + local s2 = total + for r = r2 + 1, #map do + if map[r] > map[r2] then + s2 = map[r] - 1 + break + end + end + s2 = math.max(s1, math.min(s2, total)) + local lines = vim.api.nvim_buf_get_lines(src_buf, s1 - 1, s2, false) + while #lines > 1 and lines[#lines]:match("^%s*$") do table.remove(lines) end + return lines + end + + local function yank_source(buf, r1, r2, reg) + local map, src_buf = render_ctx() + if not map then return false end + vim.fn.setreg(reg, source_lines_for(map, src_buf, r1, r2), "l") + pcall(vim.hl.range, buf, yank_ns, "IncSearch", { r1 - 1, 0 }, { r2 - 1, 0 }, { regtype = "V", timeout = 150 }) + return true + end + + local yank_group = vim.api.nvim_create_augroup("MdRenderSourceYank", { clear = true }) + vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, { + group = yank_group, + desc = "md-render: yank in render view copies markdown source", + callback = function(ev) + if vim.bo[ev.buf].filetype ~= "md-render" then return end + if vim.b[ev.buf].md_render_yank_installed then return end + vim.b[ev.buf].md_render_yank_installed = true + + vim.keymap.set("n", "yy", function() + local r, count, reg = vim.fn.line("."), vim.v.count1, vim.v.register + if not yank_source(ev.buf, r, r + count - 1, reg) then + vim.api.nvim_feedkeys('"' .. reg .. count .. "yy", "n", false) + end + end, { buffer = ev.buf, desc = "md-render: yank markdown source line(s)" }) + + local function visual_yank(always_source) + return function() + if not render_ctx() then return "y" end + if not always_source and vim.fn.mode() == "v" and vim.fn.line("v") == vim.fn.line(".") then + return "y" -- charwise within one rendered line: native yank + end + local a, b, reg = vim.fn.line("v"), vim.fn.line("."), vim.v.register + local buf = ev.buf + vim.schedule(function() yank_source(buf, math.min(a, b), math.max(a, b), reg) end) + return "" + end + end + vim.keymap.set("x", "y", visual_yank(false), { + buffer = ev.buf, expr = true, desc = "md-render: yank markdown source of selection", + }) + vim.keymap.set("x", "Y", visual_yank(true), { + buffer = ev.buf, expr = true, desc = "md-render: yank markdown source of selected rows", + }) + end, + }) end, keys = { { "mp", - function() require("md-render").preview.show({ max_width = 140 }) end, + function() require("md-render").preview.show() end, ft = "markdown", - desc = "Markdown preview (wide float toggle)", + desc = "Markdown preview (float toggle)", }, { "mt", - function() require("md-render").preview.show_tab({ max_width = 140 }) end, + function() require("md-render").preview.show_tab() end, ft = "markdown", - desc = "Markdown preview (wide tab toggle)", + desc = "Markdown preview (tab toggle)", }, { "ms", - function() require("md-render").preview.split({ max_width = 140 }) end, + function() require("md-render").preview.split() end, ft = "markdown", desc = "Markdown source/render split", }, { "mr", - function() require("md-render").preview.toggle({ max_width = 140 }) end, + function() require("md-render").preview.toggle() end, ft = "markdown", desc = "Markdown render toggle in-place", }, @@ -329,6 +506,116 @@ return { patch_offscreen_mermaid() + -- md-render bug (v3.11.1, content_builder.lua ~2616/~2693): when a + -- mermaid/PlantUML block becomes an image, the builder pops the + -- already-emitted code lines from self.lines but NOT from + -- self.source_line_map, so every rendered line below the diagram maps + -- #removed lines too early (render-mode dd/x/p/o edit the wrong line). + -- All map writes go through add_line, so re-align there. No-op once + -- fixed upstream (the map is then never longer than the lines). + local function patch_source_line_map() + local ok, mod = pcall(require, "md-render.content_builder") + local CB = ok and type(mod) == "table" and mod.ContentBuilder or nil + if not CB or CB._thembones_source_map_patch then return end + if type(CB.add_line) ~= "function" or type(CB.result) ~= "function" then return end + CB._thembones_source_map_patch = true + local original_add_line, original_result = CB.add_line, CB.result + + CB.add_line = function(self, ...) + original_add_line(self, ...) + local map, n = self.source_line_map, #self.lines + if type(map) == "table" and #map > n then + local newest = map[#map] -- entry just appended for line n + for i = #map, n, -1 do map[i] = nil end -- drop the stale tail + map[n] = newest + end + end + + CB.result = function(self, ...) + local map, n = self.source_line_map, #self.lines + if type(map) == "table" then + for i = #map, n + 1, -1 do map[i] = nil end + end + return original_result(self, ...) + end + end + + patch_source_line_map() + + -- Session:rendered_to_source() rounds a linear interpolation between + -- sync points; across a multi-row image/diagram the lower rows round to + -- the NEXT source line (dd on the bottom half of an image deleted the + -- blank line after it). Callers of the integer version (toggle cursor + -- placement, so every hop key; the float footer) want the exact line, + -- so snap to the raw map. Scroll sync uses the *_f variants, untouched. + local function patch_exact_rendered_to_source() + local ok, preview = pcall(require, "md-render.preview") + local S = ok and type(preview) == "table" and preview._Session or nil + if not S or S._thembones_exact_source_patch then return end + if type(S.rendered_to_source) ~= "function" then return end + S._thembones_exact_source_patch = true + local original_rendered_to_source = S.rendered_to_source + + S.rendered_to_source = function(self, rendered_line, ...) + local map = self.content and self.content.source_line_map + if type(map) == "table" and #map > 0 and type(rendered_line) == "number" then + local v = map[math.max(1, math.min(math.floor(rendered_line), #map))] + if type(v) == "number" and v > 0 then return v end + end + return original_rendered_to_source(self, rendered_line, ...) + end + end + + patch_exact_rendered_to_source() + + -- md-render's auto mode hops i/I/a/A/o/O from the render view to source + -- with buffer-local maps that toggle() and then vim.schedule() an + -- appended feedkeys (preview.lua install_auto_insert_keymaps). Keys + -- typed in the same burst (fast typing, a paste through typeahead) were + -- already queued, so they ran first in source Normal mode: `ohi` + -- turned "# Title" into "o# Title". After auto_on() installs those maps, + -- replace them with the same hop fed synchronously at the FRONT of the + -- typeahead (as the editing-key hop in `init` does), keeping a count. + -- Only maps md-render itself installed (matched by desc) are replaced, + -- and auto_off() still removes them. + local function patch_auto_insert_hop() + local ok, preview = pcall(require, "md-render.preview") + if not ok or type(preview) ~= "table" or preview._thembones_insert_hop_patch then return end + if type(preview.auto_on) ~= "function" or type(preview._toggle_sessions) ~= "table" then return end + preview._thembones_insert_hop_patch = true + local original_auto_on = preview.auto_on + + local function install(render_buf) + local stock = {} + for _, map in ipairs(vim.api.nvim_buf_get_keymap(render_buf, "n")) do + stock[map.lhs] = map.desc + end + for _, key in ipairs({ "i", "I", "a", "A", "o", "O" }) do + local desc = "md-render auto: switch to source then " .. key + if stock[key] == desc then + vim.keymap.set("n", key, function() + local count = vim.v.count + preview.toggle() + if vim.bo.filetype == "md-render" then return end -- toggle refused + vim.api.nvim_feedkeys((count > 0 and tostring(count) or "") .. key, "ni", false) + end, { buffer = render_buf, noremap = true, silent = true, desc = desc .. " (in order)" }) + end + end + end + + preview.auto_on = function(...) + original_auto_on(...) + for src_buf, session in pairs(preview._toggle_sessions) do + if vim.api.nvim_buf_is_valid(src_buf) and vim.b[src_buf].md_render_auto + and session.buf and vim.api.nvim_buf_is_valid(session.buf) then + install(session.buf) + end + end + end + end + + patch_auto_insert_hop() + -- md-render's Ghostty path intentionally re-transmits images on every -- placement so redraws stay visible. Its stock transport uses `t=f`, -- which means "the terminal reads this file path". Over SSH that path is @@ -753,6 +1040,84 @@ return { end end + -- md-render bug (v3.11.1, display_utils.lua place_images): image + -- placements belong to a window, not to the render buffer in it. After + -- :e / :b / a picker puts another file in that window, the window's + -- WinScrolled/CursorMoved redraw keeps placing the images at the same + -- rows over the new file. Only place them while the window still shows + -- the buffer they were set up for, clear them when that buffer leaves + -- the window, and put them back when it returns. + local function patch_image_window_guard() + local img = require("md-render.image") + local du = require("md-render.display_utils") + if img._thembones_win_guard_patch then return end + img._thembones_win_guard_patch = true + + local owner_buf = {} -- win -> buffer whose images that window shows + local original_setup_images = du.setup_images + du.setup_images = function(win, content, ns, opts) + if vim.api.nvim_win_is_valid(win) then + owner_buf[win] = opts and opts.buf or vim.api.nvim_win_get_buf(win) + end + return original_setup_images(win, content, ns, opts) + end + + local original_put_image = img.put_image + img.put_image = function(image_id, win, ...) + local owner = owner_buf[win] + if owner and vim.api.nvim_win_is_valid(win) and vim.api.nvim_win_get_buf(win) ~= owner then + return + end + return original_put_image(image_id, win, ...) + end + + local function session_for(buf) + for _, session in pairs(require("md-render").preview._toggle_sessions or {}) do + if session.buf == buf and session.image_state then return session end + end + end + + local group = vim.api.nvim_create_augroup("MdRenderImageWindowGuard", { clear = true }) + vim.api.nvim_create_autocmd("BufWinLeave", { + group = group, + desc = "md-render: clear images when the render buffer leaves its window", + callback = function(ev) + local session = session_for(ev.buf) + if not session then return end + local state = session.image_state + img.begin_batch() + for _, id in pairs(state.image_ids or {}) do + img.clear_placements(id) + end + for _, anim in pairs(state.anims or {}) do + for _, id in ipairs(anim.frame_ids or {}) do + img.clear_placements(id) + end + end + img.flush_batch() + end, + }) + vim.api.nvim_create_autocmd("BufWinEnter", { + group = group, + desc = "md-render: re-place images when the render buffer returns", + callback = function(ev) + local session = session_for(ev.buf) + if not session then return end + local win = vim.api.nvim_get_current_win() + if session.win == win then + session.image_state.schedule_redraw() + elseif not (vim.api.nvim_win_is_valid(session.win) and vim.api.nvim_win_get_buf(session.win) == session.buf) then + -- Came back in a different window: move the images here, as + -- md-render's own toggle does. + session:cleanup_images() + session:bind_window(win) + end + end, + }) + end + + patch_image_window_guard() + local function mermaid_sources(buf) local sources = {} local in_mermaid = false @@ -786,7 +1151,18 @@ return { for _, source in ipairs(mermaid_sources(buf)) do if not image.get_mermaid_cached(source) then - image.render_mermaid(source) + -- Async so Esc / :w don't freeze for the mmdc run (~1s, up to 30s + -- on the npx fallback). md-render's placement pass + -- (display_utils.lua produce()) calls the same patched + -- render_mermaid_async, which de-duplicates in-flight jobs per + -- cache path (mermaid_inflight above), so it joins this job and + -- rebuilds when the PNG lands. Until then the diagram shows + -- md-render's "Rendering mermaid diagram..." placeholder. + if image.render_mermaid_async then + image.render_mermaid_async(source, function() end) + else + image.render_mermaid(source) + end end end end @@ -794,6 +1170,10 @@ return { local function ensure_md_render_auto(buf) if not vim.api.nvim_buf_is_valid(buf) then return end if vim.bo[buf].filetype ~= "markdown" then return end + -- Skip scratch markdown buffers (LSP hover, completion docs, noice) and + -- buffers that aren't current: auto_on always targets the current buffer. + if vim.bo[buf].buftype ~= "" then return end + if vim.api.nvim_get_current_buf() ~= buf then return end if not vim.b[buf].md_render_auto then local cache_group = vim.api.nvim_create_augroup("MdRenderMermaidCache" .. buf, { clear = true }) @@ -803,7 +1183,7 @@ return { callback = function() prime_mermaid_cache(buf) end, - desc = "Prime md-render Mermaid cache before redraw", + desc = "Prime md-render Mermaid cache before redraw (async)", }) end @@ -818,7 +1198,7 @@ return { pcall(vim.api.nvim_win_del_var, win, "md_render_state") end - pcall(md.preview.auto_on, { max_width = 140 }) + pcall(md.preview.auto_on) end end diff --git a/private_dot_config/nvim/lua/plugins/indent.lua b/private_dot_config/nvim/lua/plugins/indent.lua index 1294db4..1d99062 100644 --- a/private_dot_config/nvim/lua/plugins/indent.lua +++ b/private_dot_config/nvim/lua/plugins/indent.lua @@ -1,7 +1,11 @@ -- Override LazyVim's indent-blankline for VS Code-like indent guides +-- Disabled: LazyVim now draws indent guides (and the current scope) with +-- snacks.indent ("│", toggle ug), so ibl only drew a second set. +-- Delete the `enabled = false` line to bring ibl back. return { { "lukas-reineke/indent-blankline.nvim", + enabled = false, main = "ibl", -- v3 module name opts = { indent = { diff --git a/private_dot_config/nvim/lua/plugins/lsp.lua b/private_dot_config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..ca40bd1 --- /dev/null +++ b/private_dot_config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,36 @@ +return { + { + "neovim/nvim-lspconfig", + opts = function(_, opts) + -- LazyVim maps gD unconditionally; tsgo has no textDocument/declaration. + -- Gate it so servers without it keep Vim's built-in gD. + table.insert(opts.servers["*"].keys, { + "gD", + vim.lsp.buf.declaration, + desc = "Goto Declaration", + has = "declaration", + }) + -- Call hierarchy: the tool for understanding a call chain without editing. + -- ci = who calls this (incoming); co = what this calls (outgoing). + -- Uses Telescope's picker when present. Gated on callHierarchy support. Added 2026-10-23. + table.insert(opts.servers["*"].keys, { + "ci", + function() + local ok, tb = pcall(require, "telescope.builtin") + if ok then tb.lsp_incoming_calls() else vim.lsp.buf.incoming_calls() end + end, + desc = "Incoming Calls (callers)", + has = "callHierarchy", + }) + table.insert(opts.servers["*"].keys, { + "co", + function() + local ok, tb = pcall(require, "telescope.builtin") + if ok then tb.lsp_outgoing_calls() else vim.lsp.buf.outgoing_calls() end + end, + desc = "Outgoing Calls (callees)", + has = "callHierarchy", + }) + end, + }, +} diff --git a/private_dot_config/nvim/lua/plugins/markdown-no-lint.lua b/private_dot_config/nvim/lua/plugins/markdown-no-lint.lua deleted file mode 100644 index 5b46426..0000000 --- a/private_dot_config/nvim/lua/plugins/markdown-no-lint.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - { - "mfussenegger/nvim-lint", - optional = true, - opts = { - linters_by_ft = { - markdown = {}, -- no linters for .md - ["markdown.mdx"] = {}, -- no linters for .mdx - }, - }, - }, -} diff --git a/private_dot_config/nvim/lua/plugins/markdown.lua b/private_dot_config/nvim/lua/plugins/markdown.lua index a5451dd..ad4d79b 100644 --- a/private_dot_config/nvim/lua/plugins/markdown.lua +++ b/private_dot_config/nvim/lua/plugins/markdown.lua @@ -21,6 +21,7 @@ return { opts = { linters_by_ft = { markdown = {}, + ["markdown.mdx"] = {}, }, }, }, diff --git a/private_dot_config/nvim/lua/plugins/meow-yarn.lua b/private_dot_config/nvim/lua/plugins/meow-yarn.lua new file mode 100644 index 0000000..b15b6ce --- /dev/null +++ b/private_dot_config/nvim/lua/plugins/meow-yarn.lua @@ -0,0 +1,28 @@ +-- meow.yarn.nvim — interactive, expandable call/type hierarchy TREE (like VS Code's +-- Call Hierarchy panel), built on native LSP + nui.nvim. Added 2026-10-23 for reading +-- call chains in the TS code-walkthrough prep. Telescope's lsp_*_calls is flat/one-level; +-- this one expands recursively, previews code, and lets you drill in / switch direction. +-- +-- Keys (y = "yarn"): put the cursor on a function, then +-- yc callers (who calls this) yC callees (what this calls) +-- yt supertypes yT subtypes +-- yl re-open last hierarchy +-- In the tree: jump, o/za expand, zO/zC expand/collapse all, / filter, back. +return { + { + "retran/meow.yarn.nvim", + dependencies = { "MunifTanjim/nui.nvim" }, + keys = { + { "y", "", desc = "+yarn (hierarchy)" }, + { "yc", function() require("meow.yarn").open_tree("call_hierarchy", "callers") end, desc = "Yarn: callers (who calls this)" }, + { "yC", function() require("meow.yarn").open_tree("call_hierarchy", "callees") end, desc = "Yarn: callees (what this calls)" }, + { "yt", function() require("meow.yarn").open_tree("type_hierarchy", "supertypes") end, desc = "Yarn: supertypes" }, + { "yT", function() require("meow.yarn").open_tree("type_hierarchy", "subtypes") end, desc = "Yarn: subtypes" }, + { "yl", "(MeowYarnLast)", desc = "Yarn: last hierarchy" }, + }, + opts = {}, + config = function(_, opts) + require("meow.yarn").setup(opts) + end, + }, +} diff --git a/private_dot_config/nvim/lua/plugins/minimap.lua b/private_dot_config/nvim/lua/plugins/minimap.lua index 58a4345..c184958 100644 --- a/private_dot_config/nvim/lua/plugins/minimap.lua +++ b/private_dot_config/nvim/lua/plugins/minimap.lua @@ -6,7 +6,7 @@ return { lazy = false, keys = { { "um", "Neominimap Toggle", desc = "Toggle minimap" }, - { "uf", "Neominimap Focus", desc = "Focus minimap" }, + { "uM", "Neominimap Focus", desc = "Focus minimap" }, }, init = function() vim.g.neominimap = { @@ -33,10 +33,14 @@ return { enabled = true, mode = "line", -- Highlight full line }, + -- Git changes come from gitsigns (see lua/plugins/git.lua). git = { enabled = true, mode = "line", -- Full line highlight for git changes }, + mini_diff = { + enabled = false, + }, search = { enabled = true, mode = "line", diff --git a/private_dot_config/nvim/lua/plugins/minuet.lua b/private_dot_config/nvim/lua/plugins/minuet.lua deleted file mode 100644 index 023f23f..0000000 --- a/private_dot_config/nvim/lua/plugins/minuet.lua +++ /dev/null @@ -1,115 +0,0 @@ --- Inline LLM (ghost-text) completion tuned for writing markdown/prose. --- Reuses ZAI_API_KEY from the environment (same key the :AI command uses). --- Suggestions are virtual text, auto-triggered behind a debounce delay. -local PROSE_FT = { - markdown = true, - ["md-render"] = true, - text = true, - rst = true, - tex = true, - gitcommit = true, - mail = true, -} - -return { - "milanglacier/minuet-ai.nvim", - dependencies = { "nvim-lua/plenary.nvim" }, - -- Load eagerly: minuet only sets its buffer-local auto-trigger flag from a - -- FileType autocmd registered in setup(). Lazy-loading on InsertEnter would - -- register that autocmd *after* the current buffer's FileType already fired, - -- so virtualtext would never auto-trigger on the buffer you're editing. - lazy = false, - opts = { - provider = "openai_compatible", - -- One natural continuation, not three alternatives — prose has a single - -- "next sentence", and fewer candidates means less to read past. - n_completions = 1, - -- Give the model more of the text *before* the cursor (default 0.75). - context_ratio = 0.85, - -- Cap how much surrounding text is sent. Smaller = lower, steadier latency - -- (the full default of 16000 chars is overkill for prose continuation and - -- inflates time-to-first-token). 4000 chars ≈ plenty of preceding context. - context_window = 4000, - -- Delay knobs: wait for an idle pause, and rate-limit requests. Groq is fast - -- and deterministic, so we can afford a snappier debounce than the cloud - -- defaults; throttle stays moderate to respect the free-tier rate limit. - throttle = 800, -- min ms between requests - debounce = 400, -- ms of idle typing before a request fires - provider_options = { - openai_compatible = { - api_key = "GROQ_API_KEY", -- env var NAME; minuet reads it at runtime - name = "Groq", - -- Groq's LPU inference gives ~80-100ms time-to-first-token with very low - -- variance — that consistency is the whole reason for moving off Z.AI's - -- hit-or-miss coding endpoint. OpenAI-compatible, so the schema is unchanged. - end_point = "https://api.groq.com/openai/v1/chat/completions", - -- llama-3.3-70b is Groq's flagship general model: strong prose, still fast - -- on their hardware. If you ever want the absolute lowest latency, swap to - -- "llama-3.1-8b-instant" (faster, slightly weaker prose). - model = "llama-3.3-70b-versatile", - -- Swap minuet's "code completion engine" system prompt for a prose one - -- in writing filetypes; keep the default (string) for code. Guidelines - -- and few-shots are left at defaults so minuet's parsing - -- still works. - system = { - prompt = function() - if PROSE_FT[vim.bo.filetype] then - return [[ -You are a prose writing assistant embedded in a text editor. Continue the -author's text at the marker naturally and fluently, matching -their voice, tone, and sentence rhythm. - -- Output ONLY the continuation text — no preamble, no explanation. -- Never wrap the output in markdown code fences or backticks. -- Do not add headings, bullets, or numbering unless the surrounding text - already uses them. -- Keep it to at most 1-3 sentences and stop at a natural boundary.]] - end - return require("minuet.config").default_system_prefix_first.prompt - end, - }, - optional = { - -- Short, focused completions. (No `thinking` field here — that was a - -- Z.AI-specific param; Groq's Llama models 400 on unknown body fields.) - max_tokens = 96, - temperature = 0.3, - }, - }, - }, - virtualtext = { - auto_trigger_ft = { "*" }, - -- Alt keymaps are kept as a secondary path, but the primary accept key is - -- , wired in config() below (Alt+* doesn't fire in Ghostty without - -- macos-option-as-alt, and Tab is the natural "accept" key for prose). - keymap = { - accept = "", -- accept full suggestion - accept_line = "", -- accept one line - prev = "", - next = "", - dismiss = "", - }, - }, - }, - config = function(_, opts) - require("minuet").setup(opts) - - -- Smart : accept a visible minuet ghost-text suggestion; otherwise fall - -- back to the exact super-tab behavior we had before (jump an active snippet, - -- else insert a literal Tab). Blink's menu navigates with /, not - -- Tab, so this doesn't fight the completion popup. - local vt = require("minuet.virtualtext").action - vim.keymap.set("i", "", function() - if vt.is_visible() then - vt.accept() - elseif vim.snippet.active({ direction = 1 }) then - vim.snippet.jump(1) - else - vim.api.nvim_feedkeys( - vim.api.nvim_replace_termcodes("", true, false, true), - "n", - false - ) - end - end, { desc = "minuet: accept suggestion, else snippet jump / Tab" }) - end, -} diff --git a/private_dot_config/nvim/lua/plugins/navigation.lua b/private_dot_config/nvim/lua/plugins/navigation.lua deleted file mode 100644 index 2bf3335..0000000 --- a/private_dot_config/nvim/lua/plugins/navigation.lua +++ /dev/null @@ -1,3 +0,0 @@ --- Navigation enhancement plugins --- (neoscroll removed due to conflicts with smear-cursor) -return {} diff --git a/private_dot_config/nvim/lua/plugins/neo-tree-extras.lua b/private_dot_config/nvim/lua/plugins/neo-tree-extras.lua index 5b61748..78c2758 100644 --- a/private_dot_config/nvim/lua/plugins/neo-tree-extras.lua +++ b/private_dot_config/nvim/lua/plugins/neo-tree-extras.lua @@ -10,5 +10,9 @@ return { opts.filesystem.filtered_items.always_show = opts.filesystem.filtered_items.always_show or {} table.insert(opts.filesystem.filtered_items.always_show, "*.log") + + -- 60% of neo-tree's default 40-column width + opts.window = opts.window or {} + opts.window.width = 24 end, } diff --git a/private_dot_config/nvim/lua/plugins/nvim-tree.lua b/private_dot_config/nvim/lua/plugins/nvim-tree.lua index 2760043..005e12c 100644 --- a/private_dot_config/nvim/lua/plugins/nvim-tree.lua +++ b/private_dot_config/nvim/lua/plugins/nvim-tree.lua @@ -1,5 +1,9 @@ +-- Disabled: neo-tree (LazyVim editor.neo-tree extra, customised in +-- neo-tree-extras.lua) is the file explorer. Both specs claimed e and +-- which one won changed from start to start. Delete `enabled = false` to restore. return { "nvim-tree/nvim-tree.lua", + enabled = false, dependencies = { "nvim-tree/nvim-web-devicons", }, diff --git a/private_dot_config/nvim/lua/plugins/refactoring-fix.lua b/private_dot_config/nvim/lua/plugins/refactoring-fix.lua new file mode 100644 index 0000000..6caddb8 --- /dev/null +++ b/private_dot_config/nvim/lua/plugins/refactoring-fix.lua @@ -0,0 +1,21 @@ +-- Pin refactoring.nvim (LazyVim editor.refactoring extra) on Neovim < 0.12.5. +-- +-- Since abdcad8 (2026-09-23) refactoring.nvim calls the core vim.pos(buf, row, col) and +-- vim.range(buf, start_row, start_col, end_row, end_col). Neovim only takes buf first from +-- 0.12.5 on (upstream README: "requires Neovim 0.12.5"); 0.12.0-0.12.4 expect +-- vim.range(start_row, start_col, end_row, end_col, { buf = buf }), so every refactor fails +-- with "vim/range.lua:98: attempt to index local 'opts' (a number value)". +-- 8bcf893 is the parent of abdcad8 and the last upstream commit that ships its own +-- refactoring.pos/refactoring.range with the buf-first API; the two commits after it on master +-- are CI/docs only. Pinning in the spec (not just lazy-lock.json) keeps :Lazy update from +-- moving it back to the broken commit. +-- +-- Remove this file once Neovim is >= 0.12.5 (the guard below already stops pinning there), +-- then run :Lazy update refactoring.nvim. +if vim.fn.has("nvim-0.12.5") == 1 then + return {} +end + +return { + { "ThePrimeagen/refactoring.nvim", commit = "8bcf893eb3871bc87b42adffe2fb9b0b7dc9d328" }, +} diff --git a/private_dot_config/nvim/lua/plugins/refactoring.lua b/private_dot_config/nvim/lua/plugins/refactoring.lua deleted file mode 100644 index 3a12351..0000000 --- a/private_dot_config/nvim/lua/plugins/refactoring.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - { - "ThePrimeagen/refactoring.nvim", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-treesitter/nvim-treesitter", - "lewis6991/async.nvim", - }, - ft = { "lua", "python", "javascript", "typescript", "go", "c", "cpp", "java", "php", "ruby" }, - config = function() - require("refactoring").setup() - end, - }, -} diff --git a/private_dot_config/nvim/lua/plugins/search.lua b/private_dot_config/nvim/lua/plugins/search.lua index 9592f17..fca4a2c 100644 --- a/private_dot_config/nvim/lua/plugins/search.lua +++ b/private_dot_config/nvim/lua/plugins/search.lua @@ -7,8 +7,10 @@ return { event = "VeryLazy", enabled = true, -- Set to false to disable keys = { - { "n", [[execute('normal! ' . v:count1 . 'n')lua require('hlslens').start()]], desc = "Next search result" }, - { "N", [[execute('normal! ' . v:count1 . 'N')lua require('hlslens').start()]], desc = "Previous search result" }, + -- n/N keep LazyVim's direction-stable behaviour (n always searches + -- forward, N backward, even after `?`) and open folds (zv). + { "n", [[execute('normal! ' . v:count1 . 'Nn'[v:searchforward] . 'zv')lua require('hlslens').start()]], desc = "Next Search Result" }, + { "N", [[execute('normal! ' . v:count1 . 'nN'[v:searchforward] . 'zv')lua require('hlslens').start()]], desc = "Prev Search Result" }, { "*", [[*lua require('hlslens').start()]], desc = "Search word under cursor" }, { "#", [[#lua require('hlslens').start()]], desc = "Search word under cursor (backward)" }, { "g*", [[g*lua require('hlslens').start()]], desc = "Search word under cursor (no boundary)" }, @@ -37,22 +39,36 @@ return { default_replace_single_buffer_options = "gcI", default_replace_multi_buffer_options = "egcI", }, + -- Under R: r belongs to LazyVim's refactoring extra + -- (rs and rf collided). Selection maps use mode "x", not + -- "v", so typing a space over a Shift+arrow (Select mode) selection + -- doesn't wait for a mapping. keys = { -- Single buffer replacements - { "rs", "SearchReplaceSingleBufferSelections", desc = "Search/Replace Selections", mode = "v" }, - { "ro", "SearchReplaceSingleBufferOpen", desc = "Search/Replace Open" }, - { "rw", "SearchReplaceSingleBufferCWord", desc = "Search/Replace Word" }, - { "rW", "SearchReplaceSingleBufferCWORD", desc = "Search/Replace WORD" }, - { "re", "SearchReplaceSingleBufferCExpr", desc = "Search/Replace Expr" }, - { "rf", "SearchReplaceSingleBufferCFile", desc = "Search/Replace File" }, + { "Rs", "SearchReplaceSingleBufferSelections", desc = "Search/Replace Selections", mode = "x" }, + { "Ro", "SearchReplaceSingleBufferOpen", desc = "Search/Replace Open" }, + { "Rw", "SearchReplaceSingleBufferCWord", desc = "Search/Replace Word" }, + { "RW", "SearchReplaceSingleBufferCWORD", desc = "Search/Replace WORD" }, + { "Re", "SearchReplaceSingleBufferCExpr", desc = "Search/Replace Expr" }, + { "Rf", "SearchReplaceSingleBufferCFile", desc = "Search/Replace File" }, -- Multi buffer replacements - { "rbs", "SearchReplaceMultiBufferSelections", desc = "Search/Replace Selections (Multi)", mode = "v" }, - { "rbo", "SearchReplaceMultiBufferOpen", desc = "Search/Replace Open (Multi)" }, - { "rbw", "SearchReplaceMultiBufferCWord", desc = "Search/Replace Word (Multi)" }, - { "rbW", "SearchReplaceMultiBufferCWORD", desc = "Search/Replace WORD (Multi)" }, - { "rbe", "SearchReplaceMultiBufferCExpr", desc = "Search/Replace Expr (Multi)" }, - { "rbf", "SearchReplaceMultiBufferCFile", desc = "Search/Replace File (Multi)" }, + { "Rbs", "SearchReplaceMultiBufferSelections", desc = "Search/Replace Selections (Multi)", mode = "x" }, + { "Rbo", "SearchReplaceMultiBufferOpen", desc = "Search/Replace Open (Multi)" }, + { "Rbw", "SearchReplaceMultiBufferCWord", desc = "Search/Replace Word (Multi)" }, + { "RbW", "SearchReplaceMultiBufferCWORD", desc = "Search/Replace WORD (Multi)" }, + { "Rbe", "SearchReplaceMultiBufferCExpr", desc = "Search/Replace Expr (Multi)" }, + { "Rbf", "SearchReplaceMultiBufferCFile", desc = "Search/Replace File (Multi)" }, + }, + }, + { + "folke/which-key.nvim", + optional = true, + opts = { + spec = { + { "R", group = "search/replace", mode = { "n", "x" } }, + { "Rb", group = "multi-buffer", mode = { "n", "x" } }, + }, }, }, } diff --git a/private_dot_config/nvim/lua/plugins/typescript.lua b/private_dot_config/nvim/lua/plugins/typescript.lua new file mode 100644 index 0000000..1a52cfb --- /dev/null +++ b/private_dot_config/nvim/lua/plugins/typescript.lua @@ -0,0 +1,59 @@ +-- TypeScript LSP: LazyVim's lang.typescript.tsc extra runs lspconfig's `tsc` +-- server (`tsc --lsp`), which already prefers a project-local +-- node_modules/.bin/tsc that supports --lsp (TypeScript >= 7) and disables +-- tsgo, so no server override is needed here. +return { + { + "nvim-neotest/neotest", + optional = true, + dependencies = { "marilari88/neotest-vitest" }, + opts = { + adapters = { + ["neotest-vitest"] = {}, + }, + }, + }, + + -- Inlay hints: show inferred TYPES inline while reading code. LazyVim's tsc extra + -- turns variableTypes/functionLikeReturnTypes OFF by default (noisy); for reading an + -- unfamiliar TS codebase (interview walkthroughs) the inferred types inline are the + -- point, so turn them back on. Toggle the whole thing live with uh. + -- Added 2026-10-23. + { + "neovim/nvim-lspconfig", + opts = { + servers = { + tsc = { + settings = { + ["js/ts"] = { + inlayHints = { + variableTypes = { enabled = true }, + functionLikeReturnTypes = { enabled = true }, + parameterNames = { enabled = "all", suppressWhenArgumentMatchesName = true }, + parameterTypes = { enabled = true }, + propertyDeclarationTypes = { enabled = true }, + enumMemberValues = { enabled = true }, + }, + }, + }, + }, + }, + }, + }, + + -- Turn inlay hints ON by default, but only for TS/JS buffers, so Go/Python/etc. are + -- unaffected. uh still toggles per buffer. + { + "neovim/nvim-lspconfig", + opts = function() + vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local ft = vim.bo[args.buf].filetype + if ft:match("^typescript") or ft:match("^javascript") then + pcall(vim.lsp.inlay_hint.enable, true, { bufnr = args.buf }) + end + end, + }) + end, + }, +} diff --git a/private_dot_config/nvim/lua/plugins/ui-enhancements.lua b/private_dot_config/nvim/lua/plugins/ui-enhancements.lua index 8cde267..8cfd640 100644 --- a/private_dot_config/nvim/lua/plugins/ui-enhancements.lua +++ b/private_dot_config/nvim/lua/plugins/ui-enhancements.lua @@ -7,6 +7,11 @@ return { enabled = true, dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" }, opts = { + -- md-render.nvim (lua/plugins/image.lua) owns the rendered view of + -- markdown files; the source buffer is what you edit, so keep it + -- plain. render-markdown still decorates nofile floats (LSP hover, + -- completion docs). Re-enable per buffer with :RenderMarkdown buf_toggle. + overrides = { buftype = { [""] = { enabled = false } } }, render_modes = { "n", "i", "c", "t" }, heading = { enabled = true,