Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eglot--apply-workspace-edit fails to rename a directory #1450

Open
adonovan opened this issue Sep 25, 2024 · 1 comment
Open

eglot--apply-workspace-edit fails to rename a directory #1450

adonovan opened this issue Sep 25, 2024 · 1 comment

Comments

@adonovan
Copy link

In Go's LSP server, an eglot-rename operation on a package name causes the server to respond with a directory rename. In other words, the workspace-edit's document-change's old and new URIs both refer to directories. This causes eglot--apply-workspace-edit to fail.

# Install gopls
$ go install golang.org/x/tools/gopls@latest

# create Go package
$ cat a/a.go 
package a

# Run Emacs with eglot
# M-x find-file a/a.go
# position over "a" in package a.
# M-x eglot-rename
# Choose new name "b".

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  expand-file-name(nil)
  find-file-noselect(nil)
  #f(compiled-function (prepared) #<bytecode -0xf6d62cc7c939f10>)(((("/Users/adonovan/w/xtools/a/a.go" [(:range (:start (:line 0 :character 8) :end (:line 0 :character 10)) :newText "b")] 11) (nil nil nil))))
  eglot--apply-workspace-edit((:documentChanges [(:textDocument (:version 11 :uri "file:///Users/adonovan/w/xtools/a/a.go") :edits [(:range (:start (:line 0 :character 8) :end (:line 0 :character 10)) :newText "b")]) (:kind "rename" :oldUri "file:///Users/adonovan/w/xtools/a" :newUri "file:///Users/adonovan/w/xtools/b")]) eglot-rename)
  eglot-rename("b")
  funcall-interactively(eglot-rename "b")
  call-interactively(eglot-rename record nil)
  command-execute(eglot-rename record)
  execute-extended-command(nil "eglot-rename" "eglot-ren")
  funcall-interactively(execute-extended-command nil "eglot-rename" "eglot-ren")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)
@nemethf
Copy link
Collaborator

nemethf commented Sep 25, 2024

As far as I know, Eglot does not send any resourceOperations among its client capabilities, so it is a mistake from the server to send a rename workspace edit (e.g.: (:kind "rename" :oldUri ...). Maybe the client should handle the situation better, though.

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspaceEditClientCapabilities

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants