Skip to content

Instantly share code, notes, and snippets.

@Chubek
Last active March 9, 2024 08:49
Show Gist options
  • Save Chubek/37fa48239ac0de78da45475d9533b123 to your computer and use it in GitHub Desktop.
Save Chubek/37fa48239ac0de78da45475d9533b123 to your computer and use it in GitHub Desktop.
Syntax Highlighters for NeoVim/VIm
" ebnf.vim - Syntax highlighting for EBNF
" Author: Chubak Bidpaa (chubakbidpaa@riseup.net)
if exists("b:current_syntax")
finish
endif
syntax region ebnfComment start=/\v#\s+/ end=/\v$/
syntax region ebnfMultiCharTerminal start=/\v"/ end=/\v"/
syntax region ebnfSingleCharTerminal start=/\v'/ end=/\v'/
syntax match ebnfSubsection /\v\+?[a-zA-Z0-9_-]+(::[a-zA-Z0-9_-]+)+/
syntax match ebnfNonTermIdent /\v[-_a-z0-9]+/
syntax match ebnfLhsIdent /\v^[-_a-z0-9]+/
syntax match ebnfOperator "::="
syntax match ebnfOperator "{"
syntax match ebnfOperator "}"
syntax match ebnfOperator "\["
syntax match ebnfOperator "]"
syntax match ebnfOperator "("
syntax match ebnfOperator ")"
syntax match ebnfOperator "/"
syntax match ebnfOperator "|"
syntax match ebnfOperator "\.\.\."
syntax match ebnfRegexOperator "?"
syntax match ebnfRegexOperator "*"
syntax match ebnfRegexOperator "+"
highlight link ebnfComment Comment
highlight link ebnfMultiCharTerminal String
highlight link ebnfSingleCharTerminal Character
highlight link ebnfNonTermIdent Identifier
highlight link ebnfLhsIdent Underlined
highlight link ebnfOperator Operator
highlight link ebnfRegexOperator Type
highlight link ebnfSubsection Keyword
let b:current_syntax = "ebnf"
" Vim syntax file for Vmgen
" Author: Chubak Bidpaa (chubakbidpaa@riseup.net)
if exists("b:current_syntax")
finish
endif
syntax include @vmgenCCode syntax/c.vim
syntax region vmgenInstructionCode start="\v\w+\s+\([^)]*\-\-[^)]*\)$" end="\n\n" contains=@vmgenCCode,vmgenStackEffect
syntax match vmgenComment /^\v\\ \s*.*$/
syntax match vmgenEEscape "^\v\\E \s*.+$"
syntax match vmgenCEscape "^\v\\C \s*.+$"
syntax match vmgenStackEffect "\v\w+\s+\([^)]*\-\-[^)]*\)$" contained
syntax keyword \E \C
hi link vmgenStackEffect Operator
hi link vmgenComment Comment
hi link vmgenEEScape Statement
hi link vmgenCEscape Statement
let b:current_syntax = "vmgen"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment