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

x/tools/gopls: rename package decl fails in CLI #69582

Open
adonovan opened this issue Sep 22, 2024 · 6 comments
Open

x/tools/gopls: rename package decl fails in CLI #69582

adonovan opened this issue Sep 22, 2024 · 6 comments
Labels
Documentation gopls Issues related to the Go language server, gopls. Refactoring Issues related to refactoring tools
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Sep 22, 2024

The rename package feature appears not to be working either in the CLI nor in Emacs+eglot:

xtools$ cat a/a.go 
package a

xtools$ gopls rename -diff ./a/a.go:#9 b
--- /Users/adonovan/w/xtools/a/a.go.orig
+++ /Users/adonovan/w/xtools/a/a.go
@@ -1 +1 @@
-package a
+package b
gopls: getFile: file:///Users/adonovan/w/xtools/a: read /Users/adonovan/w/xtools/a: is a directory

xtools$ echo $?
2

It is working from VS Code though.

Also, it is undocumented. I've split this out as #69624.

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Sep 22, 2024
@gopherbot gopherbot added this to the Unreleased milestone Sep 22, 2024
@adonovan adonovan added Refactoring Issues related to refactoring tools and removed gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Sep 22, 2024
@adonovan adonovan added the gopls Issues related to the Go language server, gopls. label Sep 22, 2024
@yincongcyincong
Copy link
Contributor

@findleyr
Copy link
Member

I think this requires more investigation. If it is failing on emacs, then the fix cannot just be in the command line.

My guess is that emacs does not support the 'rename' resource operation kind: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#resourceOperationKind

And my guess is that our CLI client does not either.

Renaming packages works on coc.nvim, but doesn't quite work correctly: I always get warnings when saving about overwriting the file on disk. That may be a client problem.

@findleyr findleyr modified the milestones: Unreleased, gopls/backlog Sep 25, 2024
@findleyr
Copy link
Member

Ah, it looks like the command line client does purport to support rename operations, so the associated fix may be right.

We should check whether emacs supports them.

@adonovan adonovan changed the title x/tools/gopls: rename package decl fails in CLI (and is undocumented) x/tools/gopls: rename package decl fails in CLI Sep 25, 2024
@adonovan
Copy link
Member Author

I've split the documentation and eglot issues out:

This issue is now just about the CLI.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/615375 mentions this issue: gopls: fix rename command line fail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation gopls Issues related to the Go language server, gopls. Refactoring Issues related to refactoring tools
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants