UsePlugin 'lightline.vim' let g:lightline = { \ 'colorscheme': 'nord', \ 'active': { \ 'left': [['mode', 'paste', 'gitbranch'], ['filename', 'modified']], \ 'right': [['lineinfo'], ['percent'], ['readonly', 'linter_warnings', 'linter_errors', 'linter_ok']] \ }, \ 'component_expand': { \ 'linter_warnings': 'LightlineLinterWarnings', \ 'linter_errors': 'LightlineLinterErrors', \ 'linter_ok': 'LightlineLinterOK' \ }, \ 'component_type': { \ 'readonly': 'error', \ 'linter_warnings': 'warning', \ 'linter_errors': 'error' \ }, \ 'component_function': { \ 'gitbranch': 'FugitiveHead', \ 'filename': 'LightlineFilename' \ }, \ } function! LightlineLinterWarnings() abort let l:counts = lsp#ui#vim#diagnostics#get_buffer_diagnostics_counts() return l:counts.warning == 0 ? '' : printf('W:%d', l:counts.warning) endfunction function! LightlineLinterErrors() abort let l:counts = lsp#ui#vim#diagnostics#get_buffer_diagnostics_counts() return l:counts.error == 0 ? '' : printf('E:%d', l:counts.error) endfunction function! LightlineLinterOK() abort let l:counts = lsp#ui#vim#diagnostics#get_buffer_diagnostics_counts() let l:total = l:counts.error + l:counts.warning return l:total == 0 ? 'OK' : '' endfunction function! LightlineFilename() let root = fnamemodify(get(b:, 'git_dir'), ':h') let path = expand('%:p') if path[:len(root)-1] ==# root return path[len(root)+1:] endif return expand('%') endfunction augroup LightLineOnLSP autocmd! autocmd User lsp_diagnostics_updated call lightline#update() augroup END