forked from luna/vim-rana-local
Use constants for truthy check to improve readability
This commit is contained in:
parent
32ddefaf2a
commit
5163804e71
1 changed files with 16 additions and 12 deletions
|
@ -17,11 +17,15 @@ let s:VERSION = '4.0.14'
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Use constants for truthy check to improve readability
|
||||||
|
let s:true = 1
|
||||||
|
let s:false = 0
|
||||||
|
|
||||||
" Only load plugin once
|
" Only load plugin once
|
||||||
if exists("g:loaded_wakatime")
|
if exists("g:loaded_wakatime")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let g:loaded_wakatime = 1
|
let g:loaded_wakatime = s:true
|
||||||
|
|
||||||
" Backup & Override cpoptions
|
" Backup & Override cpoptions
|
||||||
let s:old_cpo = &cpo
|
let s:old_cpo = &cpo
|
||||||
|
@ -31,8 +35,8 @@ let s:VERSION = '4.0.14'
|
||||||
let s:cli_location = expand("<sfile>:p:h") . '/packages/wakatime/cli.py'
|
let s:cli_location = expand("<sfile>:p:h") . '/packages/wakatime/cli.py'
|
||||||
let s:config_file = expand("$HOME/.wakatime.cfg")
|
let s:config_file = expand("$HOME/.wakatime.cfg")
|
||||||
let s:data_file = expand("$HOME/.wakatime.data")
|
let s:data_file = expand("$HOME/.wakatime.data")
|
||||||
let s:config_file_already_setup = 0
|
let s:config_file_already_setup = s:false
|
||||||
let s:local_cache_expire = 10
|
let s:local_cache_expire = 10 " seconds between reading s:data_file
|
||||||
let s:last_heartbeat = [0, 0, '']
|
let s:last_heartbeat = [0, 0, '']
|
||||||
|
|
||||||
" For backwards compatibility, rename wakatime.conf to wakatime.cfg
|
" For backwards compatibility, rename wakatime.conf to wakatime.cfg
|
||||||
|
@ -81,12 +85,12 @@ let s:VERSION = '4.0.14'
|
||||||
|
|
||||||
" Make sure config file has api_key
|
" Make sure config file has api_key
|
||||||
else
|
else
|
||||||
let found_api_key = 0
|
let found_api_key = s:false
|
||||||
let lines = readfile(s:config_file)
|
let lines = readfile(s:config_file)
|
||||||
for line in lines
|
for line in lines
|
||||||
let group = split(line, '=')
|
let group = split(line, '=')
|
||||||
if len(group) == 2 && s:StripWhitespace(group[0]) == 'api_key' && s:StripWhitespace(group[1]) != ''
|
if len(group) == 2 && s:StripWhitespace(group[0]) == 'api_key' && s:StripWhitespace(group[1]) != ''
|
||||||
let found_api_key = 1
|
let found_api_key = s:true
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
if !found_api_key
|
if !found_api_key
|
||||||
|
@ -97,7 +101,7 @@ let s:VERSION = '4.0.14'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let s:config_file_already_setup = 1
|
let s:config_file_already_setup = s:true
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -177,9 +181,9 @@ let s:VERSION = '4.0.14'
|
||||||
function! s:EnoughTimePassed(now, last)
|
function! s:EnoughTimePassed(now, last)
|
||||||
let prev = a:last[1]
|
let prev = a:last[1]
|
||||||
if a:now - prev > g:wakatime_HeartbeatFrequency * 60
|
if a:now - prev > g:wakatime_HeartbeatFrequency * 60
|
||||||
return 1
|
return s:true
|
||||||
endif
|
endif
|
||||||
return 0
|
return s:false
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
@ -210,10 +214,10 @@ let s:VERSION = '4.0.14'
|
||||||
|
|
||||||
augroup Wakatime
|
augroup Wakatime
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufEnter * call s:handleActivity(0)
|
autocmd BufEnter * call s:handleActivity(s:false)
|
||||||
autocmd VimEnter * call s:handleActivity(0)
|
autocmd VimEnter * call s:handleActivity(s:false)
|
||||||
autocmd BufWritePost * call s:handleActivity(1)
|
autocmd BufWritePost * call s:handleActivity(s:true)
|
||||||
autocmd CursorMoved,CursorMovedI * call s:handleActivity(0)
|
autocmd CursorMoved,CursorMovedI * call s:handleActivity(s:false)
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
Loading…
Reference in a new issue