prompt for api key after first buffer window has opened, because MacVim hangs forever waiting for user input before opening a buffer.
This commit is contained in:
parent
7936938364
commit
28ec37cab4
1 changed files with 16 additions and 12 deletions
|
@ -39,15 +39,6 @@ let s:VERSION = '3.0.5'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Create config file if does not exist
|
|
||||||
if !filereadable(expand("$HOME/.wakatime.cfg"))
|
|
||||||
let key = input("[WakaTime] Enter your wakatime.com api key: ")
|
|
||||||
if key != ''
|
|
||||||
call writefile(['[settings]', 'debug = false', printf("api_key = %s", key), 'hidefilenames = false', 'ignore =', ' ^COMMIT_EDITMSG$', ' ^TAG_EDITMSG$'], expand("$HOME/.wakatime.cfg"))
|
|
||||||
echo "[WakaTime] Setup complete! Visit http://wakatime.com to view your logged time."
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Set default action frequency in minutes
|
" Set default action frequency in minutes
|
||||||
if !exists("g:wakatime_ActionFrequency")
|
if !exists("g:wakatime_ActionFrequency")
|
||||||
let g:wakatime_ActionFrequency = 2
|
let g:wakatime_ActionFrequency = 2
|
||||||
|
@ -55,14 +46,27 @@ let s:VERSION = '3.0.5'
|
||||||
|
|
||||||
" Globals
|
" Globals
|
||||||
let s:plugin_directory = expand("<sfile>:p:h") . '/'
|
let s:plugin_directory = expand("<sfile>:p:h") . '/'
|
||||||
let s:last_action = 0
|
let s:config_file_exists = 0
|
||||||
let s:fresh = 1
|
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
|
|
||||||
" Function Definitions {{{
|
" Function Definitions {{{
|
||||||
|
|
||||||
|
function! s:SetupConfigFile()
|
||||||
|
if !s:config_file_exists
|
||||||
|
" Create config file if does not exist
|
||||||
|
if !filereadable(expand("$HOME/.wakatime.cfg"))
|
||||||
|
let key = input("[WakaTime] Enter your wakatime.com api key: ")
|
||||||
|
if key != ''
|
||||||
|
call writefile(['[settings]', 'debug = false', printf("api_key = %s", key), 'hidefilenames = false', 'ignore =', ' ^COMMIT_EDITMSG$', ' ^TAG_EDITMSG$'], expand("$HOME/.wakatime.cfg"))
|
||||||
|
echo "[WakaTime] Setup complete! Visit http://wakatime.com to view your logged time."
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
let s:config_file_exists = 1
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:GetCurrentFile()
|
function! s:GetCurrentFile()
|
||||||
return expand("%:p")
|
return expand("%:p")
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -105,7 +109,6 @@ let s:VERSION = '3.0.5'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:SetLastAction(time, last_update, targetFile)
|
function! s:SetLastAction(time, last_update, targetFile)
|
||||||
let s:fresh = 0
|
|
||||||
call writefile([substitute(printf('%d', a:time), ',', '.', ''), substitute(printf('%d', a:last_update), ',', '.', ''), a:targetFile], expand("$HOME/.wakatime.data"))
|
call writefile([substitute(printf('%d', a:time), ',', '.', ''), substitute(printf('%d', a:last_update), ',', '.', ''), a:targetFile], expand("$HOME/.wakatime.data"))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -131,6 +134,7 @@ let s:VERSION = '3.0.5'
|
||||||
" Event Handlers {{{
|
" Event Handlers {{{
|
||||||
|
|
||||||
function! s:normalAction()
|
function! s:normalAction()
|
||||||
|
call s:SetupConfigFile()
|
||||||
let targetFile = s:GetCurrentFile()
|
let targetFile = s:GetCurrentFile()
|
||||||
let now = localtime()
|
let now = localtime()
|
||||||
let last = s:GetLastAction()
|
let last = s:GetLastAction()
|
||||||
|
|
Loading…
Reference in a new issue