raku-mode
raku-mode copied to clipboard
heredoc indentation/highlighting
If I write the following (from Moritz Lentz's book)
my $sth = self!db.prepare(qq:to/SELECT/);
SELECT exitcode, timed_out, output
FROM $table
WHERE jobname = ?
ORDER BY executed DESC
LIMIT $count
SELECT
perl6-mode does not recognize the here-doc and seams to indent and highlight its contents as perl6 code.
see issue #4, basically same problem: improper indentation (and I wish I knew how to fix it!)
This is really an irritating bug. I use heredocs a LOT and often find myself giving up and using vim to fix them!
Reopened after accidentally closing the issue.
I'm getting blurry vision. Sorry.
A bit golfed down which works for me but with an error
Potential difficulties:
Asked to remove 32 spaces, but the shortest indent is 0 spaces
at /home/marcel/Languages/Raku/Projects/question-answer/x.raku:12
------> SELECT⏏<EOL>
use v6;
my Str $table = 'my-table';
my Int $count = 10;
my Str $x = qq:to/SELECT/;
SELECT exitcode, timed_out, output
FROM $table
WHERE jobname = ?
ORDER BY executed DESC
LIMIT $count
SELECT
note $x;
If there is a blank line before the SELECT (I can't see clearly), try removing it.
There is no blank line before any of the two SELECTs. The error is thrown because the last SELECT is 32 characters indented while the leftmost word is at char column 0. To get it right, the last SELECT should also be at col 0.
Any progress on this?
The issue seems to be that heredoc/qq quotes are effectively unsupported with any unmatched quotation or bracket (escaped or not) inside getting interpreted by raku-mode as raku code and not part of the quoted string.
I'm working on a raku script that autogenerates C code, and I've had to disable raku-mode entirely instead of fighting the auto-correction and incorrect highlighting. ie the following will throw off both the indentation and paren-matching:
my Str $rtv = qq:to/END/;
\} else \{
// do something
\}
END