Repository navigation
feat: turn on code lenses in Ruby LSP buffers - #19
Merged
Merged
Conversation
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 })isfalseand nothing is drawn. So a new user who followed the README saw no Run or Debug lenses above their tests.LspAttach, the plugin enables code lenses for theruby_lspclient in that buffer. A newcodelensoption (defaulttrue) controls it, andfalseleaves code lenses to the user's own config.grxtovim.lsp.codelens.run(), and the README shows how to map another key.auto_startexample that skips projects whoseGemfile.locklists solargraph. It replaces the.solargraph.ymlexample.Stacked on #18, which fixes the fake clients this branch's new test also uses. GitHub will retarget this PR to
mainonce #18 merges.Testing
make test: 194 passing, 0 failures, 0 errors. The new attach test failed before the change.make lint: clean