-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.
Milestone
Description
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
type A struct {
name string
}
func example() {
myStruct := &A{} # <- cursor on curly braces
}
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
type A struct {
name string
}
func example() {
myStruct := &A{
name: "",
}
}
The reason for that is the context being provided to gopls does not limit code actions of interest to just organizeImports
:
local context = { source = { organizeImports = true } }
This would instead do what's intended here:
local context = { only = { "source.organizeImports" } }
Although I figured this out the hard way, this has also been discussed in the discussion cited in the docs 😄
akupila and ainar-g
Metadata
Metadata
Assignees
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.