diff --git a/nvim/README.md b/nvim/README.md index 66cd153..68ed840 100644 --- a/nvim/README.md +++ b/nvim/README.md @@ -28,7 +28,7 @@ First launch will take a minute or two: `lazy.nvim` bootstraps itself and instal ## Editor basics - Relative + absolute line numbers, system clipboard integration (`unnamedplus`), persistent undo, smart-case search, always-on sign column. -- Tab width: **4 spaces**, expanded (matches `~/.clang-format`'s `IndentWidth: 4`). +- Tab width: **4**, using real tab characters — not expanded to spaces. - True color, rounded borders on floating windows (hover, LspInfo, Mason, etc. — Neovim 0.11+), styled window separators. - OSC 52 clipboard support, so yank/paste works correctly over SSH. - `c`/`cpp` indentation uses Vim's native `cindent` rather than treesitter's indent module — treesitter's C/C++ indent is known to be unreliable (inconsistent brace placement); `cindent` is far more predictable for brace-heavy code. @@ -64,13 +64,15 @@ Each buffer tab shows its ordinal position number. Pinned buffers are always kep | Key | Action | |---|---| | `` / `` | Previous / next buffer (follows the order shown on screen, including any reordering) | -| `` … `` | Jump directly to the buffer at that position | -| `` | Jump to the last buffer | +| `` … `` / ``–`` | Jump directly to the buffer at that position. `` and `` each pull double duty with the debugger (see [Debugging](#debugging-nvim-dap)) — they act as buffer jumps at rest, and hand themselves over to DAP for the duration of an active debug session. | +| `` / `` | Jump to the last buffer. | | `` / `` | Move current buffer left / right (blocked from crossing into the pinned block — wraps to the other end instead) | | `bp` | Toggle pin on current buffer | | `bx` | Close every **unpinned** buffer with **no unsaved changes** (pinned buffers and anything modified are left alone) | | `bd` | Close current buffer | +Setting an explicit `` mapping here also overrides Neovim's built-in ``-opens-help default — any explicit keymap for a key always takes precedence over Neovim's default for it. + ## File & text search (`telescope`) | Key | Action | @@ -120,8 +122,8 @@ C/C++ (and Rust) debugging via `codelldb`, auto-installed by Mason on first use. | Key | Action | |---|---| -| `F5` / `dc` | Continue / start debugging | -| `F10` / `do` | Step over | +| `F5` / `dc` | Continue / start debugging — `F5` only while a session is already active; before that it's the "jump to buffer 5" shortcut, so **start a session with `dc` or `db`**, not `F5` | +| `F10` / `do` | Step over — `F10` only while a debug session is active; otherwise it's the "jump to last buffer" shortcut (see [Buffers & tabs](#buffers--tabs-bufferline)) | | `F11` / `di` | Step into | | `F12` / `dO` | Step out | | `db` | Toggle breakpoint | @@ -150,7 +152,7 @@ Neovim's embedded terminal launches **fish** instead of your login shell, purely ## Formatting -`~/.clang-format` is written on every run (LLVM-based, `BreakBeforeBraces: Attach` for K&R-style braces, 4-space indent, 100-column limit). `clang-format` walks upward from the file being formatted looking for a `.clang-format`; since `$HOME` sits above every project, this acts as a personal default for any project that doesn't ship its own `.clang-format` — a project's own file always takes precedence. +`~/.clang-format` is written on every run (LLVM-based, `BreakBeforeBraces: Attach` for K&R-style braces, 4-wide real tabs via `UseTab: Always`/`TabWidth: 4` to match the editor, 100-column limit). `clang-format` walks upward from the file being formatted looking for a `.clang-format`; since `$HOME` sits above every project, this acts as a personal default for any project that doesn't ship its own `.clang-format` — a project's own file always takes precedence. ## Known quirks diff --git a/nvim/v4-dnf.sh b/nvim/v5-dnf.sh similarity index 93% rename from nvim/v4-dnf.sh rename to nvim/v5-dnf.sh index b4d2e5e..6552978 100755 --- a/nvim/v4-dnf.sh +++ b/nvim/v5-dnf.sh @@ -68,11 +68,11 @@ vim.g.maplocalleader = " " -- Basic Options vim.opt.number = true --- Tab width: 4 spaces, expanded (matches IndentWidth: 4 in ~/.clang-format) +-- Tab width: 4, using real tab characters (not expanded to spaces) vim.opt.tabstop = 4 vim.opt.shiftwidth = 4 vim.opt.softtabstop = 4 -vim.opt.expandtab = true +vim.opt.expandtab = false vim.opt.relativenumber = true vim.opt.mouse = "a" vim.opt.clipboard = "unnamedplus" @@ -467,6 +467,31 @@ return { require('bufferline').go_to(-1, true) end, { desc = "Go to Last Buffer" }) + -- F1..F9: same jump-by-position, on Fn+Number instead of + -- Alt+Number. Explicitly setting here overrides Neovim's + -- default -opens-help binding outright (any explicit + -- vim.keymap.set for a key always supersedes Neovim's built-in + -- default for it), so no separate step is needed to "disable" + -- that. + -- + -- and are set below, OUTSIDE this loop -- both are + -- shared with nvim-dap (Continue and Step Over respectively) and + -- toggle dynamically based on whether a debug session is active + -- (see the dap.listeners hooks in the DAP plugin further down). + -- At rest, both act as ordinary buffer jumps like everything + -- else in this loop. + for _, i in ipairs({ 1, 2, 3, 4, 6, 7, 8, 9 }) do + vim.keymap.set('n', (''):format(i), function() + require('bufferline').go_to(i, true) + end, { desc = "Go to Buffer " .. i }) + end + vim.keymap.set('n', '', function() + require('bufferline').go_to(5, true) + end, { desc = "Go to Buffer 5" }) + vim.keymap.set('n', '', function() + require('bufferline').go_to(-1, true) + end, { desc = "Go to Last Buffer" }) + -- Alt+,/. : reorder the current buffer left/right in the -- bufferline (persists for the session as long as -- sessionoptions includes "globals", which lazy.nvim's default @@ -923,6 +948,31 @@ return { dapui.close() end + -- and are each shared between an nvim-dap action + -- (Continue, Step Over) and a bufferline buffer jump (buffer 5, + -- last buffer) -- at rest they're buffer jumps; for the + -- duration of a debug session they're handed over to DAP + -- instead, so nothing fights over the same key. Note this means + -- can no longer START a fresh session on its own (there's + -- no session yet at that point, so it's still doing buffer-jump + -- duty) -- use dc or db to start one, then + -- takes over for continuing from there. Reusing the same + -- listener points as the dapui open/close hooks above. + dap.listeners.after.event_initialized["fkey_toggle"] = function() + vim.keymap.set('n', '', dap.continue, { desc = "Debug: Continue" }) + vim.keymap.set('n', '', dap.step_over, { desc = "Debug: Step Over" }) + end + local function restore_fkey_buffer_jumps() + vim.keymap.set('n', '', function() + require('bufferline').go_to(5, true) + end, { desc = "Go to Buffer 5" }) + vim.keymap.set('n', '', function() + require('bufferline').go_to(-1, true) + end, { desc = "Go to Last Buffer" }) + end + dap.listeners.before.event_terminated["fkey_toggle"] = restore_fkey_buffer_jumps + dap.listeners.before.event_exited["fkey_toggle"] = restore_fkey_buffer_jumps + -- C / C++ / Rust launch configs, all sharing the codelldb adapter dap.configurations.cpp = { { @@ -958,8 +1008,10 @@ return { vim.api.nvim_set_hl(0, "DapStoppedLine", { bg = "#0b3528" }) -- Keymaps, grouped under d (shows in which-key) - vim.keymap.set('n', '', dap.continue, { desc = "Debug: Continue" }) - vim.keymap.set('n', '', dap.step_over, { desc = "Debug: Step Over" }) + -- and intentionally NOT bound here -- both are set + -- dynamically by the dap.listeners hooks above (Continue/Step + -- Over only while a session is active; bufferline's buffer-5/ + -- last-buffer jumps otherwise). vim.keymap.set('n', '', dap.step_into, { desc = "Debug: Step Into" }) vim.keymap.set('n', '', dap.step_out, { desc = "Debug: Step Out" }) @@ -1158,8 +1210,10 @@ BasedOnStyle: LLVM BreakBeforeBraces: Attach IndentWidth: 4 ColumnLimit: 100 +UseTab: Always +TabWidth: 4 EOF -echo "Wrote ~/.clang-format (Attach braces)." +echo "Wrote ~/.clang-format (Attach braces, real tabs)." echo "=========================================" echo " Setup Complete!"