lsp-dart
lsp-dart copied to clipboard
Can not jump to definition when current opened buffer was belong to a package. (but VSCode can)
this issue just copy from here
i fork flutter_sample project here, you can try reproduce on test_jump_to_definition branch.
Following is reproduce:
- switch to
test_jump_to_definitionbranch - open lib/main.dart, hover on Dashboard, as screenshot.

- try jump to definition. (xref-find-definitions), it jump to lib/screens/dashboard/dashboard.dart, it works!
- hover on DesktopMultiWindow, try jump to def, it jump to
~/.pub-cache/hosted/pub.flutter-io.cn/desktop_multi_window-0.0.1/lib/desktop_multi_window.dart:11, it still works! - at this time, lsp give me a selection. like following screenshot.
I select to set root directory interactively, that is, ~/.pub-cache/hosted/pub.flutter-io.cn/desktop_multi_window-0.0.1, i consider this is the correct option, right? please point out if this is not intended. from my point, if not set lsp root, there is no way to continue jump to next definition. - hover on multiWindowChannel, jump to definition, it goto
~/.pub-cache/hosted/pub.flutter-io.cn/desktop_multi_window-0.0.1/lib/src/channels.dart, it seem like sitll works, though, as you can see, many flycheck error on this file.

- now my issue is coming. when hover on MethodChannel, it can't jump to definition. (but can when use VSCode)

I can't repro this, but what I do is press n when lsp-mode asks about import that new package and works
In fact, this issue same as #146 , those error not displayed if pressing n to not treat package root as LSP root, but it not jumpable as VSCode does.
as you mention in https://github.com/emacs-lsp/lsp-dart/issues/128#issuecomment-1068581681, VSCode must do some magic things which make jump to definition always happen even in package, maybe lsp-dart will work someday.
it does work for me with lsp-dart jumping to multiple packages, it could be some corner case we are not aware of yet
it does work for me with lsp-dart jumping to multiple packages, it could be some corner case we are not aware of yet
Yes, it can jumping to packages, but, then, ipressing n when tips add package folder into lsp, then, when try do jump in package, it not works.
Yeah, I need to repro to understand why it happens, can you repro on the flutter sample repo?
Yeah, I need to repro to understand why it happens, can you repro on the flutter sample repo?
No, it seem like in flutter_sample repo, there is no dart code use external package, so, there is no way to jump out to package?
Hum, I thought jumping to flutter internal is considered a external package
Hum, I thought jumping to flutter internal is considered a external package
Sure no, haha, let us leave this issue for a moment, if i meet same issue again, i will do some research, and report here ASAP.
@zw963 I made a commit which should fix this: https://github.com/emacs-lsp/lsp-dart/commit/a8939d6784c033f97941908b067fa364ee2580a3 LMK if otherwise
Cool, thanks, that will be a big improvement, i am not use dart recent days, i will test it later and give feedback.