atom / language-ruby

Ruby package for Atom
Other
101 stars 145 forks source link

Multiline YARD highlighting for tag–comment styles #228

Closed cbothner closed 3 years ago

cbothner commented 6 years ago

Description

YARD supports multiline comments for tags as long as the following lines are indented but atom-language-ruby does not extend syntax highlighting beyond the line. Namely, I expect the text on the second line to be green.

screen shot 2018-01-23 at 10 23 45

I am interested in implementing this but am looking for some guidance.

I tried naively to extend the yard_name_types pattern to match multiple lines, like this. But as y’all more experienced syntax highlighters already know, you can’t use multiline patterns.

I think the begin and end keys are promising, but while I can figure that maybe the begin pattern would be something like # @(attr|etc.), there’s no natural end key. How do you match “the lack of a comment line with two more spaces of indentation than this one” precisely enough?

Any ideas? Am I totally off base here? Is there a better dev workflow for language grammars than painstakingly restarting Atom after every change?

winstliu commented 6 years ago

How do you match “the lack of a comment line with two more spaces of indentation than this one”

Oh boy, do I have experience with this. I believe you essentially want something like ^(?!\\s*#\\1\\s{2,}) as your end pattern where \\1 refers to the capture group in ^\\s*#(\\s*) which you'll stick at the beginning of your begin pattern.

Is there a better dev workflow for language grammars than painstakingly restarting Atom after every change?

I've found that restarting Atom using the window:reload command is fairly quick.