clojureVSCode
clojureVSCode copied to clipboard
Use cljfmt from inside NodeJS
The current system to format a file only works when the REPL is connected, and the project has a dependency on cljfmt.
I have an idea on how to run formatting without needing the REPL:
We can compile cljfmt from Clojure to JavaScript using the ClojureScript compiler. We can then call the cljfmt code directly from TypeScript in the extension (in-process).
This will enable really quick format-on-save behavior.
@marcomorain, correct me if I wrong: you suggest to compile cljfmt to a JavaScript module and distribute it alongside with the extension, right? Have you checked if cljfmt compatible with ClojureScript? Otherwise, sounds great. I believe, it will make it easier to use native VSCode formatting protocol in this case.
Yeah, it seems possible based on this module: https://github.com/snoe/node-cljfmt/tree/master/bin