diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index a801487d..52128e7e 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -336,6 +336,12 @@ function! airline#extensions#load() call add(s:loaded_ext, 'lsp') endif + if (get(g:, 'airline#extensions#nvimlsp#enabled', 1) + \ && exists(':LspInstallInfo')) + call airline#extensions#nvimlsp#init(s:ext) + call add(s:loaded_ext, 'nvimlsp') + endif + if (get(g:, 'airline#extensions#coc#enabled', 1) && exists(':CocCommand')) call airline#extensions#coc#init(s:ext) call add(s:loaded_ext, 'coc') diff --git a/autoload/airline/extensions/nvimlsp.vim b/autoload/airline/extensions/nvimlsp.vim new file mode 100644 index 00000000..028aef24 --- /dev/null +++ b/autoload/airline/extensions/nvimlsp.vim @@ -0,0 +1,44 @@ +" Apache 2.0 license. Copyright (c) 2019-2020 Copyright Neovim contributors. +" Plugin: https://github.com/neovim/nvim-lsp +" vim: et ts=2 sts=2 sw=2 + +scriptencoding utf-8 + +if !(get(g:, 'airline#extensions#nvimlsp#enabled', 1) + \ && exists(':LspInstallInfo')) + finish +endif + +function! s:airline_nvimlsp_count(cnt, symbol) abort + return a:cnt ? a:symbol. a:cnt : '' +endfunction + +function! airline#extensions#nvimlsp#get(type) abort + if !exists(':LspInstallInfo') + return '' + endif + + let error_symbol = get(g:, 'airline#extensions#nvimlsp#error_symbol', 'E:') + let warning_symbol = get(g:, 'airline#extensions#nvimlsp#warning_symbol', 'W:') + + let is_err = a:type ==# 'Error' + + let symbol = is_err ? error_symbol : warning_symbol + + let num = v:lua.vim.lsp.util.buf_diagnostics_count(a:type) + + return s:airline_nvimlsp_count(num, symbol) +endfunction + +function! airline#extensions#nvimlsp#get_warning() abort + return airline#extensions#nvimlsp#get('Warning') +endfunction + +function! airline#extensions#nvimlsp#get_error() abort + return airline#extensions#nvimlsp#get('Error') +endfunction + +function! airline#extensions#nvimlsp#init(ext) abort + call airline#parts#define_function('nvimlsp_error_count', 'airline#extensions#nvimlsp#get_error') + call airline#parts#define_function('nvimlsp_warning_count', 'airline#extensions#nvimlsp#get_warning') +endfunction diff --git a/autoload/airline/init.vim b/autoload/airline/init.vim index b3191d8d..8865bb32 100644 --- a/autoload/airline/init.vim +++ b/autoload/airline/init.vim @@ -170,6 +170,7 @@ function! airline#init#bootstrap() \ 'ycm_error_count', 'ycm_warning_count', 'neomake_error_count', \ 'neomake_warning_count', 'ale_error_count', 'ale_warning_count', \ 'lsp_error_count', 'lsp_warning_count', + \ 'nvimlsp_error_count', 'nvimlsp_warning_count', \ 'languageclient_error_count', 'languageclient_warning_count', \ 'coc_warning_count', 'coc_error_count', 'vista']) call airline#parts#define_text('bookmark', '') @@ -219,9 +220,9 @@ function! airline#init#sections() endif endif if !exists('g:airline_section_error') - let g:airline_section_error = airline#section#create(['ycm_error_count', 'syntastic-err', 'eclim', 'neomake_error_count', 'ale_error_count', 'lsp_error_count', 'languageclient_error_count', 'coc_error_count']) + let g:airline_section_error = airline#section#create(['ycm_error_count', 'syntastic-err', 'eclim', 'neomake_error_count', 'ale_error_count', 'lsp_error_count', 'nvimlsp_error_count', 'languageclient_error_count', 'coc_error_count']) endif if !exists('g:airline_section_warning') - let g:airline_section_warning = airline#section#create(['ycm_warning_count', 'syntastic-warn', 'neomake_warning_count', 'ale_warning_count', 'lsp_warning_count', 'languageclient_warning_count', 'whitespace', 'coc_warning_count']) + let g:airline_section_warning = airline#section#create(['ycm_warning_count', 'syntastic-warn', 'neomake_warning_count', 'ale_warning_count', 'lsp_warning_count', 'nvimlsp_warning_count', 'languageclient_warning_count', 'whitespace', 'coc_warning_count']) endif endfunction diff --git a/doc/airline.txt b/doc/airline.txt index 36fb592e..8b3b1395 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -883,6 +883,18 @@ NrrwRgn * enable/disable NrrwRgn integration > let g:airline#extensions#nrrwrgn#enabled = 1 +------------------------------------- *airline-nvimlsp* +nvimlsp + +* enable/disable nvimlsp integration > + let g:airline#extensions#nvimlsp#enabled = 1 + +* nvimlsp error_symbol > + let airline#extensions#nvimlsp#error_symbol = 'E:' +< +* nvimlsp warning > + let airline#extensions#nvimlsp#warning_symbol = 'W:' + ------------------------------------- *airline-obsession* vim-obsession @@ -1662,7 +1674,8 @@ And the following are defined for their respective extensions: `ale_error_count` `ale_warning_count` `branch` `eclim` `hunks` `languageclient_error_count` `languageclient_warning_count` `lsp_error_count` -`lsp_warning_count` `neomake_error_count` `neomake_warning_count` `obsession` +`lsp_warning_count``neomake_error_count` `neomake_warning_count` +`nvimlsp_error_count` `nvimlsp_warning_count` `obsession` `syntastic-warn` `syntastic-err` `tagbar` `whitespace` `windowswap` `ycm_error_count` `ycm_warning_count` diff --git a/t/init.vim b/t/init.vim index 6cc5620e..085138ae 100644 --- a/t/init.vim +++ b/t/init.vim @@ -63,6 +63,8 @@ describe 'init sections' Expect airline#parts#get('ale_warning_count').raw == '' Expect airline#parts#get('lsp_error_count').raw == '' Expect airline#parts#get('lsp_warning_count').raw == '' + Expect airline#parts#get('nvimlsp_error_count').raw == '' + Expect airline#parts#get('nvimlsp_warning_count').raw == '' Expect airline#parts#get('hunks').raw == '' Expect airline#parts#get('branch').raw == '' Expect airline#parts#get('eclim').raw == ''