Skip to content

Finish OLD_FILES, save undo, XDG_DOTVIM fallback, :help mappings reference (#4, #129, #137, #103) - #142

Merged
harleypig merged 7 commits into
masterfrom
fix/editor-round-2
Nov 4, 2026
Merged

harleypig merged 7 commits into
masterfrom
fix/editor-round-2

Conversation

@harleypig

@harleypig harleypig commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Finishes the editor work left after #127 and #123: the last settings in
OLD_FILES/ move in, undo history is saved, .vimrc works with
XDG_DOTVIM unset, and the :help mappings reference matches the
mappings. One commit per item.

Closes #4
Closes #129
Closes #137
Closes #103
Refs #124
Refs #21
Refs #133
Refs #109

What changed, and why

#4: the rest of OLD_FILES/ moves in, and the directory goes

The mappings move to the late maps.vim and diffopt+=algorithm:patience
moves to set.vim. Each one was checked against what is already mapped
and loaded:

  • <Leader>O, <Leader>o, <Leader>y, <Leader>b, <Leader>ml and Y
    were unmapped, and no existing mapping starts with any of them.
  • S is Normal mode only. vim-surround's S is a Visual-mode mapping, and
    its Normal-mode keys (ys, yS, cs, ds) are untouched. The built-in
    S does the same as cc, which still works.
  • . clashed with vim-repeat. The first time vim-surround calls
    repeat#set, vim-repeat's autoload file maps . to <Plug>(RepeatDot),
    and that silently replaced our mapping. maps.vim now loads that
    autoload file itself and maps . through <Plug>(RepeatDot). Surround
    changes still repeat, and the cursor still goes back to where the change
    started. Without vim-repeat, . falls back to Vim's own repeat. Composing
    the two was chosen over dropping the mapping because it keeps both
    behaviours.
  • AppendModeline becomes script-local (s:), since only its mapping
    calls it.

OLD_FILES/ is deleted, along with its mention in .claude/WORKFLOW.md.

#129: undofile

set undofile now sits beside undodir in xdg-settings.vim, so the
existing 90-day clean-up of that directory covers the undo files.

#137: XDG_DOTVIM unset or empty

Decision: fall back, rather than fail loudly. When XDG_DOTVIM is
unset or empty, it now takes the directory .vimrc is in, and a
~/.vimrc symlink is followed to the checkout it points into. .vimrc
always sits at the top of the checkout it configures, so the right
directory is already known, and an error message would only ask the user
to type it in. The variable itself is set, rather than a script-local
copy, so the two set lines stay as they were and anything Vim starts
sees the same value.

#103: the :help mappings reference

  • Removed: [g / ]g and <Leader>adr, whose mappings are commented
    out, and the <Tab> / <C-Space> notes for a completion plugin that is
    not installed.
  • Added: the mappings moved in from Either merge or remove files in OLD_FILES #4, <Leader>y, <Leader>b, the
    quickfix list (:QuickfixToggle, <Leader>qf, <Leader>q],
    <Leader>q[), and the help window, which opens on the right at no more
    than 80 columns.
  • Moved: w!! now has its own "Writing as Root" section saying what it
    expands to. c[ / c] are in the quickfix section, marked as needing
    CoC. The help-buffer <Return> / <C-[> mappings are now listed as this
    config's, not as built-ins. The CoC section now says it needs Node.js.
  • The learning-gutter tag, which docs/gutter.md links to, is kept.

Area register (.claude/WORKFLOW.md, Refs #124)

area:filetypes no longer names checkfiletype.vim or the Perl helpers in
tools/, both removed in #124. In area:editor, "diff" (which meant the
removed after/diff.vim) becomes "diff options", meaning the diffopt
this PR adds to set.vim.

coc-html (Refs #21, #133)

coc-html is added to g:coc_global_extensions after coc-git. On the
npm registry it is version 1.9.2, from neoclide/coc-html. It bundles the
HTML language service that the hand-written languageserver.html block in
coc-settings.json tries to provide. That block never starts: it names a
library with no command, and it lists the mustache filetype where
vim-polyglot sets html.mustache. Removing the block from
coc-settings.json lands in the separate intellisense PR
, not here.

Three set.vim options that never took effect (Refs #109)

Each was checked with this configuration loaded:

  • terse only adds the s flag to shortmess, and the later
    shortmess=a replaces it.
  • scroll=11 is reset to half the window height at startup ("Last set
    from changed window size"). In an 8-row terminal it raised E49: Invalid scroll size first.
  • wrapmargin=2 is ignored while textwidth=78 is set.

Decision: remove them rather than make them work. Making them work
would bring in behaviour this configuration has never actually had. After
the removal, an 8-row terminal (a real pty, via script) starts without
E49. No automated test was added: the E49 case needs a real
short terminal, and headless vim -es always reports 24 lines.

Testing evaluation

Run to the qa-tester's standard by the PR author; the team-managed
delegation norm does not apply in this repository.

Change Verdict Automated Falsifier: what turns it red
Moved mappings needs tests: written tests/vim/maps.bats, 9 new tests driven through :normal removing any mapping; mapping . with nnoremap again (the vim-surround test goes red); dropping the fallback branch without vim-repeat
diffopt needs test: written tests/vim/set.bats removing the diffopt line
undofile needs test: written tests/vim/xdg.bats, which now checks undofile=1 in all 3 XDG cases removing set undofile
XDG_DOTVIM fallback needs tests: written tests/vim/vimrc.bats: set, unset, empty, and a ~/.vimrc symlink removing the fallback (unset, empty and symlink go red); dropping resolve() (the symlink test goes red, checked by doing it)
learning.txt no automated test: free-form help text no; manual note below none
WORKFLOW.md, coc-html nothing earns a test: register prose, one list entry none none

Every new test was run red against the code before the change, then green
after it. bats tests/vim: 61 ok. bats tests/shell: passes. markdownlint
(CI image): clean.

Entry-point reach: the .vimrc fallback was exercised through the real
entry point (vim -u <path>) in all four states, including a symlinked
~/.vimrc.

Manual verification

  1. Where: a shell with XDG_DOTVIM unset, in any directory.
    Do: vim -N -u /path/to/dotvim/.vimrc, then :echo &rtp.
    Success: the first entry is /path/to/dotvim/.vim, and :help learning opens on the right.
    Failure: the first entry is /.vim, or E149 for learning.
  2. Do: :help learning-editing.
    Success: "3. Editing" lists <Leader>O, <Leader>o, S, Y, .
    and <Leader>ml.
  3. Do: open a file, type foo bar, then 0ysiw", W and ..
    Success: the line reads "foo" "bar".
  4. Do: edit a file, :w, quit, reopen it, and press u.
    Success: the edit is undone. The undo file is under
    $XDG_STATE_HOME/vim/undo (or ~/.local/state/vim/undo).

What happened: each step was run headless (vim -es, no terminal), on
this branch:

  • Step 1: covered by vimrc.bats; rtp0 and packpath start at the
    checkout's .vim, and :QuickfixToggle exists.
  • Step 2: :help jumped to learning-editing, learning-quickfix,
    learning-sudo, learning-help and learning-gutter, each landing on
    its section heading, with no error.
  • Step 3: covered by maps.bats; the line reads "aa" "bb", and . is
    still <Plug>(RepeatDot) followed by `[.
  • Step 4: after :write, filereadable(undofile(...)) was 1, and the
    file was in state/vim/undo.

The interactive Insert-mode and terminal steps were not run in a real
terminal.

Completion report

  1. The functionality works: yes, see the tests and the manual run above.
  2. The access model is defined: N/A, a local editor configuration.
  3. Permissions are implemented: N/A.
  4. Audit logging is implemented: N/A.
  5. Validation is complete: the only input is XDG_DOTVIM; unset and empty
    are handled, and a set value is used as given, as before.
  6. Errors are handled: the vim-repeat-absent branch falls back to Vim's own
    repeat, and the test suite checks for no errors at startup.
  7. Testing is complete: yes, see the testing evaluation.
  8. Documentation exists: the :help reference is updated. Not
    complete:
    README.md still says XDG_DOTVIM must be set, and that
    startup fails without XDG_STATE_HOME/XDG_DATA_HOME, which has been
    false since fix: XDG fallbacks, w!!, paste toggle and ALE linter names (#85, #101, #25, #100) #123. That file is outside this PR. Risk: a reader sets
    variables that are no longer needed; nothing breaks. Next: a README
    pass.
  9. The completion report has been produced: this section.

Review

opt-out: no review skill ran. The change refuses no work: it adds no hook,
guard or gate. The judgement calls a reviewer should check are the
composed . mapping, which loads vim-repeat's autoload file at startup
and so also maps u, U and <C-R> from the start rather than on first
use, and the #137 fallback, which sets $XDG_DOTVIM in Vim's environment.

Co-Authored-By: AI Agent noreply@harleypig.com

harleypig and others added 6 commits November 3, 2026 15:48
The mappings left in OLD_FILES/misc.vim move to the late maps.vim, and
diffopt+=algorithm:patience to set.vim, each with a test in tests/vim/
seen red before the move and green after.

Each was checked against the mappings and plugins already loaded:

* <Leader>O, <Leader>o, <Leader>y, <Leader>b, <Leader>ml and Y were
  unmapped, and no existing mapping starts with them.
* S is Normal-mode only; vim-surround's S is Visual mode, and its
  Normal-mode keys (ys, yS, cs, ds) are untouched. Built-in S is cc.
* . clashed with vim-repeat: the first time vim-surround calls
  repeat#set, vim-repeat's autoload file maps . to <Plug>(RepeatDot),
  replacing ours without a word. maps.vim now loads that autoload file
  itself and maps . through <Plug>(RepeatDot), so surround changes still
  repeat and the cursor still returns to where the change started.
  Without vim-repeat, . uses the built-in repeat.
* AppendModeline becomes script-local.

OLD_FILES/ is deleted, and its mention in .claude/WORKFLOW.md.

Closes #4

Co-Authored-By: AI Agent <noreply@harleypig.com>
xdg-settings.vim set undodir under the XDG state directory, but nothing
set undofile, so Vim never wrote an undo file there and undo history
was lost when a buffer was unloaded. undofile is now set beside
undodir; the existing 90-day clean-up of that directory applies to the
undo files. tests/vim/xdg.bats checks undofile is on in each of its
XDG cases, alongside the undodir it already checked.

Closes #129

Co-Authored-By: AI Agent <noreply@harleypig.com>
.vimrc put $XDG_DOTVIM/.vim at the front of runtimepath and packpath.
Unset, that is /.vim, and Vim started on its own defaults with none of
the settings and no error. Unset or empty, XDG_DOTVIM now takes the
directory .vimrc is in, resolving a ~/.vimrc symlink to the checkout it
points into. A set XDG_DOTVIM is used as before.

Falling back was chosen over failing with a message: .vimrc always sits
at the top of the checkout it configures, so the right directory is
known and an error would only ask the user to type it. The variable
itself is set rather than a script-local, so the two set lines are
unchanged and anything Vim starts sees the same value.

tests/vim/vimrc.bats covers XDG_DOTVIM set, unset, empty, and a
~/.vimrc symlink; the symlink case goes red without resolve().

Closes #137

Co-Authored-By: AI Agent <noreply@harleypig.com>
The hand-written languageserver.html block in coc-settings.json never
starts: it names vscode-html-languageservice, a library with no command,
and lists the mustache filetype where vim-polyglot sets html.mustache.
coc-html (npm, 1.9.2, neoclide/coc-html) bundles the same HTML language
service, so it goes in g:coc_global_extensions, in name order after
coc-git. Removing the block from coc-settings.json lands separately.

Refs #21
Refs #133

Co-Authored-By: AI Agent <noreply@harleypig.com>
learning.txt listed keys that are not mapped and missed ones that are.

* Removed: [g / ]g and <Leader>adr, whose mappings are commented out in
  maps.vim, and the <Tab> and <C-Space> branches for a completion plugin
  that is not installed.
* Added: the editing mappings moved in from OLD_FILES (#4) - <Leader>O,
  <Leader>o, S, Y, ., <Leader>ml - with <Leader>y and <Leader>b; the
  quickfix list's :QuickfixToggle, <Leader>qf, <Leader>q] and
  <Leader>q[; and the right-hand help split capped at 80 columns.
* Refiled: w!! from "Git Integration" to its own "Writing as Root"
  section, now saying what it expands to (:SudoWrite with vim-eunuch,
  :w !sudo tee > /dev/null % without); c[ / c] to the quickfix section,
  marked CoC-only; the help-buffer <Return> and <C-[> mappings from the
  built-ins to "Help Windows", since this configuration defines them.
* <Leader>pp says it has no Insert-mode counterpart, and the CoC section
  says its mappings exist only with Node.js.

The gutter tag that docs/gutter.md links to is kept.

Closes #103

Co-Authored-By: AI Agent <noreply@harleypig.com>
The area:filetypes entry still named checkfiletype.vim and the Perl
linter helpers in tools/, both removed in #124. The area:editor entry
named "diff", which meant after/diff.vim, also removed there; it now
says "diff options", for the diffopt setting set.vim holds since #4.

Refs #124

Co-Authored-By: AI Agent <noreply@harleypig.com>
@harleypig harleypig added this to the Pre-improvement milestone Nov 3, 2026
Each was checked in Vim 9.1 with this configuration loaded:

* terse only adds the s flag to shortmess, and shortmess=a further down
  replaces the whole value, so the flag never survived.
* scroll=11 is reset to half the window height as soon as Vim learns the
  terminal size (":verbose set scroll?" reads "Last set from changed
  window size"; 19 in a 40-row terminal). In an 8-row terminal it
  raised "E49: Invalid scroll size" at startup first.
* wrapmargin=2 is not used while textwidth is non-zero, and set.vim
  sets textwidth=78.

Removed rather than made to work: making them take effect would change
behaviour nobody has seen from this configuration (search-wrap messages
gone, a fixed CTRL-D step). After the removal an 8-row terminal starts
without E49, and the Vim suite passes.

Refs #109

Co-Authored-By: AI Agent <noreply@harleypig.com>
@harleypig
harleypig merged commit edaceb8 into master Nov 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant