all repos — nixfiles @ fbcbee20593a8b899225e7de36999ac9186a8b32

System and user configuration, managed by nix and home-manager

Configure golang dev environment
Alan Pearce alan@alanpearce.eu
Sun, 26 Jan 2020 13:26:36 +0100
commit

fbcbee20593a8b899225e7de36999ac9186a8b32

parent

2413e42de9e82a752c9e7e75e07e9e036a697b10

M user/emacs/.emacs.d/init.eluser/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.nixuser/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.nixuser/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.nixuser/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