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 configuration options for third-party formatters #2092

Merged
merged 4 commits into from
Jun 21, 2024

Conversation

andyw8
Copy link
Contributor

@andyw8 andyw8 commented May 27, 2024

Closes #1775

To properly support additional formatters, we need to change how formatters are selected when using VS Code.

Currently we use an enum with fixed set of choices. We could change this to a text field, but that result in a poorer user experience.

Another option is to add the additional formatters to the enum list.

Although we generally try keep ruby-lsp itself unaware of specific addons, in this case it seems a worthwhile trade-off.

With the new choices being added, there is some additional information we want to show the user. There are two ways we could do this:

Using enumDescriptions:

Screenshot 2024-05-27 at 1 12 32 PM

Using enumLabels:

Screenshot 2024-05-27 at 1 11 30 PM

@andyw8 andyw8 added enhancement New feature or request vscode This pull request should be included in the VS Code extension's release notes labels May 27, 2024
"Auto",
"RuboCop",
"Syntax Tree",
"Standard (need v0.37 or newer of the standard gem)",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'll co-ordinate with @searls to determine the release version for the work being done in standardrb/standard#630.

@andyw8 andyw8 marked this pull request as ready for review May 27, 2024 17:21
@andyw8 andyw8 requested a review from a team as a code owner May 27, 2024 17:21
@andyw8 andyw8 requested review from st0012 and vinistock May 27, 2024 17:21
vscode/package.json Outdated Show resolved Hide resolved
vscode/package.json Outdated Show resolved Hide resolved
@st0012
Copy link
Member

st0012 commented May 28, 2024

I'm not sure about maintaining this list while we don't have any control on the community addons. For example, ruby-lsp-rubyfmt is likely not working with the recent Ruby LSP releases as it doesn't use the latest addon interface. Can we instead ask users to choose auto and focus on letting the server pick the right formatter?

@st0012
Copy link
Member

st0012 commented May 28, 2024

@vinistock mentioned that there are cases where it's not possible to purely rely addons & server to figure out the formatter. For example, if rubocop decided to become a Ruby LSP addon too and register the rubocop formatter the same way standard does, then Ruby LSP can't tell if the user wants to use standard or rubocop formatter by itself.

As an alternative, I'd like to propose a different solution here: for options that are not maintained by us, we make it extra clear and provide minimal context. So instead of:

  • Standard (need v0.37 or newer of the standard gem)
  • Rubyfmt (needs the ruby-lsp-rubyfmt gem)

We simply show:

  • Standard (supported by community addon)
  • Rubyfmt (supported by community addon)

And we use the same format for any community formatter addons in the future, which will set a clear expectation to the users and save us the need to update descriptions later.

@andyw8
Copy link
Contributor Author

andyw8 commented May 28, 2024

I'm good with that approach.

@andyw8
Copy link
Contributor Author

andyw8 commented Jun 11, 2024

@vinistock are you in agreement?

@vinistock
Copy link
Member

Yeah, I'm good with that 👍

andyw8 and others added 4 commits June 21, 2024 14:47
Co-authored-by: Vinicius Stock <vinistock@users.noreply.github.com>
Co-authored-by: Vinicius Stock <vinistock@users.noreply.github.com>
@andyw8 andyw8 force-pushed the andyw8/add-more-formatters branch from a4975be to 52f5444 Compare June 21, 2024 18:51
@andyw8 andyw8 enabled auto-merge (squash) June 21, 2024 18:52
@andyw8 andyw8 added enhancement New feature or request and removed enhancement New feature or request labels Jun 21, 2024
@andyw8 andyw8 merged commit 8d4c17e into main Jun 21, 2024
34 checks passed
@andyw8 andyw8 deleted the andyw8/add-more-formatters branch June 21, 2024 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request vscode This pull request should be included in the VS Code extension's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow non-standard values for rubyLsp.formatter option
3 participants