coc-flutter icon indicating copy to clipboard operation
coc-flutter copied to clipboard

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

Open changyiyao opened this issue 4 years ago • 1 comments

@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 https://github.com/iamcco/coc-flutter/issues/134#issuecomment-925488339

changyiyao avatar Sep 23 '21 06:09 changyiyao

@changyiyao a PR for this would be welcome

Kavantix avatar Dec 10 '21 13:12 Kavantix