mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-07-26 07:25:18 +02:00
add foldmarker to highlighter.vim
This commit is contained in:
parent
0abcdbeba5
commit
b0d4a44f0c
@ -1,5 +1,5 @@
|
|||||||
" MIT License. Copyright (c) 2013-2020 Bailey Ling Christian Brabandt et al.
|
" MIT License. Copyright (c) 2013-2020 Bailey Ling Christian Brabandt et al.
|
||||||
" vim: et ts=2 sts=2 sw=2
|
" vim: et ts=2 sts=2 sw=2 fdm=marker et
|
||||||
|
|
||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ let s:separators = {}
|
|||||||
let s:accents = {}
|
let s:accents = {}
|
||||||
let s:hl_groups = {}
|
let s:hl_groups = {}
|
||||||
|
|
||||||
function! s:gui2cui(rgb, fallback) abort
|
function! s:gui2cui(rgb, fallback) abort " {{{2
|
||||||
if a:rgb == ''
|
if a:rgb == ''
|
||||||
return a:fallback
|
return a:fallback
|
||||||
elseif match(a:rgb, '^\%(NONE\|[fb]g\)$') > -1
|
elseif match(a:rgb, '^\%(NONE\|[fb]g\)$') > -1
|
||||||
@ -23,7 +23,7 @@ function! s:gui2cui(rgb, fallback) abort
|
|||||||
return airline#msdos#round_msdos_colors(rgb)
|
return airline#msdos#round_msdos_colors(rgb)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:group_not_done(list, name) abort
|
function! s:group_not_done(list, name) abort " {{{2
|
||||||
if index(a:list, a:name) == -1
|
if index(a:list, a:name) == -1
|
||||||
call add(a:list, a:name)
|
call add(a:list, a:name)
|
||||||
return 1
|
return 1
|
||||||
@ -34,8 +34,7 @@ function! s:group_not_done(list, name) abort
|
|||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
endfu
|
endfu
|
||||||
|
function! s:get_syn(group, what, mode) abort "{{{2
|
||||||
function! s:get_syn(group, what, mode) abort
|
|
||||||
let color = ''
|
let color = ''
|
||||||
if hlexists(a:group)
|
if hlexists(a:group)
|
||||||
let color = synIDattr(synIDtrans(hlID(a:group)), a:what, a:mode)
|
let color = synIDattr(synIDtrans(hlID(a:group)), a:what, a:mode)
|
||||||
@ -50,16 +49,14 @@ function! s:get_syn(group, what, mode) abort
|
|||||||
endif
|
endif
|
||||||
return color
|
return color
|
||||||
endfunction
|
endfunction
|
||||||
|
function! s:get_array(guifg, guibg, ctermfg, ctermbg, opts) abort " {{{2
|
||||||
function! s:get_array(guifg, guibg, ctermfg, ctermbg, opts) abort
|
|
||||||
return [ a:guifg, a:guibg, a:ctermfg, a:ctermbg, empty(a:opts) ? '' : join(a:opts, ',') ]
|
return [ a:guifg, a:guibg, a:ctermfg, a:ctermbg, empty(a:opts) ? '' : join(a:opts, ',') ]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#highlighter#reset_hlcache() abort
|
function! airline#highlighter#reset_hlcache() abort " {{{2
|
||||||
let s:hl_groups = {}
|
let s:hl_groups = {}
|
||||||
endfunction
|
endfunction
|
||||||
|
function! airline#highlighter#get_highlight(group, ...) abort " {{{2
|
||||||
function! airline#highlighter#get_highlight(group, ...) abort
|
|
||||||
" only check for the cterm reverse attribute
|
" only check for the cterm reverse attribute
|
||||||
" TODO: do we need to check all modes (gui, term, as well)?
|
" TODO: do we need to check all modes (gui, term, as well)?
|
||||||
let reverse = synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'cterm')
|
let reverse = synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'cterm')
|
||||||
@ -81,16 +78,14 @@ function! airline#highlighter#get_highlight(group, ...) abort
|
|||||||
let s:hl_groups[a:group] = res
|
let s:hl_groups[a:group] = res
|
||||||
return res
|
return res
|
||||||
endfunction
|
endfunction
|
||||||
|
function! airline#highlighter#get_highlight2(fg, bg, ...) abort " {{{2
|
||||||
function! airline#highlighter#get_highlight2(fg, bg, ...) abort
|
|
||||||
let guifg = s:get_syn(a:fg[0], a:fg[1], 'gui')
|
let guifg = s:get_syn(a:fg[0], a:fg[1], 'gui')
|
||||||
let guibg = s:get_syn(a:bg[0], a:bg[1], 'gui')
|
let guibg = s:get_syn(a:bg[0], a:bg[1], 'gui')
|
||||||
let ctermfg = s:get_syn(a:fg[0], a:fg[1], 'cterm')
|
let ctermfg = s:get_syn(a:fg[0], a:fg[1], 'cterm')
|
||||||
let ctermbg = s:get_syn(a:bg[0], a:bg[1], 'cterm')
|
let ctermbg = s:get_syn(a:bg[0], a:bg[1], 'cterm')
|
||||||
return s:get_array(guifg, guibg, ctermfg, ctermbg, a:000)
|
return s:get_array(guifg, guibg, ctermfg, ctermbg, a:000)
|
||||||
endfunction
|
endfunction
|
||||||
|
function! s:hl_group_exists(group) abort " {{{2
|
||||||
function! s:hl_group_exists(group) abort
|
|
||||||
if !hlexists(a:group)
|
if !hlexists(a:group)
|
||||||
return 0
|
return 0
|
||||||
elseif empty(synIDattr(hlID(a:group), 'fg'))
|
elseif empty(synIDattr(hlID(a:group), 'fg'))
|
||||||
@ -98,8 +93,7 @@ function! s:hl_group_exists(group) abort
|
|||||||
endif
|
endif
|
||||||
return 1
|
return 1
|
||||||
endfunction
|
endfunction
|
||||||
|
function! airline#highlighter#exec(group, colors) abort " {{{2
|
||||||
function! airline#highlighter#exec(group, colors) abort
|
|
||||||
if pumvisible()
|
if pumvisible()
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -116,14 +110,17 @@ function! airline#highlighter#exec(group, colors) abort
|
|||||||
let colors = s:CheckDefined(colors)
|
let colors = s:CheckDefined(colors)
|
||||||
if old_hi != new_hi || !s:hl_group_exists(a:group)
|
if old_hi != new_hi || !s:hl_group_exists(a:group)
|
||||||
let cmd = printf('hi %s%s', a:group, s:GetHiCmd(colors))
|
let cmd = printf('hi %s%s', a:group, s:GetHiCmd(colors))
|
||||||
exe cmd
|
try
|
||||||
|
exe cmd
|
||||||
|
catch
|
||||||
|
echoerr "Error when running command: ". cmd
|
||||||
|
endtry
|
||||||
if has_key(s:hl_groups, a:group)
|
if has_key(s:hl_groups, a:group)
|
||||||
let s:hl_groups[a:group] = colors
|
let s:hl_groups[a:group] = colors
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
function! s:CheckDefined(colors) abort " {{{2
|
||||||
function! s:CheckDefined(colors) abort
|
|
||||||
" Checks, whether the definition of the colors is valid and is not empty or NONE
|
" Checks, whether the definition of the colors is valid and is not empty or NONE
|
||||||
" e.g. if the colors would expand to this:
|
" e.g. if the colors would expand to this:
|
||||||
" hi airline_c ctermfg=NONE ctermbg=NONE
|
" hi airline_c ctermfg=NONE ctermbg=NONE
|
||||||
@ -155,7 +152,7 @@ function! s:CheckDefined(colors) abort
|
|||||||
return a:colors[0:1] + [fg, bg] + [a:colors[4]]
|
return a:colors[0:1] + [fg, bg] + [a:colors[4]]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:GetHiCmd(list) abort
|
function! s:GetHiCmd(list) abort " {{{2
|
||||||
" a:list needs to have 5 items!
|
" a:list needs to have 5 items!
|
||||||
let res = ''
|
let res = ''
|
||||||
let i = -1
|
let i = -1
|
||||||
@ -179,8 +176,7 @@ function! s:GetHiCmd(list) abort
|
|||||||
endwhile
|
endwhile
|
||||||
return res
|
return res
|
||||||
endfunction
|
endfunction
|
||||||
|
function! s:exec_separator(dict, from, to, inverse, suffix) abort " {{{2
|
||||||
function! s:exec_separator(dict, from, to, inverse, suffix) abort
|
|
||||||
if pumvisible()
|
if pumvisible()
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -195,8 +191,7 @@ function! s:exec_separator(dict, from, to, inverse, suffix) abort
|
|||||||
let a:dict[group] = colors
|
let a:dict[group] = colors
|
||||||
call airline#highlighter#exec(group, colors)
|
call airline#highlighter#exec(group, colors)
|
||||||
endfunction
|
endfunction
|
||||||
|
function! airline#highlighter#load_theme() abort " {{{2
|
||||||
function! airline#highlighter#load_theme() abort
|
|
||||||
if pumvisible()
|
if pumvisible()
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -210,17 +205,14 @@ function! airline#highlighter#load_theme() abort
|
|||||||
call airline#highlighter#highlight(['normal'])
|
call airline#highlighter#highlight(['normal'])
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
function! airline#highlighter#add_separator(from, to, inverse) abort " {{{2
|
||||||
function! airline#highlighter#add_separator(from, to, inverse) abort
|
|
||||||
let s:separators[a:from.a:to] = [a:from, a:to, a:inverse]
|
let s:separators[a:from.a:to] = [a:from, a:to, a:inverse]
|
||||||
call <sid>exec_separator({}, a:from, a:to, a:inverse, '')
|
call <sid>exec_separator({}, a:from, a:to, a:inverse, '')
|
||||||
endfunction
|
endfunction
|
||||||
|
function! airline#highlighter#add_accent(accent) abort " {{{2
|
||||||
function! airline#highlighter#add_accent(accent) abort
|
|
||||||
let s:accents[a:accent] = 1
|
let s:accents[a:accent] = 1
|
||||||
endfunction
|
endfunction
|
||||||
|
function! airline#highlighter#highlight_modified_inactive(bufnr) abort " {{{2
|
||||||
function! airline#highlighter#highlight_modified_inactive(bufnr) abort
|
|
||||||
if getbufvar(a:bufnr, '&modified')
|
if getbufvar(a:bufnr, '&modified')
|
||||||
let colors = exists('g:airline#themes#{g:airline_theme}#palette.inactive_modified.airline_c')
|
let colors = exists('g:airline#themes#{g:airline_theme}#palette.inactive_modified.airline_c')
|
||||||
\ ? g:airline#themes#{g:airline_theme}#palette.inactive_modified.airline_c : []
|
\ ? g:airline#themes#{g:airline_theme}#palette.inactive_modified.airline_c : []
|
||||||
@ -233,8 +225,7 @@ function! airline#highlighter#highlight_modified_inactive(bufnr) abort
|
|||||||
call airline#highlighter#exec('airline_c'.(a:bufnr).'_inactive', colors)
|
call airline#highlighter#exec('airline_c'.(a:bufnr).'_inactive', colors)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
function! airline#highlighter#highlight(modes, ...) abort " {{{2
|
||||||
function! airline#highlighter#highlight(modes, ...) abort
|
|
||||||
let bufnr = a:0 ? a:1 : ''
|
let bufnr = a:0 ? a:1 : ''
|
||||||
let p = g:airline#themes#{g:airline_theme}#palette
|
let p = g:airline#themes#{g:airline_theme}#palette
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user