Skip to content

Instantly share code, notes, and snippets.

@ntBre
Created February 19, 2022 14:55
Show Gist options
  • Select an option

  • Save ntBre/34e3d2daad59040b4549cd8057f304c3 to your computer and use it in GitHub Desktop.

Select an option

Save ntBre/34e3d2daad59040b4549cd8057f304c3 to your computer and use it in GitHub Desktop.
My Emacs configuration for writing Go
(use-package which-key
:ensure t
:config
(which-key-mode))
(use-package lsp-mode
:ensure t
:bind (:map lsp-mode-map
("C-c d" . lsp-describe-thing-at-point)
("C-c a" . lsp-execute-code-action))
:bind-keymap ("C-c l" . lsp-command-map)
:config
(lsp-enable-which-key-integration t))
(use-package company
:ensure t
:hook ((emacs-lisp-mode . (lambda ()
(setq-local company-backends '(company-elisp))))
(emacs-lisp-mode . company-mode))
:config
(company-keymap--unbind-quick-access company-active-map)
(company-tng-configure-default)
(setq company-idle-delay 0.1
company-minimum-prefix-length 1))
(use-package flycheck
:ensure t)
;;; Go
(use-package go-mode
:ensure t
:hook ((go-mode . lsp-deferred)
(go-mode . company-mode))
:bind (:map go-mode-map
("<f6>" . gofmt)
("C-c 6" . gofmt))
:config
(require 'lsp-go)
;; https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md
(setq lsp-go-analyses
'((fieldalignment . t)
(nilness . t)
(unusedwrite . t)
(unusedparams . t)))
;; GOPATH/bin
(add-to-list 'exec-path "~/go/bin")
;; requires goimports to be installed
(setq gofmt-command "goimports"))
(global-set-key (kbd "<f5>") #'recompile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment