Skip to content

Finish #44: script-local fold and gutter functions, shared Vim launcher - #155

Merged
harleypig merged 4 commits into
masterfrom
fix/close-44
Nov 4, 2026
Merged

harleypig merged 4 commits into
masterfrom
fix/close-44

Conversation

@harleypig

Copy link
Copy Markdown
Owner

Summary

The last open items from #44, in four commits:

  1. fix(settings): CustomFoldText is script-local. The late
    fold.vim defines s:CustomFoldText() and sets
    foldtext=s:CustomFoldText(). Vim replaces the s: with the function's
    <SNR> name when the option is set (:help fold-foldtext, patch
    8.2.3908), so 'foldtext' now reads <SNR>N_CustomFoldText().
    tests/vim/fold.bats checks for that value and that there is no global
    CustomFoldText().
  2. fix(settings): the gutter toggles. ToggleLineNumbers and its
    sibling ToggleSigns in the late gutter.vim are script-local.
    <leader>ln and <leader>signs are now nnoremap mappings that call
    <SID> versions. The old recursive map also defined both keys in
    Visual and Operator-pending mode, where the :call ran once for each
    selected line. docs/gutter.md and learning.txt name no mode for
    either key, so neither changes.
  3. docs: docs/coc-ale-setup.md. The bullet saying <Tab> and
    <C-Space> check for a completion plugin is removed. Tidy-ups from #44: submodule scripts, late settings, terraform-ls #152 removed those
    branches.
  4. test(vim): the shared launcher. colors.bats, ale-settings.bats
    and tidy.bats now load helpers/vim and use vim_fixture and
    headless_vim, like every other file in tests/vim. Each file kept its
    own copy of the launcher before. No test changes what it checks.

Closes #44

#44 checklist

PR #152's table numbers the items. Every item it marked done is still done
on master. The rest:

# Item Disposition
19 g:ale_disable_lsp set twice Done in #150. Set only in the early ale.vim
20 g:ale_fixers.jsonc set twice Done in #150. Set only in after/ftplugin/json.vim
35 tests/vim/oldfiles.bats name and header Done in #151 (fold.bats)
36b after/plugin/statusline.vim autocmds Done in #146 (augroup statusline)
37b CustomFoldText global Done here (commit 1)
37c ToggleLineNumbers global Done here (commit 2), with ToggleSigns
39 Late ale.vim Markdown TODO Done in #150. The Markdown linters are in after/ftplugin/markdown.vim
43 .claude/TESTS.md does not say where helpers live Done in #151 (Shared helpers)
— docs/coc-ale-setup.md describes the removed completion branches (#152 completion report, point 8) Done here (commit 3)

The issue body's three items and all eight comments are covered by the
table above together with #152's.

Decisions

  • set foldtext=s:CustomFoldText(), not expand('<SID>'). The s:
    form is the one :help fold-foldtext documents. It has been in Vim since
    8.2.3908, well before CI's 9.1.0016. The stored value is already the
    <SNR> name, so it works in every window the option is copied to.
  • ToggleSigns is included. Small tidy-ups: envsubstitute help quote, old shell-lint warnings, proselint config path #44 names only ToggleLineNumbers, but
    ToggleSigns sits in the same file with the same two faults: a global
    function and a recursive map. Fixing one and leaving the other would
    leave the file half done.
  • nnoremap, not noremap. Both toggles change window options, so
    Visual and Operator-pending mode have no use for them. In Visual mode the
    old mapping ran the toggle once for each selected line.
  • The gutter tests go in tidy.bats. That file holds Small tidy-ups: envsubstitute help quote, old shell-lint warnings, proselint config path #44's small
    settings fixes. The two behaviour tests (each toggle still cycles as
    documented) guard against the change breaking the keys.

Testing evaluation

Run by the author, to the qa-tester's standard (no team-managed: sentinel
here).

  1. Verdict. Commits 1 and 2 needed tests and have them. Commit 3 is
    wording and needs none. Commit 4 changes only test plumbing. It is
    covered by its own tests still passing, and by each file going red when
    one behaviour it guards is broken.
  2. Automatable: yes, with bats: tests/vim/fold.bats and
    tests/vim/tidy.bats.
  3. Falsifiers, each seen red and then restored:
    • fold.bats "a closed fold shows its first line…": red against master,
      which shows foldtext=CustomFoldText() and global=1.
    • tidy.bats "the gutter toggles are Normal-mode…": red against master,
      which shows noremap=0, a Visual mapping and both functions global.
    • tidy.bats "<Leader>ln cycles…" and "<Leader>signs hides…": red
      with the <leader>ln mapping commented out and with ToggleSigns
      setting signcolumn=yes where it should set no.
    • Commit 4, one break per file, each restored: the Insert-mode
      StatusLine guibg changed to Red turned colors.bats test 1 red.
      g:ale_disable_lsp = 0 in the early ale.vim turned ale-settings.bats
      test 1 red. An empty 'spellfile' in xdg-settings.vim turned
      tidy.bats test 5 red.
  4. Disposition: written in this PR.
  5. Entry-point reach: exercised through Vim started on .vimrc. The
    mappings were pressed with :normal, not just read with maparg().

