eww why airline, very much more generic now
This commit is contained in:
parent
cd6ac810fc
commit
27315a1f8a
3 changed files with 50 additions and 49 deletions
17
README.md
17
README.md
|
@ -1,17 +1,18 @@
|
|||
# vim-combo
|
||||
Have you ever wondered how sick is your function typing? That insane very long lambda you just written in one go must have been a hell of a combo, shame it wasn't tracked.
|
||||
Have you ever wanted to obsessively classify your performance against know people of yours with a not-really-so-relevant score in different languages?
|
||||
This plugin comes right to the rescue: it keeps track of a "combo" counter that increases every time you press a key. Waiting for too long resets such counter.
|
||||
Deleting won't increase your combo but it will reset the timer. By default, the timer is 1 second. It may seem tight but longer timers lead to incredibly big combos too easily.
|
||||
Pasting counts as 1 (be it in Insert-Paste or directly from clipboard), movement does not affect the counter.
|
||||
|
||||
Wasn't until now! vim-combo is inspired by the power-mode many more graphical editors have. While all the particles and text shaking is nice, the thing I really wanted was to keep track of my typing combos.
|
||||
So here comes vim-combo! Each text edit in insert mode (autocmd on TextChangedI) increases the counter. The counter gets resetted if you type nothing for more than a second (you can set it to any number of seconds with g:timeout)
|
||||
vim-combo is inspired by the power-mode many more graphical editors have. While all the particles and text shaking is nice, the thing I really wanted was to keep track of my typing combos.
|
||||
It uses a function called on buffer change (autocmd on TextChangedI) to increases the counter. Current time is checked every time against last best time.
|
||||
|
||||
Pasting counts as 1 (be it in Insert-Paste or directly from clipboard), movement does not affect the counter and backspace keeps the combo going without increasing the counter.
|
||||
|
||||
vim-combo keeps track of your best combos for each filetype with files inside the hidden .combo folder (~/.vim/.combo). Every time vim loads, the best combo is loaded from file (one is kept for each filetype edited). Every time you get a new best score, the value on file is replaced. vim-combo also calculates the best combo across all filetypes, but it is not displayed by default (because my combo on .txt puts my combo on .c to shame). Use ```:ComboMaxOn, :ComboMaxOff``` to toggle.
|
||||
vim-combo keeps track of your best combos for each filetype with files inside the hidden .combo folder (~/.vim/.combo). Every time vim loads, the best combo is loaded from file (one is kept for each filetype edited). Every time you get a new best score, the value on file is replaced.
|
||||
|
||||
There already are few plugins which provide particles (vim-particle, vim-power-mode) but they required windows. vim-combo can run on any system since it's only vim script!
|
||||
|
||||
Note that vim-combo by default places the counter in section B of airline-vim. All combos will be always tracked, but by default not displayed (as of now) unless you use airline-vim. You can add ```%1*\[%{g:best_combo_all}|%{g:best_combo}\] %{g:combo_counter} ᛥ``` anywhere you'd like. If you know a good spot to place it by default, do contact me! I have no idea!
|
||||
If you just load this with a plugin manager, your combo will be tracked but not displayed anywhere. Current combo string is kept in `g:combo`, you can place it anywhere you'd like. If you don't have specific statusbar edits, you can add `set statusline=%{g:combo}` in your `.vimrc`.
|
||||
|
||||
Specific filetypes can be ignored (no combo will be counted while on them, and no best combo will be recorded). By default, .cmb files won't track combo. Note that none.cmb refers to files without extension, and should be in place (because the script does not create it).
|
||||
Specific filetypes can be ignored (no combo will be counted while on them, and no best combo will be recorded). By default, .cmb files won't track combo. Note that none.cmb refers to files without extension, and should be in place.
|
||||
|
||||
vim-combo should be pretty fast. It runs a lot but does very little (time difference, counter). If you have any issue contact me!
|
||||
|
|
|
@ -1,20 +1,30 @@
|
|||
*vim-combo.txt* Tracks keypresses in vim to build up combos
|
||||
________________________________________________________________________________________________________/\\\______________________
|
||||
________________________________________________________________________________________________________\/\\\______________________
|
||||
__________________/\\\___________________________________________________________________________________\/\\\______________________
|
||||
_____/\\\____/\\\_\///_____/\\\\\__/\\\\\____/\\\\\\\\\\\_____/\\\\\\\\_____/\\\\\_______/\\\\\__/\\\\\___\/\\\____________/\\\\\____
|
||||
_____\//\\\__/\\\___/\\\__/\\\///\\\\\///\\\_\///////////____/\\\//////____/\\\///\\\___/\\\///\\\\\///\\\_\/\\\\\\\\\____/\\\///\\\__
|
||||
_______\//\\\/\\\___\/\\\_\/\\\_\//\\\__\/\\\________________/\\\__________/\\\__\//\\\_\/\\\_\//\\\__\/\\\_\/\\\////\\\__/\\\__\//\\\_
|
||||
_________\//\\\\\____\/\\\_\/\\\__\/\\\__\/\\\_______________\//\\\________\//\\\__/\\\__\/\\\__\/\\\__\/\\\_\/\\\__\/\\\_\//\\\__/\\\__
|
||||
___________\//\\\_____\/\\\_\/\\\__\/\\\__\/\\\________________\///\\\\\\\\__\///\\\\\/___\/\\\__\/\\\__\/\\\_\/\\\\\\\\\___\///\\\\\/___
|
||||
_____________\///______\///__\///___\///___\///___________________\////////_____\/////_____\///___\///___\///__\/////////______\/////_____
|
||||
===========================================================================================================================================
|
||||
_______________________________________________________________
|
||||
________________________________________________________________
|
||||
__________________/\\\___________________________________________
|
||||
_____/\\\____/\\\_\///_____/\\\\\__/\\\\\_________________________
|
||||
_____\//\\\__/\\\___/\\\__/\\\///\\\\\///\\\_______________________
|
||||
_______\//\\\/\\\___\/\\\_\/\\\_\//\\\__\/\\\_______________________
|
||||
_________\//\\\\\____\/\\\_\/\\\__\/\\\__\/\\\_______________________
|
||||
___________\//\\\_____\/\\\_\/\\\__\/\\\__\/\\\_______________________
|
||||
_____________\///______\///__\///___\///___\///________________________
|
||||
______________________________________________/\\\______________________
|
||||
______________________________________________\/\\\______________________
|
||||
_______________________________________________\/\\\______________________
|
||||
____/\\\\\\\\_____/\\\\\_______/\\\\\__/\\\\\___\/\\\____________/\\\\\____
|
||||
___/\\\//////____/\\\///\\\___/\\\///\\\\\///\\\_\/\\\\\\\\\____/\\\///\\\__
|
||||
___/\\\__________/\\\__\//\\\_\/\\\_\//\\\__\/\\\_\/\\\////\\\__/\\\__\//\\\_
|
||||
___\//\\\________\//\\\__/\\\__\/\\\__\/\\\__\/\\\_\/\\\__\/\\\_\//\\\__/\\\__
|
||||
_____\///\\\\\\\\__\///\\\\\/___\/\\\__\/\\\__\/\\\_\/\\\\\\\\\___\///\\\\\/___
|
||||
________\////////_____\/////_____\///___\///___\///__\/////////______\/////_____
|
||||
=================================================================================
|
||||
|
||||
Each keystroke in insert mode increases your combo,
|
||||
but not typing for 1 second resets it.
|
||||
but not typing for 1 second (configurable) resets it.
|
||||
The script is triggered whenever a text edit is detected in insert mode.
|
||||
|
||||
Progress is tracked per filetype (and stored in ~/.vim/.combo/).
|
||||
By default inside the block B of airline vim a string x\|y\|z is
|
||||
By defa
|
||||
displayed, where
|
||||
x is the current score
|
||||
y is the best score for this filetype
|
||||
|
@ -22,12 +32,23 @@ displayed, where
|
|||
When a new high score is achieved, it is automatically saved.
|
||||
Each 10 points increases a combo bar next to the scores
|
||||
|
||||
If you get errors at launch, check that .combo folder exists. A none.cmb
|
||||
file should already be inside, create it if it is missing and place a 0
|
||||
inside.
|
||||
A string with your current score and your best score is kept in g:combo.
|
||||
You can at any time show your score by running
|
||||
:echo g:combo
|
||||
If you have a custom statusline, you can show current combo score there by
|
||||
displaying g:combo. You can access best combo in g:combo_best and current
|
||||
score in g:combo_counter, display them how you prefer.
|
||||
|
||||
If you just want to show your combo you can add
|
||||
set statusline=%{g:combo}
|
||||
to your .vimrc, but a plain statusline won't look very nice by itself.
|
||||
|
||||
You can change g:timeout to increase or decrease combo timeout.
|
||||
|
||||
If you get errors at launch, check wether you have a .vim folder in your home
|
||||
folder and wether a .combo folder exists inside.
|
||||
|
||||
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!
|
||||
There is a github (https://github.com/alemigliardi/vim-combo).
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
|
|
|
@ -25,7 +25,7 @@ endfor
|
|||
|
||||
" If file should be ignored, just set text, else continue with script
|
||||
if g:disable_combo
|
||||
let g:airline_section_b = airline#section#create(['[%{g:best_combo_all}] - ᛥ'])
|
||||
let g:combo = "N/A"
|
||||
else
|
||||
" Find best score for current filetype. If none exists, start tracking
|
||||
if filereadable(g:combo_file)
|
||||
|
@ -40,13 +40,8 @@ else
|
|||
" Configure variables
|
||||
let g:combo_counter = 0 " The actual combo variable
|
||||
let g:timeout = 1
|
||||
let g:combo = printf("[%d] 0", g:best_combo)
|
||||
let g:last_combo = reltime() " Set current time as last combo time
|
||||
hi User1 ctermfg=247 ctermbg=237
|
||||
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#'
|
||||
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
|
||||
let g:airline_section_b = airline#section#create([g:status])
|
||||
" Main check function, executed every time the file is changed
|
||||
function! UpdateCombo()
|
||||
if reltimefloat(reltime(g:last_combo)) > g:timeout
|
||||
|
@ -55,7 +50,7 @@ else
|
|||
else
|
||||
let g:combo_counter +=1
|
||||
endif
|
||||
call UpdateColor()
|
||||
let g:combo = printf("[%d] %d", g:best_combo, g:combo_counter)
|
||||
let g:last_combo = reltime()
|
||||
endfunction
|
||||
" Checks if a new combo has been achieved and saves it to file
|
||||
|
@ -66,22 +61,6 @@ else
|
|||
let g:best_combo = g:combo_counter
|
||||
endif
|
||||
endfunction
|
||||
" 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
|
||||
hi User1 ctermfg=247 ctermbg=237
|
||||
elseif g:combo_counter == 10
|
||||
hi User1 ctermfg=2 ctermbg=237
|
||||
elseif g:combo_counter == 30
|
||||
hi User1 ctermfg=6 ctermbg=237
|
||||
elseif g:combo_counter == 50
|
||||
hi User1 ctermfg=5 ctermbg=237
|
||||
elseif g:combo_counter == 70
|
||||
hi User1 ctermfg=3 ctermbg=237
|
||||
elseif g:combo_counter == 100
|
||||
hi User1 ctermfg=1 ctermbg=237
|
||||
endif
|
||||
endfunction
|
||||
|
||||
autocmd TextChangedI * call UpdateCombo() " Every time text is changed, call combo function
|
||||
autocmd InsertLeave * call SaveCombo()
|
||||
|
|
Loading…
Reference in a new issue