diff --git a/init.el b/init.el index 25cec7a..767e759 100644 --- a/init.el +++ b/init.el @@ -29,7 +29,7 @@ There are two things you can do about this warning: '(global-display-line-numbers-mode t) '(inhibit-startup-screen t) '(package-selected-packages - '(doom-themes lsp-mode hydra gitlab-ci-mode gitlab-ci-mode-flycheck web-mode impatient-mode exec-path-from-shell rust-playground all-the-icons neotree base16-theme afternoon-theme ample-theme nord-theme company-racer racer markdown-mode+ dumb-jump magit company flycheck-rust flycheck json-mode flymake-json tss tide material-theme zenburn-theme ac-js2 auto-complete projectile helm js2-mode cargo rust-mode iedit gitlab-ci-mode gitlab-ci-mode-flycheck dap-mode typescript-mode tree-sitter tree-sitter-langs)) + '(flycheck-gometalinter go-mode doom-themes lsp-mode hydra gitlab-ci-mode gitlab-ci-mode-flycheck web-mode impatient-mode exec-path-from-shell rust-playground all-the-icons neotree base16-theme afternoon-theme ample-theme nord-theme company-racer racer markdown-mode+ dumb-jump magit company flycheck-rust flycheck json-mode flymake-json tss tide material-theme zenburn-theme ac-js2 auto-complete projectile helm js2-mode cargo rust-mode iedit gitlab-ci-mode gitlab-ci-mode-flycheck dap-mode typescript-mode tree-sitter tree-sitter-langs)) '(tool-bar-mode nil)) (custom-set-faces ;; custom-set-faces was added by Custom. @@ -43,3 +43,4 @@ There are two things you can do about this warning: (require 'init-web) (require 'init-js-ts) (require 'init-rust) +(require 'init-go) diff --git a/lib/init-go.el b/lib/init-go.el new file mode 100644 index 0000000..c77737f --- /dev/null +++ b/lib/init-go.el @@ -0,0 +1,14 @@ +(require 'go-mode) +(add-to-list 'auto-mode-alist '("\\.go\\'" . go-mode)) + +(require 'lsp-mode) +(add-hook 'go-mode-hook #'lsp-deferred) + +;; Set up before-save hooks to format buffer and add/delete imports. +;; Make sure you don't have other gofmt/goimports hooks enabled. +(defun lsp-go-install-save-hooks () + (add-hook 'before-save-hook #'lsp-format-buffer t t) + (add-hook 'before-save-hook #'lsp-organize-imports t t)) +(add-hook 'go-mode-hook #'lsp-go-install-save-hooks) + +(provide 'init-go)