commit
fdafa44b2f
|
@ -6,6 +6,7 @@ This is the Changelog for the vim-airline project.
|
|||
- New features
|
||||
- Extensions:
|
||||
- [poetv](https://github.com/petobens/poet-v) support
|
||||
- [vim-lsp](https://github.com/prabirshrestha/vim-lsp) support
|
||||
- Improvements
|
||||
- git branch can also be displayed using [gina.vim](https://github.com/lambdalisue/gina.vim)
|
||||
- Other
|
||||
|
|
|
@ -305,6 +305,11 @@ function! airline#extensions#load()
|
|||
call add(s:loaded_ext, 'ale')
|
||||
endif
|
||||
|
||||
if (get(g:, 'airline#extensions#lsp#enabled', 1) && exists(':LspDeclaration'))
|
||||
call airline#extensions#lsp#init(s:ext)
|
||||
call add(s:loaded_ext, 'lsp')
|
||||
endif
|
||||
|
||||
if (get(g:, 'airline#extensions#coc#enabled', 1) && exists(':CocCommand'))
|
||||
call airline#extensions#coc#init(s:ext)
|
||||
call add(s:loaded_ext, 'coc')
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
" MIT License. Copyright (c) 2013-2019 François-Xavier Carton et al.
|
||||
" Plugin: https://github.com/prabirshrestha/vim-lsp
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
if !get(g:, 'lsp_loaded', 0)
|
||||
finish
|
||||
endif
|
||||
|
||||
function! s:airline_lsp_count(cnt, symbol) abort
|
||||
return a:cnt ? a:symbol. a:cnt : ''
|
||||
endfunction
|
||||
|
||||
function! s:airline_lsp_get_line_number(cnt, type) abort
|
||||
let result = ''
|
||||
|
||||
if a:type ==# 'error'
|
||||
let result = lsp#get_buffer_first_error_line()
|
||||
endif
|
||||
|
||||
if empty(result)
|
||||
return ''
|
||||
endif
|
||||
|
||||
let open_lnum_symbol =
|
||||
\ get(g:, 'airline#extensions#lsp#open_lnum_symbol', '(L')
|
||||
let close_lnum_symbol =
|
||||
\ get(g:, 'airline#extensions#lsp#close_lnum_symbol', ')')
|
||||
|
||||
return open_lnum_symbol . result . close_lnum_symbol
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#lsp#get(type) abort
|
||||
if !exists(':LspDeclaration')
|
||||
return ''
|
||||
endif
|
||||
|
||||
let error_symbol = get(g:, 'airline#extensions#lsp#error_symbol', 'E:')
|
||||
let warning_symbol = get(g:, 'airline#extensions#lsp#warning_symbol', 'W:')
|
||||
let show_line_numbers = get(g:, 'airline#extensions#lsp#show_line_numbers', 1)
|
||||
|
||||
let is_err = a:type ==# 'error'
|
||||
|
||||
let symbol = is_err ? error_symbol : warning_symbol
|
||||
|
||||
let num = lsp#get_buffer_diagnostics_counts()[a:type]
|
||||
|
||||
if show_line_numbers == 1
|
||||
return s:airline_lsp_count(num, symbol) . <sid>airline_lsp_get_line_number(num, a:type)
|
||||
else
|
||||
return s:airline_lsp_count(num, symbol)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#lsp#get_warning() abort
|
||||
return airline#extensions#lsp#get('warning')
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#lsp#get_error() abort
|
||||
return airline#extensions#lsp#get('error')
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#lsp#init(ext) abort
|
||||
call airline#parts#define_function('lsp_error_count', 'airline#extensions#lsp#get_error')
|
||||
call airline#parts#define_function('lsp_warning_count', 'airline#extensions#lsp#get_warning')
|
||||
endfunction
|
|
@ -165,6 +165,7 @@ function! airline#init#bootstrap()
|
|||
\ 'syntastic-err', 'eclim', 'whitespace','windowswap',
|
||||
\ 'ycm_error_count', 'ycm_warning_count', 'neomake_error_count',
|
||||
\ 'neomake_warning_count', 'ale_error_count', 'ale_warning_count',
|
||||
\ 'lsp_error_count', 'lsp_warning_count',
|
||||
\ 'languageclient_error_count', 'languageclient_warning_count',
|
||||
\ 'coc_warning_count', 'coc_error_count', 'vista'])
|
||||
call airline#parts#define_text('bookmark', '')
|
||||
|
@ -213,9 +214,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', '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', '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', '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', 'languageclient_warning_count', 'whitespace', 'coc_warning_count'])
|
||||
endif
|
||||
endfunction
|
||||
|
|
|
@ -785,6 +785,27 @@ localsearch <https://github.com/mox-mox/localsearch>
|
|||
* enable/disable localsearch indicator integration >
|
||||
let g:airline#extensions#localsearch#enabled = 1
|
||||
|
||||
------------------------------------- *airline-lsp*
|
||||
lsp <https://github.com/prabirshrestha/vim-lsp>
|
||||
|
||||
* enable/disable lsp integration >
|
||||
let g:airline#extensions#lsp#enabled = 1
|
||||
|
||||
* lsp error_symbol >
|
||||
let airline#extensions#lsp#error_symbol = 'E:'
|
||||
<
|
||||
* lsp warning >
|
||||
let airline#extensions#lsp#warning_symbol = 'W:'
|
||||
|
||||
* lsp show_line_numbers >
|
||||
let airline#extensions#lsp#show_line_numbers = 1
|
||||
<
|
||||
* lsp open_lnum_symbol >
|
||||
let airline#extensions#lsp#open_lnum_symbol = '(L'
|
||||
<
|
||||
* lsp close_lnum_symbol >
|
||||
let airline#extensions#lsp#close_lnum_symbol = ')'
|
||||
|
||||
------------------------------------- *airline-neomake*
|
||||
neomake <https://github.com/neomake/neomake>
|
||||
|
||||
|
@ -1551,10 +1572,10 @@ The following list of parts are predefined by vim-airline.
|
|||
And the following are defined for their respective extensions:
|
||||
|
||||
`ale_error_count` `ale_warning_count` `branch` `eclim` `hunks`
|
||||
`languageclient_error_count` `languageclient_warning_count`
|
||||
`neomake_error_count` `neomake_warning_count` `obsession` `syntastic-warn`
|
||||
`syntastic-err` `tagbar` `whitespace` `windowswap` `ycm_error_count`
|
||||
`ycm_warning_count`
|
||||
`languageclient_error_count` `languageclient_warning_count` `lsp_error_count`
|
||||
`lsp_warning_count` `neomake_error_count` `neomake_warning_count` `obsession`
|
||||
`syntastic-warn` `syntastic-err` `tagbar` `whitespace` `windowswap`
|
||||
`ycm_error_count` `ycm_warning_count`
|
||||
|
||||
------------------------------------- *airline-accents*
|
||||
Accents can be defined on any part, like so: >
|
||||
|
|
|
@ -61,6 +61,8 @@ describe 'init sections'
|
|||
it 'all default statusline extensions should be blank'
|
||||
Expect airline#parts#get('ale_error_count').raw == ''
|
||||
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('hunks').raw == ''
|
||||
Expect airline#parts#get('branch').raw == ''
|
||||
Expect airline#parts#get('eclim').raw == ''
|
||||
|
|
Loading…
Reference in New Issue