Currently, I'm trying to make a pretty minimal custom status line that suits my needs. One element of it, however, is a diagnostics report that depends on another plugin (coc.nvim). With a function, I can display this report on my status line conditionally, that is, only when there are errors in my code.
Although I can modify the string presented in my status bar when there are errors to report, I cannot set whitespaces, as I'm using line characters in fillchars
. This does not seems to affect whitespaces set by set statusline+=\
, however, I don't know how to include this command inside a string produced by another function.
As such, is there any special invisible character that can be set inside of a string, that could be ignored by set fillchars
?
function! StatusDiagnostic() abort
let info = get(b:, 'coc_diagnostic_info', {})
if empty(info) | return '' | endif
let msgs = []
if get(info, 'error', 0)
call add(msgs,'['. 'E' . info['error'] . ']'. ' ')
endif
if get(info, 'warning', 0)
call add(msgs, '[' . 'W ' . info['warning'] . ']'. ' ')
endif
return join(msgs, ' '). '' . get(g:, 'coc_status', '')
endfunction
set fillchars=stl:─,stlnc:─
set laststatus=2
set statusline=
set statusline+=%m
set statusline+=\
set statusline+=%t
set statusline+=\
set statusline+=
set statusline+=\
set statusline+=%{StatusDiagnostic()}
set statusline+=%=
set statusline+=\
set statusline+=
set statusline+=\
set statusline+=%l
set statusline+=:
set statusline+=%L
set statusline+=\
set statusline+=
set statusline+=\
set statusline+=%P
Here is my status line:
If I've failed to be clear, I want to put a whitespace after the closing bracket in
E1
.
fillchars
? But you could try a non-breaking space (0xA0, I think)xA0
should work to insert it. Or C-kNS
.