Replies: 1 comment 2 replies
-
Hi @gsouf thanks for taking the time to list all this cases, I think it's a very good starting point to discuss these features ! In particular, "go to type definition" from 2 or 3 should not jump to 1. Indeed, the type of I think we need a slightly bigger example to understand the current design choices and why choosing extensions is not obvious: (* In the [example.mli] file *)
module type FOO = sig
(* 0 *)
val bar : string -> unit
end
(* In the [example.ml] file *)
module type FOO = sig
(* 1 *)
val bar : string -> unit
end
module Foo : FOO = struct
(* 2 *)
let bar _s = ()
end
module Bar : FOO = struct
(* 2' *)
let bar _s = ()
end
(* 3 *)
let f = Foo.bar "s"
(* 3' *)
let f = Bar.bar "s"
In this example the declaration chains are:
It's a tree! (and can even be a dag), which is the source of the complexity for these features that provide partial navigation in that tree, often in ways constrained by the LSP protocol (which was not designed with OCaml in mind). Currently:
The main advantage of these design choices is that the results are easily predictable and well scoped. Also they fits the protocol well. I do think we should work on improving the current behavior in the future (and we are happy to receive contributions). Here a a few I could think of:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey there, started recently with OCaml and I noticed a few things with the LSP.
Here is one thing, I'm not sure whether it's a missing feature or a bug, but at least it didn't work as per my expectation (may it be right or wrong).
With the LSP we gain the ability, given a symbol, to jump to references, definition, declaration, implementations, type definition of the given symbol (note that these wordings are the ones coming from my neovim shortcuts, actual names might be different).
Below are somes cases where I couldn't get it to work as I expected.
To illustrate my findings here is a very simple code sample:
Everything I will demonstrate here revolves around the
bar
function, I annotated the 3 locations where it appears to make explanations clearer.So first of all here are few things that worked as expected:
3
-> go to2
3
-> go to1
Here are things that worked partially as expected:
2
-> go to3
. ❌ But does not go to1
3
-> go to2
. ❌ But does not go to1
Now here are things that didn't work as expected
1
-> nothing (expected to go to2
)1
-> nothing (expected to go to2
and3
)2
-> nothing (expected to go to1
)2
-> nothing (expected to go to1
)3
-> nothing (expected to go to1
)Any thoughts on this? Are there features missing, or is there something I'm not understanding correctly?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions