2010-05-12 02:00:00 +02:00
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
2010-01-20 01:00:00 +01:00
" Vimwiki syntax file
2015-02-23 12:10:42 +01:00
" Home: https://github.com/vimwiki/vimwiki/
2010-01-20 01:00:00 +01:00
" Quit if syntax file is already loaded
if version < 600
syntax clear
elseif exists ( "b:current_syntax" )
finish
endif
2013-07-18 07:55:24 +02:00
2016-12-22 19:55:20 +01:00
if vimwiki #vars #get_wikilocal ( 'maxhi' )
2015-03-17 10:33:43 +01:00
let b :existing_wikifiles =
\ vimwiki #base #get_wikilinks ( g :vimwiki_current_idx , 1 )
2014-12-04 21:18:58 +01:00
let b :existing_wikidirs =
\ vimwiki #base #get_wiki_directories ( g :vimwiki_current_idx )
2012-06-07 02:00:00 +02:00
endif
2016-12-22 19:55:20 +01:00
2012-06-07 02:00:00 +02:00
2014-02-25 15:05:28 +01:00
call vimwiki #u #reload_regexes ( )
2012-06-07 02:00:00 +02:00
" LINKS: setup of larger regexes {{{
" LINKS: setup wikilink regexps {{{
2014-06-22 16:26:40 +02:00
let s :wikilink_prefix = '[['
let s :wikilink_suffix = ']]'
let s :wikilink_separator = '|'
let s :rx_wikilink_prefix = vimwiki #u #escape ( s :wikilink_prefix )
let s :rx_wikilink_suffix = vimwiki #u #escape ( s :wikilink_suffix )
let s :rx_wikilink_separator = vimwiki #u #escape ( s :wikilink_separator )
" templates for the creation of wiki links
2012-06-07 02:00:00 +02:00
" [[URL]]
2014-06-22 16:26:40 +02:00
let g :vimwiki_WikiLinkTemplate1 = s :wikilink_prefix . '__LinkUrl__' .
\ s :wikilink_suffix
2012-06-07 02:00:00 +02:00
" [[URL|DESCRIPTION]]
2014-06-22 16:26:40 +02:00
let g :vimwiki_WikiLinkTemplate2 = s :wikilink_prefix . '__LinkUrl__' .
\ s :wikilink_separator . '__LinkDescription__' . s :wikilink_suffix
2012-06-07 02:00:00 +02:00
2014-06-22 16:26:40 +02:00
" template for matching all wiki links with a given target file
2014-06-19 15:36:11 +02:00
let g :vimwiki_WikiLinkMatchUrlTemplate =
2014-06-22 16:26:40 +02:00
\ s :rx_wikilink_prefix .
2014-06-19 15:36:11 +02:00
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
2014-06-22 16:26:40 +02:00
\ s :rx_wikilink_suffix .
2014-06-19 15:36:11 +02:00
\ '\|' .
2014-06-22 16:26:40 +02:00
\ s :rx_wikilink_prefix .
2014-06-19 15:36:11 +02:00
\ '\zs__LinkUrl__\ze\%(#.*\)\?' .
2014-06-22 16:26:40 +02:00
\ s :rx_wikilink_separator .
2014-06-19 15:36:11 +02:00
\ '.*' .
2014-06-22 16:26:40 +02:00
\ s :rx_wikilink_suffix
2014-06-19 15:36:11 +02:00
let s :valid_chars = '[^\\\]]'
2014-02-24 12:16:23 +01:00
let g :vimwiki_rxWikiLinkUrl = s :valid_chars .'\{-}'
let g :vimwiki_rxWikiLinkDescr = s :valid_chars .'\{-}'
2012-06-07 02:00:00 +02:00
2015-01-14 13:34:33 +01:00
" this regexp defines what can form a link when the user presses <CR> in the
" buffer (and not on a link) to create a link
" basically, it's Ascii alphanumeric characters plus #|./@-_~ plus all
" non-Ascii characters
let g :vimwiki_rxWord = '[^[:blank:]!"$%&''()*+,:;<=>?\[\]\\^`{}]\+'
2012-06-07 02:00:00 +02:00
2014-06-22 16:26:40 +02:00
2012-06-07 02:00:00 +02:00
" [[URL]], or [[URL|DESCRIPTION]]
" a) match [[URL|DESCRIPTION]]
2014-06-22 16:26:40 +02:00
let g :vimwiki_rxWikiLink = s :rx_wikilink_prefix .
\ g :vimwiki_rxWikiLinkUrl .'\%(' .s :rx_wikilink_separator .
\ g :vimwiki_rxWikiLinkDescr .'\)\?' .s :rx_wikilink_suffix
2012-06-07 02:00:00 +02:00
" b) match URL within [[URL|DESCRIPTION]]
2014-06-22 16:26:40 +02:00
let g :vimwiki_rxWikiLinkMatchUrl = s :rx_wikilink_prefix .
\ '\zs' . g :vimwiki_rxWikiLinkUrl .'\ze\%(' . s :rx_wikilink_separator .
\ g :vimwiki_rxWikiLinkDescr .'\)\?' .s :rx_wikilink_suffix
2012-06-07 02:00:00 +02:00
" c) match DESCRIPTION within [[URL|DESCRIPTION]]
2014-06-22 16:26:40 +02:00
let g :vimwiki_rxWikiLinkMatchDescr = s :rx_wikilink_prefix .
\ g :vimwiki_rxWikiLinkUrl .s :rx_wikilink_separator .'\%(' .
\ '\zs' . g :vimwiki_rxWikiLinkDescr . '\ze\)\?' . s :rx_wikilink_suffix
2012-06-07 02:00:00 +02:00
" }}}
" LINKS: Syntax helper {{{
2014-06-22 16:26:40 +02:00
let s :rx_wikilink_prefix1 = s :rx_wikilink_prefix . g :vimwiki_rxWikiLinkUrl .
\ s :rx_wikilink_separator
let s :rx_wikilink_suffix1 = s :rx_wikilink_suffix
2012-06-07 02:00:00 +02:00
" }}}
" LINKS: setup of wikiincl regexps {{{
let g :vimwiki_rxWikiInclPrefix = '{{'
let g :vimwiki_rxWikiInclSuffix = '}}'
let g :vimwiki_rxWikiInclSeparator = '|'
"
" '{{__LinkUrl__}}'
2013-04-19 05:46:58 +02:00
let g :vimwiki_WikiInclTemplate1 = g :vimwiki_rxWikiInclPrefix . '__LinkUrl__' .
2012-06-07 02:00:00 +02:00
\ g :vimwiki_rxWikiInclSuffix
" '{{__LinkUrl____LinkDescription__}}'
2013-04-19 05:46:58 +02:00
let g :vimwiki_WikiInclTemplate2 = g :vimwiki_rxWikiInclPrefix . '__LinkUrl__' .
2012-06-07 02:00:00 +02:00
\ '__LinkDescription__' .
\ g :vimwiki_rxWikiInclSuffix
2013-04-19 05:46:58 +02:00
2014-06-19 15:36:11 +02:00
let s :valid_chars = '[^\\\}]'
2014-02-24 12:16:23 +01:00
let g :vimwiki_rxWikiInclUrl = s :valid_chars .'\{-}'
let g :vimwiki_rxWikiInclArg = s :valid_chars .'\{-}'
2012-06-07 02:00:00 +02:00
let g :vimwiki_rxWikiInclArgs = '\%(' . g :vimwiki_rxWikiInclSeparator . g :vimwiki_rxWikiInclArg . '\)' .'\{-}'
"
"
" *. {{URL}[{...}]} - i.e. {{URL}}, {{URL|ARG1}}, {{URL|ARG1|ARG2}}, etc.
" *a) match {{URL}[{...}]}
let g :vimwiki_rxWikiIncl = g :vimwiki_rxWikiInclPrefix .
2013-04-19 05:46:58 +02:00
\ g :vimwiki_rxWikiInclUrl .
2012-06-07 02:00:00 +02:00
\ g :vimwiki_rxWikiInclArgs . g :vimwiki_rxWikiInclSuffix
" *b) match URL within {{URL}[{...}]}
let g :vimwiki_rxWikiInclMatchUrl = g :vimwiki_rxWikiInclPrefix .
\ '\zs' . g :vimwiki_rxWikiInclUrl . '\ze' .
\ g :vimwiki_rxWikiInclArgs . g :vimwiki_rxWikiInclSuffix
" }}}
" LINKS: Syntax helper {{{
let g :vimwiki_rxWikiInclPrefix1 = g :vimwiki_rxWikiInclPrefix .
\ g :vimwiki_rxWikiInclUrl .g :vimwiki_rxWikiInclSeparator
let g :vimwiki_rxWikiInclSuffix1 = g :vimwiki_rxWikiInclArgs .
\ g :vimwiki_rxWikiInclSuffix
" }}}
" LINKS: Setup weblink regexps {{{
2013-04-19 05:46:58 +02:00
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
2012-06-07 02:00:00 +02:00
" let g:vimwiki_rxWeblink = '[\["(|]\@<!'. g:vimwiki_rxWeblinkUrl .
" \ '\%([),:;.!?]\=\%([ \t]\|$\)\)\@='
" Maxim:
" Simplify free-standing links: URL starts with non(letter|digit)scheme till
" the whitespace.
" Stuart, could you check it with markdown templated links? [](http://...), as
" the last bracket is the part of URL now?
2016-12-21 22:11:44 +01:00
let g :vimwiki_rxWeblink = '\<' . vimwiki #vars #get_global ( 'rxWeblinkUrl' ) . '\S*'
2012-06-07 02:00:00 +02:00
" 0a) match URL within URL
let g :vimwiki_rxWeblinkMatchUrl = g :vimwiki_rxWeblink
" 0b) match DESCRIPTION within URL
let g :vimwiki_rxWeblinkMatchDescr = ''
" }}}
" LINKS: Setup anylink regexps {{{
2013-04-19 05:46:58 +02:00
let g :vimwiki_rxAnyLink = g :vimwiki_rxWikiLink .'\|' .
2012-06-07 02:00:00 +02:00
\ g :vimwiki_rxWikiIncl .'\|' .g :vimwiki_rxWeblink
" }}}
" }}} end of Links
" LINKS: highlighting is complicated due to "nonexistent" links feature {{{
function ! s :add_target_syntax_ON ( target , type ) " {{{
let prefix0 = 'syntax match ' .a :type .' `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,' .a :type .'Char'
let prefix1 = 'syntax match ' .a :type .'T `'
let suffix1 = '` display contained'
execute prefix0 . a :target . suffix0
execute prefix1 . a :target . suffix1
endfunction "}}}
function ! s :add_target_syntax_OFF ( target ) " {{{
let prefix0 = 'syntax match VimwikiNoExistsLink `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,VimwikiLinkChar'
let prefix1 = 'syntax match VimwikiNoExistsLinkT `'
let suffix1 = '` display contained'
execute prefix0 . a :target . suffix0
execute prefix1 . a :target . suffix1
endfunction "}}}
function ! s :highlight_existing_links ( ) "{{{
" Wikilink
" Conditional highlighting that depends on the existence of a wiki file or
" directory is only available for *schemeless* wiki links
" Links are set up upon BufEnter (see plugin/...)
2014-06-22 17:43:26 +02:00
let safe_links = '\%(' .vimwiki #base #file_pattern ( b :existing_wikifiles ) .
\ '\%(#[^|]*\)\?\|#[^|]*\)'
2012-06-07 02:00:00 +02:00
" Wikilink Dirs set up upon BufEnter (see plugin/...)
let safe_dirs = vimwiki #base #file_pattern ( b :existing_wikidirs )
" match [[URL]]
2014-06-22 16:26:40 +02:00
let target = vimwiki #base #apply_template (
\ vimwiki #u #escape ( g :vimwiki_WikiLinkTemplate1 ) ,
2012-06-07 02:00:00 +02:00
\ safe_links , g :vimwiki_rxWikiLinkDescr , '' )
call s :add_target_syntax_ON ( target , 'VimwikiLink' )
" match [[URL|DESCRIPTION]]
2014-06-22 16:26:40 +02:00
let target = vimwiki #base #apply_template (
\ vimwiki #u #escape ( g :vimwiki_WikiLinkTemplate2 ) ,
2012-06-07 02:00:00 +02:00
\ safe_links , g :vimwiki_rxWikiLinkDescr , '' )
call s :add_target_syntax_ON ( target , 'VimwikiLink' )
" match {{URL}}
2014-06-22 16:26:40 +02:00
let target = vimwiki #base #apply_template (
\ vimwiki #u #escape ( g :vimwiki_WikiInclTemplate1 ) ,
2012-06-07 02:00:00 +02:00
\ safe_links , g :vimwiki_rxWikiInclArgs , '' )
call s :add_target_syntax_ON ( target , 'VimwikiLink' )
" match {{URL|...}}
2014-06-22 16:26:40 +02:00
let target = vimwiki #base #apply_template (
\ vimwiki #u #escape ( g :vimwiki_WikiInclTemplate2 ) ,
2012-06-07 02:00:00 +02:00
\ safe_links , g :vimwiki_rxWikiInclArgs , '' )
call s :add_target_syntax_ON ( target , 'VimwikiLink' )
" match [[DIRURL]]
2014-06-22 16:26:40 +02:00
let target = vimwiki #base #apply_template (
\ vimwiki #u #escape ( g :vimwiki_WikiLinkTemplate1 ) ,
2012-06-07 02:00:00 +02:00
\ safe_dirs , g :vimwiki_rxWikiLinkDescr , '' )
call s :add_target_syntax_ON ( target , 'VimwikiLink' )
" match [[DIRURL|DESCRIPTION]]
2014-06-22 16:26:40 +02:00
let target = vimwiki #base #apply_template (
\ vimwiki #u #escape ( g :vimwiki_WikiLinkTemplate2 ) ,
2012-06-07 02:00:00 +02:00
\ safe_dirs , g :vimwiki_rxWikiLinkDescr , '' )
call s :add_target_syntax_ON ( target , 'VimwikiLink' )
endfunction "}}}
" use max highlighting - could be quite slow if there are too many wikifiles
2016-12-22 19:55:20 +01:00
if vimwiki #vars #get_wikilocal ( 'maxhi' )
2012-06-07 02:00:00 +02:00
" WikiLink
call s :add_target_syntax_OFF ( g :vimwiki_rxWikiLink )
" WikiIncl
call s :add_target_syntax_OFF ( g :vimwiki_rxWikiIncl )
" Subsequently, links verified on vimwiki's path are highlighted as existing
call s :highlight_existing_links ( )
else
" Wikilink
call s :add_target_syntax_ON ( g :vimwiki_rxWikiLink , 'VimwikiLink' )
" WikiIncl
call s :add_target_syntax_ON ( g :vimwiki_rxWikiIncl , 'VimwikiLink' )
endif
2010-01-20 01:00:00 +01:00
2012-06-07 02:00:00 +02:00
" Weblink
call s :add_target_syntax_ON ( g :vimwiki_rxWeblink , 'VimwikiLink' )
" WikiLink
" All remaining schemes are highlighted automatically
2014-02-24 12:16:23 +01:00
let s :rxSchemes = '\%(' .
2016-12-21 22:11:44 +01:00
\ join ( split ( vimwiki #vars #get_global ( 'schemes' ) , '\s*,\s*' ) , '\|' ) .'\|' .
\ join ( split ( vimwiki #vars #get_global ( 'web_schemes1' ) , '\s*,\s*' ) , '\|' ) .
2012-06-07 02:00:00 +02:00
\ '\):'
" a) match [[nonwiki-scheme-URL]]
2014-06-22 16:26:40 +02:00
let s :target = vimwiki #base #apply_template (
\ vimwiki #u #escape ( g :vimwiki_WikiLinkTemplate1 ) ,
2014-02-24 12:16:23 +01:00
\ s :rxSchemes .g :vimwiki_rxWikiLinkUrl , g :vimwiki_rxWikiLinkDescr , '' )
call s :add_target_syntax_ON ( s :target , 'VimwikiLink' )
2012-06-07 02:00:00 +02:00
" b) match [[nonwiki-scheme-URL|DESCRIPTION]]
2014-06-22 16:26:40 +02:00
let s :target = vimwiki #base #apply_template (
\ vimwiki #u #escape ( g :vimwiki_WikiLinkTemplate2 ) ,
2014-02-24 12:16:23 +01:00
\ s :rxSchemes .g :vimwiki_rxWikiLinkUrl , g :vimwiki_rxWikiLinkDescr , '' )
call s :add_target_syntax_ON ( s :target , 'VimwikiLink' )
2012-06-07 02:00:00 +02:00
" a) match {{nonwiki-scheme-URL}}
2014-06-22 16:26:40 +02:00
let s :target = vimwiki #base #apply_template (
\ vimwiki #u #escape ( g :vimwiki_WikiInclTemplate1 ) ,
2014-02-24 12:16:23 +01:00
\ s :rxSchemes .g :vimwiki_rxWikiInclUrl , g :vimwiki_rxWikiInclArgs , '' )
call s :add_target_syntax_ON ( s :target , 'VimwikiLink' )
2012-06-07 02:00:00 +02:00
" b) match {{nonwiki-scheme-URL}[{...}]}
2014-06-22 16:26:40 +02:00
let s :target = vimwiki #base #apply_template (
\ vimwiki #u #escape ( g :vimwiki_WikiInclTemplate2 ) ,
2014-02-24 12:16:23 +01:00
\ s :rxSchemes .g :vimwiki_rxWikiInclUrl , g :vimwiki_rxWikiInclArgs , '' )
call s :add_target_syntax_ON ( s :target , 'VimwikiLink' )
2012-06-07 02:00:00 +02:00
" }}}
" generic headers "{{{
if g :vimwiki_symH
"" symmetric
2014-02-24 12:16:23 +01:00
for s :i in range ( 1 , 6 )
let g :vimwiki_rxH {s :i }_Template = repeat ( g :vimwiki_rxH , s :i ) .' __Header__ ' .repeat ( g :vimwiki_rxH , s :i )
let g :vimwiki_rxH {s :i } = '^\s*' .g :vimwiki_rxH .'\{' .s :i .'}[^' .g :vimwiki_rxH .'].*[^' .g :vimwiki_rxH .']' .g :vimwiki_rxH .'\{' .s :i .'}\s*$'
let g :vimwiki_rxH {s :i }_Start = '^\s*' .g :vimwiki_rxH .'\{' .s :i .'}[^' .g :vimwiki_rxH .'].*[^' .g :vimwiki_rxH .']' .g :vimwiki_rxH .'\{' .s :i .'}\s*$'
let g :vimwiki_rxH {s :i }_End = '^\s*' .g :vimwiki_rxH .'\{1,' .s :i .'}[^' .g :vimwiki_rxH .'].*[^' .g :vimwiki_rxH .']' .g :vimwiki_rxH .'\{1,' .s :i .'}\s*$'
2012-06-07 02:00:00 +02:00
endfor
let g :vimwiki_rxHeader = '^\s*\(' .g :vimwiki_rxH .'\{1,6}\)\zs[^' .g :vimwiki_rxH .'].*[^' .g :vimwiki_rxH .']\ze\1\s*$'
else
" asymmetric
2014-02-24 12:16:23 +01:00
for s :i in range ( 1 , 6 )
let g :vimwiki_rxH {s :i }_Template = repeat ( g :vimwiki_rxH , s :i ) .' __Header__'
let g :vimwiki_rxH {s :i } = '^\s*' .g :vimwiki_rxH .'\{' .s :i .'}[^' .g :vimwiki_rxH .'].*$'
let g :vimwiki_rxH {s :i }_Start = '^\s*' .g :vimwiki_rxH .'\{' .s :i .'}[^' .g :vimwiki_rxH .'].*$'
let g :vimwiki_rxH {s :i }_End = '^\s*' .g :vimwiki_rxH .'\{1,' .s :i .'}[^' .g :vimwiki_rxH .'].*$'
2012-06-07 02:00:00 +02:00
endfor
let g :vimwiki_rxHeader = '^\s*\(' .g :vimwiki_rxH .'\{1,6}\)\zs[^' .g :vimwiki_rxH .'].*\ze$'
endif
2010-08-24 02:00:00 +02:00
2012-06-07 02:00:00 +02:00
" Header levels, 1-6
2014-02-24 12:16:23 +01:00
for s :i in range ( 1 , 6 )
execute 'syntax match VimwikiHeader' .s :i .' /' .g :vimwiki_rxH {s :i }.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,@Spell'
execute 'syntax region VimwikiH' .s :i .'Folding start=/' .g :vimwiki_rxH {s :i }_Start .
\ '/ end=/' .g :vimwiki_rxH {s :i }_End .'/me=s-1 transparent fold'
2012-06-07 02:00:00 +02:00
endfor
2010-08-24 02:00:00 +02:00
2012-06-07 02:00:00 +02:00
2013-04-19 05:46:58 +02:00
" }}}
2011-06-11 02:00:00 +02:00
2016-03-18 15:16:59 +01:00
let g :vimwiki_rxPreStart = '^\s*' .g :vimwiki_rxPreStart
let g :vimwiki_rxPreEnd = '^\s*' .g :vimwiki_rxPreEnd .'\s*$'
let g :vimwiki_rxMathStart = '^\s*' .g :vimwiki_rxMathStart
let g :vimwiki_rxMathEnd = '^\s*' .g :vimwiki_rxMathEnd .'\s*$'
2013-04-19 05:46:58 +02:00
" possibly concealed chars " {{{
2014-02-24 12:16:23 +01:00
let s :conceal = exists ( "+conceallevel" ) ? ' conceal' : ''
execute 'syn match VimwikiEqInChar contained /' .g :vimwiki_char_eqin .'/' .s :conceal
execute 'syn match VimwikiBoldChar contained /' .g :vimwiki_char_bold .'/' .s :conceal
execute 'syn match VimwikiItalicChar contained /' .g :vimwiki_char_italic .'/' .s :conceal
execute 'syn match VimwikiBoldItalicChar contained /' .g :vimwiki_char_bolditalic .'/' .s :conceal
execute 'syn match VimwikiItalicBoldChar contained /' .g :vimwiki_char_italicbold .'/' .s :conceal
execute 'syn match VimwikiCodeChar contained /' .g :vimwiki_char_code .'/' .s :conceal
execute 'syn match VimwikiDelTextChar contained /' .g :vimwiki_char_deltext .'/' .s :conceal
execute 'syn match VimwikiSuperScript contained /' .g :vimwiki_char_superscript .'/' .s :conceal
execute 'syn match VimwikiSubScript contained /' .g :vimwiki_char_subscript .'/' .s :conceal
2013-04-19 05:46:58 +02:00
" }}}
2011-06-11 02:00:00 +02:00
2013-04-19 05:46:58 +02:00
" concealed link parts " {{{
2010-08-24 02:00:00 +02:00
2013-04-19 05:46:58 +02:00
" define the conceal attribute for links only if Vim is new enough to handle it
" and the user has g:vimwiki_url_maxsave > 0
2014-02-24 12:16:23 +01:00
let s :options = ' contained transparent contains=NONE'
2013-04-19 05:46:58 +02:00
"
" A shortener for long URLs: LinkRest (a middle part of the URL) is concealed
" VimwikiLinkRest group is left undefined if link shortening is not desired
2016-12-21 21:28:48 +01:00
if exists ( "+conceallevel" ) && vimwiki #vars #get_global ( 'url_maxsave' ) > 0
2014-02-24 12:16:23 +01:00
let s :options .= s :conceal
2013-04-19 05:46:58 +02:00
execute 'syn match VimwikiLinkRest `\%(///\=[^/ \t]\+/\)\zs\S\+\ze'
2016-12-21 21:28:48 +01:00
\.'\%([/#?]\w\|\S\{' .vimwiki #vars #get_global ( 'url_maxsave' ) .'}\)`' .' cchar=~' .s :options
2013-04-19 05:46:58 +02:00
endif
2012-06-07 02:00:00 +02:00
" VimwikiLinkChar is for syntax markers (and also URL when a description
" is present) and may be concealed
2013-04-19 05:46:58 +02:00
2012-06-07 02:00:00 +02:00
" conceal wikilinks
2014-06-22 16:26:40 +02:00
execute 'syn match VimwikiLinkChar /' .s :rx_wikilink_prefix .'/' .s :options
execute 'syn match VimwikiLinkChar /' .s :rx_wikilink_suffix .'/' .s :options
execute 'syn match VimwikiLinkChar /' .s :rx_wikilink_prefix1 .'/' .s :options
execute 'syn match VimwikiLinkChar /' .s :rx_wikilink_suffix1 .'/' .s :options
2012-06-07 02:00:00 +02:00
" conceal wikiincls
2014-02-24 12:16:23 +01:00
execute 'syn match VimwikiLinkChar /' .g :vimwiki_rxWikiInclPrefix .'/' .s :options
execute 'syn match VimwikiLinkChar /' .g :vimwiki_rxWikiInclSuffix .'/' .s :options
execute 'syn match VimwikiLinkChar /' .g :vimwiki_rxWikiInclPrefix1 .'/' .s :options
execute 'syn match VimwikiLinkChar /' .g :vimwiki_rxWikiInclSuffix1 .'/' .s :options
2012-06-07 02:00:00 +02:00
" }}}
2010-01-20 01:00:00 +01:00
2012-06-07 02:00:00 +02:00
" non concealed chars " {{{
execute 'syn match VimwikiHeaderChar contained /\%(^\s*' .g :vimwiki_rxH .'\+\)\|\%(' .g :vimwiki_rxH .'\+\s*$\)/'
execute 'syn match VimwikiEqInCharT contained /' .g :vimwiki_char_eqin .'/'
2010-08-24 02:00:00 +02:00
execute 'syn match VimwikiBoldCharT contained /' .g :vimwiki_char_bold .'/'
execute 'syn match VimwikiItalicCharT contained /' .g :vimwiki_char_italic .'/'
execute 'syn match VimwikiBoldItalicCharT contained /' .g :vimwiki_char_bolditalic .'/'
execute 'syn match VimwikiItalicBoldCharT contained /' .g :vimwiki_char_italicbold .'/'
execute 'syn match VimwikiCodeCharT contained /' .g :vimwiki_char_code .'/'
execute 'syn match VimwikiDelTextCharT contained /' .g :vimwiki_char_deltext .'/'
execute 'syn match VimwikiSuperScriptT contained /' .g :vimwiki_char_superscript .'/'
execute 'syn match VimwikiSubScriptT contained /' .g :vimwiki_char_subscript .'/'
2010-01-20 01:00:00 +01:00
" Emoticons
2012-06-07 02:00:00 +02:00
"syntax match VimwikiEmoticons /\%((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/
2010-01-20 01:00:00 +01:00
2010-02-23 01:00:00 +01:00
let g :vimwiki_rxTodo = '\C\%(TODO:\|DONE:\|STARTED:\|FIXME:\|FIXED:\|XXX:\)'
2010-01-20 01:00:00 +01:00
execute 'syntax match VimwikiTodo /' . g :vimwiki_rxTodo .'/'
2012-06-07 02:00:00 +02:00
" }}}
2010-01-20 01:00:00 +01:00
2012-06-07 02:00:00 +02:00
" main syntax groups {{{
2010-01-20 01:00:00 +01:00
" Tables
2013-04-19 05:46:58 +02:00
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
2012-06-07 02:00:00 +02:00
\ transparent contains = VimwikiCellSeparator ,
\ VimwikiLinkT ,
\ VimwikiNoExistsLinkT ,
\ VimwikiEmoticons ,
\ VimwikiTodo ,
\ VimwikiBoldT ,
\ VimwikiItalicT ,
\ VimwikiBoldItalicT ,
\ VimwikiItalicBoldT ,
\ VimwikiDelTextT ,
\ VimwikiSuperScriptT ,
\ VimwikiSubScriptT ,
\ VimwikiCodeT ,
\ VimwikiEqInT ,
\ @Spell
2013-04-19 05:46:58 +02:00
syntax match VimwikiCellSeparator
2010-02-23 01:00:00 +01:00
\ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained
2010-01-20 01:00:00 +01:00
2013-07-18 07:55:24 +02:00
" Lists
2013-07-17 15:57:35 +02:00
execute 'syntax match VimwikiList /' .g :vimwiki_rxListItemWithoutCB .'/'
2010-01-20 01:00:00 +01:00
execute 'syntax match VimwikiList /' .g :vimwiki_rxListDefine .'/'
2013-07-17 15:57:35 +02:00
execute 'syntax match VimwikiListTodo /' .g :vimwiki_rxListItem .'/'
2013-07-08 11:37:35 +02:00
2016-12-21 19:43:34 +01:00
if vimwiki #vars #get_global ( 'hl_cb_checked' ) = = 1
2014-01-06 13:49:29 +01:00
execute 'syntax match VimwikiCheckBoxDone /' .g :vimwiki_rxListItemWithoutCB .'\s*\[' .g :vimwiki_listsyms_list [4 ].'\]\s.*$/ ' .
2013-07-08 11:37:35 +02:00
\ 'contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
2016-12-21 19:43:34 +01:00
elseif vimwiki #vars #get_global ( 'hl_cb_checked' ) = = 2
2013-07-08 11:37:35 +02:00
execute 'syntax match VimwikiCheckBoxDone /' .g :vimwiki_rxListItemAndChildren .'/ contains=VimwikiNoExistsLink,VimwikiLink,@Spell'
2012-06-07 02:00:00 +02:00
endif
2013-07-08 11:37:35 +02:00
2012-06-07 02:00:00 +02:00
execute 'syntax match VimwikiEqIn /' .g :vimwiki_rxEqIn .'/ contains=VimwikiEqInChar'
execute 'syntax match VimwikiEqInT /' .g :vimwiki_rxEqIn .'/ contained contains=VimwikiEqInCharT'
2010-01-20 01:00:00 +01:00
2011-06-11 02:00:00 +02:00
execute 'syntax match VimwikiBold /' .g :vimwiki_rxBold .'/ contains=VimwikiBoldChar,@Spell'
execute 'syntax match VimwikiBoldT /' .g :vimwiki_rxBold .'/ contained contains=VimwikiBoldCharT,@Spell'
2010-01-20 01:00:00 +01:00
2011-06-11 02:00:00 +02:00
execute 'syntax match VimwikiItalic /' .g :vimwiki_rxItalic .'/ contains=VimwikiItalicChar,@Spell'
execute 'syntax match VimwikiItalicT /' .g :vimwiki_rxItalic .'/ contained contains=VimwikiItalicCharT,@Spell'
2010-01-20 01:00:00 +01:00
2011-06-11 02:00:00 +02:00
execute 'syntax match VimwikiBoldItalic /' .g :vimwiki_rxBoldItalic .'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
execute 'syntax match VimwikiBoldItalicT /' .g :vimwiki_rxBoldItalic .'/ contained contains=VimwikiBoldItalicChatT,VimwikiItalicBoldCharT,@Spell'
2010-01-20 01:00:00 +01:00
2011-06-11 02:00:00 +02:00
execute 'syntax match VimwikiItalicBold /' .g :vimwiki_rxItalicBold .'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
execute 'syntax match VimwikiItalicBoldT /' .g :vimwiki_rxItalicBold .'/ contained contains=VimwikiBoldItalicCharT,VimsikiItalicBoldCharT,@Spell'
2010-01-20 01:00:00 +01:00
2011-06-11 02:00:00 +02:00
execute 'syntax match VimwikiDelText /' .g :vimwiki_rxDelText .'/ contains=VimwikiDelTextChar,@Spell'
execute 'syntax match VimwikiDelTextT /' .g :vimwiki_rxDelText .'/ contained contains=VimwikiDelTextChar,@Spell'
2010-01-20 01:00:00 +01:00
2011-06-11 02:00:00 +02:00
execute 'syntax match VimwikiSuperScript /' .g :vimwiki_rxSuperScript .'/ contains=VimwikiSuperScriptChar,@Spell'
execute 'syntax match VimwikiSuperScriptT /' .g :vimwiki_rxSuperScript .'/ contained contains=VimwikiSuperScriptCharT,@Spell'
2010-01-20 01:00:00 +01:00
2011-06-11 02:00:00 +02:00
execute 'syntax match VimwikiSubScript /' .g :vimwiki_rxSubScript .'/ contains=VimwikiSubScriptChar,@Spell'
execute 'syntax match VimwikiSubScriptT /' .g :vimwiki_rxSubScript .'/ contained contains=VimwikiSubScriptCharT,@Spell'
2010-01-20 01:00:00 +01:00
2010-08-24 02:00:00 +02:00
execute 'syntax match VimwikiCode /' .g :vimwiki_rxCode .'/ contains=VimwikiCodeChar'
execute 'syntax match VimwikiCodeT /' .g :vimwiki_rxCode .'/ contained contains=VimwikiCodeCharT'
2010-01-20 01:00:00 +01:00
" <hr> horizontal rule
execute 'syntax match VimwikiHR /' .g :vimwiki_rxHR .'/'
2016-03-18 15:16:59 +01:00
execute 'syntax region VimwikiPre start=/' .g :vimwiki_rxPreStart .
\ '/ end=/' .g :vimwiki_rxPreEnd .'/ contains=@Spell'
2010-01-20 01:00:00 +01:00
2016-03-18 15:16:59 +01:00
execute 'syntax region VimwikiMath start=/' .g :vimwiki_rxMathStart .
\ '/ end=/' .g :vimwiki_rxMathEnd .'/ contains=@Spell'
2012-06-07 02:00:00 +02:00
2010-01-20 01:00:00 +01:00
2010-05-12 02:00:00 +02:00
" placeholders
syntax match VimwikiPlaceholder /^\s*%nohtml\s*$/
2010-08-24 02:00:00 +02:00
syntax match VimwikiPlaceholder /^\s*%title\%(\s.*\)\?$/ contains = VimwikiPlaceholderParam
2011-06-11 02:00:00 +02:00
syntax match VimwikiPlaceholder /^\s*%template\%(\s.*\)\?$/ contains = VimwikiPlaceholderParam
2010-08-24 02:00:00 +02:00
syntax match VimwikiPlaceholderParam /\s.*/ contained
2010-05-12 02:00:00 +02:00
" html tags
2016-12-21 21:28:48 +01:00
if vimwiki #vars #get_global ( 'valid_html_tags' ) ! = ''
let s :html_tags = join ( split ( vimwiki #vars #get_global ( 'valid_html_tags' ) , '\s*,\s*' ) , '\|' )
2014-02-24 12:16:23 +01:00
exe 'syntax match VimwikiHTMLtag #\c</\?\%(' .s :html_tags .'\)\%(\s\{-1}\S\{-}\)\{-}\s*/\?>#'
2012-06-07 02:00:00 +02:00
execute 'syntax match VimwikiBold #\c<b>.\{-}</b># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiItalic #\c<i>.\{-}</i># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiUnderline #\c<u>.\{-}</u># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiComment /' .g :vimwiki_rxComment .'/ contains=@Spell'
endif
2015-01-04 23:44:24 +01:00
" tags
execute 'syntax match VimwikiTag /' .g :vimwiki_rxTags .'/'
2012-06-07 02:00:00 +02:00
" }}}
2011-06-11 02:00:00 +02:00
2012-06-07 02:00:00 +02:00
" header groups highlighting "{{{
2010-01-20 01:00:00 +01:00
2016-12-21 19:43:34 +01:00
if vimwiki #vars #get_global ( 'hl_headers' ) = = 0
2012-06-07 02:00:00 +02:00
" Strangely in default colorscheme Title group is not set to bold for cterm...
if ! exists ( "g:colors_name" )
hi Title cterm = bold
2011-06-11 02:00:00 +02:00
endif
2014-02-24 12:16:23 +01:00
for s :i in range ( 1 , 6 )
execute 'hi def link VimwikiHeader' .s :i .' Title'
2012-06-07 02:00:00 +02:00
endfor
else
2013-04-19 05:46:58 +02:00
" default colors when headers of different levels are highlighted differently
2012-06-07 02:00:00 +02:00
" not making it yet another option; needed by ColorScheme autocommand
let g :vimwiki_hcolor_guifg_light = ['#aa5858' , '#507030' , '#1030a0' , '#103040' , '#505050' , '#636363' ]
let g :vimwiki_hcolor_ctermfg_light = ['DarkRed' , 'DarkGreen' , 'DarkBlue' , 'Black' , 'Black' , 'Black' ]
let g :vimwiki_hcolor_guifg_dark = ['#e08090' , '#80e090' , '#6090e0' , '#c0c0f0' , '#e0e0f0' , '#f0f0f0' ]
let g :vimwiki_hcolor_ctermfg_dark = ['Red' , 'Green' , 'Blue' , 'White' , 'White' , 'White' ]
2014-02-24 12:16:23 +01:00
for s :i in range ( 1 , 6 )
execute 'hi def VimwikiHeader' .s :i .' guibg=bg guifg=' .g :vimwiki_hcolor_guifg_ {&bg }[s :i -1 ].' gui=bold ctermfg=' .g :vimwiki_hcolor_ctermfg_ {&bg }[s :i -1 ].' term=bold cterm=bold'
2012-06-07 02:00:00 +02:00
endfor
2010-01-20 01:00:00 +01:00
endif
2012-06-07 02:00:00 +02:00
"}}}
2013-04-19 05:46:58 +02:00
" syntax group highlighting "{{{
2010-01-20 01:00:00 +01:00
2011-06-11 02:00:00 +02:00
hi def link VimwikiMarkers Normal
2010-01-20 01:00:00 +01:00
2012-06-07 02:00:00 +02:00
hi def link VimwikiEqIn Number
hi def link VimwikiEqInT VimwikiEqIn
2010-01-20 01:00:00 +01:00
hi def VimwikiBold term = bold cterm = bold gui = bold
2010-08-24 02:00:00 +02:00
hi def link VimwikiBoldT VimwikiBold
2010-01-20 01:00:00 +01:00
hi def VimwikiItalic term = italic cterm = italic gui = italic
2010-08-24 02:00:00 +02:00
hi def link VimwikiItalicT VimwikiItalic
2010-01-20 01:00:00 +01:00
hi def VimwikiBoldItalic term = bold cterm = bold gui = bold , italic
hi def link VimwikiItalicBold VimwikiBoldItalic
2010-08-24 02:00:00 +02:00
hi def link VimwikiBoldItalicT VimwikiBoldItalic
hi def link VimwikiItalicBoldT VimwikiBoldItalic
hi def VimwikiUnderline gui = underline
2010-01-20 01:00:00 +01:00
hi def link VimwikiCode PreProc
2010-08-24 02:00:00 +02:00
hi def link VimwikiCodeT VimwikiCode
2010-05-12 02:00:00 +02:00
hi def link VimwikiPre PreProc
2010-08-24 02:00:00 +02:00
hi def link VimwikiPreT VimwikiPre
2012-06-07 02:00:00 +02:00
hi def link VimwikiMath Number
hi def link VimwikiMathT VimwikiMath
2011-06-11 02:00:00 +02:00
hi def link VimwikiNoExistsLink SpellBad
hi def link VimwikiNoExistsLinkT VimwikiNoExistsLink
2010-01-20 01:00:00 +01:00
hi def link VimwikiLink Underlined
2011-06-11 02:00:00 +02:00
hi def link VimwikiLinkT VimwikiLink
2010-08-24 02:00:00 +02:00
2011-06-11 02:00:00 +02:00
hi def link VimwikiList Identifier
2012-06-07 02:00:00 +02:00
hi def link VimwikiListTodo VimwikiList
2010-01-20 01:00:00 +01:00
hi def link VimwikiCheckBoxDone Comment
hi def link VimwikiEmoticons Character
2012-06-07 02:00:00 +02:00
hi def link VimwikiHR Identifier
2015-01-04 23:44:24 +01:00
hi def link VimwikiTag Keyword
2010-08-24 02:00:00 +02:00
2010-01-20 01:00:00 +01:00
hi def link VimwikiDelText Constant
2010-08-24 02:00:00 +02:00
hi def link VimwikiDelTextT VimwikiDelText
2010-01-20 01:00:00 +01:00
hi def link VimwikiSuperScript Number
2010-08-24 02:00:00 +02:00
hi def link VimwikiSuperScriptT VimwikiSuperScript
2010-01-20 01:00:00 +01:00
hi def link VimwikiSubScript Number
2010-08-24 02:00:00 +02:00
hi def link VimwikiSubScriptT VimwikiSubScript
2010-01-20 01:00:00 +01:00
hi def link VimwikiTodo Todo
hi def link VimwikiComment Comment
2010-02-23 01:00:00 +01:00
2010-05-12 02:00:00 +02:00
hi def link VimwikiPlaceholder SpecialKey
2010-08-24 02:00:00 +02:00
hi def link VimwikiPlaceholderParam String
2010-05-12 02:00:00 +02:00
hi def link VimwikiHTMLtag SpecialKey
2010-08-24 02:00:00 +02:00
2012-06-07 02:00:00 +02:00
hi def link VimwikiEqInChar VimwikiMarkers
2011-06-11 02:00:00 +02:00
hi def link VimwikiCellSeparator VimwikiMarkers
hi def link VimwikiBoldChar VimwikiMarkers
hi def link VimwikiItalicChar VimwikiMarkers
hi def link VimwikiBoldItalicChar VimwikiMarkers
hi def link VimwikiItalicBoldChar VimwikiMarkers
hi def link VimwikiDelTextChar VimwikiMarkers
hi def link VimwikiSuperScriptChar VimwikiMarkers
hi def link VimwikiSubScriptChar VimwikiMarkers
hi def link VimwikiCodeChar VimwikiMarkers
hi def link VimwikiHeaderChar VimwikiMarkers
2010-08-24 02:00:00 +02:00
2012-06-07 02:00:00 +02:00
hi def link VimwikiEqInCharT VimwikiMarkers
2011-06-11 02:00:00 +02:00
hi def link VimwikiBoldCharT VimwikiMarkers
hi def link VimwikiItalicCharT VimwikiMarkers
hi def link VimwikiBoldItalicCharT VimwikiMarkers
hi def link VimwikiItalicBoldCharT VimwikiMarkers
hi def link VimwikiDelTextCharT VimwikiMarkers
hi def link VimwikiSuperScriptCharT VimwikiMarkers
hi def link VimwikiSubScriptCharT VimwikiMarkers
hi def link VimwikiCodeCharT VimwikiMarkers
hi def link VimwikiHeaderCharT VimwikiMarkers
2010-08-24 02:00:00 +02:00
hi def link VimwikiLinkCharT VimwikiLinkT
2012-06-07 02:00:00 +02:00
hi def link VimwikiNoExistsLinkCharT VimwikiNoExistsLinkT
2010-01-20 01:00:00 +01:00
"}}}
2012-06-07 02:00:00 +02:00
" Load syntax-specific functionality
2013-07-18 07:55:24 +02:00
call vimwiki #u #reload_regexes_custom ( )
2012-06-07 02:00:00 +02:00
2013-04-19 05:46:58 +02:00
" FIXME it now does not make sense to pretend there is a single syntax "vimwiki"
2010-01-20 01:00:00 +01:00
let b :current_syntax = "vimwiki"
" EMBEDDED syntax setup "{{{
2016-12-22 19:12:03 +01:00
let s :nested = vimwiki #vars #get_wikilocal ( 'nested_syntaxes' )
if vimwiki #vars #get_wikilocal ( 'automatic_nested_syntaxes' )
2016-05-17 20:29:59 +02:00
let s :nested = extend ( s :nested , vimwiki #base #detect_nested_syntax ( ) , "keep" )
2016-01-27 16:30:30 +01:00
endif
2014-02-24 12:16:23 +01:00
if ! empty ( s :nested )
for [s :hl_syntax , s :vim_syntax ] in items ( s :nested )
call vimwiki #base #nested_syntax ( s :vim_syntax ,
2016-03-18 15:16:59 +01:00
\ g :vimwiki_rxPreStart .'\%(.*[[:blank:][:punct:]]\)\?' .
2014-02-24 12:16:23 +01:00
\ s :hl_syntax .'\%([[:blank:][:punct:]].*\)\?' ,
2016-03-18 15:16:59 +01:00
\ g :vimwiki_rxPreEnd , 'VimwikiPre' )
2010-01-20 01:00:00 +01:00
endfor
endif
2012-07-07 02:00:00 +02:00
" LaTeX
2013-04-19 05:46:58 +02:00
call vimwiki #base #nested_syntax ( 'tex' ,
2016-03-18 15:16:59 +01:00
\ g :vimwiki_rxMathStart .'\%(.*[[:blank:][:punct:]]\)\?' .
2012-07-07 02:00:00 +02:00
\ '\%([[:blank:][:punct:]].*\)\?' ,
2016-03-18 15:16:59 +01:00
\ g :vimwiki_rxMathEnd , 'VimwikiMath' )
2010-01-20 01:00:00 +01:00
"}}}
2012-06-07 02:00:00 +02:00
2013-04-19 05:46:58 +02:00
syntax spell toplevel