From 8e52d7716d6248b0e5be905a64eb9ebc4ed63396 Mon Sep 17 00:00:00 2001 From: alemi Date: Sat, 2 Nov 2019 05:22:03 +0100 Subject: [PATCH] Added ignored files --- plugin/vim-combo.vim | 94 +++++++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 40 deletions(-) diff --git a/plugin/vim-combo.vim b/plugin/vim-combo.vim index a4dfca6..fbf69ab 100644 --- a/plugin/vim-combo.vim +++ b/plugin/vim-combo.vim @@ -14,47 +14,61 @@ for f in split(globpath($HOME . '/.vim/.combo/', '*'), '\n') endfor let g:best_combo_all = max(scores) -" Find best score for current filetype -if filereadable(g:combo_file) - let g:best_combo = readfile(g:combo_file) - let g:best_combo = g:best_combo[0] +" Checking for ignored extensions +let ignored = [ 'txt' ] +let g:disable_combo = 0 +for f in ignored + if expand("%:e") == f + let g:disable_combo = 1 + endif +endfor + +" If file should be ignored, just set text, else continue with script +if g:disable_combo + let g:airline_section_b = 'ᛥ -|-|%{g:best_combo_all}' else - silent !echo 0 > $HOME/.vim/.combo/%:e.cmb - let g:best_combo = 0 -endif - -" Configure variables -let g:combo_counter = 0 " The actual combo variable -let g:timeout = 1 -let g:emphasis = '' -let g:mult = 10 -let g:last_combo = reltime() " Set current time as last combo time -let g:airline_section_b = 'ᛥ %{g:combo_counter}|%{g:best_combo}|%{g:best_combo_all} %{g:emphasis}' -function! UpdateCombo() - if reltimefloat(reltime(g:last_combo)) > g:timeout - call SaveCombo() - let g:combo_counter = 1 + " Find best score for current filetype + if filereadable(g:combo_file) + let g:best_combo = readfile(g:combo_file) + let g:best_combo = g:best_combo[0] else - let g:combo_counter +=1 + silent !echo 0 > $HOME/.vim/.combo/%:e.cmb + let g:best_combo = 0 endif + + " Configure variables + let g:combo_counter = 0 " The actual combo variable + let g:timeout = 1 let g:emphasis = '' - let ceil = g:combo_counter / g:mult - let i = 0 - while i < ceil - let g:emphasis = g:emphasis . 'ᛞ' - let i+=1 - endwhile - let g:last_combo = reltime() -endfunction -function! SaveCombo() - if g:combo_counter > g:best_combo - call writefile([g:combo_counter], g:combo_file) - let g:best_combo = g:combo_counter - endif -endfunction - -autocmd TextChangedI * call UpdateCombo() " Every time the cursor moves, call combo function -autocmd InsertLeave * call SaveCombo() - -" Options for Backspace Cheaters -" inoremap :let g:combo_counter-=1 + let g:mult = 10 + let g:last_combo = reltime() " Set current time as last combo time + let g:airline_section_b = 'ᛥ %{g:combo_counter}|%{g:best_combo}|%{g:best_combo_all} %{g:emphasis}' + function! UpdateCombo() + if reltimefloat(reltime(g:last_combo)) > g:timeout + call SaveCombo() + let g:combo_counter = 1 + else + let g:combo_counter +=1 + endif + let g:emphasis = '' + let ceil = g:combo_counter / g:mult + let i = 0 + while i < ceil + let g:emphasis = g:emphasis . 'ᛞ' + let i+=1 + endwhile + let g:last_combo = reltime() + endfunction + function! SaveCombo() + if g:combo_counter > g:best_combo + call writefile([g:combo_counter], g:combo_file) + let g:best_combo = g:combo_counter + endif + endfunction + + autocmd TextChangedI * call UpdateCombo() " Every time the cursor moves, call combo function + autocmd InsertLeave * call SaveCombo() + + " Options for Backspace Cheaters + " inoremap :let g:combo_counter-=1 +endif