New g:wakatime_OverrideCommandPrefix setting

This commit is contained in:
Alan Hamlett 2018-05-25 06:50:30 -07:00
parent f98bb02423
commit 3d88d49551
2 changed files with 18 additions and 3 deletions

View File

@ -48,6 +48,13 @@ Configuring
Tells the plugin to use a custom python binary.
The default is to use `python` from your system PATH.
let g:wakatime_OverrideCommandPrefix = '/usr/bin/wakatime' " (Default: '')
Overrides the WakaTime CLI command prefix. You might need this when running
[wakatime-cli][wakatime-cli] with a custom wrapper script or from the pip
installed binary. Normally, the bundled [wakatime-cli][wakatime-cli] is used
so this setting is not needed.
WakaTime plugins also share a common `~/.wakatime.cfg` config file. [See common configs...][wakatime-cli-config]

View File

@ -309,6 +309,16 @@ let s:VERSION = '7.1.1'
return python_bin
endfunction
function! s:GetCommandPrefix()
if exists("g:wakatime_OverrideCommandPrefix") && g:wakatime_OverrideCommandPrefix
let prefix = [g:wakatime_OverrideCommandPrefix]
else
let python_bin = s:GetPythonBinary()
let prefix = [python_bin, '-W', 'ignore', s:cli_location]
endif
return prefix
endfunction
function! s:SendHeartbeats()
let start_time = localtime()
let stdout = ''
@ -326,9 +336,7 @@ let s:VERSION = '7.1.1'
let extra_heartbeats = ''
endif
let python_bin = s:GetPythonBinary()
let cmd = [python_bin, '-W', 'ignore', s:cli_location]
let cmd = cmd + ['--entity', heartbeat.entity]
let cmd = s:GetCommandPrefix() + ['--entity', heartbeat.entity]
let cmd = cmd + ['--time', heartbeat.time]
let cmd = cmd + ['--plugin', printf('vim/%s vim-wakatime/%s', s:n2s(v:version), s:VERSION)]
if heartbeat.is_write