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

prefer the dart binary located in dart_sdk rather than flutter_sdk

Open FlafyDev opened this issue 2 years ago • 3 comments

The flutter package in nix doesn't expose the dart binary in <Flutter SDK>/bin/dart. The binary is only found in the Dart SDK (<Flutter SDK>/bin/cache/dart_sdk/bin/dart). This PR prefers the dart binary located in the Dart SDK rather than the Flutter SDK.

Concers

This PR is ready to merge only if the dart binary is always located in the dart_sdk (which I'm pretty use is always the case, but idk). If the dart_sdk path is found but there is no <dart_sdk>/bin/dart then the plugin would fail to get the dart binary. That's because the PR doesn't check if the dart binary exists, only if paths.dart_sdk doesn't exists then it checks paths.flutter_sdk.

FlafyDev avatar Aug 26 '22 15:08 FlafyDev

This seems potentially very risky and like it will introduce a bunch of problems for a plugin that is currently fairly stable. Can this not be solved in your config file by you just explicitly referencing where it should look for the binary. Tbh I haven't looked at all this logic in months so am defo rusty on the specifics.

akinsho avatar Aug 26 '22 16:08 akinsho

This seems potentially very risky and like it will introduce a bunch of problems for a plugin that is currently fairly stable. Can this not be solved in your config file by you just explicitly referencing where it should look for the binary. Tbh I haven't looked at all this logic in months so am defo rusty on the specifics.

I could've just changed my Neovim config. But I wanted my Neovim to pick the Dart binary that is associated with the Flutter that is currently in PATH (because different projects have different flutter versions). Setting the location of the Dart binary in the Neovim config wont let me do it..

FlafyDev avatar Aug 26 '22 16:08 FlafyDev

Just a thought, could you use the flutter_lookup_cmd = nil, -- example "dirname $(which flutter)" or "asdf where flutter" configuration option to do what you're looking for. This could reference a small script in which you can stat for files and return the PATH which you feel is most appropriate.

moonlitknight avatar Mar 15 '23 01:03 moonlitknight