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

Handle multiple formatters #2328

Merged
merged 5 commits into from
Sep 28, 2023
Merged

Handle multiple formatters #2328

merged 5 commits into from
Sep 28, 2023

Conversation

jwortmann
Copy link
Member

Closes #2150.

@@ -780,6 +780,14 @@
"LSP": {
"type": "object",
"markdownDescription": "The dictionary of your configured language servers or overrides for existing configurations. The keys of this dictionary are free-form. They give a humany-friendly name to the server configuration. They are shown in the bottom-left corner in the status bar once attached to a view (unless you have `\"show_view_status\"` set to `false`).",
"properties": {
"formatters": {
Copy link
Member Author

Choose a reason for hiding this comment

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

I guess we can assume that there will be no client config with this name.

Copy link
Member

Choose a reason for hiding this comment

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

Feels weird to mix client configurations and other settings but I suppose this could be considered a bad initial design...

Copy link
Member Author

Choose a reason for hiding this comment

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

Alternatively we could use a different top-level key under "settings", for example "lsp_formatters". But I'd prefer to keep all LSP settings together under "LSP". And even if there were a config named "formatters" everything should still work fine, because the settings from that config and the formatter scope keys stored under the same name wouldn't influence each other.

Copy link
Member

@rchl rchl left a comment

Choose a reason for hiding this comment

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

I think the FormattingTask task (the lsp_format_on_save setting) should also consider the stored formatter preference.

If nothing is stored yet and it's ambiguous which formatter to use then maybe use first like now and post a status message saying "No formatter selected, using default"

plugin/core/windows.py Outdated Show resolved Hide resolved
plugin/formatting.py Outdated Show resolved Hide resolved
plugin/formatting.py Outdated Show resolved Hide resolved
plugin/formatting.py Outdated Show resolved Hide resolved
plugin/formatting.py Outdated Show resolved Hide resolved
plugin/formatting.py Outdated Show resolved Hide resolved
@@ -780,6 +780,14 @@
"LSP": {
"type": "object",
"markdownDescription": "The dictionary of your configured language servers or overrides for existing configurations. The keys of this dictionary are free-form. They give a humany-friendly name to the server configuration. They are shown in the bottom-left corner in the status bar once attached to a view (unless you have `\"show_view_status\"` set to `false`).",
"properties": {
"formatters": {
Copy link
Member

Choose a reason for hiding this comment

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

Feels weird to mix client configurations and other settings but I suppose this could be considered a bad initial design...

@predragnikolic
Copy link
Member

Can you add a section in the docs about the command and setting?

@jwortmann
Copy link
Member Author

Can you add a section in the docs about the command and setting?

Well, the command is the same as before (lsp_format_document), now it just has a new optional select argument, following the design of the built-in build command (Tools > Build / Build With...). This is not really intended to be used for key bindings or such, it's just something that automatically shows up when you trigger document formatting at the first time with multiple language servers running, and then after you selected your preferenced formatter you can forget about it (more or less at least, as it's "only" saved per project or for the running session if there is no project). Similarly, the setting in the project file is also not really intended to be edited manually.

So I don't think there is anything which needs to be added to the docs. Or is there anything special you had in mind?

@rchl
Copy link
Member

rchl commented Sep 28, 2023

I think it's fine. The new "setting" is not really meant to be manually controlled anyway.

@rchl rchl merged commit 83ed935 into sublimelsp:main Sep 28, 2023
4 checks passed
@jwortmann jwortmann deleted the multi-formatters branch September 28, 2023 17:45
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.

Handle multiple formatters
3 participants