commit 9f8b0082dbd99e706cc18de2076f7a66c2ca0a90
parent f60923eaa3acd712fefe75ee424e676f61d2b140
Author: Michael F. Schönitzer <michael@schoenitzer.de>
Date: Tue, 12 Jun 2018 20:55:56 +0200
Add a command that shows the version or commit
Ref #512
Diffstat:
1 file changed, 24 insertions(+), 0 deletions(-)
diff --git a/plugin/vimwiki.vim b/plugin/vimwiki.vim
@@ -9,6 +9,11 @@ if exists("g:loaded_vimwiki") || &cp
endif
let g:loaded_vimwiki = 1
+" Set to version number for release, otherwise -1 for dev-branch
+let s:plugin_vers = -1
+
+" Get the directory the script is installed in
+let s:plugin_dir = expand('<sfile>:p:h:h')
let s:old_cpo = &cpo
set cpo&vim
@@ -186,6 +191,23 @@ function! s:set_windowlocal_options()
endfunction
+function! s:get_version()
+ if s:plugin_vers != -1
+ echo "Stable version: " . s:plugin_vers
+ else
+ let a:plugin_rev = system("git --git-dir " . s:plugin_dir . "/.git rev-parse --short HEAD")
+ let a:plugin_branch = system("git --git-dir " . s:plugin_dir . "/.git rev-parse --abbrev-ref HEAD")
+ let a:plugin_date = system("git --git-dir " . s:plugin_dir . "/.git show -s --format=%ci")
+ if v:shell_error == 0
+ echo "Branch: " . a:plugin_branch
+ echo "Revision: " . a:plugin_rev
+ echo "Date: " . a:plugin_date
+ else
+ echo "Unknown version"
+ endif
+ endif
+endfunction
+
" Initialization of Vimwiki starts here. Make sure everything below does not
@@ -279,6 +301,8 @@ command! -count=1 VimwikiMakeTomorrowDiaryNote
command! VimwikiDiaryGenerateLinks
\ call vimwiki#diary#generate_diary_section()
+command! VimwikiShowVersion call s:get_version()
+
let s:map_prefix = vimwiki#vars#get_global('map_prefix')