Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ocaml-lsp 1.5.0 does not suggest keywords #420

Closed
Tchou opened this issue Apr 19, 2021 · 9 comments
Closed

ocaml-lsp 1.5.0 does not suggest keywords #420

Tchou opened this issue Apr 19, 2021 · 9 comments
Labels
wontfix This will not be worked on

Comments

@Tchou
Copy link

Tchou commented Apr 19, 2021

While working on a code base with OCaml 4.12.0 in VS Code, it occurred to me that the OCaml Platform extension was not giving keywords such as in as possible completions (which quickly gets annoying because, you don't use in_channel_length all that often ;)).

When I switched back to OCaml 4.11.2 (with opam), the same extension works as expected, and has since ocaml-lsp-server 1.2.0 (which fixed #173).

I also tried the current master with 4.12.0 and it does not work either. I wiped clean both switches (no pins) and created a simple directory with a simple .ml file to ensure that this was not caused by a local switch, forgotten pin or other.

Screenshot with OCaml 4.12.0/ocaml-lsp-server 1.5.0:

image

Screenshot with OCaml 4.11.2/ocaml-lsp-server 1.4.1:

image

@rgrinberg
Copy link
Member

Unfortunately we had to remove this feature. It wasn't going to be upstreamed by the merlin devs in a useful form and it is kind of a pain to maintain. In addition, the merlin devs are working on a smarter alternative to keyword completion. I don't have more information about an ETA but perhaps @voodoos does.

@Tchou
Copy link
Author

Tchou commented Apr 20, 2021

I see. That's unfortunate indeed. For reference and as a workaround in vscode, "editor.acceptSuggestionOnEnter": "off" makes for a reasonable experience (I haven't found a way to set a length threshold so that completion only kicks in after 3 chars).
The keyword in has a really bad combination of features here, which is why it would maybe warrant a special treatment :

  • it's a prefix of types (int, in_channel, …) and identifiers (incr, input_*, …) from Stdlib.
  • its use is pervasive in idiomatic OCaml code
  • it's often at the end of a line, thus followed by an [enter] keypress (which accepts the first completion in vscode default config)

The only other keyword with these characteristics that I found is do with do_at_exit, and is used far less often. for is not problematic as it is rarely followed by a new line.

It also seems (at least from the bug tracker) that both issues are mutually dependent, since ocaml/merlin#1229 seems to mention that this is handled by a work-around in ocaml-lsp (which has now been disabled waiting for a solution in merlin).

But I have no problem with the issue being closed or marked as feature/enhancement as long as it's monitored somewhere.

@voodoos
Copy link
Collaborator

voodoos commented Apr 20, 2021

Looking at Merlin's PR history there was that one: ocaml/merlin#1243 by @trefis
Is it not in a "useful form" for Ocaml-LSP because of the lack of "completion by context" ?

@rgrinberg
Copy link
Member

Yes. Suggesting all keywords in every context adds a lot of noise.

@bluddy
Copy link

bluddy commented Dec 8, 2023

This is a very annoying issue that hits me in neovim as well. I think it needs to be dealt with as it greatly hampers the experience of writing ocaml compared to other languages.

@daytoncf
Copy link

daytoncf commented Dec 8, 2023

This is a very annoying issue that hits me in neovim as well. I think it needs to be dealt with as it greatly hampers the experience of writing ocaml compared to other languages.

100% agree with @bluddy here. I use VSCode and the amount of timed I get irrelevant autocomplete when using language keywords is infuriating. Never had this problem w any other language

@rgrinberg
Copy link
Member

I agree 100% with all of you as well. But the question is, how do we proceed?

@bluddy
Copy link

bluddy commented Dec 9, 2023

I think the first priority is to special case in. in is at the end of our lines, which means it needs to be followed up by an return key. It's also extremely common. do is the next candidate but it's far less common. @Tchou already said this in more detail 2 years ago, and he's right. We need to suggest these two keywords before all other choices.

@rgrinberg
Copy link
Member

Okay, PR's welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

6 participants