Skip to content

Commit

Permalink
Run python code without vim file to avoid spaces in file path
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhamlett committed Dec 11, 2021
1 parent 5e92269 commit 137b19b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 38 deletions.
23 changes: 11 additions & 12 deletions plugin/wakatime.vim
Original file line number Diff line number Diff line change
Expand Up @@ -191,41 +191,40 @@ let s:VERSION = '9.0.1'
let stdout = system(s:JoinArgs(cmd) . ' &')
endif
endif
elseif executable(v:progname) && (has('python3') || has('python'))
call s:InstallCLIRoundAbout()
elseif has('python3')
if executable(v:progname)
call s:InstallCLIRoundAbout()
else
python3 << EOF
python3 << EOF
import sys
import vim
from os.path import abspath, join
sys.path.insert(0, abspath(join(vim.eval('s:plugin_root_folder'), 'scripts')))
from install_cli import main
main(home=vim.eval('s:home'))
EOF
endif
elseif has('python')
if executable(v:progname)
call s:InstallCLIRoundAbout()
else
python << EOF
python << EOF
import sys
import vim
from os.path import abspath, join
sys.path.insert(0, abspath(join(vim.eval('s:plugin_root_folder'), 'scripts')))
from install_cli import main
main(home=vim.eval('s:home'))
EOF
endif
elseif !filereadable(s:wakatime_cli)
let url = printf('https://github.com/wakatime/wakatime-cli/releases/latest/download/wakatime-cli-%s-%s.zip', s:osname, s:architecture)
echo printf("Download wakatime-cli and extract into the ~/.wakatime/ folder:\n%s", url)
endif
endfunction

function! s:InstallCLIRoundAbout()
let install_script = s:plugin_root_folder . '/scripts/install.vim'
let cmd = [v:progname, '-u', 'NONE', '-c', 'source ' . install_script, '+qall']
if has('python3')
let py = 'python3'
else
let py = 'python'
endif
let code = py . " import sys, vim;from os.path import abspath, join;sys.path.insert(0, abspath(join('" . s:plugin_root_folder . "', 'scripts')));from install_cli import main;main(home='" . s:home . "');"
let cmd = [v:progname, '-u', 'NONE', '-c', code, '+qall']
if s:has_async
if s:IsWindows()
let job_cmd = [&shell, &shellcmdflag] + cmd
Expand Down
26 changes: 0 additions & 26 deletions scripts/install.vim

This file was deleted.

0 comments on commit 137b19b

Please sign in to comment.