├── README.md ├── ftdetect └── pegjs.vim └── syntax └── pegjs.vim /README.md: -------------------------------------------------------------------------------- 1 | # pegjs.vim 2 | 3 | Syntax highlighting for PEGjs files in VIM. 4 | 5 | Enough to be useful - feedback/patches welcome. 6 | 7 | 8 | ## Usage 9 | 10 | $ vim myAwesomeGrammar.pegjs 11 | :syntax on 12 | :setf pegjs 13 | 14 | 15 | ## Installation 16 | 17 | The easiest way is to install using [pathogen.vim][pathogen]: 18 | 19 | cd ~/.vim/bundle 20 | git clone https://github.com/alunny/pegjs-vim 21 | 22 | If you do not want to use pathogen. You can always install *pegjs-vim* in the 23 | normal manner by copying each directory to your `~/.vim` directory. Make sure 24 | not to overwrite any existing directory of the same name and instead copy only 25 | the contents of the source directory to the directory of the same name in your 26 | `~/.vim` directory. 27 | 28 | [pathogen]: https://github.com/tpope/vim-pathogen 29 | 30 | 31 | ## Important 32 | 33 | * http://pegjs.majda.cz/ 34 | * http://www.vim.org 35 | 36 | 37 | ## License 38 | 39 | MIT 40 | -------------------------------------------------------------------------------- /ftdetect/pegjs.vim: -------------------------------------------------------------------------------- 1 | " Jade 2 | autocmd BufNewFile,BufReadPost *.pegjs set filetype=pegjs 3 | autocmd BufNewFile,BufReadPost *.language set filetype=pegjs 4 | -------------------------------------------------------------------------------- /syntax/pegjs.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: PEG JS Grammars 3 | " Maintainer: Andrew Lunny 4 | " Latest Revision: 15 June 2012 5 | " License: MIT 6 | 7 | if exists("b:current_syntax") 8 | finish 9 | endif 10 | 11 | syn include @js syntax/javascript.vim 12 | 13 | syn match pegOperator "[/.+*?&!]" 14 | syn region charSet start="\[" end="\]" 15 | syn match rule "[a-zA-Z$_][a-zA-Z$_0-9]*" 16 | syn match ruleDef "[_a-zA-Z$][a-zA-Z$_0-9]*" contained 17 | syn match equals "=" contained 18 | syn match initialize "[a-zA-Z$_][a-zA-Z$_0-9]*[\n\t ]*\".*\"[\n\t ]*=" contains=ruleDef,equals,innerLiteral 19 | syn match initialize "[a-zA-Z$_][a-zA-Z$_0-9]*[\n\t ]*'.*'[\n\t ]*=" contains=ruleDef,equals,innerLiteral 20 | syn match initialize "[a-zA-Z$_][a-zA-Z$_0-9]*[\n\t ]*=" contains=ruleDef,equals 21 | syn match exprLabel "[a-zA-Z$_][a-zA-Z$_0-9]*:"he=e-1 22 | syn region literal start="'" end="'" skip="\(\\\)\@