Skip to content

Replace gofmt-before-save with gofmt minor mode #426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PuercoPop
Copy link
Contributor

Using a minor mode has the advantage that disabling the hook is easier.

To enable it (add-hook 'go-mode-hook 'gofmt-mode)

Comment on lines +1762 to +1763
\(use-package go-mode
:hook ((go-mode . gofmt-mode)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I included the use-package instructions because it is now included with Emacs. Let me know if you prefer to remove it


(interactive)
(when (eq major-mode 'go-mode) (gofmt)))
(define-minor-mode gofmt-mode
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The minor mode approach is what the prettier mode does as well. It was where I got the idea.

https://github.com/prettier/prettier-emacs/blob/e9b73e81d3e1642aec682195f127a42dfb0b5774/prettier-js.el#L203-L210

@dominikh
Copy link
Owner

Thanks, I'll take a look at this soon.

Using a minor mode has the advantage that disabling the hook is easier.

To enable it (add-hook 'go-mode-hook 'gofmt-mode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants