artempyanykh / marksman

Write Markdown with code assist and intelligence in the comfort of your favourite editor.
MIT License
1.98k stars 35 forks source link

Word count? #260

Closed phelps-sg closed 11 months ago

phelps-sg commented 11 months ago

Is there any way to get a word count in marksman? Or is there better done with another plugin? Thanks in advance for any suggestions.

artempyanykh commented 11 months ago

Hi @phelps-sg! Thanks for asking! I think this is something that can and should be done in the editor itself rather than in the LSP server such as Marksman. I'd recommend checking a documentation for your editor on how to get word count.

David-Else commented 10 months ago

@phelps-sg I recommend using Pandoc and this filter: https://github.com/pandoc/lua-filters/blob/master/wordcount/wordcount.lua

When that is copied into your Pandoc scripts dir you can use pandoc filename --lua-filter=wordcount.lua and get something like:

94 words in body
496 characters in body
580 characters in body (including spaces)

It is not so simple to do an accurate word count. You might need to strip out markup that is part of your document but not really part of the words you want counting, you need a tool like Pandoc that is aware of that.

You could add this to your bashrc:

wordcount() { pandoc --lua-filter wordcount.lua "$@"; }