flutter-tools.nvim icon indicating copy to clipboard operation
flutter-tools.nvim copied to clipboard

[Feature] Add interactive with 'flutter pub' commands

Open leoncruz opened this issue 2 years ago • 8 comments

Flutter has a command line with some useful commands for development, some examples are:

flutter pub add packageName this command add a package with the informed name

flutter pub run packageName executable this executes a command from an executable from a package

So, I think that a possibility of run this commands inside the neovim there is a great additional for the plugin

leoncruz avatar Jan 15 '22 00:01 leoncruz

So would what you want be to be able to run the terminal commands with a wrapper like :Flutter <command>? An easier alternative would be to run the commands with !flutter <command>. If you want to do the asynchronously you could use tpope/vim-dispatch and do it as :Dispatch flutter <command>.

Are you asking more so for autocomplete with this?

joshpetit avatar Jan 19 '22 18:01 joshpetit

Similar to the point @joshpetit makes, this doesn't really seem necessary since nvim already has a built-in terminal, and you can just run the commands there. Seems like basically adding a bunch of logic to replicate just typing these commands into a terminal or as pointed out above you can achieve the same with just a !

akinsho avatar Jan 19 '22 23:01 akinsho

Your arguments that you can run the commands in a terminal also serve for: "Why have a command to run the project with 'FlutterRun' when you can just run that command in the terminal?" or "Why see the devices with the 'FlutterDevices' command when I can just run the command in the terminal?" This was just a suggestion that I thought while developing, that it could be interesting to have the possibility to execute these commands inside the editor, a way to help the development, which I think is the purpose of this plugin

leoncruz avatar Jan 22 '22 01:01 leoncruz

@leoncruz these actually are not the same with the flutter run command as an example the reason why it's valuable to have built in is that often choosing a device can cause clashes. If you have both an emulator and the device connected, which I often do, so it's useful to have the plug-in have a specific command which can actually handle conflicts by opening up a floating window. Also, on choosing a device it's nice to be able to see what your available options are and just select one. Whereas in the terminal you would have to run the flutter list devices command and then get the ID and then run the command with a specific ID. So actually having a custom command improves your workflow. I'm less convinced that this advantage would exist with the flutter pub command, it might do, but frankly I'm not really looking to take on that work right now. If you'd like to submit a PR for that, I'd be happy to look over it.

Unfortunately I don't have an infinite amount of time so I can't just add every flutter command that the binary gives only those that have a clear value that can't be achieved easily with just the CLI

akinsho avatar Jan 22 '22 09:01 akinsho

I understand your point. I'm sorry if I sounded rude in my previous comment, I didn't mean to impose anything. Of course, it doesn't make sense to add every command that flutter offers, but I just wanted to expose here a small suggestion to hear your opinions about it and maybe someone, or myself, implement

leoncruz avatar Jan 23 '22 01:01 leoncruz

@leoncruz I too was looking/hoping for the same features with this plugin. I've started working on a plugin for this that will at least take care of most commonly used commands (pub add, get, build_runner etc).

p4-k4 avatar May 12 '22 12:05 p4-k4

@leoncruz I too was looking/hoping for the same features with this plugin. I've started working on a plugin for this that will at least take care of most commonly used commands (pub add, get, build_runner etc).

@p4-k4 Imo there's already specialized packages that do what you're looking for. You can use https://github.com/akinsho/pubspec-assist.nvim for pub commands, you can use something like https://github.com/pianocomposer321/yabs.nvim (there's many alternatives) for running arbitrary commands like build_runner etc. Also, FlutterPubGet, FlutterPubUpgrade are already commands in this package!

rlch avatar May 12 '22 13:05 rlch

@p4-k4 I mentioned above that probably the biggest blocker to this was someone actually contributing the changes 🤷🏾 obviously it's FOSS so entirely your prerogative but if you had wanted those features I would have thought that submitting a PR to help this plugin out would have been an easier place to start than building a plugin from scratch just for that purpose 🤷🏾‍♂️ anyway, entirely your choice.

akinsho avatar May 12 '22 13:05 akinsho

Hello @p4-k4, I agree now with @akinsho and with @rlch. I'm not interesting anymore on this functionality. I thought would be good, but now I think is unnecessary, so I'm closing this issue.

leoncruz avatar Aug 25 '22 04:08 leoncruz