From 6fe1d77eafd56f9b50df6d1d6bd5dd56b7b0df03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Tue, 26 Jan 2016 23:08:07 +0100 Subject: [PATCH] Unify interface for highlight group init --- autoload/unite/sources/vimtex_labels.vim | 6 ------ autoload/unite/sources/vimtex_toc.vim | 8 -------- autoload/vimtex/imaps.vim | 9 +++++---- autoload/vimtex/index.vim | 5 ++--- autoload/vimtex/labels.vim | 16 ++++++++-------- autoload/vimtex/toc.vim | 19 +++++++++++-------- autoload/vimtex/util.vim | 7 +++++++ 7 files changed, 33 insertions(+), 37 deletions(-) diff --git a/autoload/unite/sources/vimtex_labels.vim b/autoload/unite/sources/vimtex_labels.vim index 6ad406c..f6294d7 100644 --- a/autoload/unite/sources/vimtex_labels.vim +++ b/autoload/unite/sources/vimtex_labels.vim @@ -36,12 +36,6 @@ function! s:source.hooks.on_syntax(args, context) " {{{1 \ contained containedin=uniteSource__vimtex syntax match VimtexLabelsTab /tab:.*$/ contains=@Tex \ 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 " }}}1 diff --git a/autoload/unite/sources/vimtex_toc.vim b/autoload/unite/sources/vimtex_toc.vim index 8a96f31..0b3e8f0 100644 --- a/autoload/unite/sources/vimtex_toc.vim +++ b/autoload/unite/sources/vimtex_toc.vim @@ -53,14 +53,6 @@ function! s:source.hooks.on_syntax(args, context) " {{{1 syntax match VimtexTocNum \ /\(\([A-Z]\+\>\|\d\+\)\(\.\d\+\)*\)\?\s*/ \ 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 " }}}1 diff --git a/autoload/vimtex/imaps.vim b/autoload/vimtex/imaps.vim index 8d0b035..256574c 100644 --- a/autoload/vimtex/imaps.vim +++ b/autoload/vimtex/imaps.vim @@ -84,6 +84,11 @@ endfunction " }}}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 = [] endfunction @@ -152,10 +157,6 @@ function! vimtex#imaps#list() " {{{1 syntax match VimtexImapsArrow /->/ contained nextgroup=VimtexImapsRhs syntax match VimtexImapsRhs /\s*\S*/ contained nextgroup=VimtexImapsWrapper syntax match VimtexImapsWrapper /.*/ contained - highlight link VimtexImapsLhs ModeMsg - highlight link VimtexImapsArrow Comment - highlight link VimtexImapsRhs ModeMsg - highlight link VimtexImapsWrapper Type endfunction " }}}1 diff --git a/autoload/vimtex/index.vim b/autoload/vimtex/index.vim index 69dc44c..e1f6d04 100644 --- a/autoload/vimtex/index.vim +++ b/autoload/vimtex/index.vim @@ -14,6 +14,8 @@ endfunction " }}}1 function! vimtex#index#init_script() " {{{1 + call vimtex#util#set_highlight('IndexHelp', 'helpVim') + call vimtex#util#set_highlight('IndexLine', 'ModeMsg') endfunction " }}}1 @@ -226,9 +228,6 @@ endfunction function! s:syntax() dict " {{{1 syntax match IndexHelp /^.*: .*/ syntax match IndexLine /^ .*$/ contains=@Tex - - highlight link IndexHelp helpVim - highlight link IndexLine ModeMsg endfunction " }}}1 diff --git a/autoload/vimtex/labels.vim b/autoload/vimtex/labels.vim index 056282a..56cc10d 100644 --- a/autoload/vimtex/labels.vim +++ b/autoload/vimtex/labels.vim @@ -10,6 +10,14 @@ endfunction " }}}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 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 VimtexLabelsSec /^sec:.*$/ 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 " }}}1 diff --git a/autoload/vimtex/toc.vim b/autoload/vimtex/toc.vim index 8535d5e..8d3f951 100644 --- a/autoload/vimtex/toc.vim +++ b/autoload/vimtex/toc.vim @@ -18,6 +18,14 @@ endfunction " }}}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 let s:name = 'Table of contents (vimtex)' @@ -147,6 +155,8 @@ endfunction " }}}1 function! vimtex#toc#get_entries() " {{{1 + if !exists('b:vimtex') | return [] | endif + " " Parses tex project for TOC entries " @@ -160,6 +170,7 @@ function! vimtex#toc#get_entries() " {{{1 " level : 2, " } " + let l:parsed = vimtex#parser#tex(b:vimtex.tex) let s:max_level = 0 @@ -375,14 +386,6 @@ function! s:index_syntax() dict "{{{1 syntax match VimtexTocSec3 /^.*3$/ contains=VimtexTocNum,@Tex syntax match VimtexTocSec4 /^.*4$/ contains=VimtexTocNum,@Tex 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 " }}}1 diff --git a/autoload/vimtex/util.vim b/autoload/vimtex/util.vim index 053a111..aeb0606 100644 --- a/autoload/vimtex/util.vim +++ b/autoload/vimtex/util.vim @@ -340,6 +340,13 @@ function! vimtex#util#set_default_os_specific(variable, default) " {{{1 endif 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 " vim: fdm=marker sw=2