doomemacs / doomemacs

An Emacs framework for the stubborn martian hacker
MIT License
19.41k stars 3.05k forks source link

Replace cmd/guru (go-guru) with gopls #7995

Closed satchel9 closed 2 months ago

satchel9 commented 2 months ago

I confirm that...

Expected behavior

Use gopls

Current behavior

Use guru for code navigation & refactoring commands

cmd/guru was deleted in March 2024. It has long been superseded by gopls, a language (LSP) server for Go that works with a wide range of editors.

Steps to reproduce

n/a

System Information

macOS 14.5

panchoh commented 2 months ago

The deletion announcement can be read here.

panchoh commented 2 months ago

The issue has already been reported upstream, and it will be fixed by an upcoming rewrite of go-mode.el, which will be based on tree-sitter.

Until then, we can keep using go-guru as it is, but be ready for dropping it.

My 2¢.

hlissner commented 2 months ago

I agree with this change (and I've added go-guru to our packages under review board), but I don't dogfood the module (nor do I write Go), so I'm not sure if this is sufficient for dropping go-guru (ideally, I'd like there to be alternatives if the user opts out of +lsp on the :lang go module, but I don't know how practical that is with the direction go-mode is headed):

modified   modules/lang/go/config.el
@@ -7,8 +7,6 @@ (after! go-mode
   (set-docsets! 'go-mode "Go")
   (set-repl-handler! 'go-mode #'gorepl-run)
   (set-lookup-handlers! 'go-mode
-    :definition #'go-guru-definition
-    :references #'go-guru-referrers
     :documentation #'godoc-at-point)

   (if (modulep! +lsp)
@@ -24,18 +22,6 @@ (after! go-mode
         "d" #'go-tag-remove
         "e" #'+go/play-buffer-or-region
         "i" #'go-goto-imports      ; Go to imports
-        (:prefix ("h" . "help")
-          "." #'godoc-at-point     ; Lookup in godoc
-          "d" #'go-guru-describe   ; Describe this
-          "v" #'go-guru-freevars   ; List free variables
-          "i" #'go-guru-implements ; Implements relations for package types
-          "p" #'go-guru-peers      ; List peers for channel
-          "P" #'go-guru-pointsto   ; What does this point to
-          "r" #'go-guru-referrers  ; List references to object
-          "e" #'go-guru-whicherrs  ; Which errors
-          "w" #'go-guru-what       ; What query
-          "c" #'go-guru-callers    ; Show callers of this function
-          "C" #'go-guru-callees)   ; Show callees of this function
         (:prefix ("ri" . "imports")
           "a" #'go-import-add
           "r" #'go-remove-unused-imports)
modified   modules/lang/go/packages.el
@@ -2,8 +2,7 @@
 ;;; lang/go/packages.el

 (package! go-eldoc :pin "cbbd2ea1e94a36004432a9ac61414cb5a95a39bd")
-(package! go-guru :pin "636d36e37a0d2b6adb2e12d802ff4794ccbba336")
-(package! go-mode :pin "636d36e37a0d2b6adb2e12d802ff4794ccbba336")
+(package! go-mode :pin "602d73e22646b1b98b2eb97927fd426c0d1d2f92")
 (package! gorepl-mode :pin "6a73bf352e8d893f89cad36c958c4db2b5e35e07")
 (package! go-tag :pin "33f2059551d5298ca228d90f525b99d1a8d70364")
 (package! go-gen-test :pin "af00a9abbaba2068502327ecdef574fd894a884b")

If that's not enough, it'll be some time before I get around to this, but I'll welcome PRs for this.

Also, are there any other packages in the go module that we don't need anymore? E.g. Maybe go-eldoc is unneeded if we lean entirely onto gopls.

panchoh commented 2 months ago

Also, are there any other packages in the go module that we don't need anymore? E.g. Maybe go-eldoc is unneeded if we lean entirely onto gopls.

go-eldoc.el leverages gocode, which is also deprecated.

These days, it's gopls or the highway, /methinks. Not unsurprisingly though, since it is the officially supported way.

I'll test the diff tomorrow, and report back here, thanks!