iamcco / coc-flutter

flutter support for (Neo)vim
472 stars 38 forks source link

LSP snapshot not automatically found on windows #101

Closed hai-ttb19 closed 3 years ago

hai-ttb19 commented 3 years ago

I installed coc-flutter through latest coc.nvim version LSP server did'nt run when I open the flutter project "flutter.lsp.restart" give the message "analyzer LSP server is not running" and Here is the cocnvim log file: image And the flutter-lsp output is empty

My cocnvim info:

vim version: NVIM v0.5.0-741-gca6815115
node version: v13.14.0
coc.nvim version: 0.0.80-9184dcccc4
coc.nvim directory: C:\Users\Admin\AppData\Local\nvim\plugged\coc.nvim
term: undefined
platform: win32 (window 7)

I installed flutter and set path to flutter:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.0.0, on Microsoft Windows [Version 6.1.7601], locale vi-VN)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
[!] Android Studio (not installed)
[√] Connected device (1 available)

! Doctor found issues in 2 categories.

Both flutter 1.23 and flutter 2.0 give the same issues Even I set the "flutter.sdk.path" and "flutter.sdk.searchPaths" but "CocList FlutterSDKs" give empty list. I see that this issues was fix before but I don't know why it appear now ?

iamcco commented 3 years ago

Please test https://github.com/iamcco/coc-flutter/pull/102/files

Kavantix commented 3 years ago

@hai-ttb19 could you also share your coc config

hai-ttb19 commented 3 years ago

@hai-ttb19 could you also share your coc config

Please test https://github.com/iamcco/coc-flutter/pull/102/files

same error image

hai-ttb19 commented 3 years ago

@hai-ttb19 could you also share your coc config

here is it

{
    "cursors.previousKey":"<S-Tab>",
    "coc.preferences.formatOnSaveFiletypes":[
        "dart",
        "python",
        "cpp"
    ],
    "flutter.lsp.debug": true,
    "flutter.sdk.path":"E:/flutter_windows_2.0.0-stable/flutter/bin",
    "python.pythonPath": "D:/python/python.exe",
    "python.analysis.diagnosticPublishDelay": 500,
  "python.autoComplete.extraPaths": [
    "${env:SPARK_HOME}\\python",
    "${env:SPARK_HOME}\\python\\pyspark"
  ]
}
Kavantix commented 3 years ago

Your flutter sdk path is wrong it should not include the bin part Try using the following and then opening the list: "flutter.sdk.searchPaths": ["E:/flutter_windows_2.0.0-stableA/flutter"]"

hai-ttb19 commented 3 years ago

It's error image

I think it is : "flutter.sdk.searchPaths": ["E:/flutter_windows_2.0.0-stableA/flutter"], but it still not working

Your flutter sdk path is wrong it should not include the bin part Try using the following and then opening the list: "flutter.sdk.searchPaths: ["E:/flutter_windows_2.0.0-stableA/flutter"]"

Your flutter sdk path is wrong it should not include the bin part Try using the following and then opening the list: "flutter.sdk.searchPaths: ["E:/flutter_windows_2.0.0-stableA/flutter"]"

Kavantix commented 3 years ago

Did you restart coc :CocRestart after changing the config?

hai-ttb19 commented 3 years ago

Did you restart coc :CocRestart after changing the config?

yes sir

Kavantix commented 3 years ago

A wait your using linux style instead of windows style for the path. try using: "E:\\flutter_windows_2.0.0-stableA\\flutter" as search path. (double slash to escape them)

hai-ttb19 commented 3 years ago

A wait your using linux style instead of windows style for the path. try using: "E:\\flutter_windows_2.0.0-stableA\\flutter" as search path. (double slash to escape them)

