Skip to content

feat: turn on code lenses in Ruby LSP buffers - #19

Merged
wassimk merged 10 commits into
mainfrom
wm/enable-codelens
Nov 2, 2026
Merged

wassimk merged 10 commits into
mainfrom
wm/enable-codelens

Conversation

@wassimk

@wassimk wassimk commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Neovim 0.12 leaves code lenses off until something enables them. I checked in a clean 0.12.6: once Ruby LSP attaches, vim.lsp.codelens.is_enabled({ bufnr }) is false and nothing is drawn. So a new user who followed the README saw no Run or Debug lenses above their tests.

  • On LspAttach, the plugin enables code lenses for the ruby_lsp client in that buffer. A new codelens option (default true) controls it, and false leaves code lenses to the user's own config.
  • No keymap is added. Neovim 0.12 maps grx to vim.lsp.codelens.run(), and the README shows how to map another key.
  • The README gets a Code Lenses section, the new option, and an auto_start example that skips projects whose Gemfile.lock lists solargraph. It replaces the .solargraph.yml example.

Stacked on #18, which fixes the fake clients this branch's new test also uses. GitHub will retarget this PR to main once #18 merges.

Testing

  • make test: 194 passing, 0 failures, 0 errors. The new attach test failed before the change.
  • make lint: clean
  • In a clean headless Neovim 0.12.6, enabling code lenses for the attached client drew lens virtual lines in a Minitest file.

Neovim 0.12 leaves code lenses off until something enables them, so a
new user saw no Run or Debug lenses above their tests. Enable them for
the ruby_lsp client on attach, behind a codelens option that defaults
to true. Neovim's grx mapping already runs a lens, so the plugin adds
no keymap.
Point users to grx for running a lens and show how to map their own
key. Replace the .solargraph.yml example with one that checks
Gemfile.lock, which matches how projects usually opt into solargraph.
@wassimk wassimk self-assigned this Nov 2, 2026
panvimdoc uppercases headings byte by byte, and under a UTF-8 locale
that rewrote the bytes of each heading's emoji. Run it in the C locale
so those bytes pass through unchanged.
The attach tests each built their own buffer and fake clients and
restored their stubs at the end of the test body. The two older ones
did not stub vim.lsp.codelens.enable, so once code lenses were on by
default they called the real API with a fake client and failed.

Move the buffer, the fake clients, and the get_client_by_id,
codelens.enable, and $/progress stubs into before_each and after_each,
so every attach test gets them and a failed assertion cannot leak a
stub into later tests.
With client_id in the filter, Neovim records the enable flag on the
client instead of the buffer. is_enabled({ bufnr }) then reports false,
so toggling lenses off in a buffer did nothing. When the client stopped
or restarted, the lenses stayed behind and the next edit raised an
assertion in codelens.lua.

Scope the call to the buffer, and test it through the real API so the
spec checks what a user observes.
@wassimk
wassimk deleted the branch wm/fix-init-spec-attach-client November 2, 2026 02:11
@wassimk wassimk closed this Nov 2, 2026
@wassimk wassimk reopened this Nov 2, 2026
@wassimk
wassimk changed the base branch from wm/fix-init-spec-attach-client to main November 2, 2026 02:12
@wassimk
wassimk merged commit eaf285f into main Nov 2, 2026
6 checks passed
@wassimk
wassimk deleted the wm/enable-codelens branch November 2, 2026 02:12
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.

1 participant