x/tools/gopls: documented imports function for Neovim LSP executes any available code action #47181
Labels
Documentation
FrozenDueToAge
gopls
Issues related to the Go language server, gopls.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
The Lua function for supporting imports with Neovim native LSP support documented here does work for imports, but also runs any other code action available in the current range.
For example, if your cursor is on an empty struct declaration like this
and run the function with imports currently already organized, the next available code action that will be applied is filling that struct. So the result would be
The reason for that is the context being provided to gopls does not limit code actions of interest to just
organizeImports
:This would instead do what's intended here:
Although I figured this out the hard way, this has also been discussed in the discussion cited in the docs 😄
The text was updated successfully, but these errors were encountered: