kakoune-lsp / kakoune-lsp

Kakoune Language Server Protocol Client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Renaming symbol does not update other files with gopls

raiguard opened this issue · comments

When renaming a symbol with gopls, the new name is not reflected in other files. The language server will report undeclared name: bar until you open the file with the definition, at which time it will update and the errors will resolve.

I tested the same thing in vscode and it worked fine.

Reproduction:

  • Install gopls
  • Set up kak-lsp to use gopls:
[language.go]
filetypes = ["go"]
roots = ["go.mod", ".git", ".hg"]
command = "gopls"
  • mkdir gopls-test; cd gopls-test; go mod init gopls-test
  • Create main.go:
package main

func main() {
	foo()
}
  • Create foo.go:
package main

import "fmt"

func foo() {
	fmt.Println("bar!")
}
  • Go back to main.go and rename foo to bar
  • Observe an undeclared name: bar error
  • Go to foo.go and then back to main.go
  • Error is gone
2023-05-02T23.19.40.731579156-06.00.mp4

I have been able to observe this bug. Thanks for the succinct reproducer.

This issues occurs whether or not the file foo.go is open in kakoune after renaming is done.

This issues occurs whether or not the file foo.go is open in kakoune after renaming is done.

I can't reproduce a problem when both files are opened

Should be fixed, thanks!

I can't reproduce a problem when both files are opened

As @raiguard writes:

Go to foo.go and then back to main.go
Error is gone

Just the act of shifting and shifting back seems to fix the problem. The change you made does not seem to made a difference to that behavior...

when both files are open and I rename from main.go then I get this log:

May 03 17:55:36.478 DEBG To editor `91260`: evaluate-commands -client client0 -verbatim -- evaluate-commands -client client0 -draft -save-regs ^ 'edit -existing -- ''/home/johannes/git/kak-lsp/t/gopls-test/main.go''
select 4.2,4.5
execute-keys -save-regs "" Z
execute-keys "z<space><esc>,<esc>cbar8<esc>"', module: kak_lsp::editor_transport:91
May 03 17:55:36.489 DEBG From editor: 
session  = "91260"
buffile  = "/home/johannes/git/kak-lsp/t/gopls-test/foo.go"
filetype = "go"
version  = 11
method   = "textDocument/didChange"
hook     = true
[params]
draft    = """
package main

import \"fmt\"

func bar8() {
\tfmt.Println(\"BAR\")
}
"""
, module: kak_lsp::editor_transport:138

I think the first evaluate-commands triggers the didChange hook. I'm not sure why that doesn't work for you.

sorry my bad, I can reproduce with

HOME=$(mktemp -d) kak -e '
    eval %sh{kak-lsp --kakoune -s $kak_session}
    set global lsp_cmd "kak-lsp -s %val{session} -vvvv --log /tmp/kak-lsp.log"
    lsp-enable' main.go foo.go

I can confirm it's fixed! Thank you.