BS does not increase combo anymore by default. Small fixes.
This commit is contained in:
parent
93b1f9003f
commit
69a78b724f
1 changed files with 18 additions and 8 deletions
|
@ -27,7 +27,7 @@ endfor
|
||||||
if g:disable_combo
|
if g:disable_combo
|
||||||
let g:airline_section_b = airline#section#create(['[%{g:best_combo_all}] - ᛥ'])
|
let g:airline_section_b = airline#section#create(['[%{g:best_combo_all}] - ᛥ'])
|
||||||
else
|
else
|
||||||
" Find best score for current filetype
|
" Find best score for current filetype. If none exists, start tracking
|
||||||
if filereadable(g:combo_file)
|
if filereadable(g:combo_file)
|
||||||
let g:best_combo = readfile(g:combo_file)
|
let g:best_combo = readfile(g:combo_file)
|
||||||
let g:best_combo = g:best_combo[0]
|
let g:best_combo = g:best_combo[0]
|
||||||
|
@ -40,14 +40,14 @@ else
|
||||||
" Configure variables
|
" Configure variables
|
||||||
let g:combo_counter = 0 " The actual combo variable
|
let g:combo_counter = 0 " The actual combo variable
|
||||||
let g:timeout = 1
|
let g:timeout = 1
|
||||||
|
let g:last_combo = reltime() " Set current time as last combo time
|
||||||
hi User1 ctermfg=247 ctermbg=237
|
hi User1 ctermfg=247 ctermbg=237
|
||||||
let g:status = '%1*[%{g:best_combo}] %{g:combo_counter} ᛥ%#airline_b#'
|
let g:status = '%1*[%{g:best_combo}] %{g:combo_counter} ᛥ%#airline_b#'
|
||||||
let g:status_max = '%1*[%{g:best_combo_all}|%{g:best_combo}] %{g:combo_counter} ᛥ%#airline_b#'
|
let g:status_max = '%1*[%{g:best_combo_all}|%{g:best_combo}] %{g:combo_counter} ᛥ%#airline_b#'
|
||||||
command ComboMaxOn let g:airline_section_b = airline#section#create([g:status_max]) | AirlineRefresh
|
command ComboMaxOn let g:airline_section_b = airline#section#create([g:status_max]) | AirlineRefresh
|
||||||
command ComboMaxOff let g:airline_section_b = airline#section#create([g:status]) | AirlineRefresh
|
command ComboMaxOff let g:airline_section_b = airline#section#create([g:status]) | AirlineRefresh
|
||||||
let g:airline_section_b = airline#section#create([g:status])
|
let g:airline_section_b = airline#section#create([g:status])
|
||||||
|
" Main check function, executed every time the file is changed
|
||||||
let g:last_combo = reltime() " Set current time as last combo time
|
|
||||||
function! UpdateCombo()
|
function! UpdateCombo()
|
||||||
if reltimefloat(reltime(g:last_combo)) > g:timeout
|
if reltimefloat(reltime(g:last_combo)) > g:timeout
|
||||||
call SaveCombo()
|
call SaveCombo()
|
||||||
|
@ -58,6 +58,7 @@ else
|
||||||
call UpdateColor()
|
call UpdateColor()
|
||||||
let g:last_combo = reltime()
|
let g:last_combo = reltime()
|
||||||
endfunction
|
endfunction
|
||||||
|
" Checks if a new combo has been achieved and saves it to file
|
||||||
function! SaveCombo() " Should check inside because it can be called on InsertLeave
|
function! SaveCombo() " Should check inside because it can be called on InsertLeave
|
||||||
if g:combo_counter > g:best_combo
|
if g:combo_counter > g:best_combo
|
||||||
call writefile([g:combo_counter], g:combo_file)
|
call writefile([g:combo_counter], g:combo_file)
|
||||||
|
@ -65,7 +66,8 @@ else
|
||||||
let g:best_combo = g:combo_counter
|
let g:best_combo = g:combo_counter
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
function! UpdateColor()
|
" This is kind of sketchy but it works fast! Reloading is very slow
|
||||||
|
function! UpdateColor() " Hope User1 isn't used elsewhere?
|
||||||
if g:combo_counter == 1
|
if g:combo_counter == 1
|
||||||
hi User1 ctermfg=247 ctermbg=237
|
hi User1 ctermfg=247 ctermbg=237
|
||||||
elseif g:combo_counter == 10
|
elseif g:combo_counter == 10
|
||||||
|
@ -80,11 +82,19 @@ else
|
||||||
hi User1 ctermfg=1 ctermbg=237
|
hi User1 ctermfg=1 ctermbg=237
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
function! Cheated()
|
|
||||||
call writefile([g:best_last_combo], g:combo_file)
|
|
||||||
let g:best_combo = g:best_last_combo
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
autocmd TextChangedI * call UpdateCombo() " Every time text is changed, call combo function
|
autocmd TextChangedI * call UpdateCombo() " Every time text is changed, call combo function
|
||||||
autocmd InsertLeave * call SaveCombo()
|
autocmd InsertLeave * call SaveCombo()
|
||||||
|
" In case you want to revert your last combo
|
||||||
|
function! Cheated()
|
||||||
|
let g:best_combo = g:best_last_combo
|
||||||
|
let g:combo_counter = g:best_last_combo
|
||||||
|
call writefile([g:combo_counter], g:combo_file)
|
||||||
|
endfunction
|
||||||
|
" This is only needed to avoid backspace cheating.
|
||||||
|
function! Decrease()
|
||||||
|
let g:combo_counter -= 1
|
||||||
|
return "\<BS>"
|
||||||
|
endfunction
|
||||||
|
inoremap <expr> <BS> Decrease()
|
||||||
endif
|
endif
|
||||||
|
|
Loading…
Reference in a new issue