From 9c0183faa70cee1604d69f204be731f5959e555a Mon Sep 17 00:00:00 2001 From: haya14busa Date: Fri, 17 Jan 2014 15:12:33 +0900 Subject: [PATCH] Modify prompt message and make it more configurable --- autoload/EasyMotion/command_line.vim | 24 ++++++++++++++++++++---- plugin/EasyMotion.vim | 3 ++- t/easymotion_spec.vim | 2 +- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/autoload/EasyMotion/command_line.vim b/autoload/EasyMotion/command_line.vim index 46a2c88..fcb534c 100644 --- a/autoload/EasyMotion/command_line.vim +++ b/autoload/EasyMotion/command_line.vim @@ -40,14 +40,30 @@ function! s:Cancell() " {{{ return '' endfunction " }}} +function! s:getPromptMessage(num_strokes) + if a:num_strokes == 1 + let prompt = substitute( + \ substitute(g:EasyMotion_prompt,'{n}', a:num_strokes, 'g'), + \ '(s)', '', 'g') + elseif a:num_strokes == -1 + let prompt = substitute( + \ substitute(g:EasyMotion_prompt, '{n}\s\{0,1}', '', 'g'), + \ '(s)', 's', 'g') + else + let prompt = substitute( + \ substitute(g:EasyMotion_prompt,'{n}', a:num_strokes, 'g'), + \ '(s)', 's', 'g') + endif + return prompt +endfunction + function! EasyMotion#command_line#GetInput(num_strokes, ...) "{{{ let previous_input = a:0 == 1 ? a:1 : '' let input = '' - " repeat a:num_strokes times - let prompt_num = a:num_strokes != -1 ? a:num_strokes : '' - let prompt = prompt_num . g:EasyMotion_prompt + let prompt = s:getPromptMessage(a:num_strokes) + while EasyMotion#helper#strchars(input) < a:num_strokes || - \ a:num_strokes == -1 + \ a:num_strokes == -1 if g:EasyMotion_show_prompt call s:InputPrompt(prompt, input) endif diff --git a/plugin/EasyMotion.vim b/plugin/EasyMotion.vim index 83b507e..5ee74be 100644 --- a/plugin/EasyMotion.vim +++ b/plugin/EasyMotion.vim @@ -32,7 +32,8 @@ let g:EasyMotion_use_migemo = get(g: , 'EasyMotion_use_migemo' , let g:EasyMotion_use_upper = get(g: , 'EasyMotion_use_upper' , 0) let g:EasyMotion_enter_jump_first = get(g: , 'EasyMotion_enter_jump_first' , 0) let g:EasyMotion_show_prompt = get(g: , 'EasyMotion_show_prompt' , 1) -let g:EasyMotion_prompt = get(g: , 'EasyMotion_prompt' , '> ') +let g:EasyMotion_prompt = + \ get(g: , 'EasyMotion_prompt' , 'Search for {n} character(s): ') let g:EasyMotion_command_line_key_mappings = \ get(g: , 'EasyMotion_command_line_key_mappings' , {}) diff --git a/t/easymotion_spec.vim b/t/easymotion_spec.vim index 3069394..8b96bfc 100644 --- a/t/easymotion_spec.vim +++ b/t/easymotion_spec.vim @@ -425,7 +425,7 @@ describe 'Default settings' Expect g:EasyMotion_use_upper ==# 0 Expect g:EasyMotion_enter_jump_first ==# 0 Expect g:EasyMotion_show_prompt ==# 1 - Expect g:EasyMotion_prompt ==# '> ' + Expect g:EasyMotion_prompt ==# 'Search for {n} character(s): ' Expect g:EasyMotion_command_line_key_mappings ==# {} " }}}