Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for PEG syntax #615

Merged
merged 3 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A collection of language packs for Vim.
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.

- It **won't affect your startup time**, as scripts are loaded only on demand\*.
- It **installs and updates 120+ times faster** than the <!--Package Count-->597<!--/Package Count--> packages it consists of.
- It **installs and updates 120+ times faster** than the <!--Package Count-->598<!--/Package Count--> packages it consists of.
- It is also more secure (scripts loaded for every filetype are generated by vim-polyglot)
- Best syntax and indentation support (no other features). Hand-selected language packs.
- Automatically detects indentation (includes performance-optimized version of [vim-sleuth](https://github.com/tpope/vim-sleuth), can be disabled)
Expand Down Expand Up @@ -138,6 +138,7 @@ On top of all language packs from [vim repository](https://github.com/vim/vim/tr
- [odin](https://github.com/Tetralux/odin.vim) (Odin syntax highlighting for odin files)
- [opencl](https://github.com/petRUShka/vim-opencl) (OpenCL syntax highlighting for cl and opencl files)
- [perl](https://github.com/vim-perl/vim-perl) (Perl syntax highlighting for pl, al, cgi, fcgi, perl and 12 more files)
- [pest](https://github.com/pest-parser/pest.vim) (PEG syntax for Rust Pest crate)
- [pgsql](https://github.com/lifepillar/pgsql.vim) (PLpgSQL syntax highlighting for pgsql files)
- [php](https://github.com/StanAngeloff/php.vim) (PHP syntax highlighting for php, aw, ctp, fcgi, inc and 7 more files)
- [plantuml](https://github.com/aklt/plantuml-syntax) (PlantUML syntax highlighting for puml, iuml, plantuml, uml and pu files)
Expand Down
4 changes: 4 additions & 0 deletions ftdetect/polyglot.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1998,6 +1998,10 @@ if !has_key(g:polyglot_is_disabled, 'requirements')
au BufNewFile,BufRead *.pip,*require.{txt,in},*requirements.{txt,in},constraints.{txt,in} setf requirements
endif

if !has_key(g:polyglot_is_disabled, 'pest')
au BufNewFile,BufRead *.pest setf pest
endif

if !has_key(g:polyglot_is_disabled, 'python')
au BufNewFile,BufRead *.cgi,*.fcgi,*.gyp,*.gypi,*.lmi,*.ptl,*.py,*.py3,*.pyde,*.pyi,*.pyp,*.pyt,*.pyw,*.rpy,*.smk,*.spec,*.tac,*.wsgi,*.xpy,{.,}gclient,{.,}pythonrc,{.,}pythonstartup,DEPS,SConscript,SConstruct,Snakefile,wscript setf python
endif
Expand Down
7 changes: 7 additions & 0 deletions packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,13 @@ filetypes:
- name: blade
linguist: Blade
---
name: pest
remote: pest-parser/pest.vim
filetypes:
- name: pest
extensions:
- pest
---
name: plantuml
remote: aklt/plantuml-syntax
filetypes:
Expand Down
131 changes: 131 additions & 0 deletions syntax/pest.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
" Comments
syntax keyword pestTodo contained TODO FIXME XXX NOTE
syntax match pestComment "\/\/.*$" contains=celTodo

" Rule names
syntax match pestName "^[a-z_][a-z0-9_]*"

" String types
syntax region pestString start=/"/ skip=/\\\\\|\\"/ end=/"/ oneline contained
syntax region pestStringIcase start=/\^"/ skip=/\\\\\|\\"/ end=/"/ oneline contained
syntax region pestChar start=/'/ end=/'/ oneline contained

" Operators, modifiers, keywords
syntax match pestModifier "\v[_@$!]"
syntax match pestOperator "\v[~|*+?&!]" contained
syntax keyword pestKeyword PUSH POP POP_ALL PEEK PEEK_ALL DROP contained
syntax keyword pestSpecial WHITESPACE COMMENT ANY SOI EOI ASCII_DIGIT ASCII_NONZERO_DIGIT ASCII_BIN_DIGIT ASCII_OCT_DIGIT ASCII_HEX_DIGIT
\ ASCII_ALPHA_LOWER ASCII_ALPHA_UPPER ASCII_ALPHA ASCII_ALPHANUMERIC ASCII NEWLINE
syntax keyword pestGeneral contained
\ LETTER
\ CASED_LETTER
\ UPPERCASE_LETTER
\ LOWERCASE_LETTER
\ TITLECASE_LETTER
\ MODIFIER_LETTER
\ OTHER_LETTER
\ MARK
\ NONSPACING_MARK
\ SPACING_MARK
\ ENCLOSING_MARK
\ NUMBER
\ DECIMAL_NUMBER
\ LETTER_NUMBER
\ OTHER_NUMBER
\ PUNCTUATION
\ CONNECTOR_PUNCTUATION
\ DASH_PUNCTUATION
\ OPEN_PUNCTUATION
\ CLOSE_PUNCTUATION
\ INITIAL_PUNCTUATION
\ FINAL_PUNCTUATION
\ OTHER_PUNCTUATION
\ SYMBOL
\ MATH_SYMBOL
\ CURRENCY_SYMBOL
\ MODIFIER_SYMBOL
\ OTHER_SYMBOL
\ SEPARATOR
\ SPACE_SEPARATOR
\ LINE_SEPARATOR
\ PARAGRAPH_SEPARATOR
\ OTHER
\ CONTROL
\ FORMAT
\ SURROGATE
\ PRIVATE_USE
\ UNASSIGNED
syntax keyword pestBinary contained
\ ALPHABETIC
\ BIDI_CONTROL
\ CASE_IGNORABLE
\ CASED
\ CHANGES_WHEN_CASEFOLDED
\ CHANGES_WHEN_CASEMAPPED
\ CHANGES_WHEN_LOWERCASED
\ CHANGES_WHEN_TITLECASED
\ CHANGES_WHEN_UPPERCASED
\ DASH
\ DEFAULT_IGNORABLE_CODE_POINT
\ DEPRECATED
\ DIACRITIC
\ EXTENDER
\ GRAPHEME_BASE
\ GRAPHEME_EXTEND
\ GRAPHEME_LINK
\ HEX_DIGIT
\ HYPHEN
\ IDS_BINARY_OPERATOR
\ IDS_TRINARY_OPERATOR
\ ID_CONTINUE
\ ID_START
\ IDEOGRAPHIC
\ JOIN_CONTROL
\ LOGICAL_ORDER_EXCEPTION
\ LOWERCASE
\ MATH
\ NONCHARACTER_CODE_POINT
\ OTHER_ALPHABETIC
\ OTHER_DEFAULT_IGNORABLE_CODE_POINT
\ OTHER_GRAPHEME_EXTEND
\ OTHER_ID_CONTINUE
\ OTHER_ID_START
\ OTHER_LOWERCASE
\ OTHER_MATH
\ OTHER_UPPERCASE
\ PATTERN_SYNTAX
\ PATTERN_WHITE_SPACE
\ PREPENDED_CONCATENATION_MARK
\ QUOTATION_MARK
\ RADICAL
\ REGIONAL_INDICATOR
\ SENTENCE_TERMINAL
\ SOFT_DOTTED
\ TERMINAL_PUNCTUATION
\ UNIFIED_IDEOGRAPH
\ UPPERCASE
\ VARIATION_SELECTOR
\ WHITE_SPACE
\ XID_CONTINUE
\ XID_START
syntax keyword pestForbidden abstract alignof as become box break const continue crate do else enum extern false
\ final fn for if impl in let loop macro match mod move mut offsetof override priv proc pure pub ref return
\ Self self sizeof static struct super trait true type typeof unsafe unsized use virtual where while yield

" Rule blocks
syntax region pestBlock start=/{/ end=/}/ fold transparent contains=pestString,pestStringIcase,pestChar,pestOperator,pestKeyword,pestSpecial,pestGeneral,pestBinary,pestForbidden,pestComment,pestBlock
syntax region pestRule start=/^/ end=/ / fold transparent contains=pestName,pestForbidden,pestComment

highlight default link pestTodo Todo
highlight default link pestComment Comment
highlight default link pestString String
highlight default link pestStringIcase String
highlight default link pestChar Character
highlight default link pestName Identifier
highlight default link pestModifier Operator
highlight default link pestOperator Operator
highlight default link pestKeyword Keyword
highlight default link pestSpecial Type
highlight default link pestGeneral Type
highlight default link pestBinary Type
highlight default link pestForbidden Error