Skip to content

Commit

Permalink
- Added <Plug>(vimshell_history_neocomplete) mapping.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Jun 24, 2013
1 parent 5f10c2f commit 2f9e7da
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 5 deletions.
64 changes: 64 additions & 0 deletions autoload/neocomplete/sources/vimshell_history.vim
@@ -0,0 +1,64 @@
"=============================================================================
" FILE: vimshell_history.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" 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
14 changes: 10 additions & 4 deletions autoload/vimshell/mappings.vim
@@ -1,7 +1,7 @@
"=============================================================================
" FILE: mappings.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" 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
Expand Down Expand Up @@ -116,9 +116,13 @@ function! vimshell#mappings#define_default_mappings() "{{{
\ <ESC>:call <SID>exit()<CR>
inoremap <buffer><silent> <Plug>(vimshell_hide)
\ <ESC>:call <SID>hide()<CR>
inoremap <expr><buffer><silent> <Plug>(vimshell_history_unite)
\ unite#sources#vimshell_history#start_complete(!0)
inoremap <expr><buffer><silent> <Plug>(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

Expand Down Expand Up @@ -168,9 +172,11 @@ function! vimshell#mappings#define_default_mappings() "{{{
\ getline('.')[col('.') - 2] ==# "\<C-]>" ? "\<BS>" : ''
imap <buffer> <C-]> <C-]><SID>(bs-ctrl-])
imap <buffer> <CR> <C-]><Plug>(vimshell_enter)
" History completion.
inoremap <buffer> <expr><silent> <C-l>
\ unite#sources#vimshell_history#start_complete(!0)
imap <buffer> <expr><silent> <C-l>
\ <Plug>(vimshell_history_unite)
" Command completion.
imap <buffer> <TAB> <Plug>(vimshell_command_complete)
" Move to Beginning of command.
Expand Down
15 changes: 14 additions & 1 deletion doc/vimshell.txt
Expand Up @@ -621,6 +621,14 @@ Insert mode key mappings.
<Plug>(vimshell_exit) *i_<Plug>(vimshell_exit)*
Quit vimshell buffer.

<Plug>(vimshell_history_unite) *i_<Plug>(vimshell_history_unite)*
Execute vimshell histories by unite interface.
Note: To use it, you must install |unite.vim| plugin.

<Plug>(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}
-------- -----------------------------
Expand Down Expand Up @@ -653,7 +661,7 @@ Insert mode default key mappings.
{lhs} {rhs}
-------- -----------------------------
<CR> <Plug>(vimshell_enter)
<C-l> Start vimshell/history source
<C-l> <Plug>(vimshell_history_unite)
<TAB> <Plug>(vimshell_command_complete)
<C-a> <Plug>(vimshell_move_head)
<C-u> <Plug>(vimshell_delete_backward_line)
Expand Down Expand Up @@ -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 |<Plug>(vimshell_history_neocomplete)| mapping.
Note: |neocomplete| is required.

==============================================================================
vim:tw=78:ts=8:ft=help:norl:noet:fen:isk+=-:

0 comments on commit 2f9e7da

Please sign in to comment.