Configure golang dev environment
Alan Pearce alan@alanpearce.eu
Sun, 26 Jan 2020 13:26:36 +0100
5 files changed, 31 insertions(+), 0 deletions(-)
M user/emacs/.emacs.d/init.el → user/emacs/.emacs.d/init.el
@@ -505,6 +505,7 @@ :config (setq all-the-icons-color-icons nil)) (use-package company-lsp :config (progn + (setq company-lsp-enable-snippet nil) (add-to-list 'company-backends #'company-lsp))) (eval-when-compile (require 'subr-x)) @@ -677,6 +678,16 @@ :ghook ('prog-mode-hook)) ;;; Major modes +;;;; golang +(use-package go-mode + :config (progn + (setq-default gofmt-command "goimports") + (add-hook 'go-mode-hook (lambda () + (add-hook 'before-save-hook #'gofmt-before-save) + (if (not (string-match-p "go" compile-command)) + (set (make-local-variable 'compile-command) + "go build -v && go test && go vet")))))) + ;;;; js (setq js-indent-level 2 js-enabled-frameworks '(javascript)) @@ -852,6 +863,7 @@ dockerfile-mode-hook yaml-mode-hook js-mode-hook css-mode-hook + go-mode-hook scss-mode-hook html-mode-hook haskell-mode-hook)
M user/settings/emacs.nix → user/settings/emacs.nix
@@ -123,6 +123,7 @@ gitconfig-mode gitignore-mode gitlab-ci-mode gitlab-ci-mode-flycheck + go-mode goto-chg haskell-mode helpful
A user/settings/golang.nix
@@ -0,0 +1,10 @@+{ config, pkgs, ... }: + +{ + home.packages = (with pkgs; [ + go + go-langserver + goimports + gotools + ]); +}
M user/settings/tabnine.nix → user/settings/tabnine.nix
@@ -75,6 +75,13 @@ "language.haskell" = { command = "hie"; args = [ "--stdio" ]; }; + "language.go" = { + command = "go-langserver"; + args = [ + "-mode" "stdio" + "-gocodecompletion" + ]; + }; }; };
M user/trillian.nix → user/trillian.nix
@@ -10,6 +10,7 @@ ./settings/darwin.nix ./settings/emacs.nix ./settings/git.nix ./settings/gnupg.nix + ./settings/golang.nix ./settings/javascript.nix ./settings/ledger.nix ./settings/nixpkgs.nix