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

in keyword completion #1088

Open
3Rafal opened this issue Mar 22, 2023 · 7 comments
Open

in keyword completion #1088

3Rafal opened this issue Mar 22, 2023 · 7 comments
Labels
ocamllsp upstream Issues that need to be addressed in upstream projects

Comments

@3Rafal
Copy link
Collaborator

3Rafal commented Mar 22, 2023

Scenario:

  1. User types a line of code that ends with in(very common OCaml pattern)
  2. Tries to open a new line with enter key
  3. Gets the autocompletion instead

The problem has already been discussed:
#183
ocaml/ocaml-lsp#420
The consensus seems that it takes more work to resolve this problem systemically for all OCaml keywords.

However, I have found a simple hack that resolves this specific case. It was inspired by this Stack Overflow issue.

This workaround for in can be implemented as:

	"in": {
        "body": "in",
        "prefix": "in",
        "description": "this is to prevent irrelevant suggestions for the keyword in"
    }

Which provides in autocompletion and seems much more intuitive.
image

We can either add this snippet to vscode-ocaml-platform list of built-in snippets or explain this workaround in README.

@mshinwell
Copy link

It would be nice to see this fixed completely properly, but the above gives a really significant improvement, to what seems a fairly serious usability issue.

@abbysmal
Copy link

Agreeing this would be a very nice improvement.

@rgrinberg
Copy link
Contributor

If it's a snippet, should we just suggest it from the lsp server?

Also, what is the difference between this workaround and just adding the keyword as a normal completion candidate?

@3Rafal
Copy link
Collaborator Author

3Rafal commented Mar 22, 2023

@rgrinberg , as I understand it, the keyword completion was expected to be context aware. This comment suggests that adding keyword completions without it is too noisy.
Do you think of adding completion just for in? Or should we add all keywords?

My "solution" is a cheap attempt at helping with a common pain point that was reported by Mark and seems to affect a lot of users. I wanted to add it in the topmost "layer" of the completion stack and then wait for a proper solution. I'm unsure if hiding this kind of hack inside the lsp server is better.

@rgrinberg
Copy link
Contributor

Does this issue affect every editor? If yes, then a solution in ocamllsp seems more appropriate.

Do you think of adding completion just for in? Or should we add all keywords?

No strong opinion here. We could experiment and see which ad-hoc solution works better in practice.

My "solution" is a cheap attempt at helping with a common pain point that was reported by Mark and seems to affect a lot of users. I wanted to add it in the topmost "layer" of the completion stack and then wait for a proper solution. I'm unsure if hiding this kind of hack inside the lsp server is better.

I don't mind a temporary hack, but I don't see the advantage of doing it in vscode if the issue affects multiple editors. Unless of course the hack proposed here is somehow different than doing it right in the server.

@lukstafi
Copy link

The completion exception cannot easily be patched in a vscode extension, because it seems to be happening between VSCode and the LSP without the LSP client having a say. So it would be easiest to intervene somewhere in the completion logic. Except it would be kinda ugly.

@3Rafal 3Rafal mentioned this issue Jun 12, 2023
@smorimoto
Copy link
Collaborator

I don't think we can even say that this is a problem that only happens with VSCode. In other words, it should ideally and definitely be addressed on the LSP side.

@smorimoto smorimoto added ocamllsp upstream Issues that need to be addressed in upstream projects labels Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ocamllsp upstream Issues that need to be addressed in upstream projects
Projects
None yet
Development

No branches or pull requests

6 participants