I'm a vim user for years and start to play emacs recently, after having tried Spacemacs and Prelude, Doom Emacs is my final choose. I'm configuring golang development those days with (go +lsp) and (lsp) module, and all the out-of-box features of Doom are impressive, thanks for your outstanding job hlissner.
Now I'm happy with the basic features like:
Auto completion
But to be more productive, I want more IDE-like features such as:
Could anybody help me on this? And any experiences/tips are appreciated.
You press “Ctrl” and “x” at the same time, then release them, then press “Ctrl” and “c” at the same time and then release them and voila, you are in the process of exiting Emacs. Doom Note: Emacs has a special extension called “evil mode” that emulates a lot of vi like functionality.
To install Doom Emacs, we need to get a remote code repository from the internet. To do this, install Git. It allows us to instantly copy the code and, more importantly, update between major versions. In my case, I am installing Git in Void Linux.
Welcome aboard!
I'm not a go programmer myself, so these are mostly 2nd hand accounts, but Doom's :lang go
module provides most of what you're asking for. I would suggest using the gopls
langserver. To do so:
:lang (go +lsp)
:tools lsp
:editor snippets
(should be enabled by default)gopls
through your OS' package manager (iirc it comes with Go 1.12+).~/.emacs.d/bin/doom sync
to ensure Doom is properly synchronized with these changes.And you should be good to go. Here are some helpful (evil centric) keybinds you should know:
+lookup/definition
-> go to definition of the symbol at point+lookup/references
-> jump to reference of the symbol at point+lookup/documentation
-> look up documentation of the symbol at pointlsp-execute-code-action
-> executes an arbitrary code action (which should include auto-generate what you're asking for).go-guru-describe
-> Describe thisgo-guru-freevars
-> List free variablesgo-guru-implements
-> Implements relations for package typesgo-guru-peers
-> List peers for channelgo-guru-pointsto
-> What does this point togo-guru-referrers
-> List references to objectgo-guru-callers
-> Show callers of this functiongo-guru-callees
-> Show callees of this function+go/test-rerun
-> rerun last test+go/test-all
-> run all tests+go/test-single
-> run test at point+go/test-nested
-> run tests belowYou'll find a more comprehensive list of keybinds in the :lang go module (Note that SPC
is Doom's leader key, and SPC m
is its localleader key. For non-evil users, these are C-c
and C-c l
, respectively).
The snippets module comes with a snippets library. You can find our modest go snippets here, and you can add your own to ~/.doom.d/snippets/go-mode/
.
I also suggest you visit the :lang go
readme. It needs updating, and I'm hardly a good resource on how much of it you need with gopls, but perhaps there are corner cases it can help cover.
Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With