mirror of
https://github.com/vim-airline/vim-airline.git
synced 2026-01-09 13:02:19 +08:00
wordcount: move User autocommand to plugin
Do not scatter the autocommands around, but rather move the auto command to the main plugin file. The function that handles the auto command will be created in the autoload script. Also add a call to force updating the tabline, if g:airline_statusline_ontop is defined. In addition, the wordcount() extension did not correctly notice block-wise visual mode, so while creating the airline#mode_changed() function, make the mode also detect blockwise visual mode correctly.
This commit is contained in:
@@ -68,9 +68,8 @@ function! s:update_wordcount(force_update)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let s:visual_active = 0 " Boolean: for when to get visual wordcount
|
||||
function airline#extensions#wordcount#get()
|
||||
if s:visual_active
|
||||
if get(g:, 'airline#visual_active', 0)
|
||||
return s:format_wordcount(s:get_wordcount(1))
|
||||
else
|
||||
if get(b:, 'airline_changedtick', 0) != b:changedtick
|
||||
@@ -109,9 +108,5 @@ function! airline#extensions#wordcount#apply(...)
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#wordcount#init(ext)
|
||||
augroup airline_wordcount
|
||||
autocmd! User AirlineModeChanged nested
|
||||
\ let s:visual_active = (mode() ==? 'v' || mode() ==? 's')
|
||||
augroup END
|
||||
call a:ext.add_statusline_func('airline#extensions#wordcount#apply')
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user