From 6c21f85332c9b120122e0d0811a2beb85c99bd23 Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Tue, 7 May 2019 01:02:39 -0700 Subject: [PATCH] New command :WakaTimeToday for displaying today's coding time --- README.md | 3 ++- plugin/wakatime.vim | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0205d64..c23799c 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Installation Or with [Vim-plug](https://github.com/junegunn/vim-plug): add `Plug 'wakatime/vim-wakatime'` to .vimrc file. While in vim reload .vimrc with `:so ~/.vimrc` or restart vim, enter `:PlugInstall`. -2. Enter your [api key](https://wakatime.com/settings#apikey), then press `enter`. +2. Enter your [api key](https://wakatime.com/settings#apikey), then press `enter`. 3. Use Vim and your coding activity will be displayed on your [WakaTime dashboard](https://wakatime.com). @@ -43,6 +43,7 @@ Configuring * `:WakaTimeScreenRedrawEnable` - enable screen redraw to prevent artifacts (only for Vim < 8.0) * `:WakaTimeScreenRedrawEnableAuto` - redraw screen when plugin takes too long (only for Vim < 8.0) * `:WakaTimeScreenRedrawDisable` - disable screen redraw +* `:WakaTimeToday` - echo your total coding activity for Today #### Vimrc Settings: diff --git a/plugin/wakatime.vim b/plugin/wakatime.vim index cccb529..6278646 100644 --- a/plugin/wakatime.vim +++ b/plugin/wakatime.vim @@ -118,6 +118,10 @@ let s:VERSION = '7.1.5' return substitute(a:str, '^\s*\(.\{-}\)\s*$', '\1', '') endfunction + function! s:Chomp(str) + return substitute(a:str, '\n\+$', '', '') + endfunction + function! s:SetupConfigFile() if !s:config_file_already_setup @@ -588,6 +592,11 @@ let s:VERSION = '7.1.5' endif endfunction + function! g:WakaTimeToday() + let cmd = s:GetCommandPrefix() + ['--show-time-today'] + echo "Today: " . s:Chomp(system(s:JoinArgs(cmd))) + endfunction + " }}} @@ -616,6 +625,7 @@ call s:Init() :command -nargs=0 WakaTimeScreenRedrawDisable call s:DisableScreenRedraw() :command -nargs=0 WakaTimeScreenRedrawEnable call s:EnableScreenRedraw() :command -nargs=0 WakaTimeScreenRedrawEnableAuto call s:EnableScreenRedrawAuto() + :command -nargs=0 WakaTimeToday call g:WakaTimeToday() " }}}