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

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lua/flutter-tools/dap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ function M.setup(config)
local root_patterns = { ".git", "pubspec.yaml" }
local current_dir = vim.fn.expand("%:p:h")
local root_dir = path.find_root(root_patterns, current_dir) or current_dir
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\'?

end
local is_flutter_project = vim.loop.fs_stat(path.join(root_dir, ".metadata")) or search_pubspec_for_flutter_sdk()

if is_flutter_project then
dap.adapters.dart = {
Expand Down