ocaml-lsp
ocaml-lsp copied to clipboard
lsp-rename and ppx annotation
With ocaml-lsp
+ lsp-mode
+ emacs
. When I do M-x lsp-rename
(t -> foo
) on type t = T of t [@@deriving show]
I get type foooooo = T of foo [@@deriving show]
, together with a message saying that 4 edits have been applied. It does do as expected when without "ppx" annotation. My ocaml-lsp
is from April 15.
Still reproducible with latest master.
When you move around the cursor, and try to trigger the lsp-rename
action, you can observe that the right-hand-side t
is identified as an identifier all by itself, which is as expected. The replacement will be wrong though.
What is more funny is that when you place the cursor anywhere else on the above ppx-annotated type declaration, and then try the lsp-rename
action, it is the whole declaration, annotation included, that is considered as an identifier.
If you add let () = print_string "hello"
below the type declaration, place the cursor on ()
, and then invoke lsp-rename
with () -> foo
, you will end up with ()
replaced by foo
, but also the whole ppx-annotated type declaration replaced by foo
too.
All that is reflected by the highlighting when you move the cursor around.
I've noticed ocaml-lsp
can now be installed with 4.10.0
.
When compiled in that setting, when opening an ocaml file, I get a message:
seems to be compiled with a version of OCaml that is not supported by Merlin.
However everything that was going wrong in the previous comment, seem to be now working alright.
But the [@@deriving show]
is now not fully considered, since I also get unbound value show
: that could explain why the lsp-replace
is not doing funny things any more.
(Could that be related to #147?)
hmm.. from the "seems to be compiled with" message, it looks like you installed the server on a switch and used another switch to compile your programs. Can you check ? I've added this issue to the first release milestone, it's probably a tiny fix and should be done before release, but it's not a priority
"seems to be compiled with": I don't know what caused it to use mismatched versions. But your assumption seems correct. So for this here issue, it is just as described initially. Glad we can use 4.10.0 now.