I've noticed that when discussing Nim on other forums, it always turns out that some people seem to be unable to keep their code indented without special markers, so every time they use an indent-based language, their code doesn't work properly. I've created something just for them. Please forgive me for my sins.
https://github.com/xigoi/nimdenter/
With this tool, you can write code with subtle indentation errors like this:
# Main procedure
proc main() = #{
if true: #{
for _ in 0..<8: #{
echo "oh my gosh this is terribly indented";
#}
#}
#}
and as long as the hashbrackets are correct, it will be automatically changed to:
# Main procedure
proc main() = #{
if true: #{
for _ in 0..<8: #{
echo "oh my gosh this is terribly indented";
#}
#}
#}
Isn't this beautiful?
I think making text editor plugin that help seeing indented blocks is better than adding text to code. These hashbrackets would be visual noise for most of pure Nimmers. Such editor plugin would display some lines, shapes or signs to show blocks but doesn't affect content of code. It allows people to configure how code is displayed, and doesn't bother other people who read your code.
Text editor plugin that display Nim code like:
proc main() =
| let
| | abc = 1
| +-xyz = 2
|
| for i in 0 .. 8:
| | echo i + abc + xyz
| | inc abc
| | dec xyz
| |
| | if abc * xyz > 0:
+-+-+-break
proc bar =
+-echo "bar"
or
+-
|proc main() =
| +-
| |let
| | abc = 1
| | xyz = 2
| +-
|
| +-
| |for i in 0 .. 8:
| | echo i + abc + xyz
| | inc abc
| | dec xyz
| |
| | +-
| | |if abc * xyz > 0:
| | | break
| | +-
| +-
+-
+-
|proc bar =
| echo "bar"
+-
or
proc main() =
-→let
~~~>abc = 1
xyz = 2
-→for i in 0 .. 8:
~~~>echo i + abc + xyz
inc abc
dec xyz
if abc * xyz > 0:
=====>break
proc bar =
-→echo "bar"
I think making text editor plugin that help seeing indented blocks is better than adding text to code.
If you use VSCode this might be useful for you? https://marketplace.visualstudio.com/items?itemName=oderwat.indent-rainbow
Of course, different from nimdenter which is more a formatter that corrects indents.