Unify interface for highlight group init

This commit is contained in:
Karl Yngve Lervåg 2016-01-26 23:08:07 +01:00
parent e329ad8eca
commit 6fe1d77eaf
7 changed files with 33 additions and 37 deletions

View File

@ -36,12 +36,6 @@ function! s:source.hooks.on_syntax(args, context) " {{{1
\ contained containedin=uniteSource__vimtex \ contained containedin=uniteSource__vimtex
syntax match VimtexLabelsTab /tab:.*$/ contains=@Tex syntax match VimtexLabelsTab /tab:.*$/ contains=@Tex
\ contained containedin=uniteSource__vimtex \ contained containedin=uniteSource__vimtex
highlight link VimtexLabelsChap PreProc
highlight link VimtexLabelsEq Statement
highlight link VimtexLabelsFig Identifier
highlight link VimtexLabelsSec Type
highlight link VimtexLabelsTab String
endfunction endfunction
" }}}1 " }}}1

View File

@ -53,14 +53,6 @@ function! s:source.hooks.on_syntax(args, context) " {{{1
syntax match VimtexTocNum syntax match VimtexTocNum
\ /\(\([A-Z]\+\>\|\d\+\)\(\.\d\+\)*\)\?\s*/ \ /\(\([A-Z]\+\>\|\d\+\)\(\.\d\+\)*\)\?\s*/
\ contained \ contained
highlight link VimtexTocSec0 Title
highlight link VimtexTocSec1 Normal
highlight link VimtexTocSec2 helpVim
highlight link VimtexTocSec3 NonText
highlight link VimtexTocSec4 Comment
highlight link VimtexTocSecs VimtexTocSec1
highlight link VimtexTocNum Number
endfunction endfunction
" }}}1 " }}}1

View File

@ -84,6 +84,11 @@ endfunction
" }}}1 " }}}1
function! vimtex#imaps#init_script() " {{{1 function! vimtex#imaps#init_script() " {{{1
call vimtex#util#set_highlight('VimtexImapsLhs', 'ModeMsg')
call vimtex#util#set_highlight('VimtexImapsArrow', 'Comment')
call vimtex#util#set_highlight('VimtexImapsRhs', 'ModeMsg')
call vimtex#util#set_highlight('VimtexImapsWrapper', 'Type')
let s:created_maps = [] let s:created_maps = []
endfunction endfunction
@ -152,10 +157,6 @@ function! vimtex#imaps#list() " {{{1
syntax match VimtexImapsArrow /->/ contained nextgroup=VimtexImapsRhs syntax match VimtexImapsArrow /->/ contained nextgroup=VimtexImapsRhs
syntax match VimtexImapsRhs /\s*\S*/ contained nextgroup=VimtexImapsWrapper syntax match VimtexImapsRhs /\s*\S*/ contained nextgroup=VimtexImapsWrapper
syntax match VimtexImapsWrapper /.*/ contained syntax match VimtexImapsWrapper /.*/ contained
highlight link VimtexImapsLhs ModeMsg
highlight link VimtexImapsArrow Comment
highlight link VimtexImapsRhs ModeMsg
highlight link VimtexImapsWrapper Type
endfunction endfunction
" }}}1 " }}}1

View File

@ -14,6 +14,8 @@ endfunction
" }}}1 " }}}1
function! vimtex#index#init_script() " {{{1 function! vimtex#index#init_script() " {{{1
call vimtex#util#set_highlight('IndexHelp', 'helpVim')
call vimtex#util#set_highlight('IndexLine', 'ModeMsg')
endfunction endfunction
" }}}1 " }}}1
@ -226,9 +228,6 @@ endfunction
function! s:syntax() dict " {{{1 function! s:syntax() dict " {{{1
syntax match IndexHelp /^.*: .*/ syntax match IndexHelp /^.*: .*/
syntax match IndexLine /^ .*$/ contains=@Tex syntax match IndexLine /^ .*$/ contains=@Tex
highlight link IndexHelp helpVim
highlight link IndexLine ModeMsg
endfunction endfunction
" }}}1 " }}}1

View File

