Prettify Syntax: Reduce var name && Move from vars.vim to syntax.vim
This commit is contained in:
parent
94a78859d7
commit
40f02293bf
@ -598,84 +598,59 @@ function! vimwiki#vars#populate_syntax_vars(syntax) abort
|
|||||||
let g:vimwiki_syntax_variables[a:syntax] = {}
|
let g:vimwiki_syntax_variables[a:syntax] = {}
|
||||||
let syntax_dic = g:vimwiki_syntax_variables[a:syntax]
|
let syntax_dic = g:vimwiki_syntax_variables[a:syntax]
|
||||||
|
|
||||||
|
" Init Typeface (filled in custom syntax)
|
||||||
|
let syntax_dic.dTypeface = {}
|
||||||
|
|
||||||
" Autoload default syntax file
|
" Autoload default syntax file
|
||||||
execute 'runtime! syntax/vimwiki_'.a:syntax.'.vim'
|
execute 'runtime! syntax/vimwiki_'.a:syntax.'.vim'
|
||||||
|
|
||||||
" text: `code` or ``code`` only inline
|
|
||||||
" Note: `\%(^\|[^`]\)\@<=` means after a new line or a non `
|
|
||||||
let syntax_dic.dTypeface['code'] = [
|
|
||||||
\ ['\%(^\|[^`]\)\@<=`\%($\|[^`]\)\@=',
|
|
||||||
\ '\%(^\|[^`]\)\@<=`\%($\|[^`]\)\@='],
|
|
||||||
\ ['\%(^\|[^`]\)\@<=``\%($\|[^`]\)\@=',
|
|
||||||
\ '\%(^\|[^`]\)\@<=``\%($\|[^`]\)\@='],
|
|
||||||
\ ]
|
|
||||||
|
|
||||||
" text: ~~deleted text~~
|
|
||||||
let syntax_dic.dTypeface['del'] = ([
|
|
||||||
\ ['\~\~', '\~\~']])
|
|
||||||
|
|
||||||
" text: $ equation_inline $
|
|
||||||
" Match only one $
|
|
||||||
" ( ^ or not $) before $ and after: not $
|
|
||||||
let syntax_dic.dTypeface['eq'] = ([
|
|
||||||
\ ['\%(^\|[^$]\)\@<=\$\%($\|[^$]\)\@=',
|
|
||||||
\ '\%(^\|[^$]\)\@<=\$\%($\|[^$]\)\@=']])
|
|
||||||
|
|
||||||
" text: ^superscript^
|
|
||||||
let syntax_dic.dTypeface['sup'] = ([
|
|
||||||
\ ['\^', '\^']])
|
|
||||||
|
|
||||||
" text: ,,subscript,,
|
|
||||||
let syntax_dic.dTypeface['sub'] = ([
|
|
||||||
\ [',,', ',,']])
|
|
||||||
|
|
||||||
|
|
||||||
" TODO make that clean (i.e clearify what is local to syntax ot to buffer)
|
" TODO make that clean (i.e clearify what is local to syntax ot to buffer)
|
||||||
" Get from local vars
|
" Get from local vars
|
||||||
let bullet_types = vimwiki#vars#get_wikilocal('bullet_types')
|
let bullet_types = vimwiki#vars#get_wikilocal('bullet_types')
|
||||||
if !empty(bullet_types)
|
if !empty(bullet_types)
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['bullet_types'] = bullet_types
|
let syntax_dic['bullet_types'] = bullet_types
|
||||||
endif
|
endif
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['cycle_bullets'] =
|
let syntax_dic['cycle_bullets'] =
|
||||||
\ vimwiki#vars#get_wikilocal('cycle_bullets')
|
\ vimwiki#vars#get_wikilocal('cycle_bullets')
|
||||||
|
|
||||||
" Populate generic stuff
|
" Populate generic stuff
|
||||||
let header_symbol = g:vimwiki_syntax_variables[a:syntax].rxH
|
let header_symbol = syntax_dic.rxH
|
||||||
if g:vimwiki_syntax_variables[a:syntax].symH
|
if syntax_dic.symH
|
||||||
" symmetric headers
|
" symmetric headers
|
||||||
for i in range(1,6)
|
for i in range(1,6)
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Template'] =
|
let syntax_dic['rxH'.i.'_Template'] =
|
||||||
\ repeat(header_symbol, i).' __Header__ '.repeat(header_symbol, i)
|
\ repeat(header_symbol, i).' __Header__ '.repeat(header_symbol, i)
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i] =
|
let syntax_dic['rxH'.i] =
|
||||||
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'
|
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'
|
||||||
\ .header_symbol.'\{'.i.'}\s*$'
|
\ .header_symbol.'\{'.i.'}\s*$'
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Text'] =
|
let syntax_dic['rxH'.i.'_Text'] =
|
||||||
\ '^\s*'.header_symbol.'\{'.i.'}\zs[^'.header_symbol.'].*[^'.header_symbol.']\ze'
|
\ '^\s*'.header_symbol.'\{'.i.'}\zs[^'.header_symbol.'].*[^'.header_symbol.']\ze'
|
||||||
\ .header_symbol.'\{'.i.'}\s*$'
|
\ .header_symbol.'\{'.i.'}\s*$'
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Start'] =
|
let syntax_dic['rxH'.i.'_Start'] =
|
||||||
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'
|
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'
|
||||||
\ .header_symbol.'\{'.i.'}\s*$'
|
\ .header_symbol.'\{'.i.'}\s*$'
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_End'] =
|
let syntax_dic['rxH'.i.'_End'] =
|
||||||
\ '^\s*'.header_symbol.'\{1,'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'
|
\ '^\s*'.header_symbol.'\{1,'.i.'}[^'.header_symbol.'].*[^'.header_symbol.']'
|
||||||
\ .header_symbol.'\{1,'.i.'}\s*$'
|
\ .header_symbol.'\{1,'.i.'}\s*$'
|
||||||
endfor
|
endfor
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxHeader =
|
let syntax_dic.rxHeader =
|
||||||
\ '^\s*\('.header_symbol.'\{1,6}\)\zs[^'.header_symbol.'].*[^'.header_symbol.']\ze\1\s*$'
|
\ '^\s*\('.header_symbol.'\{1,6}\)\zs[^'.header_symbol.'].*[^'.header_symbol.']\ze\1\s*$'
|
||||||
else
|
else
|
||||||
" asymmetric
|
" asymmetric
|
||||||
for i in range(1,6)
|
for i in range(1,6)
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Template'] =
|
let syntax_dic['rxH'.i.'_Template'] =
|
||||||
\ repeat(header_symbol, i).' __Header__'
|
\ repeat(header_symbol, i).' __Header__'
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i] =
|
let syntax_dic['rxH'.i] =
|
||||||
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*$'
|
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*$'
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Text'] =
|
let syntax_dic['rxH'.i.'_Text'] =
|
||||||
\ '^\s*'.header_symbol.'\{'.i.'}\zs[^'.header_symbol.'].*\ze$'
|
\ '^\s*'.header_symbol.'\{'.i.'}\zs[^'.header_symbol.'].*\ze$'
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_Start'] =
|
let syntax_dic['rxH'.i.'_Start'] =
|
||||||
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*$'
|
\ '^\s*'.header_symbol.'\{'.i.'}[^'.header_symbol.'].*$'
|
||||||
let g:vimwiki_syntax_variables[a:syntax]['rxH'.i.'_End'] =
|
let syntax_dic['rxH'.i.'_End'] =
|
||||||
\ '^\s*'.header_symbol.'\{1,'.i.'}[^'.header_symbol.'].*$'
|
\ '^\s*'.header_symbol.'\{1,'.i.'}[^'.header_symbol.'].*$'
|
||||||
endfor
|
endfor
|
||||||
let g:vimwiki_syntax_variables[a:syntax].rxHeader =
|
let syntax_dic.rxHeader =
|
||||||
\ '^\s*\('.header_symbol.'\{1,6}\)\zs[^'.header_symbol.'].*\ze$'
|
\ '^\s*\('.header_symbol.'\{1,6}\)\zs[^'.header_symbol.'].*\ze$'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -22,6 +22,36 @@ let b:vimwiki_syntax_concealends = has('conceal') ? ' concealends' : ''
|
|||||||
" Include syntax/vimwiki_markdown.vim as "side effect"
|
" Include syntax/vimwiki_markdown.vim as "side effect"
|
||||||
call vimwiki#vars#populate_syntax_vars(s:current_syntax)
|
call vimwiki#vars#populate_syntax_vars(s:current_syntax)
|
||||||
|
|
||||||
|
let syntax_dic = g:vimwiki_syntax_variables[s:current_syntax]
|
||||||
|
|
||||||
|
" text: `code` or ``code`` only inline
|
||||||
|
" Note: `\%(^\|[^`]\)\@<=` means after a new line or a non `
|
||||||
|
let syntax_dic.dTypeface.code = [
|
||||||
|
\ ['\%(^\|[^`]\)\@<=`\%($\|[^`]\)\@=',
|
||||||
|
\ '\%(^\|[^`]\)\@<=`\%($\|[^`]\)\@='],
|
||||||
|
\ ['\%(^\|[^`]\)\@<=``\%($\|[^`]\)\@=',
|
||||||
|
\ '\%(^\|[^`]\)\@<=``\%($\|[^`]\)\@='],
|
||||||
|
\ ]
|
||||||
|
|
||||||
|
" text: ~~deleted text~~
|
||||||
|
let syntax_dic.dTypeface.del = ([
|
||||||
|
\ ['\~\~', '\~\~']])
|
||||||
|
|
||||||
|
" text: $ equation_inline $
|
||||||
|
" Match only one $
|
||||||
|
" ( ^ or not $) before $ and after: not $
|
||||||
|
let syntax_dic.dTypeface.eq = ([
|
||||||
|
\ ['\%(^\|[^$]\)\@<=\$\%($\|[^$]\)\@=',
|
||||||
|
\ '\%(^\|[^$]\)\@<=\$\%($\|[^$]\)\@=']])
|
||||||
|
|
||||||
|
" text: ^superscript^
|
||||||
|
let syntax_dic.dTypeface.sup = ([
|
||||||
|
\ ['\^', '\^']])
|
||||||
|
|
||||||
|
" text: ,,subscript,,
|
||||||
|
let syntax_dic.dTypeface.sub = ([
|
||||||
|
\ [',,', ',,']])
|
||||||
|
|
||||||
|
|
||||||
" LINKS: highlighting is complicated due to "nonexistent" links feature
|
" LINKS: highlighting is complicated due to "nonexistent" links feature
|
||||||
function! s:add_target_syntax_ON(target, type) abort
|
function! s:add_target_syntax_ON(target, type) abort
|
||||||
@ -88,9 +118,6 @@ function! s:highlight_existing_links() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! s:in_typeface(s_typeface_char)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" use max highlighting - could be quite slow if there are too many wikifiles
|
" use max highlighting - could be quite slow if there are too many wikifiles
|
||||||
if vimwiki#vars#get_wikilocal('maxhi')
|
if vimwiki#vars#get_wikilocal('maxhi')
|
||||||
" WikiLink
|
" WikiLink
|
||||||
|
@ -15,24 +15,21 @@ let s:default_syntax = g:vimwiki_syntax_variables['default']
|
|||||||
let b:vimwiki_syntax_conceal = exists('+conceallevel') ? ' conceal' : ''
|
let b:vimwiki_syntax_conceal = exists('+conceallevel') ? ' conceal' : ''
|
||||||
let b:vimwiki_syntax_concealends = has('conceal') ? ' concealends' : ''
|
let b:vimwiki_syntax_concealends = has('conceal') ? ' concealends' : ''
|
||||||
|
|
||||||
" Typeface:
|
|
||||||
let s:default_syntax.dTypeface = {}
|
|
||||||
|
|
||||||
" text: *strong*
|
" text: *strong*
|
||||||
let s:default_syntax.dTypeface['bold'] = [
|
let s:default_syntax.dTypeface.bold = [
|
||||||
\ ['\S\@<=\*\|\*\S\@=', '\S\@<=\*\|\*\S\@='],
|
\ ['\S\@<=\*\|\*\S\@=', '\S\@<=\*\|\*\S\@='],
|
||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
" text: _italic_
|
" text: _italic_
|
||||||
let s:default_syntax.dTypeface['italic'] = [
|
let s:default_syntax.dTypeface.italic = [
|
||||||
\ ['\S\@<=_\|_\S\@=', '\S\@<=_\|_\S\@='],
|
\ ['\S\@<=_\|_\S\@=', '\S\@<=_\|_\S\@='],
|
||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
" text: no underline defined
|
" text: no underline defined
|
||||||
let s:default_syntax.dTypeface['underline'] = []
|
let s:default_syntax.dTypeface.underline = []
|
||||||
|
|
||||||
" text: *_bold italic_* or _*italic bold*_
|
" text: *_bold italic_* or _*italic bold*_
|
||||||
let s:default_syntax.dTypeface['bold_italic'] = [
|
let s:default_syntax.dTypeface.bold_italic = [
|
||||||
\ ['\S\@<=\*_\|\*_\S\@=', '\S\@<=_\*\|_\*\S\@='],
|
\ ['\S\@<=\*_\|\*_\S\@=', '\S\@<=_\*\|_\*\S\@='],
|
||||||
\ ['\S\@<=_\*\|_\*\S\@=', '\S\@<=\*_\|\*_\S\@='],
|
\ ['\S\@<=_\*\|_\*\S\@=', '\S\@<=\*_\|\*_\S\@='],
|
||||||
\ ]
|
\ ]
|
||||||
|
@ -14,22 +14,19 @@ let b:vimwiki_syntax_conceal = exists('+conceallevel') ? ' conceal' : ''
|
|||||||
let b:vimwiki_syntax_concealends = has('conceal') ? ' concealends' : ''
|
let b:vimwiki_syntax_concealends = has('conceal') ? ' concealends' : ''
|
||||||
|
|
||||||
|
|
||||||
" Typeface:
|
|
||||||
let s:markdown_syntax.dTypeface = {}
|
|
||||||
|
|
||||||
" text: **bold** or __bold__
|
" text: **bold** or __bold__
|
||||||
let s:markdown_syntax.dTypeface['bold'] = vimwiki#u#hi_expand_regex([
|
let s:markdown_syntax.dTypeface.bold = vimwiki#u#hi_expand_regex([
|
||||||
\ ['__', '__'], ['\*\*', '\*\*']])
|
\ ['__', '__'], ['\*\*', '\*\*']])
|
||||||
|
|
||||||
" text: *italic* or _italic_
|
" text: *italic* or _italic_
|
||||||
let s:markdown_syntax.dTypeface['italic'] = vimwiki#u#hi_expand_regex([
|
let s:markdown_syntax.dTypeface.italic = vimwiki#u#hi_expand_regex([
|
||||||
\ ['\*', '\*'], ['_', '_']])
|
\ ['\*', '\*'], ['_', '_']])
|
||||||
|
|
||||||
" text: no underline defined
|
" text: no underline defined
|
||||||
let s:markdown_syntax.dTypeface['underline'] = []
|
let s:markdown_syntax.dTypeface.underline = []
|
||||||
|
|
||||||
" text: *_bold italic_* or _*italic bold*_ or ___bi___ or ***bi***
|
" text: *_bold italic_* or _*italic bold*_ or ___bi___ or ***bi***
|
||||||
let s:markdown_syntax.dTypeface['bold_italic'] = vimwiki#u#hi_expand_regex([
|
let s:markdown_syntax.dTypeface.bold_italic = vimwiki#u#hi_expand_regex([
|
||||||
\ ['\*_', '_\*'], ['_\*', '\*_'], ['\*\*\*', '\*\*\*'], ['___', '___']])
|
\ ['\*_', '_\*'], ['_\*', '\*_'], ['\*\*\*', '\*\*\*'], ['___', '___']])
|
||||||
|
|
||||||
|
|
||||||
@ -37,8 +34,6 @@ let s:markdown_syntax.dTypeface['bold_italic'] = vimwiki#u#hi_expand_regex([
|
|||||||
let s:markdown_syntax.rxH = '#'
|
let s:markdown_syntax.rxH = '#'
|
||||||
let s:markdown_syntax.symH = 0
|
let s:markdown_syntax.symH = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
" <hr>, horizontal rule
|
" <hr>, horizontal rule
|
||||||
let s:markdown_syntax.rxHR = '\(^---*$\|^___*$\|^\*\*\**$\)'
|
let s:markdown_syntax.rxHR = '\(^---*$\|^___*$\|^\*\*\**$\)'
|
||||||
|
|
||||||
|
@ -9,8 +9,6 @@
|
|||||||
|
|
||||||
let s:media_syntax = g:vimwiki_syntax_variables['media']
|
let s:media_syntax = g:vimwiki_syntax_variables['media']
|
||||||
|
|
||||||
let s:media_syntax.dTypeface = {}
|
|
||||||
|
|
||||||
" text: '''strong'''
|
" text: '''strong'''
|
||||||
let s:media_syntax.dTypeface['bold'] = [
|
let s:media_syntax.dTypeface['bold'] = [
|
||||||
\ ['\S\@<=''''''\|''''''\S\@=', '\S\@<=''''''\|''''''\S\@='],
|
\ ['\S\@<=''''''\|''''''\S\@=', '\S\@<=''''''\|''''''\S\@='],
|
||||||
@ -35,7 +33,6 @@ let s:media_syntax.rxH = '='
|
|||||||
let s:media_syntax.symH = 1
|
let s:media_syntax.symH = 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
" <hr>, horizontal rule
|
" <hr>, horizontal rule
|
||||||
let s:media_syntax.rxHR = '^-----*$'
|
let s:media_syntax.rxHR = '^-----*$'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user