mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-07-26 23:44:30 +02:00
hunks: still some problems with coc-git integration
Fix remaining problems, test correctly for enabled coc-git plugin.
This commit is contained in:
parent
29eec37c66
commit
adf2afae7c
@ -211,7 +211,11 @@ function! airline#extensions#load()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if get(g:, 'airline#extensions#hunks#enabled', 1)
|
if get(g:, 'airline#extensions#hunks#enabled', 1)
|
||||||
\ && (exists('g:loaded_signify') || exists('g:loaded_gitgutter') || exists('g:loaded_changes') || exists('g:loaded_quickfixsigns'))
|
\ && (exists('g:loaded_signify')
|
||||||
|
\ || exists('g:loaded_gitgutter')
|
||||||
|
\ || exists('g:loaded_changes')
|
||||||
|
\ || exists('g:loaded_quickfixsigns')
|
||||||
|
\ || exists(':CocCommand'))
|
||||||
call airline#extensions#hunks#init(s:ext)
|
call airline#extensions#hunks#init(s:ext)
|
||||||
call add(s:loaded_ext, 'hunks')
|
call add(s:loaded_ext, 'hunks')
|
||||||
endif
|
endif
|
||||||
|
@ -4,13 +4,38 @@
|
|||||||
|
|
||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
|
|
||||||
if !get(g:, 'loaded_signify', 0) && !get(g:, 'loaded_gitgutter', 0) && !get(g:, 'loaded_changes', 0) && !get(g:, 'loaded_quickfixsigns', 0) && !empty(get(g:, 'coc_git_status',''))
|
if !get(g:, 'loaded_signify', 0)
|
||||||
|
\ && !get(g:, 'loaded_gitgutter', 0)
|
||||||
|
\ && !get(g:, 'loaded_changes', 0)
|
||||||
|
\ && !get(g:, 'loaded_quickfixsigns', 0)
|
||||||
|
\ && !exists("*CocAction")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let s:non_zero_only = get(g:, 'airline#extensions#hunks#non_zero_only', 0)
|
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', ['+', '~', '-'])
|
let s:hunk_symbols = get(g:, 'airline#extensions#hunks#hunk_symbols', ['+', '~', '-'])
|
||||||
|
|
||||||
|
function! s:coc_git_enabled() abort
|
||||||
|
if !exists("*CocAction")
|
||||||
|
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
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:get_hunks_signify() abort
|
function! s:get_hunks_signify() abort
|
||||||
let hunks = sy#repo#get_stats()
|
let hunks = sy#repo#get_stats()
|
||||||
if hunks[0] >= 0
|
if hunks[0] >= 0
|
||||||
@ -68,7 +93,7 @@ function! airline#extensions#hunks#get_raw_hunks() abort
|
|||||||
let b:source_func = 's:get_hunks_changes'
|
let b:source_func = 's:get_hunks_changes'
|
||||||
elseif exists('*quickfixsigns#vcsdiff#GetHunkSummary')
|
elseif exists('*quickfixsigns#vcsdiff#GetHunkSummary')
|
||||||
let b:source_func = 'quickfixsigns#vcsdiff#GetHunkSummary'
|
let b:source_func = 'quickfixsigns#vcsdiff#GetHunkSummary'
|
||||||
elseif exists("g:coc_git_status")
|
elseif s:coc_git_enabled()
|
||||||
let b:source_func = 's:get_hunks_coc'
|
let b:source_func = 's:get_hunks_coc'
|
||||||
else
|
else
|
||||||
let b:source_func = 's:get_hunks_empty'
|
let b:source_func = 's:get_hunks_empty'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user