From e542f5e9d0d40b8684774927330056e0a2c421a0 Mon Sep 17 00:00:00 2001 From: Dood of Distinction Date: Tue, 2 Nov 2021 14:27:37 -0700 Subject: [PATCH] Modifies the wordcount to use the vimtex wordcount function when editing TeX files and the vimtex plugin is loaded. With help from Karl Lervag's suggestion on how to reliably tell when the above mentioned conditions are the case for the current buffer Checked to work with other filetypes that use the wordcount in vim-airline, and these seem to work as before. Also checked that if two of these filetypes (one TeX and the other another type, such as markdown) the two coexist peacefully, with TeX using Karl's wordcount function, and the other using the (I assume) native wordcount? Fixed comment wording --- autoload/airline/extensions/wordcount.vim | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/autoload/airline/extensions/wordcount.vim b/autoload/airline/extensions/wordcount.vim index 8b7a63a8..a1e32f60 100644 --- a/autoload/airline/extensions/wordcount.vim +++ b/autoload/airline/extensions/wordcount.vim @@ -9,8 +9,13 @@ if exists('*wordcount') if get(g:, 'actual_curbuf', '') != bufnr('') return endif - let query = a:visual_mode_active ? 'visual_words' : 'words' - return get(wordcount(), query, 0) + if &filetype ==# 'tex' && exists('b:vimtex') +" We're in a TeX file and vimtex is a plugin, so use vimtex's wordcount... + return vimtex#misc#wordcount() + else + let query = a:visual_mode_active ? 'visual_words' : 'words' + return get(wordcount(), query, 0) + endif endfunction else " Pull wordcount from the g_ctrl-g stats function! s:get_wordcount(visual_mode_active)