Skip to content

Made function 'start' in 'lua/flutter-tools.lua' public#429

Closed
obemu wants to merge 2 commits intonvim-flutter:mainfrom
obemu:feat_01
Closed

Made function 'start' in 'lua/flutter-tools.lua' public#429
obemu wants to merge 2 commits intonvim-flutter:mainfrom
obemu:feat_01

Conversation

@obemu
Copy link
Contributor

@obemu obemu commented Jan 13, 2025

This PR changes the visibility of the function start in lua/flutter-tools.lua from private to public.

Currently, it is not possible to execute user commands from flutter-tools (FlutterRun, FlutterDebug, ...) before a .dart or the pubspec.yaml file has been entered. These commands can only be used once the start function, which registers them, is called. The problem is, that instead of calling start in setup, it is called once a .dart or the pubspec.yaml file is entered.

This change allows the user to call flutter.start() in their init.lua (or local .nvim.lua) file, to register all user commands. Therefore, the user is not required to enter a .dart/pubspec.yaml file to run their app and view log messages.

@sidlatau
Copy link
Collaborator

Registering commands in .nvim.lua is already supported via this pull request. I'm not sure if exposing the start function adds significant value. Could you elaborate on the specific use case this PR addresses?

@obemu
Copy link
Contributor Author

obemu commented Jan 14, 2025

I took a closer look at setup_project and found that I can achieve my desired outcome (being able to use the user commands without entering a .dart/pubspec.yaml file) by calling flutter.setup_project({}) in my init.lua. So accepting the PR would not add any new feature.

Nevertheless, I still think that there is some value in my approach, because I think that

local flutter = require("flutter-tools")
flutter.setup({ ... })
flutter.start()

semantically makes a lot more sense than

local flutter = require("flutter-tools")
flutter.setup({ ... })
flutter.setup_project({})

@obemu obemu closed this May 23, 2025
@obemu obemu deleted the feat_01 branch May 23, 2025 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants