Improve command line for find motion

Add:
  - autocmd User
  - InsertRegister
  - EMCommandLine Map, NoreMap, UnMap
  - Emacs like keymapping by default

Change:
  - Modify default buffer completion key from <C-d> to <C-l>
This commit is contained in:
haya14busa 2014-02-05 14:20:50 +09:00
parent 09aed7af0c
commit d3ee7bb8d9
2 changed files with 63 additions and 32 deletions

View File

@ -2,7 +2,7 @@
" FILE: autoload/EasyMotion/command_line.vim " FILE: autoload/EasyMotion/command_line.vim
" AUTHOR: haya14busa " AUTHOR: haya14busa
" Reference: https://github.com/osyo-manga/vim-over " Reference: https://github.com/osyo-manga/vim-over
" Last Change: 01 Feb 2014. " Last Change: 05 Feb 2014.
" License: MIT license {{{ " License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining " Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the " a copy of this software and associated documentation files (the
@ -36,12 +36,15 @@ let s:search = s:cmdline.make_plain("/")
let s:search.highlights.prompt = "Question" let s:search.highlights.prompt = "Question"
" Add Module: {{{ " Add Module: {{{
call s:search.connect(s:cmdline.module_delete()) call s:search.connect('Delete')
call s:search.connect(s:cmdline.module_cursor_move()) call s:search.connect('CursorMove')
call s:search.connect(s:cmdline.module_paste()) call s:search.connect('Paste')
call s:search.connect(s:cmdline.module_buffer_complete()) call s:search.connect('BufferComplete')
call s:search.connect(s:cmdline.module_history("/")) call s:search.connect('InsertRegister')
call s:search.connect(s:cmdline.module_no_insert_special_chars()) call s:search.connect(s:cmdline.get_module('History').make('/'))
call s:search.connect(s:cmdline.get_module('NoInsert').make_special_chars())
call s:search.connect(s:cmdline.get_module('KeyMapping').make_emacs())
call s:search.connect(s:cmdline.get_module('Doautocmd').make('EMCommandLine'))
let s:module = { let s:module = {
\ "name" : "EasyMotion", \ "name" : "EasyMotion",
@ -70,20 +73,51 @@ call s:search.connect(s:module)
"}}} "}}}
" CommandLine Keymap: {{{ " CommandLine Keymap: {{{
let s:default_key_mapping = { function! s:search.keymapping() "{{{
\ "\<C-d>" : "<Over>(buffer-complete)", return {
\ "\<Tab>" : "<Over>(em-scroll-f)", \ "\<C-l>" : {
\ "\<S-Tab>" : "<Over>(em-scroll-b)", \ "key" : "<Over>(buffer-complete)",
\ "\<C-o>" : "<Over>(em-jumpback)", \ "noremap" : 1,
\ "\<C-z>" : "<Over>(em-openallfold)", \ },
\} \ "\<Tab>" : {
function! EasyMotion#command_line#keymaps() "{{{ \ "key" : "<Over>(em-scroll-f)",
return extend(deepcopy(s:default_key_mapping), \ "noremap" : 1,
\ g:EasyMotion_command_line_key_mappings) \ },
endfunction "}}} \ "\<S-Tab>" : {
function! s:search.keymappings() "{{{ \ "key" : "<Over>(em-scroll-b)",
return EasyMotion#command_line#keymaps() \ "noremap" : 1,
\ },
\ "\<C-o>" : {
\ "key" : "<Over>(em-jumpback)",
\ "noremap" : 1,
\ },
\ "\<C-z>" : {
\ "key" : "<Over>(em-openallfold)",
\ "noremap" : 1,
\ },
\ }
endfunction "}}} endfunction "}}}
" Fins Motion CommandLine Mapping Command: {{{
function! EasyMotion#command_line#cmap(args)
let lhs = s:as_keymapping(a:args[0])
let rhs = s:as_keymapping(a:args[1])
call s:search.cmap(lhs, rhs)
endfunction
function! EasyMotion#command_line#cnoremap(args)
let lhs = s:as_keymapping(a:args[0])
let rhs = s:as_keymapping(a:args[1])
call s:search.cnoremap(lhs, rhs)
endfunction
function! EasyMotion#command_line#cunmap(lhs)
let lhs = s:as_keymapping(a:lhs)
call s:search.cunmap(lhs)
endfunction
function! s:as_keymapping(key)
execute 'let result = "' . substitute(a:key, '\(<.\{-}>\)', '\\\1', 'g') . '"'
return result
endfunction
"}}}
"}}} "}}}
" Event: {{{ " Event: {{{

View File

@ -3,7 +3,7 @@
" Author: Kim Silkebækken <kim.silkebaekken+vim@gmail.com> " Author: Kim Silkebækken <kim.silkebaekken+vim@gmail.com>
" haya14busa <hayabusa1419@gmail.com> " haya14busa <hayabusa1419@gmail.com>
" Source: https://github.com/Lokaltog/vim-easymotion " Source: https://github.com/Lokaltog/vim-easymotion
" Last Change: 02 Feb 2014. " Last Change: 04 Feb 2014.
" == Script initialization {{{ " == Script initialization {{{
if expand("%:p") ==# expand("<sfile>:p") if expand("%:p") ==# expand("<sfile>:p")
unlet! g:EasyMotion_loaded unlet! g:EasyMotion_loaded
@ -387,18 +387,15 @@ if g:EasyMotion_do_mapping == 1
endif "}}} endif "}}}
" == CommandLine Mapping {{{ " == CommandLine Mapping {{{
function! s:key_mapping(lhs, rhs)
let g:EasyMotion_command_line_key_mappings[a:lhs] = a:rhs
endfunction
function! s:as_keymapping(key)
execute 'let result = "' . substitute(a:key, '\(<.\{-}>\)', '\\\1', 'g') . '"'
return result
endfunction
command! -nargs=* command! -nargs=*
\ EMCommandLineNoremap \ EMCommandLineNoreMap
\ call call("s:key_mapping", map([<f-args>], "s:as_keymapping(v:val)")) \ call EasyMotion#command_line#cnoremap([<f-args>])
command! -nargs=*
\ EMCommandLineMap
\ call EasyMotion#command_line#cmap([<f-args>])
command! -nargs=1
\ EMCommandLineUnMap
\ call EasyMotion#command_line#cunmap(<f-args>)
"}}} "}}}
" == Restore 'cpoptions' {{{ " == Restore 'cpoptions' {{{