fix #1 by removing all python code from the vim script
This commit is contained in:
parent
cbe12f887c
commit
25e7405794
1 changed files with 6 additions and 22 deletions
|
@ -15,12 +15,6 @@ let s:VERSION = '1.4.0'
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Check for Python support
|
|
||||||
if !has('python')
|
|
||||||
echoerr "This plugin requires Vim to be compiled with Python support."
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Only load plugin once
|
" Only load plugin once
|
||||||
if exists("g:loaded_wakatime")
|
if exists("g:loaded_wakatime")
|
||||||
finish
|
finish
|
||||||
|
@ -62,10 +56,6 @@ let s:VERSION = '1.4.0'
|
||||||
let s:last_action = 0
|
let s:last_action = 0
|
||||||
let s:fresh = 1
|
let s:fresh = 1
|
||||||
|
|
||||||
" Import things python needs
|
|
||||||
python import time
|
|
||||||
python import vim
|
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,11 +65,6 @@ let s:VERSION = '1.4.0'
|
||||||
return expand("%:p")
|
return expand("%:p")
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:GetCurrentTime()
|
|
||||||
python vim.command('let current_time=%f' % time.time())
|
|
||||||
return current_time
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:Api(targetFile, time, is_write, last)
|
function! s:Api(targetFile, time, is_write, last)
|
||||||
let targetFile = a:targetFile
|
let targetFile = a:targetFile
|
||||||
if targetFile == ''
|
if targetFile == ''
|
||||||
|
@ -88,7 +73,6 @@ let s:VERSION = '1.4.0'
|
||||||
if targetFile != ''
|
if targetFile != ''
|
||||||
let cmd = ['python', '-W', 'ignore', s:plugin_directory . 'packages/wakatime/wakatime-cli.py']
|
let cmd = ['python', '-W', 'ignore', s:plugin_directory . 'packages/wakatime/wakatime-cli.py']
|
||||||
let cmd = cmd + ['--file', shellescape(targetFile)]
|
let cmd = cmd + ['--file', shellescape(targetFile)]
|
||||||
let cmd = cmd + ['--time', substitute(printf('%f', a:time), ',', '.', '')]
|
|
||||||
let cmd = cmd + ['--plugin', printf('vim-wakatime/%s', s:VERSION)]
|
let cmd = cmd + ['--plugin', printf('vim-wakatime/%s', s:VERSION)]
|
||||||
if a:is_write
|
if a:is_write
|
||||||
let cmd = cmd + ['--write']
|
let cmd = cmd + ['--write']
|
||||||
|
@ -101,18 +85,18 @@ let s:VERSION = '1.4.0'
|
||||||
|
|
||||||
function! s:GetLastAction()
|
function! s:GetLastAction()
|
||||||
if !filereadable(expand("$HOME/.wakatime.data"))
|
if !filereadable(expand("$HOME/.wakatime.data"))
|
||||||
return [0.0, '', 0.0]
|
return [0, 0, '']
|
||||||
endif
|
endif
|
||||||
let last = readfile(expand("$HOME/.wakatime.data"), '', 3)
|
let last = readfile(expand("$HOME/.wakatime.data"), '', 3)
|
||||||
if len(last) != 3
|
if len(last) != 3
|
||||||
return [0.0, '', 0.0]
|
return [0, 0, '']
|
||||||
endif
|
endif
|
||||||
return [str2float(last[0]), str2float(last[1]), last[2]]
|
return last
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:SetLastAction(time, last_update, targetFile)
|
function! s:SetLastAction(time, last_update, targetFile)
|
||||||
let s:fresh = 0
|
let s:fresh = 0
|
||||||
call writefile([substitute(printf('%f', a:time), ',', '.', ''), substitute(printf('%f', 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
|
||||||
|
|
||||||
function! s:GetChar()
|
function! s:GetChar()
|
||||||
|
@ -138,7 +122,7 @@ let s:VERSION = '1.4.0'
|
||||||
|
|
||||||
function! s:normalAction()
|
function! s:normalAction()
|
||||||
let targetFile = s:GetCurrentFile()
|
let targetFile = s:GetCurrentFile()
|
||||||
let now = s:GetCurrentTime()
|
let now = localtime()
|
||||||
let last = s:GetLastAction()
|
let last = s:GetLastAction()
|
||||||
if s:EnoughTimePassed(now, last) || targetFile != last[2]
|
if s:EnoughTimePassed(now, last) || targetFile != last[2]
|
||||||
call s:Api(targetFile, now, 0, last)
|
call s:Api(targetFile, now, 0, last)
|
||||||
|
@ -151,7 +135,7 @@ let s:VERSION = '1.4.0'
|
||||||
|
|
||||||
function! s:writeAction()
|
function! s:writeAction()
|
||||||
let targetFile = s:GetCurrentFile()
|
let targetFile = s:GetCurrentFile()
|
||||||
let now = s:GetCurrentTime()
|
let now = localtime()
|
||||||
let last = s:GetLastAction()
|
let last = s:GetLastAction()
|
||||||
call s:Api(targetFile, now, 1, last)
|
call s:Api(targetFile, now, 1, last)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
Loading…
Reference in a new issue