dominikh / go-mode.el

Emacs mode for the Go programming language
BSD 3-Clause "New" or "Revised" License
1.37k stars 209 forks source link

Can't override "g d" from godef-jump #435

Open Lawqup opened 3 months ago

Lawqup commented 3 months ago

I'm not sure if this is a go mode issue, an evil issue, or some issue with how C-c C-j is being translated to evil-mode keybindings, but I'm unable to rebind "g d" to evil-goto-definition or lsp-find-definition.

I've tried local-set-key, bind-key, making my own minor mode and trying to override "g d".

I have godef installed (apparently the latest version), but for some reason I can't get it to work for anything, e.g.:

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x104feb5e4]

goroutine 172 [running]:
go/types.(*Checker).handleBailout(0x1400060c400, 0x140002b9c38)
        /opt/homebrew/Cellar/go/1.22.1/libexec/src/go/types/check.go:367 +0x9c
...

This is on OSX but I get the same thing on Arch.

So, I either need to fix godef or rebind "g d" to use the lsp find definition.

I should note, I can bind evil-goto-definition to other stuff like "g D", but this isn't ideal since all other languages use g d to jump to definition.

Lawqup commented 3 months ago

I've found a workaround: override godef-jump in the go mode hook. I.e., in the hook, redefine godef-jump:

(defun godef-jump ()
    (interactive)
    (lsp-find-definition))
jjuliano commented 1 month ago

You can also use go install github.com/jjuliano/godef@latest.