avli / clojureVSCode

Clojure support for Visual Studio Code
https://avli.github.io/clojureVSCode/
MIT License
205 stars 34 forks source link

Use cljfmt from inside NodeJS #106

Open marcomorain opened 6 years ago

marcomorain commented 6 years ago

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.

avli commented 6 years ago

@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.

marcomorain commented 6 years ago

Yeah, it seems possible based on this module: https://github.com/snoe/node-cljfmt/tree/master/bin