Skip to content

Instantly share code, notes, and snippets.

@Ikke
Created January 24, 2019 09:11
Show Gist options
  • Save Ikke/db0fc8fcd2d60e470348d71d8dad4a36 to your computer and use it in GitHub Desktop.
Save Ikke/db0fc8fcd2d60e470348d71d8dad4a36 to your computer and use it in GitHub Desktop.
Ruby heredoc syntax highlighting
let s:bcs = b:current_syntax
unlet b:current_syntax
syntax include @SQL syntax/sql.vim
unlet b:current_syntax
syntax include @SHELL syntax/sh.vim
unlet b:current_syntax
syntax include @CONF syntax/conf.vim
unlet b:current_syntax
syntax include @PHP syntax/php.vim
let b:current_syntax = s:bcs
syntax region hereDocText matchgroup=Statement start=+<<[-~.]*\z([A-Z]\+\)+ end=+^\s*\z1+ contains=NONE
syntax region hereDocDashSQL matchgroup=Statement start=+<<[-~.]*\z(SQL\)+ end=+^\s*\z1+ contains=@SQL
syntax region hereDocDashSHELL matchgroup=Statement start=+<<[-~.]*\z(SHELL\)+ end=+^\s*\z1+ contains=@SHELL
syntax region hereDocDashCONF matchgroup=Statement start=+<<[-~.]*\z(CONF\)+ end=+^\s*\z1+ contains=@CONF
syntax region hereDocDashPHP matchgroup=Statement start=+<<[-~.]*\z(PHP\)+ end=+^\s*\z1+ contains=@PHP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment