Hi all,
I'm working on a tool similar to pindent.py for Nim.
The aim is twofold:
Providing a command-line tool to add / remove / visible block delimiters (in the shape of comments) to Nim code to:
1- Help people who feel uncomfortable in the absence of visible bloc delimiters in source code.
2- Make "cut and paste" operations safer by relying on visible bloc delimiters and auto-formatting (the equivalent of CB for C++), as opposed to "cut and paste and shift the block and readjust the lines that have become misaligned in the operation"
I was thinking about allowing for two variations of bloc delimiters:
- Pascal style:
#begin
#end
and
- C style:
#{
#}
Here is an example:
proc C() =
#{
while true:
#{
let tried = chan.tryRecv;
if tried.dataAvailable:
#{
echo "From C:";
echo tried.msg;
if len(tried.msg) < 1:
#{
break
#}
#}
#}
#}
What do you think?
All suggestions welcome!
"cut and paste and shift the block and readjust the lines that have become misaligned in the operation"
That's actually solvable in the editor itself. The trick is to use the cursor's indentation level to determine the block of the insert operation. Unfortunately I know of no editor/plugin that can do it.
Just for comparison, here is an example of delimiters Pascal-style:
proc C() =
while true:
let tried = chan.tryRecv
if tried.dataAvailable:
echo "From C:"
echo tried.msg;
if len(tried.msg) < 1:
break
# end if
# end if
# end while
# end proc
The Python extension in vs code had to do some fixes in this space, this comment is a nice index of relevant PRs: https://github.com/microsoft/vscode-python/issues/6886#issuecomment-520582609
Also had a peek at the extension and I suspect that the language config is likely wrong: https://github.com/saem/vscode-nim/blob/master/src/nimvscode/vscodeExt.nim#L307
It's a pile of regex though. :/
Via side loading or by setting up debug.
I personally use the latter, it's faster. tl;dr open the older with the extension git repo, press F5, use the debug version that just launched.
Detailed steps I take/why:
Since the launch.json and task.json are already in the .settings folder the only thing you should have to do is ensure the correct build task and debug task are set the first time.
I should add this to the readme.