searchcount: add configuration

- Allow disabling displaying the search term.
- Allow setting the length for truncating the search term.

- Fix inconsistent status format for timed out:
  No space between search term and counts.
This commit is contained in:
Simon Truscott 2022-12-29 23:40:02 +11:00
parent 9e2d021fc6
commit e9c09a2e66
2 changed files with 14 additions and 2 deletions

View File

@ -18,10 +18,16 @@ function! airline#extensions#searchcount#apply(...) abort
endfunction
function! s:search_term()
let show_search_term = get(g:, 'airline#extensions#searchcount#show_search_term', 1)
let search_term_limit = get(g:, 'airline#extensions#searchcount#search_term_limit', 8)
if show_search_term == 0
return ''
endif
" shorten for all width smaller than 300 (this is just a guess)
" this uses a non-breaking space, because it looks like
" a leading space is stripped :/
return "\ua0" . '/' . airline#util#shorten(getreg('/'), 300, 8)
return "\ua0" . '/' . airline#util#shorten(getreg('/'), 300, search_term_limit)
endfunction
function! airline#extensions#searchcount#status() abort
@ -31,7 +37,7 @@ function! airline#extensions#searchcount#status() abort
return ''
endif
if result.incomplete ==# 1 " timed out
return printf('%s [?/??]', s:search_term())
return printf('%s[?/??]', s:search_term())
elseif result.incomplete ==# 2 " max count exceeded
if result.total > result.maxcount &&
\ result.current > result.maxcount

View File

@ -1072,6 +1072,12 @@ highlighting (e.g. using |:nohls|), it this will be disabled.
* enable/disable searchcount integration >
let g:airline#extensions#searchcount#enabled = 1
* enable/disable displaying search term >
let g:airline#extensions#searchcount#show_search_term = 1
* truncate long search terms to a fixed length >
let g:airline#extensions#searchcount#search_term_limit = 8
<
------------------------------------- *airline-syntastic*
syntastic <https://github.com/vim-syntastic/syntastic>