leodevbro / vscode-blockman

VSCode extension to highlight nested code blocks
https://github.com/leodevbro/vscode-blockman
MIT License
345 stars 16 forks source link

Clojure support #98

Open PEZ opened 1 year ago

PEZ commented 1 year ago

Thanks for providing Blockman!

I would love for it to have Clojure support. Clojure is a LISP, so therefore structured, similar to XML, but using only (), [], and {} to mark start and end of forms (a.k.a. S-expressions).

In this screenshot you can see that Blockman does the right thing (afaiu) on {} forms, but doesn't mark up the two other form types:

image

At line 29 I have tried to trick Blockman by putting } inside a string, and also in a line comment, but Blockman handles it. Leading me to think that at least basic Clojure support might be in close reach for it (speculation, but anyway 😄).

If you think you need a ”real” Clojure tokenizer, I have one in Calva to use for inspiration, and if that one is not a good fit, I think I know where to find two other JavaScript implementations. But hopefully a naïve ”if Clojure or other LISP, do whatever is currently done with {} with () and [] too” could work.

Cheers!

PEZ commented 1 year ago

Another option for the tokenization is that we add an API to Calva to get the tokens it has already lexed out. For larger documents it might save performance to not tokenize several times.

leodevbro commented 1 year ago

Hello, thanks for creating this issue. Well, I guess I have good news. Blockman has disabled square bracket ([]) and round bracket (()) block rendering by default, because I think most languages does not need other than only curly bracket block rendering (otherwise it may look too overloaded) as a visual help for most users. So you can enable square and round brackets:

Go to VS Code settings, and search: blockman n23 analyze square brackets make it true then search: blockman n24 analyze round brackets make it true That's it.

I hope it will work. If not, please let me know.

PEZ commented 1 year ago

Awesome! It works great for Clojure. Looks like so now:

image

It doesn't start highlighting blocks in JS and JSON files for me. Which is good, but a bit strange, since I enabled it.

Is there a way you can make it possible to scope Blockman settings by language? Then users could do:

    "[clojure]": {
        "blockman.n23AnalyzeSquareBrackets": true,
        "blockman.n24AnalyzeRoundBrackets": true
    },

That currently is marked as a problem with the message: ”This setting cannot be applied because it is not registered as language override setting.” Indicating that we can registering settings as being overridable by language. And then Blockman could provide configurationDefaults for [clojure], making it work out of the box.

leodevbro commented 1 year ago

Thanks, I'll try that soon.