Hi, I made a tiny vscode extension which provides auto-completion for .ocamlformat file. (I posted this on discord but let me post it here too.)
…BTW I’m a complete beginner so this is written in TS. If I become comfortable with OCaml and its ecosystems, I’d like to re-write this in OCaml. But as of now, I have no clue.
If you decide to try this, you can look VSCode OCaml Platform source code to see how we wrote the OCaml extension in OCaml code. The basic idea is that it uses the Js_of_ocaml compiler to compile OCaml code to Javascript with bindings to the VSCode API.
I glanced over your source code and it looks like it would translate very well to OCaml code. Feel free to reach out if you’d like help.
You can add support for ocamlformat file completions not only in vscode but all editors supporting Language Server Protocol by adding such support to ocaml-lsp. I’d be glad to help you if you want (it also should be easier than writing your own extension in OCaml from scratch).
However, if I were actually to do that, I’d like to consider changing current project to a monorepo setup because I want to have both lsp-server implementation and vscode extension in a single same repository, which sounds rather complex to me tbh. In any case, I’m going to do some research first. And If I get stuck, I might ask for help. Thanks!
Hi, Just a quick update to let you know the current progress.
I’ve created another repository for OCaml translation. And It took me a while to figure out how to use dune properly, but I think I’m about halfway through the core part. At least I’m making some progress.
Well, I think lsp-server implementation is almost done! (I’m not going to lie, as a beginner, it was quit challenging. I found linol library and it helped me a lot. Big thanks to all the useful libraries.)
I’ve just tested the lsp-server with a simple vscode lsp-client, and it does auto-complete things as I expected.