Created
September 4, 2011 13:56
-
-
Save ehamberg/1192882 to your computer and use it in GitHub Desktop.
Vim: Syntax highlighting for in-line code in gitit markdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " from http://vim.wikia.com/wiki/VimTip857 | |
| function! TextEnableCodeSnip(filetype, start, end, textSnipHl) | |
| let ft=toupper(a:filetype) | |
| let group='textGroup'.ft | |
| if exists('b:current_syntax') | |
| let s:current_syntax=b:current_syntax | |
| " Remove current syntax definition, as some syntax files (e.g. cpp.vim) | |
| " do nothing if b:current_syntax is defined. | |
| unlet b:current_syntax | |
| endif | |
| execute 'syntax include @'.group.' syntax/'.a:filetype.'.vim' | |
| try | |
| execute 'syntax include @'.group.' after/syntax/'.a:filetype.'.vim' | |
| catch | |
| endtry | |
| if exists('s:current_syntax') | |
| let b:current_syntax=s:current_syntax | |
| else | |
| unlet b:current_syntax | |
| endif | |
| execute 'syntax region textSnip'.ft.' | |
| \ matchgroup='.a:textSnipHl.' | |
| \ start="'.a:start.'" end="'.a:end.'" | |
| \ contains=@'.group | |
| endfunction | |
| for l in ["cpp", "haskell", "python", "scala", "dot", "xml"] | |
| call TextEnableCodeSnip(l, '^\s*\~\{3,}{\s*\.'.l.'\s*}\s*$', '^\s*\~\{3,}\s*$', 'specialComment') | |
| endfor | |
| " hightlight latex maths | |
| call TextEnableCodeSnip("plaintex", '\$\+', '\$\+', 'specialComment') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment