clojureVSCode icon indicating copy to clipboard operation
clojureVSCode copied to clipboard

Use cljfmt from inside NodeJS

Open marcomorain opened this issue 7 years ago • 2 comments

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 avatar May 12 '18 17:05 marcomorain

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

avli avatar May 15 '18 19:05 avli

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

marcomorain avatar May 15 '18 19:05 marcomorain