From d56f199405728f703216db10690f70a2387f25ab Mon Sep 17 00:00:00 2001 From: eximus Date: Fri, 28 Oct 2022 14:34:04 -0400 Subject: [PATCH] Use the coc status variable to format error/warning line number --- autoload/airline/extensions/coc.vim | 9 +++++++-- doc/airline.txt | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/autoload/airline/extensions/coc.vim b/autoload/airline/extensions/coc.vim index 38417116..79d3a4af 100644 --- a/autoload/airline/extensions/coc.vim +++ b/autoload/airline/extensions/coc.vim @@ -20,18 +20,23 @@ function! airline#extensions#coc#get(type) abort if !exists(':CocCommand') return '' endif - let _backup = get(g:, 'coc_stl_format', '') + let is_err = (a:type is# 'error') let info = get(b:, 'coc_diagnostic_info', {}) 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) if empty(cnt) return '' else - let lnum = printf('(L%d)', (info.lnums)[is_err ? 0 : 1]) + let lnum = printf(format, (info.lnums)[is_err ? 0 : 1]) return (is_err ? s:error_symbol : s:warning_symbol).cnt.lnum endif endfunction diff --git a/doc/airline.txt b/doc/airline.txt index e03092a9..46efdb51 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -649,6 +649,12 @@ coc < * enable/disable coc status display > g:airline#extensions#coc#show_coc_status = 1 + +* change the error format: > + let airline#extensions#coc#stl_format_err = '(L%d)' +< +* change the warning format: > + let airline#extensions#coc#stl_format_warn = '(L%d)' < ------------------------------------- *airline-commandt* command-t