Commit Graph

15 Commits

Author SHA1 Message Date
Liam Fleming 264c1fefd2 wordcount: Compatibility fixes and General upkeep
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
2018-09-22 03:34:27 +01:00
Christian Brabandt 7957bd1d32 wordcount: only add fmt function once to statusline functions
This prevents a warning message, when the function is tried to add
several times. Also while at it, add a '!' so that no error is thrown if
the file is sourced a second times.
2018-09-20 10:41:50 +02:00
Liam Fleming 0756b9a4aa wordcount: Re-enable updating the format string 2018-09-18 20:12:17 +01:00
Liam Fleming 487d262901 wordcount: formatter: code quality improvements
- Rename new formatting function: transform() -> to_string()
- Optimise separator selection
- Other quality improvements
2018-09-18 02:04:35 +01:00
Liam Fleming 44da0a4761 wordcount: Replace formatter interface
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.
2018-07-28 18:24:12 +01:00
Christian Brabandt 044a90ed55 use get(v:, 'lang', '') instead of v:lang
closes #1735
2018-06-04 21:45:46 +02:00
Christian Brabandt 5db4c408bd Update copyright notifications 2018-01-05 10:37:59 +01:00
Taikuh ccc4c9f430 Add option to change wordcount display for the default formatter 2017-10-26 01:02:10 +08:00
Christian Brabandt db01efd508 Better reformat wordcount format in with separator 2017-02-24 18:28:48 +01:00
Christian Brabandt b2bbe7dbc2 Small wordcount format output on windows < 80 2017-02-24 18:25:29 +01:00
thawk 45d77ca909 Add 'scriptencoding utf-8' to all scripts 2016-09-24 08:16:30 +08:00
Daniel Hahler 5652b576b0 Add bang to function definitions
This makes it easier to reload the files, e.g. via vim-scriptease's
`:Runtime`.
2016-04-20 21:10:28 +02:00
Werner Freund 447cf71ef2 Added visual mode word counting 2016-02-09 19:31:55 +01:00
Christian Brabandt da21b97529 fix stupid typo 2016-01-27 21:22:39 +01:00
Christian Brabandt 97e204f3b6 Some improvements to the wordcount plugin
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.
2016-01-25 21:00:05 +01:00