Put a word-boundary regex atom before and after the current filetype, to
make sure that a `C` filetype won't be detected as a filetype that
enables the wordcount extension. (`c` matches asciidoc).
[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.
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.
for older Vims, the wordcount extension falls back to `g<c-g>` and
parses the messaage that is generated.
When doing so, it expects the English locale, which might not be true.
Therefore, try to regex parse the result without using the english words
(assuming the output is still in the same order as in English).
Compatibility:
- Don't use a script-local function to update the format strings
- Protect against `:normal!' moving the cursor on on the wordcount check
Bugfix:
- Let to_string() try to return something for all values
- Now returns correctly when passed both 0 and '0'
Upkeep:
- Simplify check again no valid key from winwidth()
- Old wordcount check: use matchstr() - more expressive and fewer steps
- Improve documentation style/clarity/detail
v:t_list is an internal variable describing the type of a list.
Unfortunately, this is not available in older vims. So let's fall back
to using `type([])`
see #1795
Checking for wordcount changes now uses a b:changedtick comparison in
the statusline funcref. The autocommand strategy that used to do this is
removed, simplifying the code.
- Formatter is now only called when the wordcount changes
- ...#apply() now only compares against the filetype list when necessary
- Old format() function is no longer called for (unsupported) counting
of visual words
- Misc code quality improvements
Various improvements:
- Seperate out visual mode detection.
- Use TextChanged rather than CursorMoved where supported.
- Let users specify the filetypes for which wordcounting is enabled
with a list rather than a pattern.
- Move the filetype check to when airline is refreshed, as opposed to
on every update; autocommands are not created if wordcounting is
disabled
Currently the formatter, and not the wordcount plugin, is responsible
for providing the wordcount as well as formatting it. The default
formatter allows visual mode word counting, although this is not
documented.
The new interface - a transform() function, allows the main wordcount
plugin to internalise this logic. Providing the wordcount simplifies
formatter implementations:
- All formatters can display the visual wordcount.
- Formatters do not have to worry about compatibility with different
vim versions.
The old format() function can now be deprecated, although the wordcount
plugin retains compatibility with formatters using it. The default
formatter will also be used as a fallback if no suitable function is
found.
The default formatter is rewritten to use the new interface.
1) allow for custom formatting of the output of the wordcount formatter
This allows for formatting numbers correctly e.g. 1,042 in English
locale and 1.042 in German locale.
2) cache values, so that no on every cursor move the wordcount needs to
be recalculated.