Fork me on GitHub

👍 will do. I think my vscode is haunted for clojure so glad you reproduced anything;)


I'd like to track down what messes up the formatting in those other ways too. Even if Calva can't do anything about it, we can learn how to instruct people to set their editor up for Clojure.


What happens if you press tab when you have pressed enter the first time inside that defn?


So, immediately after pressing enter, my caret is 1 column indented, with a single space inserted after it. Pressing tab brings that rightmost paren back onto the first line, and my line is now (defn sqr[x]|) with | being the caret position.


hmm. let me blow away EVERY extension but calva


though i don't think that's the issue, can't hurt to try.


Yes, of course, I forgot about the white space removal. To make the test I wanted to do you need to set the calva-fmt setting about surrounding whitespace to false.


ooh, i am suddenly updating to calva-fmt 0.0.17 in the background 🙂


let's wait for that and i'll try with that setting


About the issue that I could reproduce: I just released a crude fix for it. Calva Formatter 0.0.17. Please upgrade and let me know if that issue at least is handled.


I’ll be offline now for a while. Will look back here as soon as I can.


okay no worries, thanks!


okay your setting had no effect but I think I found the problem


I am running under windowz, so my newline character was set to CRLF


changing it to LF fixes the problem, so I think you're not handling "\r\n" correctly!


the behaviour is much more sane now


I'll open up an issue


Thanks! Awesome find.


np! and now I can actually start to use Calva, so I can help test other issues 🙂


I still can't believe we haven't standardized newlines in 2018...


I foolishly thought we had. 😂


silly. at least apple moved from "\r" to "\n"... at one point there were THREE different standards 😉


This will potentially be tricky for me to fix. I am not by a computer atm, can you test a thing for me? If you type something like a 1 and a 2 on separate, adjacent, lines. Then select both the 1 and the 2. How many characters does vscode say are selected? Or, rather, does it differ if you change the line ending setting?


3 selected for LF, 4 selected for CRLF


afk for about half an hour, but I will attempt to get the plugin to build when I get back and see if I can lend a hand.


If you get the time you will notice six failing tests. I added those to expose the problem with top level indents. But this crlf thing is a different matter of course.


okay, thanks! I will start poking around after lunch.


Just reading through the code atm, nicely written, good job!


Well, I’m beginning to wonder if it is a bit too naïve. The top level cursor positioning seems a bit too tricky to bolt on the current solution, but it might be that I haven’t thought it through enough yet also.


The actual formatting is done using cljfmt, which is a bit expensive and I try to format as small ranges of code as possible to keep it fast enough. That’s why I can’t just format the whole buffer for the top-level situation. I need a way to figure out that the cursor is at the top level and handle that case separately, I think.


The problem with CRLF (which I thought vscode had solved for me) is still marinating in my head, since I don’t have access to the code atm, I can only just think about it. Maybe it is not too hard to account for that lineending in those regular expressions, but I have a feeling some of them might prove tricky. Maybe you will find out. Please just ask if it is something you wonder about in that code, I might be slow to answer, but anyway. 😃


Will do 🙂 today is more hectic than I had planned but I'm slowly going through it.


It is a bit less tidy than you thought at first. 😂


btw is there a reason why keywords don't get highlighted a different colour?


Yes, VS Code’s default highlighting for Clojure does not care about keywords, and extensions can’t amend that. Fortunately the default grammar does recognize keywords and you can customize the highlighting in your settings. Add this to your settings.json and you’ll have keywords in their own color:

"editor.tokenColorCustomizations": {
        "[Default Dark+]": {
          "textMateRules": [
              "scope": [
              "settings": {
                "foreground": "#9cdcfeff"
              "scope": [
              "settings": {
                "foreground": "#999"


oh, nice, thanks!


that's much better.