Updated doc, timeout is back to 1 second by default, minor fixes
This commit is contained in:
parent
ce88e430d0
commit
85c413b33d
2 changed files with 58 additions and 29 deletions
|
@ -9,13 +9,25 @@ _________\//\\\\\____\/\\\_\/\\\__\/\\\__\/\\\_______________\//\\\________\//\\
|
|||
___________\//\\\_____\/\\\_\/\\\__\/\\\__\/\\\________________\///\\\\\\\\__\///\\\\\/___\/\\\__\/\\\__\/\\\_\/\\\\\\\\\___\///\\\\\/___
|
||||
_____________\///______\///__\///___\///___\///___________________\////////_____\/////_____\///___\///___\///__\/////////______\/////_____
|
||||
===========================================================================================================================================
|
||||
Each keystroke in insert mode increases your combo, but not typing for 0.5 seconds resets it.
|
||||
Hacks are not patched around : you can keep a key pressed to increase your combo, and CTRL+SHIFT+V will all be counted as a combo.
|
||||
Each keystroke in insert mode increases your combo,
|
||||
but not typing for 1 second resets it.
|
||||
Hacks are not patched around : you can keep a key pressed to increase your
|
||||
combo, and CTRL+SHIFT+V will all be counted as a combo.
|
||||
( since afaik vim does not allow to remap all letters to an action combo
|
||||
counter is increased with every cursor movement )
|
||||
|
||||
Best score is displayed next to the current combo in square brackets. When a new high score is achieved, it is saved inside .vim as .combo.
|
||||
If you get errors at launch, check that .combo exists and has just a number inside (should be 0, or last best combo).
|
||||
Best score is displayed next to the current combo in square brackets.
|
||||
When a new high score is achieved, it is saved inside .vim as .combo.
|
||||
If you get errors at launch, check that .combo exists and has just a
|
||||
number inside (should be 0, or last best combo).
|
||||
|
||||
The plugin is still under construction. Right now, you will need to edit the path to the .combo file and choose where to display the combo information.
|
||||
By default, the section B of airline-vim is overwritten to display current combo. A random Runic character has been chosen to indicate the combo field.
|
||||
The plugin is not in its final version. Right now, you will need to edit
|
||||
the path to the .combo file and choose where to display the combo information.
|
||||
By default, the section B of airline-vim is overwritten to display current
|
||||
combo. A random Runic character has been chosen to indicate the combo field.
|
||||
|
||||
If you think you can help this little script, absolutely do contact me!
|
||||
There is a github (https://github.com/alemigliardi/vim-combo). I still know
|
||||
very little of vim-script!
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
" COMBO Counter
|
||||
let g:disable_combo = 0
|
||||
" Combo counting is disabled in plain text, LaTeX, vim config and files
|
||||
" without extension (usually configuration files)
|
||||
if expand("%:e") == "txt" || expand("%:e") == "tex" || expand("%:e") == "vim" || expand("%:e") == ""
|
||||
let g:disable_combo = 1
|
||||
endif
|
||||
|
||||
if g:disable_combo == 1
|
||||
let g:best_combo = readfile('$HOME/.vim/.combo')
|
||||
let g:best_combo = g:best_combo[0]
|
||||
let g:airline_section_b = 'ᛥ [%{g:best_combo}]'
|
||||
else
|
||||
let g:combo_counter = 0 " The actual combo variable
|
||||
let g:best_combo = readfile('/home/$USER/.vim/.combo') " ~ is not expanded ???
|
||||
let g:best_combo = readfile('$HOME/.vim/.combo') " ~ is not expanded ???
|
||||
let g:best_combo = g:best_combo[0] " Reading from file returns a list, but an int is needed
|
||||
let g:last_combo = reltime() " Set current time as last combo time
|
||||
let g:airline_section_b = 'ᛥ %{g:combo_counter} [%{g:best_combo}]' " I use airline vim and inserted the combo meter in it
|
||||
function! UpdateCombo()
|
||||
if reltimefloat(reltime(g:last_combo)) > 0.5 " Timeout is 0.5 seconds
|
||||
if reltimefloat(reltime(g:last_combo)) > 1 " Timeout is 1 second
|
||||
if g:combo_counter > g:best_combo " Before resetting combo counter, check if new high score
|
||||
call writefile([g:combo_counter], "/home/$USER/.vim/.combo") " Sorry no idea how to solve this yes
|
||||
call writefile([g:combo_counter], "$HOME/.vim/.combo")
|
||||
let g:best_combo = g:combo_counter
|
||||
endif
|
||||
let g:combo_counter = 1
|
||||
|
@ -16,10 +28,15 @@ function! UpdateCombo()
|
|||
endif
|
||||
let g:last_combo = reltime()
|
||||
endfunction
|
||||
autocmd CursorMovedI * call UpdateCombo() " Every time the cursor moves, cwall combo function
|
||||
autocmd CursorMovedI * call UpdateCombo() " Every time the cursor moves, call combo function
|
||||
function! ResetCombo()
|
||||
let g:combo_counter = 0
|
||||
call writefile(0, "$HOME/.vim/.combo")
|
||||
endfunction
|
||||
|
||||
" NOT NECESSARY! Only enable if you find yourself cheating!
|
||||
" NOT NECESSARY! Only enable if you find yourself cheating by staying in insert mode!
|
||||
" inoremap <Left> <C-o>:let g:combo_counter=0<CR><Left>
|
||||
" inoremap <Right> <C-o>:let g:combo_counter=0<CR><Right>
|
||||
" inoremap <Up> <C-o>:let g:combo_counter=0<CR><Up>
|
||||
" inoremap <Down> <C-o>:let g:combo_counter=0<CR><Down>
|
||||
endif
|
||||
|
|
Loading…
Reference in a new issue