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

fix(dap): Flutter/Dart project detection improvement #292

Conversation

m-salman-a
Copy link
Contributor

@m-salman-a m-salman-a commented Sep 20, 2023

This PR aims to fix #282 by searching for the flutter sdk dependency from the pubspec.yaml file located in the root directory. This is based on the fact that the pubspec.yaml in all flutter projects requires the flutter sdk dependency, as stated by this specification.

This is the simplest way that I can think of to differentiate between flutter or dart project, but any other suggestions are welcome 😀.

EDIT: This is still not a perfect solution as this still doesn't account for any comments that can be provided in the yaml file, but I think with this change and keeping the old behavior should be good enough for most users.

@m-salman-a m-salman-a force-pushed the flutter_dart_detection_improvement branch from 3aa0e51 to 7388b8a Compare September 20, 2023 19:13
local is_flutter_project = vim.loop.fs_stat(path.join(root_dir, ".metadata"))
local function search_pubspec_for_flutter_sdk()
local pubspec_path = path.join(root_dir, "pubspec.yaml")
return pcall(vim.cmd, "silent 1vimgrep! /sdk:\\_s\\+flutter\\C/j" .. pubspec_path)
Copy link
Collaborator

Choose a reason for hiding this comment

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

For the reference, I see Dart-Code uses a similar approach, it parses yaml and checks dependencies:
https://github.com/Dart-Code/Dart-Code/blob/0f3afe552c2cd918b0031fc1b77ede100b3fbea8/src/shared/utils/fs.ts#L163C11-L176

So I think this approach is valid, but I just do not fully understand regex: is underscore needed in '\_s\'?

@sidlatau
Copy link
Collaborator

PR with almost the same logic was merged (#326) so closing this one.

@sidlatau sidlatau closed this Aug 21, 2024
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.

Flutter/Dart project detection improvement
2 participants