Merge pull request #2355 from patrick96/coc_current_function

coc: Show the current function in section_x
This commit is contained in:
Christian Brabandt 2021-03-27 17:15:19 +01:00 committed by GitHub
commit ed60e1d369
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 3 deletions

View File

@ -20,7 +20,7 @@ This is the Changelog for the vim-airline project.
- [gen_tags.vim](https://github.com/jsfaint/gen_tags.vim) support - [gen_tags.vim](https://github.com/jsfaint/gen_tags.vim) support
- 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 as well as the current function
- [coc-git](https://github.com/neoclide/coc-git) extension integrated into hunks extension - [coc-git](https://github.com/neoclide/coc-git) extension integrated into hunks extension
- Other - Other
- Changed CI from travis-ci.org to GitHub Actions - Changed CI from travis-ci.org to GitHub Actions

View File

@ -48,8 +48,13 @@ function! airline#extensions#coc#get_status() abort
return airline#util#shorten(get(g:, 'coc_status', ''), 91, 9) return airline#util#shorten(get(g:, 'coc_status', ''), 91, 9)
endfunction endfunction
function! airline#extensions#coc#get_current_function() abort
return get(b:, 'coc_current_function', '')
endfunction
function! airline#extensions#coc#init(ext) abort function! airline#extensions#coc#init(ext) abort
call airline#parts#define_function('coc_error_count', 'airline#extensions#coc#get_error') call airline#parts#define_function('coc_error_count', 'airline#extensions#coc#get_error')
call airline#parts#define_function('coc_warning_count', 'airline#extensions#coc#get_warning') call airline#parts#define_function('coc_warning_count', 'airline#extensions#coc#get_warning')
call airline#parts#define_function('coc_status', 'airline#extensions#coc#get_status') call airline#parts#define_function('coc_status', 'airline#extensions#coc#get_status')
call airline#parts#define_function('coc_current_function', 'airline#extensions#coc#get_current_function')
endfunction endfunction

View File

@ -164,6 +164,10 @@ function! airline#init#bootstrap()
\ 'raw': '', \ 'raw': '',
\ 'accent': 'bold' \ 'accent': 'bold'
\ }) \ })
call airline#parts#define('coc_current_function', {
\ 'raw': '',
\ 'accent': 'bold'
\ })
call airline#parts#define('lsp_progress', { call airline#parts#define('lsp_progress', {
\ 'raw': '', \ 'raw': '',
\ 'accent': 'bold' \ 'accent': 'bold'
@ -211,7 +215,7 @@ function! airline#init#sections()
let g:airline_section_gutter = airline#section#create(['%=']) let g:airline_section_gutter = airline#section#create(['%='])
endif endif
if !exists('g:airline_section_x') if !exists('g:airline_section_x')
let g:airline_section_x = airline#section#create_right(['bookmark', 'tagbar', 'vista', 'gutentags', 'gen_tags', 'omnisharp', 'grepper', 'filetype']) let g:airline_section_x = airline#section#create_right(['coc_current_function', 'bookmark', 'tagbar', 'vista', 'gutentags', 'gen_tags', 'omnisharp', 'grepper', 'filetype'])
endif endif
if !exists('g:airline_section_y') if !exists('g:airline_section_y')
let g:airline_section_y = airline#section#create_right(['ffenc']) let g:airline_section_y = airline#section#create_right(['ffenc'])

View File

@ -34,7 +34,7 @@ describe 'init sections'
end end
it 'section x should be filetype' it 'section x should be filetype'
Expect g:airline_section_x == '%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#wrap(airline#parts#filetype(),0)}' Expect g:airline_section_x == '%#__accent_bold#%#__restore__#%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#prepend("",0)}%{airline#util#wrap(airline#parts#filetype(),0)}'
end end
it 'section y should be fenc and ff' it 'section y should be fenc and ff'
@ -81,6 +81,7 @@ describe 'init sections'
Expect airline#parts#get('languageclient_error_count').raw == '' Expect airline#parts#get('languageclient_error_count').raw == ''
Expect airline#parts#get('languageclient_warning_count').raw == '' Expect airline#parts#get('languageclient_warning_count').raw == ''
Expect airline#parts#get('coc_status').raw == '' Expect airline#parts#get('coc_status').raw == ''
Expect airline#parts#get('coc_current_function').raw == ''
Expect airline#parts#get('vista').raw == '' Expect airline#parts#get('vista').raw == ''
Expect airline#parts#get('coc_warning_count').raw == '' Expect airline#parts#get('coc_warning_count').raw == ''
Expect airline#parts#get('coc_error_count').raw == '' Expect airline#parts#get('coc_error_count').raw == ''