@ -10,6 +10,14 @@ endfunction
" }}}1 " }}}1
function! vimtex#labels#init_script() " {{{1 function! vimtex#labels#init_script() " {{{1
call vimtex#util#set_highlight('VimtexLabelsHelp', 'helpVim')
call vimtex#util#set_highlight('VimtexLabelsLine', 'Todo')
call vimtex#util#set_highlight('VimtexLabelsChap', 'PreProc')
call vimtex#util#set_highlight('VimtexLabelsEq', 'Statement')
call vimtex#util#set_highlight('VimtexLabelsFig', 'Identifier')
call vimtex#util#set_highlight('VimtexLabelsSec', 'Type')
call vimtex#util#set_highlight('VimtexLabelsTab', 'String')
if !g:vimtex_labels_enabled | return | endif if !g:vimtex_labels_enabled | return | endif
let s:name = 'Table of labels (vimtex)' let s:name = 'Table of labels (vimtex)'
@ -115,14 +123,6 @@ function! s:index_syntax() dict " {{{1
syntax match VimtexLabelsFig /^fig:.*$/ contains=@Tex syntax match VimtexLabelsFig /^fig:.*$/ contains=@Tex
syntax match VimtexLabelsSec /^sec:.*$/ contains=@Tex syntax match VimtexLabelsSec /^sec:.*$/ contains=@Tex
syntax match VimtexLabelsTab /^tab:.*$/ contains=@Tex syntax match VimtexLabelsTab /^tab:.*$/ contains=@Tex
highlight link VimtexLabelsHelp helpVim
highlight link VimtexLabelsLine Todo
highlight link VimtexLabelsChap PreProc
highlight link VimtexLabelsEq Statement
highlight link VimtexLabelsFig Identifier
highlight link VimtexLabelsSec Type
highlight link VimtexLabelsTab String
endfunction endfunction
" }}}1 " }}}1

View File

@ -18,6 +18,14 @@ endfunction
" }}}1 " }}}1
function! vimtex#toc#init_script() " {{{1 function! vimtex#toc#init_script() " {{{1
call vimtex#util#set_highlight('VimtexTocNum', 'Number')
call vimtex#util#set_highlight('VimtexTocSec0', 'Title')
call vimtex#util#set_highlight('VimtexTocSec1', 'Normal')
call vimtex#util#set_highlight('VimtexTocSec2', 'helpVim')
call vimtex#util#set_highlight('VimtexTocSec3', 'NonText')
call vimtex#util#set_highlight('VimtexTocSec4', 'Comment')
call vimtex#util#set_highlight('VimtexTocHelp', 'helpVim')
if !g:vimtex_toc_enabled | return | endif if !g:vimtex_toc_enabled | return | endif
let s:name = 'Table of contents (vimtex)' let s:name = 'Table of contents (vimtex)'
@ -147,6 +155,8 @@ endfunction
" }}}1 " }}}1
function! vimtex#toc#get_entries() " {{{1 function! vimtex#toc#get_entries() " {{{1
if !exists('b:vimtex') | return [] | endif
" "
" Parses tex project for TOC entries " Parses tex project for TOC entries
" "
@ -160,6 +170,7 @@ function! vimtex#toc#get_entries() " {{{1
" level : 2, " level : 2,
" } " }
" "
let l:parsed = vimtex#parser#tex(b:vimtex.tex) let l:parsed = vimtex#parser#tex(b:vimtex.tex)
let s:max_level = 0 let s:max_level = 0
@ -375,14 +386,6 @@ function! s:index_syntax() dict "{{{1
syntax match VimtexTocSec3 /^.*3$/ contains=VimtexTocNum,@Tex syntax match VimtexTocSec3 /^.*3$/ contains=VimtexTocNum,@Tex
syntax match VimtexTocSec4 /^.*4$/ contains=VimtexTocNum,@Tex syntax match VimtexTocSec4 /^.*4$/ contains=VimtexTocNum,@Tex
syntax match VimtexTocHelp /^\S.*: .*/ syntax match VimtexTocHelp /^\S.*: .*/
highlight link VimtexTocNum Number
highlight link VimtexTocSec0 Title
highlight link VimtexTocSec1 Normal
highlight link VimtexTocSec2 helpVim
highlight link VimtexTocSec3 NonText
highlight link VimtexTocSec4 Comment
highlight link VimtexTocHelp helpVim
endfunction endfunction
" }}}1 " }}}1

View File

@ -340,6 +340,13 @@ function! vimtex#util#set_default_os_specific(variable, default) " {{{1
endif endif
endfunction endfunction
" }}}1
function! vimtex#util#set_highlight(name, target) " {{{1
if !hlexists(a:name)
silent execute 'highlight link' a:name a:target
endif
endfunction
" }}}1 " }}}1
" vim: fdm=marker sw=2 " vim: fdm=marker sw=2