summary refs log tree commit diff stats
path: root/user
diff options
context:
space:
mode:
authorAlan Pearce2020-01-26 13:26:36 +0100
committerAlan Pearce2020-01-26 13:26:36 +0100
commitfbcbee20593a8b899225e7de36999ac9186a8b32 (patch)
tree72e01b8e8f98df527d83bd924b8ae1c223cfa3a1 /user
parent2413e42de9e82a752c9e7e75e07e9e036a697b10 (diff)
downloadnixfiles-fbcbee20593a8b899225e7de36999ac9186a8b32.tar.lz
nixfiles-fbcbee20593a8b899225e7de36999ac9186a8b32.tar.zst
nixfiles-fbcbee20593a8b899225e7de36999ac9186a8b32.zip
Configure golang dev environment
Diffstat (limited to 'user')
-rw-r--r--user/emacs/.emacs.d/init.el12
-rw-r--r--user/settings/emacs.nix1
-rw-r--r--user/settings/golang.nix10
-rw-r--r--user/settings/tabnine.nix7
-rw-r--r--user/trillian.nix1
5 files changed, 31 insertions, 0 deletions
diff --git a/user/emacs/.emacs.d/init.el b/user/emacs/.emacs.d/init.el
index d679f086..fe736b13 100644
--- a/user/emacs/.emacs.d/init.el
+++ b/user/emacs/.emacs.d/init.el
@@ -505,6 +505,7 @@ _p_rev       _u_pper              _=_: upper/lower       _r_esolve
 
 (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 @@ _p_rev       _u_pper              _=_: upper/lower       _r_esolve
 
 ;;; 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 @@ _p_rev       _u_pper              _=_: upper/lower       _r_esolve
             yaml-mode-hook
             js-mode-hook
             css-mode-hook
+            go-mode-hook
             scss-mode-hook
             html-mode-hook
             haskell-mode-hook)
diff --git a/user/settings/emacs.nix b/user/settings/emacs.nix
index 2ce508f9..00f5bad4 100644
--- a/user/settings/emacs.nix
+++ b/user/settings/emacs.nix
@@ -123,6 +123,7 @@ in
       gitignore-mode
       gitlab-ci-mode
       gitlab-ci-mode-flycheck
+      go-mode
       goto-chg
       haskell-mode
       helpful
diff --git a/user/settings/golang.nix b/user/settings/golang.nix
new file mode 100644
index 00000000..4cc59343
--- /dev/null
+++ b/user/settings/golang.nix
@@ -0,0 +1,10 @@
+{ config, pkgs, ... }:
+
+{
+  home.packages = (with pkgs; [
+    go
+    go-langserver
+    goimports
+    gotools
+  ]);
+}
diff --git a/user/settings/tabnine.nix b/user/settings/tabnine.nix
index daf86c39..aaaf9617 100644
--- a/user/settings/tabnine.nix
+++ b/user/settings/tabnine.nix
@@ -75,6 +75,13 @@ in {
         command = "hie";
         args = [ "--stdio" ];
       };
+      "language.go" = {
+        command = "go-langserver";
+        args = [
+          "-mode" "stdio"
+          "-gocodecompletion"
+        ];
+      };
     };
   };
 
diff --git a/user/trillian.nix b/user/trillian.nix
index 282e5cf0..d5e91417 100644
--- a/user/trillian.nix
+++ b/user/trillian.nix
@@ -10,6 +10,7 @@
     ./settings/emacs.nix
     ./settings/git.nix
     ./settings/gnupg.nix
+    ./settings/golang.nix
     ./settings/javascript.nix
     ./settings/ledger.nix
     ./settings/nixpkgs.nix