diff options
author | Franck Cuny <franck@fcuny.net> | 2022-06-20 14:07:33 -0700 |
---|---|---|
committer | Franck Cuny <franck@fcuny.net> | 2022-06-20 14:07:33 -0700 |
commit | cec7c55d56cad41f09225554451765e12b309ffc (patch) | |
tree | 2dd714138adcfa8f754ace8326fdf3082532c5af | |
parent | feat(prog): use nixpkgs-fmt to format nix code (diff) | |
download | emacs.d-cec7c55d56cad41f09225554451765e12b309ffc.tar.gz |
fix(prog): use gofmt to format go code
When using LSP to format the code, I keep running into weird behavior with eglot. I think it's because the code is being formatted while flymake is running but I need more evidence.
-rw-r--r-- | emacs/custom/my-prog.el | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/emacs/custom/my-prog.el b/emacs/custom/my-prog.el index 97eec00..379262f 100644 --- a/emacs/custom/my-prog.el +++ b/emacs/custom/my-prog.el @@ -69,6 +69,10 @@ "Hooks for `go-mode'." (setq tab-width 4) + ;; format the buffer using gofmt, for reasons unclear, doing this + ;; with LSP is not working great. + (add-hook 'before-save-hook 'gofmt-before-save) + (set (make-local-variable 'compile-command) "go build -v && go test -v -cover") (define-key go-mode-map (kbd "C-c C-r") 'compile) @@ -112,9 +116,6 @@ (dolist (hook '(go-mode-hook nix-mode-hook)) (add-hook hook 'eglot-ensure)) -;; rely on eglot to do the formatting for go buffers -(add-hook 'go-mode-hook #'(lambda() (add-hook 'before-save-hook 'eglot-format-buffer nil t))) - (provide 'my-prog) ;;; my-prog.el ends here |