forked from luna/vim-rana-local
improve setting updatetime
This commit is contained in:
parent
61b18c06f4
commit
a2e10e1386
1 changed files with 21 additions and 3 deletions
|
@ -5,6 +5,7 @@
|
||||||
" Version: 0.1.2
|
" Version: 0.1.2
|
||||||
" ============================================================================
|
" ============================================================================
|
||||||
|
|
||||||
|
|
||||||
" Init {{{
|
" Init {{{
|
||||||
|
|
||||||
" Check Vim version
|
" Check Vim version
|
||||||
|
@ -46,9 +47,9 @@ set cpo&vim
|
||||||
|
|
||||||
let s:plugin_directory = expand("<sfile>:p:h")
|
let s:plugin_directory = expand("<sfile>:p:h")
|
||||||
|
|
||||||
" Set a nice updatetime value, if updatetime is too short
|
" Set default updatetime
|
||||||
if &updatetime < 60 * 1000 * 2
|
if !exists("g:wakatime_updatetime")
|
||||||
let &updatetime = 60 * 1000 * 15 " 15 minutes
|
let g:wakatime_updatetime = 15 " 15 minutes
|
||||||
endif
|
endif
|
||||||
|
|
||||||
python << ENDPYTHON
|
python << ENDPYTHON
|
||||||
|
@ -62,6 +63,7 @@ ENDPYTHON
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
|
|
||||||
" Function Definitions {{{
|
" Function Definitions {{{
|
||||||
|
|
||||||
function! s:initVariable(var, value)
|
function! s:initVariable(var, value)
|
||||||
|
@ -72,6 +74,12 @@ function! s:initVariable(var, value)
|
||||||
return 0
|
return 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:setUpdateTime()
|
||||||
|
if &updatetime < 60 * 1000 * 2
|
||||||
|
let &updatetime = g:wakatime_updatetime * 60 * 1000
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:GetCurrentFile()
|
function! s:GetCurrentFile()
|
||||||
return expand("%:p")
|
return expand("%:p")
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -94,6 +102,7 @@ endfunction
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
|
|
||||||
" Event Handlers {{{
|
" Event Handlers {{{
|
||||||
|
|
||||||
function! s:bufenter()
|
function! s:bufenter()
|
||||||
|
@ -132,6 +141,10 @@ function! s:cursormoved()
|
||||||
python vim.command("let away_end=%f" % time.time())
|
python vim.command("let away_end=%f" % time.time())
|
||||||
let away_unit = "minutes"
|
let away_unit = "minutes"
|
||||||
let away_duration = (away_end - s:away_start) / 60
|
let away_duration = (away_end - s:away_start) / 60
|
||||||
|
if away_duration < 2
|
||||||
|
call s:setUpdateTime()
|
||||||
|
return
|
||||||
|
endif
|
||||||
if away_duration > 59
|
if away_duration > 59
|
||||||
let away_duration = away_duration / 60
|
let away_duration = away_duration / 60
|
||||||
let away_unit = "hours"
|
let away_unit = "hours"
|
||||||
|
@ -153,6 +166,10 @@ endfunction
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
|
|
||||||
|
call s:setUpdateTime()
|
||||||
|
|
||||||
|
|
||||||
" Autocommand Events {{{
|
" Autocommand Events {{{
|
||||||
|
|
||||||
augroup Wakatime
|
augroup Wakatime
|
||||||
|
@ -167,5 +184,6 @@ augroup END
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
|
|
||||||
" Restore cpoptions
|
" Restore cpoptions
|
||||||
let &cpo = s:old_cpo
|
let &cpo = s:old_cpo
|
||||||
|
|
Loading…
Reference in a new issue