p42ai / js-assistant

120+ refactorings and code-assists for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=p42ai.refactor
MIT License
119 stars 7 forks source link

Feature: global/user configuration #10

Closed trasherdk closed 2 years ago

trasherdk commented 2 years ago

While I really enjoy this extension, the inability to disable something like Add Numeric Separator without polluting upstream repositories with my personal preferences, kinda annoy me.

Being able to configure stuff like that in VS Code User settings would help.

On a side note: As per p42 configuration

Adding a p42.toml to .gitignore and a p42.toml file to repository root, containing:

[refactoring.add-numeric-separator]
enable = false

Have zero effect ??? image

lgrammel commented 2 years ago

Thanks for the feedback.

The TOML configuration issue is a bug. I'll work on a fix today.

The VS Code settings are something I'm considering. However they can potentially conflict with the p42.toml configuration, which is why I haven't added them yet. In particular, cases where a user has multiple workspaces and the p42.toml (team/repository oconfiguration) sets certain refactorings true in one workspace and false in another, and the VS Code settings (user configuration) enables them in both (leading to issues in the workspace where they should be disabled).

My current is that there could be an enum with 3 settings in the configuration for each refactoring with suggestions:

Would that work for your use case?

lgrammel commented 2 years ago

I just looked deeper into the p42.toml configuration issue that you reported. While the configuration does not get immediately applied when you edit p42.toml, it does refresh once the file is edited or reloaded. As a work-around, you can just (with the refactoring being disabled in the p42.toml) add and remove a space in the file you are editing and the suggestions should update (in your case remove the hints for the numeric literals). Please let me know if that works for you. I'll implement a file watching mechanism for the p42.toml meanwhile.

lgrammel commented 2 years ago

@trasherdk I've just released version 1.68.2. It automatically updates the hints in open editors when p42.toml is saved. Please let me know if you still encounter the bug in version 1.68.2 or higher. Thanks again for the bug report!

lgrammel commented 2 years ago

@trasherdk I also noticed a small typo in your p42.toml: the setting is called enabled (not enable).

trasherdk commented 2 years ago

Damn.. That's embarrassing :blush: A typo in the config. So, it turns out, I was the bug.

It looks like extensions are auto updating, as I'm already on 1.68.2 and with the fixed typo all is good.

I would still love to see config in user settings, avoiding that p42.toml file.

In the case where a project already has p42.toml config, that config should override users personal preferences.

lgrammel commented 2 years ago

It happens to the best of us 😊 ideally, the content of p42.toml would get validated, and there would be syntax errors while editing, but that's a pretty lousy effort/value ratio, thus not a priority.

Regarding the user settings, I like your approach of having the project config override the user preferences way better than my original idea. That way, projects could easily enforce their settings. I'll see if I can get this implemented by the end of Jan.

trasherdk commented 2 years ago

Thank you for a useful tool, and looking forward to that settings feature.

I'm closing this a resolved :+1:

lgrammel commented 2 years ago

@trasherdk I've added the VS Code settings in 1.72.0. Here is how it works now:

action-feature-vscode-config

Thanks for the suggestion!

trasherdk commented 2 years ago

That is so cool :+1: I just got the updated plug-in :smile:
This is one of the more useful tools in the arsenal.