mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-07-27 07:54:44 +02:00
hunks: integrate coc-git extension
The coc-git extension to coc does show similar statistics as e.g. gitgutter, therefore, integrate the coc-git interface into the hunk extension. closes #2094
This commit is contained in:
parent
02a0ab4b59
commit
a13bed2f51
@ -10,6 +10,7 @@ This is the Changelog for the vim-airline project.
|
|||||||
- Improvements
|
- Improvements
|
||||||
- git branch can also be displayed using [gina.vim](https://github.com/lambdalisue/gina.vim)
|
- git branch can also be displayed using [gina.vim](https://github.com/lambdalisue/gina.vim)
|
||||||
- coc extensions can also show additional status messages
|
- coc extensions can also show additional status messages
|
||||||
|
- [coc-git](https://github.com/neoclide/coc-git) extension integrated into hunks extension
|
||||||
- Other
|
- Other
|
||||||
- Introduce Vim script static analysis using [reviewdog](https://github.com/reviewdog/action-vint)
|
- Introduce Vim script static analysis using [reviewdog](https://github.com/reviewdog/action-vint)
|
||||||
- Added multiple Vim versions to unit tests using Travis CI
|
- Added multiple Vim versions to unit tests using Travis CI
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
" MIT License. Copyright (c) 2013-2019 Bailey Ling et al.
|
" MIT License. Copyright (c) 2013-2019 Bailey Ling et al.
|
||||||
" Plugin: vim-gitgutter, vim-signify, changesPlugin, quickfixsigns
|
" Plugin: vim-gitgutter, vim-signify, changesPlugin, quickfixsigns, coc-git
|
||||||
" vim: et ts=2 sts=2 sw=2
|
" vim: et ts=2 sts=2 sw=2
|
||||||
|
|
||||||
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)
|
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',''))
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -19,6 +19,24 @@ function! s:get_hunks_signify()
|
|||||||
return []
|
return []
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:get_hunks_coc()
|
||||||
|
let hunks = get(b:, 'coc_git_status', '')
|
||||||
|
if empty(hunks)
|
||||||
|
return []
|
||||||
|
endif
|
||||||
|
let result = [0, 0, 0]
|
||||||
|
for val in split(hunks)
|
||||||
|
if val[0] is# '+'
|
||||||
|
let result[0] = val[1:] + 0
|
||||||
|
elseif val[0] is# '~'
|
||||||
|
let result[1] = val[1:] + 0
|
||||||
|
elseif val[0] is# '-'
|
||||||
|
let result[2] = val[1:] + 0
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return result
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:is_branch_empty()
|
function! s:is_branch_empty()
|
||||||
return exists('*airline#extensions#branch#head') &&
|
return exists('*airline#extensions#branch#head') &&
|
||||||
\ empty(get(b:, 'airline_head', ''))
|
\ empty(get(b:, 'airline_head', ''))
|
||||||
@ -53,9 +71,13 @@ function! airline#extensions#hunks#get_raw_hunks()
|
|||||||
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")
|
||||||
|
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'
|
||||||
endif
|
endif
|
||||||
|
else
|
||||||
|
let b:source_func = 's:get_hunks_empty'
|
||||||
endif
|
endif
|
||||||
return {b:source_func}()
|
return {b:source_func}()
|
||||||
endfunction
|
endfunction
|
||||||
@ -78,6 +100,7 @@ function! airline#extensions#hunks#get_hunks()
|
|||||||
let string = ''
|
let string = ''
|
||||||
let winwidth = get(airline#parts#get('hunks'), 'minwidth', 100)
|
let winwidth = get(airline#parts#get('hunks'), 'minwidth', 100)
|
||||||
if !empty(hunks)
|
if !empty(hunks)
|
||||||
|
" hunks should contain [added, changed, deleted]
|
||||||
for i in [0, 1, 2]
|
for i in [0, 1, 2]
|
||||||
if (s:non_zero_only == 0 && airline#util#winwidth() > winwidth) || hunks[i] > 0
|
if (s:non_zero_only == 0 && airline#util#winwidth() > winwidth) || hunks[i] > 0
|
||||||
let string .= printf('%s%s ', s:hunk_symbols[i], hunks[i])
|
let string .= printf('%s%s ', s:hunk_symbols[i], hunks[i])
|
||||||
|
@ -738,6 +738,7 @@ vim-gitgutter <https://github.com/airblade/vim-gitgutter>
|
|||||||
vim-signify <https://github.com/mhinz/vim-signify>
|
vim-signify <https://github.com/mhinz/vim-signify>
|
||||||
changesPlugin <https://github.com/chrisbra/changesPlugin>
|
changesPlugin <https://github.com/chrisbra/changesPlugin>
|
||||||
quickfixsigns <https://github.com/tomtom/quickfixsigns_vim>
|
quickfixsigns <https://github.com/tomtom/quickfixsigns_vim>
|
||||||
|
coc-git <https://github.com/neoclide/coc-git>
|
||||||
|
|
||||||
You can use `airline#extensions#hunks#get_raw_hunks()` to get the full hunks,
|
You can use `airline#extensions#hunks#get_raw_hunks()` to get the full hunks,
|
||||||
without shortening. This allows for advanced customization, or a quick way of
|
without shortening. This allows for advanced customization, or a quick way of
|
||||||
|
Loading…
x
Reference in New Issue
Block a user