PEG.js syntax highlighting for vim

67 views
Skip to first unread message

Andrew Lunny

unread,
Jun 16, 2012, 1:44:16 AM6/16/12
to pe...@googlegroups.com
Hello all,

I'm a big fan of PEG.js - I used it to generate a parser for XCode project files[1] and it was a lot of fun.

I've written a small vim-script for syntax highlighting PEG.js files that you can find here:

It's missing syntax highlighting for the inline JS code, but I've found it pretty useful as is. Hopefully it's useful for others too.

Cheers,
Andrew

David Majda

unread,
Jun 16, 2012, 7:48:02 AM6/16/12
to alu...@gmail.com, pe...@googlegroups.com
2012/6/16 Andrew Lunny <alu...@gmail.com>:
> I've written a small vim-script for syntax highlighting PEG.js files that
> you can find here:
> https://github.com/alunny/pegjs-vim
>
> It's missing syntax highlighting for the inline JS code, but I've found it
> pretty useful as is. Hopefully it's useful for others too.

Nice work, I just added it into my vim config :-) I also retweeted
your tweet [1] so that more PEG.js users get to know about this.

BTW it would be cool if the highlighter could be automatically
generated from PEG.js's grammar itself, but I don't know whether this
is feasible (I know only little about vim's syntax highlighting
capabilities). Even if it is, it's certainly a project of much bigger
magnitude...

[1] https://twitter.com/alunny/statuses/213870117933694976

--
David Majda
Entropy fighter
http://majda.cz/

Andrew Lunny

unread,
Jun 16, 2012, 12:08:53 PM6/16/12
to da...@majda.cz, pe...@googlegroups.com
On 16 June 2012 04:48, David Majda <da...@majda.cz> wrote:
2012/6/16 Andrew Lunny <alu...@gmail.com>:
> I've written a small vim-script for syntax highlighting PEG.js files that
> you can find here:
> https://github.com/alunny/pegjs-vim
>
> It's missing syntax highlighting for the inline JS code, but I've found it
> pretty useful as is. Hopefully it's useful for others too.

Nice work, I just added it into my vim config :-) I also retweeted
your tweet [1] so that more PEG.js users get to know about this.

BTW it would be cool if the highlighter could be automatically
generated from PEG.js's grammar itself, but I don't know whether this
is feasible (I know only little about vim's syntax highlighting
capabilities). Even if it is, it's certainly a project of much bigger
magnitude...

I'm new to Vim syntax highlighting too (one of the main reasons I attempted this script) - I'm still trying to wrap my head around defining vim syntax rules in terms of other rules, something that's trivial in a fully-featured language.

My main impression tbh is that now I've got something working, I never want to touch VimL again :)

Cheers,
Andrew

Reply all
Reply to author
Forward
0 new messages