Emacs completion keywords issue (`in` gets completed to `in_channel_length`)

I’m trying to understand why completion does not work very well in my emacs setup. I’m using company-mode and tuareg, and for some reason when I type in I get offered the completion in_channel_length which gets selected if I type enter (which is a bit annoying). Is there a reason why keywords are not taken into account? Is this a tuareg or caml-mode bug?


Same thing happens with VSCode and OCaml LSP: Share your VS Code `settings.json` for OCaml dev

1 Like

That’s a known issue both in merlin and ocamllsp (and vscode extension). Merlin doesn’t support keyword completions yet, so completion offers symbols that are in the environment, AFAIU

Thank you for the suggestion. I’ll look into turning auto-complete on enter off.

It would be probably an ugly workaround but why cannot be the handling on in be hardcoded?

Or maybe make the length of prefix for autocomplete configurable. Setting it to 3 would solve that problem.

Ideally all keywords should be hardcoded. When I type end, the suggestion given is exn, so even 3 letter keywords are problematic.

I don’t know the precise reason why not except that it’s a hacky solution. The goal is to have context-aware non-hacky keyword completion, I guess.