pedro-w / vscode-tmlanguage

Syntax highlighting for TextMate/SublimeText language definitions
MIT License
18 stars 4 forks source link

Begin/while and whileCaptures support #14

Closed FALLAI-Denis closed 1 year ago

FALLAI-Denis commented 1 year ago

Hi,

Thank you for the excellent work done.

I suggest adding support for begin/while grouping and whileCaptures directive.

Although these syntaxes are undocumented, they are supported by VS Code and widely implemented in the markdown document validation grammar, (as well as the use of the \G regular expression marker which seems related and whose operation remains obscure to me).

See Writing a TextMate Grammar: Some Lessons Learned

Thank you.

pedro-w commented 1 year ago

Thanks @FALLAI-Denis I will try and look at this but at the moment I am a bit short on time (and also I don't use textmate grammars myself any more so motivation is low!)

pedro-w commented 1 year ago

Just on this - what kind of support do you think would be needed here? Can we put together some ideas for this

FALLAI-Denis commented 1 year ago

Hi @pedro-w

I think it's enough to add the syntax highlighting for the "while" and "whileCaptures" keywords in ./syntaxes/json-tmlanguage.tmLanguage and in ./syntaxes/yaml-tmlanguage.tmLanguage.

Thanks.

pedro-w commented 1 year ago

I can see where in json-tmLanguage it recognises the various keywords so I have added 'while' into the same place as 'begin' and 'end', and 'whileCaptures' in the same place as 'captures', 'beginCaptures' and 'endCaptures'

However I can't figure out if, when editing a grammar in YAML format, it does anything special with the keywords or not. So, I have not changed yaml-tmLanguage.

Anyway the changes are on a branch vscode-tmlanguage/issue-14 if you could have a try?

Thanks, Pete

FALLAI-Denis commented 1 year ago

Hi @pedro-w

It seems to me that it is also necessary to modify the yaml grammar otherwise the while and whileCaptures tokens appear invalid: image

As for the json grammar, for some reason there is no coloring at all, only regex are colorized, (even after fetching the new json-tmlanguage.tmLanguage file): image

pedro-w commented 1 year ago

OK, back to the drawing board! I could definitely see highlighting on the file I tried (it was grammar for markdown) and as the changes are minor I'm surprised it's gone wrong so badly.

On the YAML, I just couldn't see which part of the grammar was responsible for picking out those keywords but I will look some more.

What grammar files are you using to test (COBOL I guess?) could you post a link to them?

FALLAI-Denis commented 1 year ago

Hi,

I'm trying to build a grammar for the COBOL language. Attached is the corresponding yaml file, (work in progress).

mycobol.tmLanguage.yaml.txt

pedro-w commented 1 year ago

This should be fixed by version 0.13.0 which I have just uploaded to the marketplace so may be a little while before it becomes available.