Allow users and/or packages to create custom versions of "Wrap with ..." actions
It doesn't seem like there's an issue specifically for this, but there has been some discussion across various other issues (and PRs like https://github.com/Dart-Code/Dart-Code/pull/4232).
There is a desire to have more options in the "Wrap with..." actions list. Sometimes package-specific widgets, and sometimes widgets that users feel they use a lot. Including all of them in the default list could make it unwieldy (and doesn't handle packages). Perhaps analysis server plugins are the best way to handle this, but they might also be a bit complex for simple uses where a user just wants a simple extra wrap for a widget.
It's not great, but I noticed that user-defined snippets in VS Code can use $TM_SELECTED_TEXT to wrap a selection. So VS Code users can create their own snippets to do this, but they will need invoking/selecting from the command palette (maybe there's a way to optimise this, but I couldn't see anything obvious).
https://github.com/user-attachments/assets/90c74582-765b-49fc-841d-7f1a894f41c9
(ofc, for something this simple you should just use wrap with widget... but if you have something more complex, you can add multiple parameters, tabstops etc. in snippets)
I saw this comment here from the PR mentioned above.
I was thinking if this ever becomes a thing, there could be a way for the user to set which assists they'd like to see. Like a list option in vs code configs or something where they tick whatever they want to show. WDYT?
Not really sure how could we make that reflect the options on the analyzer, but maybe not to select what you want but possibly the other way around. Like what you'd like to hide kind of a thing.
I was thinking if this ever becomes a thing, there could be a way for the user to set which assists they'd like to see.
Do you mean allowing the user to also hide some of the existing values (like "Wrap with Padding"), or also hide other kinds of assists (like "Change to double quotes")?
Assuming the former and that the goal is to reduce the number of entries, something that might not be obvious (and doesn't negate the desire for this, but might help in the meantime), is that you can type to jump around the code actions list. For example here, I hit Ctrl+. and then typed column and it jumped to that action in the list:
I meant only hiding the "Wrap with ..." assists. Great help, will use your tip!
However, your comment got me wondering if the user's created "Wrap with" could be added to non-Widget classes for dart packages that add wrappers to their own or Dart base classes. Or even for List and other base classes like ValueNotifier if these assists can be made by users.
your comment got me wondering if the user's created "Wrap with" could be added to non-Widget classes for dart packages that add wrappers to their own or Dart base classes
I think that would be more difficult, because the current assists are specifically written for Widgets with build, and child/children. For non-widget classes, presumably these patterns might not be the same. However, for your own classes, analysis server plugins might be a way to achieve some of this (although at this point they're still a work in progress).
How about Shopify's approach? Shopify is building ruby lsp (language server for ruby, and it's mainstream in ecosysyem)
As you see this article, Shopify add capability to extending language server's feature. So called ruby lsp addon
https://railsatscale.com/2024-10-03-the-ruby-lsp-addon-system/
Thanks for the reference.
Ruby's approach is very similar to what we refer to as analysis server plugins. (The analysis server is our LSP support.) The initial prototype of plugins for Dart has been around for several years, and we're in the process of updating and simplifying the whole system with a goal of releasing it more formally.
Plugins are one way to provide some extensibility. They would support the "packages" portion of this request, but wouldn't support the "users" portion. For that I think we'd need a different solution.
@bwilkerson
Okay. (If i guested corrrectly), Do you mean, Even though it's referencing package in local path, they would support package's customized behaviour? not in Project's configuration? Like custom lint ruies?
There are two potential ways to provide this kind of capability.
This first is to allow a package author to specify that some of the widgets in that package should have a "Wrap with" action created for them. Plugins would support this use case.
The second is to allow an individual user to specify that they want a "Wrap with" action for a given widget even though the author of the widget didn't specify this. Plugins are too heavy weight, IMO, to be a good way to support this second use case.