Initial version of VimtexWordCount (#166)
It has some more potential for improvement, both in how the count is displayed after `:VimtexWordCount` and in adding some options.
This commit is contained in:
parent
188fd8ed37
commit
62236ee002
@ -24,6 +24,7 @@ disabled if desired.
|
||||
- Document navigation through
|
||||
- table of content
|
||||
- table of labels
|
||||
- Word count (through `texcount`)
|
||||
- Motions
|
||||
- Move between sections with `[[`, `[]`, `][`, `]]`
|
||||
- Move between matching delimiters with `%`
|
||||
|
@ -51,6 +51,7 @@ function! vimtex#info() " {{{1
|
||||
for f in ['aux', 'out', 'log']
|
||||
silent execute 'let d.' . f . ' = data.' . f . '()'
|
||||
endfor
|
||||
let d.words = data.words()
|
||||
|
||||
" Print data blob title line
|
||||
call vimtex#echo#formatted([
|
||||
@ -90,6 +91,7 @@ function! s:init_environment() " {{{1
|
||||
function data.out() dict
|
||||
return s:get_main_ext(self, 'pdf')
|
||||
endfunction
|
||||
let data.words = function('s:get_wordcount')
|
||||
|
||||
call add(g:vimtex#data, data)
|
||||
let b:vimtex.id = len(g:vimtex#data) - 1
|
||||
@ -97,6 +99,8 @@ function! s:init_environment() " {{{1
|
||||
|
||||
" Define commands
|
||||
command! -buffer VimtexInfo call vimtex#info()
|
||||
command! -buffer VimtexWordCount
|
||||
\ echo g:vimtex#data[b:vimtex.id].words()
|
||||
|
||||
" Define mappings
|
||||
nnoremap <buffer> <plug>(vimtex-info) :call vimtex#info()<cr>
|
||||
@ -291,6 +295,14 @@ function! s:get_main_ext(self, ext) " {{{1
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
function! s:get_wordcount() dict " {{{1
|
||||
let cmd = 'cd ' . vimtex#util#fnameescape(self.root)
|
||||
let cmd .= '; texcount -sum -brief -merge '
|
||||
\ . vimtex#util#fnameescape(self.base)
|
||||
return str2nr(matchstr(system(cmd), '^\d\+'))
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
|
||||
function! s:print_dict(dict, ...) " {{{1
|
||||
|
@ -78,6 +78,7 @@ Feature overview~
|
||||
- Document navigation through
|
||||
- table of content
|
||||
- table of labels
|
||||
- Word count (through `texcount`)
|
||||
- Motions
|
||||
- Move between sections with `[[`, `[]`, `][`, `]]`
|
||||
- Move between matching delimiters with `%`
|
||||
@ -729,6 +730,13 @@ Commands~
|
||||
*<plug>(vimtex-reverse-search)*
|
||||
:VimtexRSearch Do reverse search (only available for MuPDF viewer).
|
||||
|
||||
*VimtexWordCount*
|
||||
:VimtexWordCount Shows the number of words in the current project.
|
||||
The count is created with `texcount` through a call
|
||||
on the main project file similar to: >
|
||||
|
||||
texcount -sum -brief -merge FILE
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
Map definitions~
|
||||
*vimtex-mappings*
|
||||
|
Loading…
Reference in New Issue
Block a user