mirror of
https://github.com/vim-airline/vim-airline.git
synced 2024-11-22 09:58:29 +08:00
Coc integration
This commit is contained in:
parent
193e350440
commit
b3ecf49f86
|
@ -272,6 +272,11 @@ function! airline#extensions#load()
|
|||
call add(s:loaded_ext, 'ale')
|
||||
endif
|
||||
|
||||
if (get(g:, 'airline#extensions#coc#enabled', 1) && exists(':CocCommand'))
|
||||
call airline#extensions#coc#init(s:ext)
|
||||
call add(s:loaded_ext, 'coc')
|
||||
endif
|
||||
|
||||
if (get(g:, 'airline#extensions#languageclient#enabled', 1) && exists(':LanguageClientStart'))
|
||||
call airline#extensions#languageclient#init(s:ext)
|
||||
call add(s:loaded_ext, 'languageclient')
|
||||
|
|
40
autoload/airline/extensions/coc.vim
Normal file
40
autoload/airline/extensions/coc.vim
Normal file
|
@ -0,0 +1,40 @@
|
|||
|
||||
let s:error_symbol = get(g:, 'airline#extensions#coc#error_symbol', 'E:')
|
||||
let s:warning_symbol = get(g:, 'airline#extensions#coc#warning_symbol', 'W:')
|
||||
|
||||
function! airline#extensions#coc#get_warning()
|
||||
return airline#extensions#coc#get('warning')
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#coc#get_error()
|
||||
return airline#extensions#coc#get('error')
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#coc#get(type)
|
||||
let _backup = get(g:, 'coc_stl_format', '')
|
||||
let is_err = (a:type is# 'error')
|
||||
if is_err
|
||||
let g:coc_stl_format = get(g:, 'airline#extensions#coc#stl_format_err', '%E{[%e(#%fe)]}')
|
||||
else
|
||||
let g:coc_stl_format = get(g:, 'airline#extensions#coc#stl_format_warn', '%W{[%w(#%fw)]}')
|
||||
endif
|
||||
let info = get(b:, 'coc_diagnostic_info', {})
|
||||
if empty(info) | return '' | endif
|
||||
|
||||
|
||||
let cnt = get(info, a:type, 0)
|
||||
if !empty(_backup)
|
||||
let g:coc_stl_format = _backup
|
||||
endif
|
||||
|
||||
if empty(cnt)
|
||||
return ''
|
||||
else
|
||||
return (is_err ? s:error_symbol : s:warning_symbol).cnt
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#coc#init(ext)
|
||||
call airline#parts#define_function('coc_error_count', 'airline#extensions#coc#get_error')
|
||||
call airline#parts#define_function('coc_warning_count', 'airline#extensions#coc#get_warning')
|
||||
endfunction
|
|
@ -211,9 +211,9 @@ function! airline#init#sections()
|
|||
endif
|
||||
endif
|
||||
if !exists('g:airline_section_error')
|
||||
let g:airline_section_error = airline#section#create(['ycm_error_count', 'syntastic-err', 'eclim', 'neomake_error_count', 'ale_error_count', 'languageclient_error_count'])
|
||||
let g:airline_section_error = airline#section#create(['ycm_error_count', 'syntastic-err', 'eclim', 'neomake_error_count', 'ale_error_count', 'languageclient_error_count', 'coc_error_count'])
|
||||
endif
|
||||
if !exists('g:airline_section_warning')
|
||||
let g:airline_section_warning = airline#section#create(['ycm_warning_count', 'syntastic-warn', 'neomake_warning_count', 'ale_warning_count', 'languageclient_warning_count', 'whitespace'])
|
||||
let g:airline_section_warning = airline#section#create(['ycm_warning_count', 'syntastic-warn', 'neomake_warning_count', 'ale_warning_count', 'languageclient_warning_count', 'whitespace', 'coc_warning_count'])
|
||||
endif
|
||||
endfunction
|
||||
|
|
|
@ -546,6 +546,24 @@ vim-capslock <https://github.com/tpope/vim-capslock>
|
|||
* enable/disable vim-capslock integration >
|
||||
let g:airline#extensions#capslock#enabled = 1
|
||||
|
||||
------------------------------------- *airline-coc*
|
||||
coc <https://github.com/neoclide/coc>
|
||||
|
||||
* enable/disable coc integration >
|
||||
let g:airline#extensions#coc#enabled = 1
|
||||
<
|
||||
* change error symbol: >
|
||||
let airline#extensions#coc#error_symbol = 'E:'
|
||||
<
|
||||
* change warning symbol: >
|
||||
let airline#extensions#coc#warning_symbol = 'W:'
|
||||
<
|
||||
* change error format: >
|
||||
let airline#extensions#coc#stl_format_err = '%E{[%e(#%fe)]}'
|
||||
<
|
||||
* change warning format: >
|
||||
let airline#extensions#coc#stl_format_warn = '%W{[%w(#%fw)]}'
|
||||
|
||||
------------------------------------- *airline-csv*
|
||||
csv.vim <https://github.com/chrisbra/csv.vim>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user