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

[Feature] let flutter.workspace.ignore pass to ignoredRootPaths of LanguageClientOptions #141

Open
changyiyao opened this issue Sep 23, 2021 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@changyiyao
Copy link

changyiyao commented Sep 23, 2021

@dkbast Have the similar issue but workaround well as the following:

  1. make the package be the local dependency of the example project, you may configure like ../ on dependency_overrides to the pubspec of example.
  2. cd to example dir in your terminal emulator.
  3. open vim/nvim editor without args.
  4. :e lib/main.dart (In my experience it must firstly open one dart file which belongs to example project, otherwise the lsp doesn't work well for dart files of example project if you open a dart file of package project at once)
  5. At last, with cocconfig I mentioned above, you will see the lsp works both in example and package project.

Finally, I found another way to work properly without cd into the example folder:

Background:
The whole project structure may be like:

. (package project root)
├── CHANGELOG.md
├── LICENSE
├── README.md
├── example
│   ├── README.md
│   ├── android/
│   ├── example.iml
│   ├── ios/
│   ├── lib/main.dart
│   ├── pubspec.lock
│   ├── pubspec.yaml
│   ├── test/
├── lib/
├── pubspec.lock
├── pubspec.yaml
└── test/

Since default rootPatterns of workspace when you open dart files is like:
{"global": [".git", ".hg", ".projections.json"], "buffer": [], "server": ["pubspec.yaml"]}
Coc.nvim recognize workspaces by this patterns when you once open a file.
By default, when opening example/lib/main.dart from package project root path, Coc use up-bottom mode to specify the workspace, which only treats the package project root path as the workspace rather than the example folder, which causes commands such as flutter.run cannot found the entry lib/main.dart file, even though you append args -t example/lib/main.dart.

To solve the issue:

  1. Set workspace.bottomUpFiletypes, such as
{
  ...
  "workspace.bottomUpFiletypes": ["dart", "yaml"],
  ...
}
  1. Enter (neo)vim from package project root path, then open a dart file or yaml file under example folder, then the flutter commands works well.

But there is an issue left:
Since no exclusive config for rootPattern of coc's workspace and flutter.workspaceFolder.ignore is not be passed to the coc's LanguageClient, the CocList files/grep -workspace includes the unexpected files in workspace folders that should also be ignored.
For example:
As the setting is

  "flutter.workspaceFolder.ignore": [
    "~/.pub-cache/",
    "~/.config/",
    "~/.dotfiles/"
  ],

The ~/.pub-cache/** should be expected excluded when CocList -workspace files/grep, which is still treated as coc's workspace folder.

Request:
pass flutter.workspaceFolder.ignore to ignoredRootPath

Originally posted by @changyiyao in #134 (comment)

@changyiyao changyiyao changed the title [feature] let flutter.workspace.ignore pass to ignoredRootPaths of LanguageClientOptions [Feature] let flutter.workspace.ignore pass to ignoredRootPaths of LanguageClientOptions Sep 23, 2021
@Kavantix Kavantix added enhancement New feature or request good first issue Good for newcomers labels Nov 22, 2021
@Kavantix
Copy link
Collaborator

@changyiyao a PR for this would be welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants