fix: codelens.enable() nil error and GoListImports crash on empty result - #616
Merged
Merged
Conversation
Two independent bug fixes: 1. codelens: replace non-existent vim.lsp.codelens.enable() with refresh() vim.lsp.codelens.enable() does not exist in Neovim 0.11.x (available API: refresh, clear, run, get, display, save). Commit c8a356b introduced a regression by replacing the working: vim.lsp.codelens.refresh({ bufnr = 0 }) with: vim.lsp.codelens.enable(true, { bufnr = 0 }) causing the following error on every BufWritePre for *.go files when lsp_codelens = true: Error executing lua callback: ...go/codelens.lua:59: attempt to call field 'enable' (a nil value) 2. GoListImports: guard against empty import list When gopls returns no PackageImports, the code fell through to vim.lsp.util.open_floating_preview() with height = 0, triggering a spurious error. Add an early return with an INFO notification instead.
Owner
|
A release tag for nvim 0.11 is available: v0.11. Alternatively, you might use something like this in your config for old versions: |
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.
Two independent bug fixes for Neovim 0.11.x compatibility and a spurious error in
GoListImports.Bug 1:
BufWritePreerror —attempt to call field 'enable' (a nil value)When
lsp_codelens = true, saving any.gofile triggers:vim.lsp.codelens.enable()does not exist in Neovim 0.11.x.The available API is:
refresh,clear,run,get,display,save.Commit
c8a356bintroduced this regression by replacing the working:with:
This PR reverts to the working
refresh()call.Bug 2:
GoListImportsspurious error on files with no importsWhen gopls returns an empty import list, the code fell through to
vim.lsp.util.open_floating_preview()withheight = 0, producing a spurious error. An early return with anINFOnotification is added instead.Changes
lua/go/codelens.luavim.lsp.codelens.enable()withvim.lsp.codelens.refresh({ bufnr = 0 })lua/go/commands.luaGoListImportsagainst empty result before opening floating previewReproduction Steps
Bug 1: Set
lsp_codelens = true, open any.gofile, save it → error fires onBufWritePre:Bug 2: Run
:GoListImportson a file with no imports → spurious floating window error.