<commit_before>" MIT License. Copyright (c) 2013-2016 <NAME>.
" vim: et ts=2 sts=2 sw=2

scriptencoding utf-8

let s:formatter = get(g:, 'airline#extensions#wordcount#formatter', 'default')
let g:airline#extensions#wordcount#filetypes = get(g:, 'airline#extensions#wordcount#filetypes',
      \ '\vhelp|markdown|rst|org|text|asciidoc|tex|mail')

function! s:update()
  if match(&ft, get(g:, 'airline#extensions#wordcount#filetypes')) > -1
    let l:mode = mode()
    if l:mode ==# 'v' || l:mode ==# 'V' || l:mode ==# 's' || l:mode ==# 'S'
      let b:airline_wordcount = airline#extensions#wordcount#formatters#{s:formatter}#format()
      let b:airline_change_tick = b:changedtick
    else
      if get(b:, 'airline_wordcount_cache', '') is# '' ||
            \ b:airline_wordcount_cache isnot# get(b:, 'airline_wordcount', '') ||
            \ get(b:, 'airline_change_tick', 0) != b:changedtick
        " cache data
        let b:airline_wordcount = airline#extensions#wordcount#formatters#{s:formatter}#format()
        let b:airline_wordcount_cache = b:airline_wordcount
        let b:airline_change_tick = b:changedtick
      endif
    endif
  endif
endfunction

function! airline#extensions#wordcount#apply(...)
  if match(&ft, get(g:, 'airline#extensions#wordcount#filetypes')) > -1
    call airline#extensions#prepend_to_section('z', '%{get(b:, "airline_wordcount", "")}')
  endif
endfunction

function! airline#extensions#wordcount#init(ext)
  call a:ext.add_statusline_func('airline#extensions#wordcount#apply')
  autocmd BufReadPost,CursorMoved,CursorMovedI * call s:update()
endfunction<commit_msg>Reset wordcount cache on window size<commit_after>" MIT License. Copyright (c) 2013-2016 <NAME>.
" vim: et ts=2 sts=2 sw=2

scriptencoding utf-8

let s:formatter = get(g:, 'airline#extensions#wordcount#formatter', 'default')
let g:airline#extensions#wordcount#filetypes = get(g:, 'airline#extensions#wordcount#filetypes',
      \ '\vhelp|markdown|rst|org|text|asciidoc|tex|mail')

function! s:update()
  if match(&ft, get(g:, 'airline#extensions#wordcount#filetypes')) > -1
    let l:mode = mode()
    if l:mode ==# 'v' || l:mode ==# 'V' || l:mode ==# 's' || l:mode ==# 'S'
      let b:airline_wordcount = airline#extensions#wordcount#formatters#{s:formatter}#format()
      let b:airline_change_tick = b:changedtick
    else
      if get(b:, 'airline_wordcount_cache', '') is# '' ||
            \ b:airline_wordcount_cache isnot# get(b:, 'airline_wordcount', '') ||
            \ get(b:, 'airline_change_tick', 0) != b:changedtick || 
            \ get(b:, 'airline_winwidth', 0) != winwidth(0)
        " cache data
        let b:airline_wordcount = airline#extensions#wordcount#formatters#{s:formatter}#format()
        let b:airline_wordcount_cache = b:airline_wordcount
        let b:airline_change_tick = b:changedtick
        let b:airline_winwidth = winwidth(0)
      endif
    endif
  endif
endfunction

function! airline#extensions#wordcount#apply(...)
  if match(&ft, get(g:, 'airline#extensions#wordcount#filetypes')) > -1
    call airline#extensions#prepend_to_section('z', '%{get(b:, "airline_wordcount", "")}')
  endif
endfunction

function! airline#extensions#wordcount#init(ext)
  call a:ext.add_statusline_func('airline#extensions#wordcount#apply')
  autocmd BufReadPost,CursorMoved,CursorMovedI * call s:update()
endfunction
{'fraction_non_alphanumeric': 0.15393794749403342, 'fraction_numerical': 0.009844868735083532, 'mean_word_length': 4.8927943760984185, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6634056', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1160, 'n_words': 209}