Closed dkbast closed 2 years ago
Can you try opening the project from the example directory itself. Also, you should not need the part in ‘coc-settings`, coc-flutter handles that
There seems to be no difference between vim example/lib/main.dart
and cd example
vim lib/main.dart
In both cases I get '[coc.nvim] No code action available' and no analyzer, closing tags etc pp
The path within vim is displayed as 'example/lib/main.dart' no matter from where I start - so I guess there is some magic going on in discovering which kind of project I'm working on and to auto discover other files and folders?
try setting flutter.lsp.initialization.onlyAnalyzeProjectsWithOpenFiles
to false
@changyiyao I tried, but this didn't work for me - did you give it a try? Does it work for you?
@dkbast Have the similar issue but workaround well as the following:
make the package be the local dependency of the example project, you may configure like ../ on dependency_overrides to the pubspec of example.
cd to example dir in your terminal emulator.
open vim/nvim editor without args.
: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)
At last, with cocconfig I mentioned above, you will see the lsp works both in example and package project.
@dkbast can you check if v1.9.6 fixed your issue?
@dkbast Have the similar issue but workaround well as the following:
- make the package be the local dependency of the example project, you may configure like ../ on dependency_overrides to the pubspec of example.
- cd to example dir in your terminal emulator.
- open vim/nvim editor without args.
: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)- 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:
{
...
"workspace.bottomUpFiletypes": ["dart", "yaml"],
...
}
PS:
Legacy issues: no exclude options for rootPattern of coc's workspace and flutter.workspaceFolder.ignore
cannot be tranferred to it(coc client side), CocList files/grep
can include the ~/.pub-cache/** which is declared in flutter.workspaceFolder.ignore
Sorry for not being very responsive on this issue - today I opened up another package and it looks like this problem does not exist anymore. @Kavantix looks like this is fixed without needing any configuration. Thanks!
For others wondering if this is working, I've just checked out https://github.com/trufi-association/trufi-core and and can confirm that I can work in the package as well as in the example directory, at least at first glance I didn't run into any issues.
Describe the bug I am developing a new Flutter package - when I'm in package_name/lib everything works as expected, but when I'm writing the examples in package_name/example/lib/main.dart I don't get any code actions or language server features.
To Reproduce Steps to reproduce the behavior:
Expected behavior I can develop the example using all the features I usually have - It would be ok if I would need two different sessions for developing the example and the package - the entry point could determine where the language server should start.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Config If you have any config for this specific extenstion in you
coc-settings
please include them here.