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

Enhance version manager config to accept more fields #1831

Merged
merged 1 commit into from
Apr 11, 2024

Conversation

vinistock
Copy link
Member

Motivation

Step towards #1822

Because each version manager has its own customizations, I believe we need to offer more settings to match the behaviour in the editor. We currently only allow setting the identifier of the manager, but that's not always enough (e.g.: see the issue).

Implementation

The idea is to change the versionManager setting so that it becomes an object and then we nest the identifier inside of that object. After this goes in, then we'll be able to add extra configuration fields, like the version manager executable path.

All of the changes are solely to migrate versionManager from a string to an object that looks like { identifier: "chruby" }.

The only other change is the automated migration in extension.ts, where we read all of the existing configuration values and update them automatically to match the new format. That code is temporary and can be removed after it has been there for a while.

Automated Tests

Adapted our existing tests.

Manual Tests

  1. Start the extension on this branch
  2. Open your JSON settings
  3. Verify that your version manager setting was migrated to the new format
  4. verify the server boots properly

@vinistock vinistock added vscode This pull request should be included in the VS Code extension's release notes other Changes that aren't bugfixes, enhancements or breaking changes labels Mar 26, 2024
@vinistock vinistock self-assigned this Mar 26, 2024
@vinistock vinistock requested a review from a team as a code owner March 26, 2024 13:44
@vinistock vinistock requested review from st0012 and egiurleo March 26, 2024 13:44
@vinistock vinistock force-pushed the vs/enhance_version_manager_config branch from 031d839 to 853676a Compare March 26, 2024 13:44
Copy link
Member

@paracycle paracycle left a comment

Choose a reason for hiding this comment

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

I don't have any specific comments on the implementation but one configuration pattern that I really like and suggest we use is using shorthands. So, I suggest that we leave the rubyLsp.rubyVersionManager config exactly as it is, but also allow it to be passed as an object if users want to pass in more options.

So, either "rubyLsp.rubyVersionManager": "chruby", or "rubyLsp.rubyVersionManager": { "identifier": "chruby", "foo": "bar" } would be valid configuration, and I find that to be very user-friendly.

@paracycle
Copy link
Member

For reference, the older Ruby extension used that pattern for Ruby linter configuration: https://github.com/rubyide/vscode-ruby/blob/main/packages/vscode-ruby-client/package.json#L283-L343

You can see how rubocop is either a boolean or object with rich fields, so either "ruby.lint": { "rubocop": true } or "ruby.lint": { "rubocop": { "command": "foo" } } is valid configuration.

@andyw8
Copy link
Contributor

andyw8 commented Mar 26, 2024

So we'd avoid the identifier key, and do this?

"rubyLsp.rubyVersionManager": { "chruby": { "foo": "bar" } }

@vinistock
Copy link
Member Author

Talked with Ufuk on Slack. Unfortunately, if we use the string or object types, we lose the ability to provide enum completions.

In fact, you can add the enum and it does show the right completions, but then it considers the { identifier: } version of the setting as invalid, which makes the experience a bit odd.

With the current implementation, old settings get migrated automatically and you get completion every step of the way, so I think this is a nicer approach.

@vinistock vinistock requested a review from andyw8 March 27, 2024 18:50
@vinistock vinistock force-pushed the vs/enhance_version_manager_config branch from 853676a to f391642 Compare March 28, 2024 18:34
@egiurleo egiurleo removed their request for review March 29, 2024 13:50
@vinistock vinistock force-pushed the vs/enhance_version_manager_config branch from f391642 to 7be1827 Compare April 5, 2024 18:02
Copy link
Contributor

@egiurleo egiurleo left a comment

Choose a reason for hiding this comment

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

🥳 This is exciting!

@vinistock vinistock merged commit aac424d into main Apr 11, 2024
39 checks passed
@vinistock vinistock deleted the vs/enhance_version_manager_config branch April 11, 2024 13:28
Earlopain added a commit to Earlopain/ruby-lsp that referenced this pull request Apr 12, 2024
vinistock pushed a commit that referenced this pull request Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
other Changes that aren't bugfixes, enhancements or breaking changes 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.

4 participants