Manual verification

  1. Where: a checkout of this branch, with Vim started on its .vimrc.
  2. What: run :set foldtext?, :map <Leader>ln and
    :map <Leader>signs. Fill a buffer with three lines and run :%fold.
    Then press <Leader>ln.
  3. Success: foldtext=<SNR>N_CustomFoldText(). Each mapping is listed
    once, for n only, with * (no remap) and a <SNR>N_ call. The fold
    reads alpha.... 3 lines [100.0%] +--. After <Leader>ln, nonumber
    and relativenumber.
  4. Failure: foldtext=CustomFoldText(), a mapping listed without n,
    or a fold shown as Vim's default +-- 3 lines: alpha.
  5. Result (run headless with a throwaway HOME and XDG directories):
    • foldtext=<SNR>42_CustomFoldText().
    • n \ln * :call <SNR>43_ToggleLineNumbers()<CR>.
    • n \signs * :call <SNR>43_ToggleSigns()<CR>.
    • The fold read alpha.............................................. 3 lines [100.0%] +--.
    • After \ln: nonumber, relativenumber.
    • Vim exited 0.

Test plan

  • bats tests/vim: 93 pass, with a fresh empty TMPDIR that is still
    empty afterwards.
  • bash -c "trap '' PIPE; exec bats tests/shell": 100 pass, same TMPDIR
    check.
  • markdownlint (CI's pinned image) on docs/coc-ale-setup.md: clean.

Review

opt-out: no named review skill ran. None of these changes can block or
refuse work, and the author read the diff in its place.

Points worth a second look:

Completion report

  1. Functionality works: yes. The suites and the manual run above show it.
  2. Access model: not applicable (a personal editor configuration).
  3. Permissions: not applicable.
  4. Audit logging: not applicable.
  5. Validation: not applicable. No new input is read.
  6. Errors handled: not applicable. No new failure path.
  7. Testing complete: yes, see Testing evaluation.
  8. Documentation: docs/coc-ale-setup.md is updated. docs/gutter.md and
    learning.txt already describe the keys as they now behave.
  9. AI Completion Report: this section.

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

harleypig and others added 4 commits November 4, 2026 01:54
The late fold.vim's fold-text function is now s:CustomFoldText(), and
'foldtext' is set with the s: form, which Vim (8.2.3908 and later) replaces
with the function's <SNR> name. tests/vim/fold.bats checks for that name
and that no global CustomFoldText() exists.

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

ToggleLineNumbers and its sibling ToggleSigns in the late gutter.vim are
now script-local, and <leader>ln and <leader>signs are nnoremap calls to
<SID> versions. The old recursive map also defined them in Visual and
Operator-pending mode, where the :call ran once per selected line. The
docs name no mode for either, so they are unchanged.

tests/vim/tidy.bats checks the mappings' modes, that neither function is
global, and that each toggle still cycles as documented.

Co-Authored-By: AI Agent <noreply@harleypig.com>
The <Tab> and <C-Space> mappings in the late coc.vim no longer check for
a completion plugin that is not installed (removed in #152 - coc.vim
tidy-ups), so the bullet saying they do is gone.

Co-Authored-By: AI Agent <noreply@harleypig.com>
The three Vim test files added alongside #151 each carried their own copy
of the headless-Vim launcher. They now load helpers/vim, set up with
vim_fixture and start Vim with headless_vim, as every other file in
tests/vim does. No test changes what it checks.

Each file was seen to fail with one guarded behaviour broken: the Insert
mode StatusLine colour (colors), g:ale_disable_lsp in the early ale.vim
(ale-settings) and 'spellfile' (tidy).

Co-Authored-By: AI Agent <noreply@harleypig.com>
@harleypig harleypig added this to the Pre-improvement milestone Nov 4, 2026
@harleypig
harleypig merged commit e5ba1f4 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

Development

Successfully merging this pull request may close these issues.

Small tidy-ups: envsubstitute help quote, old shell-lint warnings, proselint config path

1 participant