Editor autocomplete with let..."in"?

Hey! I’m pretty new to Ocaml (coming from Javascript.) Looking forward to learning more.

One thing that I’m running into is that my editor - vscode - is very aggressive about trying to autocomplete in. If I open a new file and just type

let () = 
  let x = 5 in

it will try to auto-complete that last in with a longer word - I often accidentally select a menu item and constantly have to go back and fix it.

Does anyone else run into this? I asked in the #beginners discord channel and someone commented they only see it with vscode. Any solutions or workarounds?

(Edit: using the OCaml Platform v1.12.2 extension)

2 Likes

It’s a known issue at the LSP level: Emacs completion keywords issue (`in` gets completed to `in_channel_length`)

Interesting. So these menu items do show up when typing let, but when I looked up the icon it wasn’t the keyword icon but a snippet one. So I guess the most currently official way of having this work is to always use snippets by hitting tab after typing let.

except that there are two: let toplevel and let…in, and as far as I can tell there’s no awareness of whether or not you’re on the top level. So you have to look and see which one it wants to autocomplete, and that order might change based on which one you’re using more frequently :(.

I could be wrong…still learning ofc.

1 Like