it still not work Few day ago, it still work well without any config before I update cocnvim and all extensions (I don't remember the previous version) to the latest version

Kavantix commented 3 years ago

Strange, Could you share the output like suggested in the template:

  1. Set "flutter.trace.server": "verbose"
  2. Reproduce the issue
  3. :CocCommand workspace.showOutput open output list and select flutter

(but make sure to do a :CocRestart after changing to verbose)

And also share the directory structure of both E:/flutter_windows_2.0.0-stableA and E:/flutter_windows_2.0.0-stableA/flutter

hai-ttb19 commented 3 years ago

Strange, Could you share the output like suggested in the template:

  1. Set "flutter.trace.server": "verbose"
  2. Reproduce the issue
  3. :CocCommand workspace.showOutput open output list and select flutter

(but make sure to do a :CocRestart after changing to verbose)

And also share the directory structure of both E:/flutter_windows_2.0.0-stableA and E:/flutter_windows_2.0.0-stableA/flutter

Oh, it work !!! "flutter.sdk.searchPaths": ["E:\\flutter_windows_2.0.0-stableA\\flutter"], It should have "\flutter"

In my opinion, you should change Readme.md into required "flutter.sdk.searchPaths", without it, lsp will not find the sdk, it is very difference than the previous version that I don't need config anything

Thank you !!!

Kavantix commented 3 years ago

Nice that it works, but if your install worked without config before it should still do that. So could you give me the output you get when not having any config for the sdk

hai-ttb19 commented 3 years ago

Nice that it works, but if your install worked without config before it should still do that. So could you give me the output you get when not having any config for the sdk

The coc-nvim.log give the old error

Here is the flutter output (I rename the folder "flutter_windows_2.0.0-stableA" to "flutter_windows_2.0.0-stable" , those path bellow is true)

[dev-command]: register dev command
[sdk]: No local fvm sdk
[sdk]: which flutter command => E:\flutter_windows_2.0.0-stable\flutter\bin\flutter.BAT
[sdk]: searchPaths: ~/snap/flutter/common/flutter,~/fvm/versions
[sdk]: which dart command => E:\flutter_windows_2.0.0-stable\flutter\bin\dart.BAT
[sdk]: dart command path => E:\flutter_windows_2.0.0-stable\flutter\bin\dart.BAT
[sdk]: dart sdk home => E:\flutter_windows_2.0.0-stable\flutter
[sdk]: analyzer path => E:\flutter_windows_2.0.0-stable\flutter\bin\snapshots\analysis_server.dart.snapshot
[sdk]: dart command path => E:\flutter_windows_2.0.0-stable\flutter\bin\dart.bat
[sdk]: Dart SDK not found!
[sdk]: {
  "dartHome": "E:\\flutter_windows_2.0.0-stable\\flutter",
  "analyzerSnapshotPath": "E:\\flutter_windows_2.0.0-stable\\flutter\\bin\\snapshots\\analysis_server.dart.snapshot"
}
[lsp-server]: flutter SDK not found!
[server]: bufName C:\Users\Admin\Desktop\flutter\test_app\lib\main.dart
[server]: bufName C:\Users\Admin\AppData\Local\nvim\coc-settings.json
Kavantix commented 3 years ago

Very interesting especially since (as you can see in the log) it does actually have paths to the snapshot and such. I'll have to do some debugging on windows for this, but could you already validate for me that the paths actually exist (so the \bin\snapshots\analysis_server.dart.snapshot for instance

hai-ttb19 commented 3 years ago

Very interesting especially since (as you can see in the log) it does actually have paths to the snapshot and such. I'll have to do some debugging on windows for this, but could you already validate for me that the paths actually exist (so the \bin\snapshots\analysis_server.dart.snapshot for instance

That path doesn't exist I find this path, maybe it is: E:\flutter_windows_2.0.0-stable\flutter\bin\cache\dart-sdk\bin\snapshots there is a file "analysis_server.dart.snapshot" in this path

Kavantix commented 3 years ago

Ah I see what happens, It's because the which flutter ends with \bin\flutter.bat instead of \bin\flutter which it does on mac

hai-ttb19 commented 3 years ago

Ah I see what happens, It's because the which flutter ends with \bin\flutter.bat instead of \bin\flutter which it does on mac

Congratulations, I think this is the problem of "coc-flutter-tools" too !

Kavantix commented 3 years ago

Could you check if my the fix works :)

hai-ttb19 commented 3 years ago

Could you check if my the fix works :)

Yeah ! It's working without any configs now ! :100:

[dev-command]: register dev command
[sdk]: No local fvm sdk
[sdk]: which flutter command => E:\flutter_windows_2.0.0-stable\flutter\bin\flutter.BAT
[fs]: executing command cat E:\flutter_windows_2.0.0-stable\flutter\version
[sdk]: searchPaths: ~/snap/flutter/common/flutter,~/fvm/versions
[sdk]: flutter command path => E:\flutter_windows_2.0.0-stable\flutter\bin\flutter.bat
[sdk]: dart sdk home => E:\flutter_windows_2.0.0-stable\flutter\bin\cache\dart-sdk
[sdk]: analyzer path => E:\flutter_windows_2.0.0-stable\flutter\bin\cache\dart-sdk\bin\snapshots\analysis_server.dart.snapshot
[sdk]: dart command path => E:\flutter_windows_2.0.0-stable\flutter\bin\cache\dart-sdk\bin\dart.exe
[fs]: executing command E:\flutter_windows_2.0.0-stable\flutter\bin\cache\dart-sdk\bin\dart.exe --version
[sdk]: dart version: v2.12.0
[lsp-server]: rightVersion true
[lsp-server]: analysis server ready!
[lsp-closing-labels]: register closing labels