mirror of
https://github.com/vim-airline/vim-airline.git
synced 2024-11-22 14:05:04 +08:00
Improve coc error/warning status format to include count
This commit is contained in:
parent
d734be8cd3
commit
b86e5e09b2
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
|
|
||||||
let s:error_symbol = get(g:, 'airline#extensions#coc#error_symbol', 'E:')
|
|
||||||
let s:warning_symbol = get(g:, 'airline#extensions#coc#warning_symbol', 'W:')
|
|
||||||
let s:show_coc_status = get(g:, 'airline#extensions#coc#show_coc_status', 1)
|
let s:show_coc_status = get(g:, 'airline#extensions#coc#show_coc_status', 1)
|
||||||
|
|
||||||
function! airline#extensions#coc#get_warning() abort
|
function! airline#extensions#coc#get_warning() abort
|
||||||
|
@ -17,28 +15,25 @@ function! airline#extensions#coc#get_error() abort
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#coc#get(type) abort
|
function! airline#extensions#coc#get(type) abort
|
||||||
if !exists(':CocCommand')
|
if !exists(':CocCommand') | return '' | endif
|
||||||
return ''
|
|
||||||
endif
|
|
||||||
|
|
||||||
let is_err = (a:type is# 'error')
|
let is_err = (a:type is# 'error')
|
||||||
let info = get(b:, 'coc_diagnostic_info', {})
|
let info = get(b:, 'coc_diagnostic_info', {})
|
||||||
if empty(info) | return '' | endif
|
if empty(info) | return '' | endif
|
||||||
|
|
||||||
if is_err
|
|
||||||
let format = get(g:, 'airline#extensions#coc#stl_format_err', '(L%d)')
|
|
||||||
else
|
|
||||||
let format = get(g:, 'airline#extensions#coc#stl_format_warn', '(L%d)')
|
|
||||||
endif
|
|
||||||
|
|
||||||
let cnt = get(info, a:type, 0)
|
let cnt = get(info, a:type, 0)
|
||||||
|
if empty(cnt) | return '' | endif
|
||||||
|
|
||||||
if empty(cnt)
|
let error_symbol = get(g:, 'airline#extensions#coc#error_symbol', 'E:')
|
||||||
return ''
|
let warning_symbol = get(g:, 'airline#extensions#coc#warning_symbol', 'W:')
|
||||||
else
|
let error_format = get(g:, 'airline#extensions#coc#stl_format_err', '%C(L%L)')
|
||||||
let lnum = printf(format, (info.lnums)[is_err ? 0 : 1])
|
let warning_format = get(g:, 'airline#extensions#coc#stl_format_warn', '%C(L%L)')
|
||||||
return (is_err ? s:error_symbol : s:warning_symbol).cnt.lnum
|
|
||||||
endif
|
" replace %C with error count and %L with line number
|
||||||
|
return (is_err ? error_symbol : warning_symbol) .
|
||||||
|
\ substitute(substitute(is_err ? error_format : warning_format,
|
||||||
|
\ '%C', cnt, 'g'),
|
||||||
|
\ '%L', (info.lnums)[is_err ? 0 : 1], 'g')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#coc#get_status() abort
|
function! airline#extensions#coc#get_status() abort
|
||||||
|
|
|
@ -650,11 +650,11 @@ coc <https://github.com/neoclide/coc.nvim>
|
||||||
* enable/disable coc status display >
|
* enable/disable coc status display >
|
||||||
g:airline#extensions#coc#show_coc_status = 1
|
g:airline#extensions#coc#show_coc_status = 1
|
||||||
|
|
||||||
* change the error format: >
|
* change the error format (%C - error count, %L - line number): >
|
||||||
let airline#extensions#coc#stl_format_err = '(L%d)'
|
let airline#extensions#coc#stl_format_err = '%C(L%L)'
|
||||||
<
|
<
|
||||||
* change the warning format: >
|
* change the warning format (%C - error count, %L - line number): >
|
||||||
let airline#extensions#coc#stl_format_warn = '(L%d)'
|
let airline#extensions#coc#stl_format_warn = '%C(L%L)'
|
||||||
<
|
<
|
||||||
------------------------------------- *airline-commandt*
|
------------------------------------- *airline-commandt*
|
||||||
command-t <https://github.com/wincent/command-t>
|
command-t <https://github.com/wincent/command-t>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user