-
-
Notifications
You must be signed in to change notification settings - Fork 922
Add format on save option (issue #3944) #4753
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
Add format on save option (issue #3944) #4753
Conversation
lsp-mode.el
Outdated
(defcustom lsp-format-buffer-on-save-list '() | ||
"If the list is empty format all buffer on save. Else only format buffers | ||
if their major-mode is in the list." | ||
:type '(repeat string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should store a list of symbols instead of string. Comparing symbol is always faster than compare string and cost less to store it. Plus, it's more natural to set a list of symbols than a list of string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually used symbols at first and then changed it to strings cause for some reason though that would be more accessible, but I agree with you using symbols is better.
Updated the branch to use symbols.
9048e33
to
6b79dd2
Compare
Thanks for adding this! |
@jcs090218 Thanks. Maybe issue #3944 can be closed? |
Add `:safe t` and `:local t` properties to `lsp-format-buffer-on-save` to enable project-specific configuration through `.dir-locals.el` without security prompts. Thanks to PR emacs-lsp#4753 for implementing the `format-on-save` functionality. This enhancement allows keeping automatic formatting disabled by default (avoiding unwanted diffs in third-party projects) while enabling it for personal or team projects with established formatting standards. The security implications are minimal since LSP formatting capabilities are limited to code reformatting, and any project where you're running an LSP server already has significant execution privileges.
…4760) Add `:safe t` and `:local t` properties to `lsp-format-buffer-on-save` to enable project-specific configuration through `.dir-locals.el` without security prompts. Thanks to PR #4753 for implementing the `format-on-save` functionality. This enhancement allows keeping automatic formatting disabled by default (avoiding unwanted diffs in third-party projects) while enabling it for personal or team projects with established formatting standards. The security implications are minimal since LSP formatting capabilities are limited to code reformatting, and any project where you're running an LSP server already has significant execution privileges.
Add format on save (issue #3944) with two option:
lsp-format-buffer-on-save
to turn on / offlsp-format-buffer-on-save-list
to specify what major modes to save (nil saves all buffer)