Added support for built-in nvim-lsp

This commit is contained in:
tooSadman 2020-07-20 00:04:45 +03:00
parent 7fc51f6952
commit 782774c0dc
5 changed files with 69 additions and 3 deletions

View File

@ -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')

View File

@ -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

View File

@ -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

View File

@ -883,6 +883,18 @@ NrrwRgn <https://github.com/chrisbra/NrrwRgn>
* enable/disable NrrwRgn integration >
let g:airline#extensions#nrrwrgn#enabled = 1
------------------------------------- *airline-nvimlsp*
nvimlsp <https://github.com/neovim/nvim-lsp>
* 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 <https://github.com/tpope/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`

View File

@ -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 == ''