diff --git a/README.md b/README.md index 1cc2a3b..d96a8dd 100644 --- a/README.md +++ b/README.md @@ -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] diff --git a/plugin/wakatime.vim b/plugin/wakatime.vim index dca480d..0da8f77 100644 --- a/plugin/wakatime.vim +++ b/plugin/wakatime.vim @@ -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