diff --git a/autoload/neocomplete/sources/vimshell_history.vim b/autoload/neocomplete/sources/vimshell_history.vim new file mode 100644 index 00000000..b8bb14f2 --- /dev/null +++ b/autoload/neocomplete/sources/vimshell_history.vim @@ -0,0 +1,64 @@ +"============================================================================= +" FILE: vimshell_history.vim +" AUTHOR: Shougo Matsushita +" Last Modified: 24 Jun 2013. +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +function! neocomplete#sources#vimshell_history#define() "{{{ + return s:source +endfunction "}}} + +let s:source = { + \ 'name' : 'vimshell/history', + \ 'kind' : 'manual', + \ 'hooks' : {}, + \ 'max_candidates' : 100, + \ 'matchers' : [], + \ 'sorters' : [], + \ 'mark' : '[history]', + \ } + +function! s:source.hooks.on_init(context) "{{{ + let a:context.source__histories = vimshell#history#read() +endfunction"}}} +function! s:source.hooks.on_post_filter(context) "{{{ + for candidate in a:context.candidates + let candidate.abbr = + \ substitute(candidate.word, '\s\+$', '>-', '') + endfor +endfunction"}}} + +function! s:source.get_complete_position(context) "{{{ + if neocomplete#is_auto_complete() || !vimshell#check_prompt() + return -1 + endif + + return len(vimshell#get_prompt()) +endfunction "}}} + +function! s:source.gather_candidates(context) "{{{ + return filter(copy(a:context.source__histories), + \ 'stridx(v:val, a:context.complete_str) >= 0') +endfunction "}}} + +" ies foldmethod=marker diff --git a/autoload/vimshell/mappings.vim b/autoload/vimshell/mappings.vim index 89512164..9a4137e4 100644 --- a/autoload/vimshell/mappings.vim +++ b/autoload/vimshell/mappings.vim @@ -1,7 +1,7 @@ "============================================================================= " FILE: mappings.vim " AUTHOR: Shougo Matsushita -" Last Modified: 07 Jun 2013. +" Last Modified: 24 Jun 2013. " License: MIT license {{{ " Permission is hereby granted, free of charge, to any person obtaining " a copy of this software and associated documentation files (the @@ -116,9 +116,13 @@ function! vimshell#mappings#define_default_mappings() "{{{ \ :call exit() inoremap (vimshell_hide) \ :call hide() + inoremap (vimshell_history_unite) + \ unite#sources#vimshell_history#start_complete(!0) + inoremap (vimshell_history_neocomplete) + \ neocomplete#start_manual_complete('vimshell/history') "}}} - if exists('g:vimshell_no_default_keymappings') && g:vimshell_no_default_keymappings + if get(g:, 'vimshell_no_default_keymappings', 0) return endif @@ -168,9 +172,11 @@ function! vimshell#mappings#define_default_mappings() "{{{ \ getline('.')[col('.') - 2] ==# "\" ? "\" : '' imap (bs-ctrl-]) imap (vimshell_enter) + " History completion. - inoremap - \ unite#sources#vimshell_history#start_complete(!0) + imap + \ (vimshell_history_unite) + " Command completion. imap (vimshell_command_complete) " Move to Beginning of command. diff --git a/doc/vimshell.txt b/doc/vimshell.txt index a30c958b..086bbcc8 100644 --- a/doc/vimshell.txt +++ b/doc/vimshell.txt @@ -621,6 +621,14 @@ Insert mode key mappings. (vimshell_exit) *i_(vimshell_exit)* Quit vimshell buffer. +(vimshell_history_unite) *i_(vimshell_history_unite)* + Execute vimshell histories by unite interface. + Note: To use it, you must install |unite.vim| plugin. + +(vimshell_history_neocomplete) + Execute vimshell histories by neocomplete interface. + Note: To use it, you must install |neocomplete| plugin. + Normal mode default key mappings. {lhs} {rhs} -------- ----------------------------- @@ -653,7 +661,7 @@ Insert mode default key mappings. {lhs} {rhs} -------- ----------------------------- (vimshell_enter) - Start vimshell/history source + (vimshell_history_unite) (vimshell_command_complete) (vimshell_move_head) (vimshell_delete_backward_line) @@ -1533,5 +1541,10 @@ Note: In below page(Japanese), it emulates dynamic prompt in vimshell. http://kannokanno.hatenablog.com/entry/2013/05/10/140947 But this behavior is unexpected. It may be not worked in later version. +Q: I want to execute history by completion interface. + +A: You can use |(vimshell_history_neocomplete)| mapping. +Note: |neocomplete| is required. + ============================================================================== vim:tw=78:ts=8:ft=help:norl:noet:fen:isk+=-: