adopt denite ver3.0

closes #1918
This commit is contained in:
kazukazuinaina 2019-05-13 18:46:41 +09:00 committed by Christian Brabandt
parent 9a1acf144f
commit 03f63eb666
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09

View File

@ -7,6 +7,7 @@ if !get(g:, 'loaded_denite', 0)
finish finish
endif endif
let s:denite_ver = (exists('*get_status_mode') ? 2 : 3)
" Denite does not use vim's built-in modal editing but has a custom prompt " Denite does not use vim's built-in modal editing but has a custom prompt
" that implements its own insert/normal mode so we have to handle changing the " that implements its own insert/normal mode so we have to handle changing the
" highlight " highlight
@ -14,7 +15,12 @@ function! airline#extensions#denite#check_denite_mode(bufnr)
if &filetype != 'denite' if &filetype != 'denite'
return '' return ''
endif endif
let mode = split(denite#get_status_mode(), ' ')
if s:denite_ver == 3
let mode = split(denite#get_status("mode"), ' ')
else
let mode = split(denite#get_status_mode(), ' ')
endif
let mode = tolower(get(mode, 1, '')) let mode = tolower(get(mode, 1, ''))
if !exists('b:denite_mode_cache') || mode != b:denite_mode_cache if !exists('b:denite_mode_cache') || mode != b:denite_mode_cache
call airline#highlighter#highlight([mode], a:bufnr) call airline#highlighter#highlight([mode], a:bufnr)
@ -27,10 +33,17 @@ function! airline#extensions#denite#apply(...)
if &ft == 'denite' if &ft == 'denite'
let w:airline_skip_empty_sections = 0 let w:airline_skip_empty_sections = 0
call a:1.add_section('airline_a', ' Denite %{airline#extensions#denite#check_denite_mode('.a:2['bufnr'].')}') call a:1.add_section('airline_a', ' Denite %{airline#extensions#denite#check_denite_mode('.a:2['bufnr'].')}')
call a:1.add_section('airline_c', ' %{denite#get_status_sources()}') if s:denite_ver == 3
call a:1.split() call a:1.add_section('airline_c', ' %{denite#get_status("sources")}')
call a:1.add_section('airline_y', ' %{denite#get_status_path()} ') call a:1.split()
call a:1.add_section('airline_z', ' %{denite#get_status_linenr()} ') call a:1.add_section('airline_y', ' %{denite#get_status("path")} ')
call a:1.add_section('airline_z', ' %{denite#get_status("linenr")} ')
else
call a:1.add_section('airline_c', ' %{denite#get_status_sources()}')
call a:1.split()
call a:1.add_section('airline_y', ' %{denite#get_status_path()} ')
call a:1.add_section('airline_z', ' %{denite#get_status_linenr()} ')
endif
return 1 return 1
endif endif
endfunction endfunction