gopls/doc: fix imports function for Neovim LSP

The documented Lua function for supporting imports with Neovim native
LSP support does work for imports, but also runs any other code action
available in the current range. For example, if the function was to run
with the user's cursor on an empty struct being initialized, the code
action for filling that struct would also run.
This change restricts the desired actions to only be organizeImports.

Fixes golang/go#47181

Change-Id: Ie4eb5961cb4405091477b79175acc7052ff16d4c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/334749
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Trust: Robert Findley <rfindley@google.com>
This commit is contained in:
Francesco Renzi 2021-07-15 09:44:06 +01:00 committed by Hyang-Ah Hana Kim
parent 0cf4e2708a
commit 6e9046bfcd
1 changed files with 1 additions and 1 deletions

View File

@ -165,7 +165,7 @@ lua <<EOF
-- …
function goimports(timeout_ms)
local context = { source = { organizeImports = true } }
local context = { only = { "source.organizeImports" } }
vim.validate { context = { context, "t", true } }
local params = vim.lsp.util.make_range_params()