mirror of
https://github.com/vim-airline/vim-airline.git
synced 2024-11-22 09:22:53 +08:00
hunks: only enable coc-git extension, if explicitly enabled by the user
As requested by the coc maintainer, this is explicitly disabled, unless the user configures vim-airline to use it for the branch extension. This is done, because the `CocAction('extensionStats')` function is known to be slow and this may cause a slow startup.
This commit is contained in:
parent
e7f78bbc0f
commit
48064e24d5
|
@ -16,24 +16,14 @@ let s:non_zero_only = get(g:, 'airline#extensions#hunks#non_zero_only', 0)
|
|||
let s:hunk_symbols = get(g:, 'airline#extensions#hunks#hunk_symbols', ['+', '~', '-'])
|
||||
|
||||
function! s:coc_git_enabled() abort
|
||||
if !exists("*CocAction")
|
||||
if !exists("*CocAction") ||
|
||||
!get(g:, 'airline#extensions#hunks#coc_git', 0)
|
||||
" coc-git extension is disabled by default
|
||||
" unless specifically being enabled by the user
|
||||
" (as requested from coc maintainer)
|
||||
return 0
|
||||
endif
|
||||
if exists("s:airline_coc_git_enabled")
|
||||
return s:airline_coc_git_enabled
|
||||
endif
|
||||
let extensions=CocAction('extensionStats')
|
||||
if type(extensions) != type([])
|
||||
" not yet initialized? Assume it is available...
|
||||
return 1
|
||||
endif
|
||||
let coc_git=filter(extensions, 'v:val.id is# "coc-git" && v:val.state is# "activated"')
|
||||
if !empty(coc_git)
|
||||
let s:airline_coc_git_enabled = 1
|
||||
else
|
||||
let s:airline_coc_git_enabled = 0
|
||||
endif
|
||||
return s:airline_coc_git_enabled
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! s:get_hunks_signify() abort
|
||||
|
|
|
@ -758,6 +758,11 @@ querying how many changes you got. It will return something like '+4 ~2 -1'.
|
|||
<
|
||||
* set hunk count symbols. >
|
||||
let g:airline#extensions#hunks#hunk_symbols = ['+', '~', '-']
|
||||
|
||||
* enable coc-git extension.
|
||||
If not set to 1, vim-airline will not consider to use coc-git for the hunks
|
||||
extension. Make sure to have the coc-git extension enabled. >
|
||||
let g:airline#extensions#hunks#coc_git = 1
|
||||
<
|
||||
------------------------------------- *airline-keymap*
|
||||
vim-keymap
|
||||
|
|
Loading…
Reference in New Issue
Block a user