Add a call to coc#status() in statusline

Don't miss out on the status of coc.nvim by insuring updates are
rendered in the statusline.
This commit is contained in:
Kenneth Benzie 2021-04-06 14:05:18 +01:00
parent 2b02d0ae81
commit 78e821e386

View File

@ -1,4 +1,5 @@
" Show the statusline above the commandline. " Show the statusline above the commandline.
scriptencoding utf-8
set laststatus=2 set laststatus=2
" Define color variables. " Define color variables.
@ -6,10 +7,11 @@ let g:statusline#light_green = {'fg': ['235', '#080808'], 'bg': [ '35', '#0087f
let g:statusline#light_blue = {'fg': ['235', '#080808'], 'bg': [ '33', '#0087ff']} let g:statusline#light_blue = {'fg': ['235', '#080808'], 'bg': [ '33', '#0087ff']}
let g:statusline#light_orange = {'fg': ['235', '#080808'], 'bg': ['209', '#eb754d']} let g:statusline#light_orange = {'fg': ['235', '#080808'], 'bg': ['209', '#eb754d']}
let g:statusline#light_red = {'fg': ['235', '#080808'], 'bg': ['124', '#af0000']} let g:statusline#light_red = {'fg': ['235', '#080808'], 'bg': ['124', '#af0000']}
let g:statusline#light_grey = {'fg': ['250', "#bcbcbc"], 'bg': ['236', "#303030"]} let g:statusline#light_grey = {'fg': ['250', '#bcbcbc'], 'bg': ['236', '#303030']}
let g:statusline#light_violet = {'fg': ['235', '#080808'], 'bg': [ '99', '#986fec']} let g:statusline#light_violet = {'fg': ['235', '#080808'], 'bg': [ '99', '#986fec']}
let g:statusline#dark_white = {'fg': [ '15', '#ffffff'], 'bg': ['233', '#121212']} let g:statusline#dark_white = {'fg': [ '15', '#ffffff'], 'bg': ['233', '#121212']}
let g:statusline#dark_yellow = {'fg': ['179', '#dfaf5f'], 'bg': ['233', '#121212']} let g:statusline#dark_yellow = {'fg': ['179', '#dfaf5f'], 'bg': ['233', '#121212']}
let g:statusline#dark_grey = {'fg': ['244', '#808080'], 'bg': ['233', '#121212']}
" Create highlight groups. " Create highlight groups.
function! s:hi(group, color) abort function! s:hi(group, color) abort
@ -27,9 +29,12 @@ call s:hi('StatusLineDusk', g:statusline#light_grey)
" StatusLineDark shows the filename and filetype and takes up most of the " StatusLineDark shows the filename and filetype and takes up most of the
" statusline, give it a dark background. " statusline, give it a dark background.
call s:hi('StatusLineDark', g:statusline#dark_white) call s:hi('StatusLineDark', g:statusline#dark_white)
" StatusLineChange show changes in the file by changing the colour of the " StatusLineChange shows changes in the file by changing the colour of the
" filename, give if a dark background. " filename, give if a dark background.
call s:hi('StatusLineChange', g:statusline#dark_yellow) call s:hi('StatusLineChange', g:statusline#dark_yellow)
" StatusLineFade shows the status of completion engines but using colors which
" fade into the background to avoid grabbing attention.
call s:hi('StatusLineDuskFade', g:statusline#dark_grey)
" Construct a statusline for special buffer types. " Construct a statusline for special buffer types.
function! statusline#special(group, name, title) function! statusline#special(group, name, title)
@ -59,6 +64,8 @@ function! statusline#generic(group, mode)
let l:state = '%#StatusLineDark#' let l:state = '%#StatusLineDark#'
\.'%{&readonly ? " 🔒" : ""}' \.'%{&readonly ? " 🔒" : ""}'
\.'%{&modifiable ? "" : " ⛔"}' \.'%{&modifiable ? "" : " ⛔"}'
" Display coc.nvim status.
let l:coc = '%#StatusLineDuskFade#%( %{coc#status()}%)'
" Display filetype if set. " Display filetype if set.
let l:type = '%#StatusLineDark# %{&filetype} ' let l:type = '%#StatusLineDark# %{&filetype} '
" Display fileencoding if not utf-8 and fileformat if not unix with dusk " Display fileencoding if not utf-8 and fileformat if not unix with dusk
@ -70,7 +77,7 @@ function! statusline#generic(group, mode)
" Display current/total lines and column with dynamic highlights. " Display current/total lines and column with dynamic highlights.
let l:line = '%#'.a:group.'# ☰ %l/%L ㏑%2c ' let l:line = '%#'.a:group.'# ☰ %l/%L ㏑%2c '
" Combine the elements into a single string to be evaluated. " Combine the elements into a single string to be evaluated.
return l:mode.l:edit.l:file.l:state.'%='.l:type.l:format.l:line return l:mode.l:edit.l:file.l:state.l:coc.'%='.l:type.l:format.l:line
endfunction endfunction
" Define active statusline, this statusline is dynamic with StatusLineLight " Define active statusline, this statusline is dynamic with StatusLineLight