From a15ad8b98e50bca3e89c1e669ced698dc135297d Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sat, 1 Jan 2022 22:30:05 +0800 Subject: [PATCH] feat(help): add key binding to display current time close https://github.com/SpaceVim/SpaceVim/issues/4510 --- autoload/SpaceVim/mapping/space.vim | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index e47b1ab29..9ec5f0357 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -7,6 +7,7 @@ "============================================================================= let s:BUF = SpaceVim#api#import('vim#buffer') +let s:TIME = SpaceVim#api#import('time') let s:file = expand(':~') let s:funcbeginline = expand('') + 1 @@ -579,6 +580,17 @@ function! SpaceVim#mapping#space#init() abort call SpaceVim#mapping#space#def('nnoremap', ['h', 'd', 'k'], \ 'call SpaceVim#plugins#help#describe_key()', \ 'describe-key-bindings', 1) + let s:lnum = expand('') + 3 + call SpaceVim#mapping#space#def('nnoremap', ['h', 'd', 't'], 'call call(' + \ . string(function('s:describe_current_time')) + \ . ', [])', ['describe-current-time', + \ [ + \ 'SPC h d t is to display current time.', + \ '', + \ 'Definition: ' . s:file . ':' . s:lnum, + \ ] + \ ] + \ , 1) call SpaceVim#custom#SPC('nnoremap', ['a', 'o'], 'call SpaceVim#plugins#todo#list()', 'open-todo-manager', 1) endfunction @@ -800,6 +812,11 @@ function! s:previous_buffer() abort endtry endfunction +function! s:describe_current_time() abort + let time = s:TIME.current_date() . ' ' . s:TIME.current_time() + echo time +endfunction + " function() wrapper if v:version > 703 || v:version == 703 && has('patch1170') function! s:_function(fstr) abort