Fork me on GitHub
#calva
<
2018-11-10
>
mseddon02:11:11

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

pez08:11:42

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.

pez08:11:46

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

mseddon12:11:32

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.

mseddon12:11:48

hmm. let me blow away EVERY extension but calva

mseddon12:11:00

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

pez12:11:45

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.

mseddon12:11:38

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

mseddon12:11:51

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

pez12:11:57

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.

pez12:11:31

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

mseddon12:11:42

okay no worries, thanks!

mseddon12:11:33

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

mseddon12:11:47

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

mseddon12:11:06

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

mseddon12:11:43

the behaviour is much more sane now

mseddon12:11:37

I'll open up an issue

pez12:11:09

Thanks! Awesome find.

mseddon12:11:38

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

mseddon12:11:09

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

pez12:11:27

I foolishly thought we had. 😂

mseddon12:11:45

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

pez12:11:44

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?

mseddon12:11:30

3 selected for LF, 4 selected for CRLF

mseddon12:11:39

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.

pez13:11:03

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.

mseddon14:11:31

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

mseddon15:11:07

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

pez15:11:48

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.

pez15:11:19

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.

pez15:11:10

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

mseddon17:11:32

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

pez17:11:40

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

mseddon17:11:05

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

pez17:11:09

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": [
                "constant.keyword.clojure"
              ],
              "settings": {
                "foreground": "#9cdcfeff"
              }
            },
            {
              "scope": [
                "punctuation.section.expression.begin.clojure",
                "punctuation.section.expression.end.trailing.clojure"
              ],
              "settings": {
                "foreground": "#999"
              }
            }
          ]
        }
    },

mseddon17:11:38

oh, nice, thanks!

mseddon17:11:51

that's much better.