wordcount: Word count for the combined file types

[Pandoc flavoured Markdown](https://en.wikipedia.org/wiki/Markdown#CommonMark) has its [own file type in `vim`](https://github.com/vim-pandoc/vim-pandoc-syntax#standalone), namely `markdown.pandoc`.
Word count by default in `vim-airline` obviously would make a lot of sense for this popular file type.

Fix this, by making sure that the wordcount extensions will apply
correctly if any of the combined filetypes (e.g. either pandoc or
markdwon) matches the list of allowed filetypes.
This commit is contained in:
Serge Y. Stroobandt 2020-02-20 19:20:00 +01:00 committed by Christian Brabandt
parent 71a7e23f32
commit 3b339fee98
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09

View File

@ -93,10 +93,12 @@ function! airline#extensions#wordcount#apply(...)
" Check if filetype needs testing
if did_filetype()
" correctly test for compound filetypes (e.g. markdown.pandoc)
let ft = substitute(&filetype, '\.', '\\|', 'g')
" Select test based on type of "filetypes": new=list, old=string
if type(filetypes) == get(v:, 't_list', type([]))
\ ? index(filetypes, &filetype) > -1 || index(filetypes, 'all') > -1
\ ? match(filetypes, ft) > -1 || index(filetypes, 'all') > -1
\ : match(&filetype, filetypes) > -1
let b:airline_changedtick = -1
call s:update_wordcount(1) " force update: ensures initial worcount exists