Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): add project configuration #232

Merged
merged 9 commits into from
Apr 11, 2023
Merged

Conversation

akinsho
Copy link
Collaborator

@akinsho akinsho commented Apr 2, 2023

Implements #79
cc @sidlatau here's the branch I mentioned.

Currently the workflow is, a user creates an exrc file ie. a .nvim.lua or a .nvimrc and they add something like

require('flutter-tools').setup_project({
  device = "iPhone10",
  flavour = "Production",
})

-- Or
require('flutter-tools').setup_project({
	{
  		device = "iPhone10",
	    flavour = "Production",
		dart_define = {
			API_URL = "blah/thing.com",
		}
	},
	{
		device = "macOS",
		flavour = "Desktop",
	}
})

I've only implemented support for the device key atm but the others could be added eventually. The plan won't be to support everything immediately, but just to get a system in place for this PR.

@akinsho akinsho force-pushed the feature/project-config branch from 79399f1 to 767b0ff Compare April 2, 2023 17:40
@sidlatau
Copy link
Collaborator

sidlatau commented Apr 2, 2023

I want to add more details, about what problem I want to solve with project config: I have a project with two flavors and dart-defines(eg. DEV and PROD flavors). Now I have keymaps set up for each flavor in my dotfiles (FlutterRun --flavor...). But that is only related to the project, so it nice candidate for the project .nvim.lua configuration. So there are two configurations and I want an easy way to switch between them (maybe with the ability in lualine to see which configuration is currently selected).
Am I correct that in this PR the configuration will be set only on vim start?

@akinsho
Copy link
Collaborator Author

akinsho commented Apr 2, 2023

@sidlatau yeah currently the idea was just picking one of the configs on startup but that's somewhat arbitrary since I don't have that use case. It can easily store both configs and then when you run start we can check if you have a project config and show the selection prompt at that stage? would that solve the runtime issue?

@sidlatau
Copy link
Collaborator

sidlatau commented Apr 2, 2023

Yes, that may work. I was also thinking about a separate command for setting configuration. But configuration should be set before running FlutterRun. So maybe there is no point in adding separate command if that is a part of the process of starting the flutter app.

@akinsho akinsho force-pushed the feature/project-config branch 2 times, most recently from 278868a to 66acf6f Compare April 9, 2023 20:41
akinsho added 3 commits April 9, 2023 21:54
Rather than asking at startup, at each run command if there are multiple
project configurations as the user which they would like use
@akinsho akinsho force-pushed the feature/project-config branch from 66acf6f to 70be502 Compare April 9, 2023 20:54
@akinsho
Copy link
Collaborator Author

akinsho commented Apr 9, 2023

@sidlatau yeah the configuration is IMO similar to a launch.json or something it's something that you can change over time but isn't intended to be some super dynamic thing that needs changing with a command presumably there are standard ways to run your project and those are fairly consistent and not things that are changing super often.

@sidlatau
Copy link
Collaborator

Could support for flavor and dart_define be added to this PR too? I think these two adds most of the value plus then I would be able to help with testing this functionality with my project setup.

@akinsho akinsho force-pushed the feature/project-config branch 2 times, most recently from b13f765 to be7a714 Compare April 11, 2023 07:25
lua/flutter-tools/commands.lua Outdated Show resolved Hide resolved
lua/flutter-tools/commands.lua Outdated Show resolved Hide resolved
lua/flutter-tools/commands.lua Show resolved Hide resolved
@akinsho akinsho force-pushed the feature/project-config branch from be7a714 to cab6a37 Compare April 11, 2023 09:56
Copy link
Collaborator

@sidlatau sidlatau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functionality works with my project configuration 👍🏻
I think mentioning in README/docs is missing, and it will be LGTM

@sidlatau
Copy link
Collaborator

One more thing: if the app is already started and I run FlutterRun, then I get the selector and then the info message:

Info  14:57:31 notify.info Flutter tools Flutter is already running!

Maybe it is possible to check if Flutter is already running before showing the selector?

@akinsho akinsho merged commit f898ac2 into main Apr 11, 2023
@akinsho akinsho deleted the feature/project-config branch April 11, 2023 15:30
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