Closed jakepearson closed 1 year ago
Shebangs are not currently supported, but I'm open to pull requests to add that feature.
Okie dokie, I'll take a look when I get some free time.
Probably best to do it as a wrapper function, i.e. check for the shebang, remove it and pass it onto the formatting function, then take the result and add the shebang back.
I started to take a look and wrote a test that appeared to pass without any changes. I then found that there was already a test for shebang (https://github.com/weavejester/cljfmt/blob/master/cljfmt/test/cljfmt/core_test.cljc#L432C7-L437) that passes and reformats the code. I assume that means I need another test.
Do you think I should put the wrapper function you mentioned around fix-one
and check-one
in tool.clj (https://github.com/weavejester/cljfmt/blob/master/cljfmt/src/cljfmt/tool.clj#L123-L134)?
It looks like rewrite-clj already supports reading shebangs, so there's no need for a wrapper function after all.
I ran a quick test using the latest version of cljfmt and it seems to handle reformatting fine, even with files that have a shebang. Can you provide an example of when it fails?
I see this in VSCode with Calva, when I try in the terminal it works just fine. I'll dig in on the Calva side. Thanks for the help!!
Have a nice day
Hi. I have a clojure file (for babashka) that has a shebang at the top (
#!/usr/bin/env bb
). When I have the shebang, the file is not formatted by cljfmt. Is there a way to enable this? Or is this a bug? I would be happy to work on it if someone can point me in the right direction.