mirror of
https://github.com/vim-airline/vim-airline.git
synced 2024-11-25 09:41:33 +08:00
impl vim-lsp progress
This commit is contained in:
parent
5601c0928e
commit
0c8164b1b3
|
@ -61,7 +61,44 @@ function! airline#extensions#lsp#get_error() abort
|
||||||
return airline#extensions#lsp#get('error')
|
return airline#extensions#lsp#get('error')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
let s:lsp_progress = []
|
||||||
|
function! airline#extensions#lsp#progress() abort
|
||||||
|
if get(w:, 'airline_active', 0)
|
||||||
|
if exists('*lsp#get_progress')
|
||||||
|
let s:lsp_progress = lsp#get_progress()
|
||||||
|
|
||||||
|
if len(s:lsp_progress) == 0 | return '' | endif
|
||||||
|
|
||||||
|
" show only most new progress
|
||||||
|
let s:lsp_progress = s:lsp_progress[0]
|
||||||
|
if s:lsp_progress['message'] != '' && s:lsp_progress['percentage'] != 100
|
||||||
|
let percent = ''
|
||||||
|
if s:lsp_progress['percentage'] >= 0
|
||||||
|
let percent = ' ' . string(s:lsp_progress['percentage']) . '%'
|
||||||
|
endif
|
||||||
|
let s:title = s:lsp_progress['title']
|
||||||
|
let message = airline#util#shorten(s:lsp_progress['message'] . percent, 91, 9)
|
||||||
|
return s:lsp_progress['server'] . ':' . s:title . ' ' . message
|
||||||
|
endif
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
let s:timer = 0
|
||||||
|
let s:ignore_time = 0
|
||||||
|
function! airline#extensions#lsp#update() abort
|
||||||
|
if reltimefloat(reltime()) - s:ignore_time >=
|
||||||
|
\ get(g:, 'airline#extensions#lsp#progress_skip_time', 0.3)
|
||||||
|
\ || len(s:lsp_progress) == 0
|
||||||
|
call airline#update_statusline()
|
||||||
|
let s:ignore_time = reltimefloat(reltime())
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! airline#extensions#lsp#init(ext) abort
|
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_error_count', 'airline#extensions#lsp#get_error')
|
||||||
call airline#parts#define_function('lsp_warning_count', 'airline#extensions#lsp#get_warning')
|
call airline#parts#define_function('lsp_warning_count', 'airline#extensions#lsp#get_warning')
|
||||||
|
call airline#parts#define_function('lsp_progress', 'airline#extensions#lsp#progress')
|
||||||
|
autocmd User lsp_progress_updated call airline#extensions#lsp#update()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
|
@ -164,6 +164,10 @@ function! airline#init#bootstrap()
|
||||||
\ 'raw': '',
|
\ 'raw': '',
|
||||||
\ 'accent': 'bold'
|
\ 'accent': 'bold'
|
||||||
\ })
|
\ })
|
||||||
|
call airline#parts#define('lsp_progress', {
|
||||||
|
\ 'raw': '',
|
||||||
|
\ 'accent': 'bold'
|
||||||
|
\ })
|
||||||
call airline#parts#define_empty(['obsession', 'tagbar', 'syntastic-warn',
|
call airline#parts#define_empty(['obsession', 'tagbar', 'syntastic-warn',
|
||||||
\ 'syntastic-err', 'eclim', 'whitespace','windowswap',
|
\ 'syntastic-err', 'eclim', 'whitespace','windowswap',
|
||||||
\ 'ycm_error_count', 'ycm_warning_count', 'neomake_error_count',
|
\ 'ycm_error_count', 'ycm_warning_count', 'neomake_error_count',
|
||||||
|
@ -198,9 +202,9 @@ function! airline#init#sections()
|
||||||
endif
|
endif
|
||||||
if !exists('g:airline_section_c')
|
if !exists('g:airline_section_c')
|
||||||
if exists("+autochdir") && &autochdir == 1
|
if exists("+autochdir") && &autochdir == 1
|
||||||
let g:airline_section_c = airline#section#create(['%<', 'path', spc, 'readonly', 'coc_status'])
|
let g:airline_section_c = airline#section#create(['%<', 'path', spc, 'readonly', 'coc_status', 'lsp_progress'])
|
||||||
else
|
else
|
||||||
let g:airline_section_c = airline#section#create(['%<', 'file', spc, 'readonly', 'coc_status'])
|
let g:airline_section_c = airline#section#create(['%<', 'file', spc, 'readonly', 'coc_status', 'lsp_progress'])
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
if !exists('g:airline_section_gutter')
|
if !exists('g:airline_section_gutter')
|
||||||
|
|
|
@ -888,6 +888,12 @@ lsp <https://github.com/prabirshrestha/vim-lsp>
|
||||||
<
|
<
|
||||||
* lsp close_lnum_symbol >
|
* lsp close_lnum_symbol >
|
||||||
let airline#extensions#lsp#close_lnum_symbol = ')'
|
let airline#extensions#lsp#close_lnum_symbol = ')'
|
||||||
|
<
|
||||||
|
* lsp progress skip time
|
||||||
|
Suppresses the frequency of status line updates.
|
||||||
|
Prevents heavy operation when using a language server that sends frequent progress notifications. >
|
||||||
|
g:airline#extensions#lsp#progress_skip_time = 0.3 (default)
|
||||||
|
<
|
||||||
|
|
||||||
------------------------------------- *airline-neomake*
|
------------------------------------- *airline-neomake*
|
||||||
neomake <https://github.com/neomake/neomake>
|
neomake <https://github.com/neomake/neomake>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user