Skip to content
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

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

Conversation

Ndot
Copy link

@Ndot Ndot commented Apr 3, 2025

Add format on save (issue #3944) with two option:

  • lsp-format-buffer-on-save to turn on / off
  • lsp-format-buffer-on-save-list to specify what major modes to save (nil saves all buffer)

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)
Copy link
Member

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.

Copy link
Author

@Ndot Ndot Apr 3, 2025

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 you be more accessible, but I agree with you using symbols is better.

Updated the branch to use symbols.

@Ndot Ndot force-pushed the fix-3944-add-format-on-save-option branch from 9048e33 to 6b79dd2 Compare April 3, 2025 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants