- Improved g:neosnippet#disable_select_mode_mappings behavior.

This commit is contained in:
Shougo Matsushita 2012-10-27 18:04:53 +09:00
parent e9db76f71f
commit b955d17e5e
3 changed files with 27 additions and 12 deletions

View File

@ -35,7 +35,7 @@ call neosnippet#util#set_default(
\ '', 'g:neocomplcache_snippets_dir') \ '', 'g:neocomplcache_snippets_dir')
call neosnippet#util#set_default( call neosnippet#util#set_default(
\ 'g:neosnippet#disable_select_mode_mappings', \ 'g:neosnippet#disable_select_mode_mappings',
\ 0, 'g:neocomplcache_disable_select_mode_mappings') \ 1, 'g:neocomplcache_disable_select_mode_mappings')
"}}} "}}}
" Variables "{{{ " Variables "{{{
@ -99,17 +99,7 @@ function! s:initialize()"{{{
" Select mode mappings."{{{ " Select mode mappings."{{{
if g:neosnippet#disable_select_mode_mappings if g:neosnippet#disable_select_mode_mappings
snoremap <CR> a<BS> autocmd neosnippet BufEnter * call s:clear_select_mode_mappings()
snoremap <BS> a<BS>
snoremap <right> <ESC>a
snoremap <left> <ESC>bi
snoremap ' a<BS>'
snoremap ` a<BS>`
snoremap % a<BS>%
snoremap U a<BS>U
snoremap ^ a<BS>^
snoremap \ a<BS>\
snoremap <C-x> a<BS><c-x>
endif"}}} endif"}}}
" Caching _ snippets. " Caching _ snippets.
@ -939,6 +929,22 @@ function! s:trigger(function)"{{{
\ a:function, string(cur_text), col) \ a:function, string(cur_text), col)
endfunction"}}} endfunction"}}}
function! s:clear_select_mode_mappings()"{{{
redir => mappings
silent! smap
redir END
for line in map(filter(split(mappings, '\n'),
\ "v:val !~# '<Plug>(\\%(neosnippet\\|neocomplcache_snippets\\)_[^)]*'"),
\ "substitute(v:val, '<NL>', '<C-J>', 'g')")
let map = matchstr(line, '^\a*\s*\zs\S\+')
let map = substitute(map, '<NL>', '<C-j>', 'g')
silent! execute 'sunmap' map
silent! execute 'sunmap <buffer>' map
endfor
endfunction"}}}
" Plugin key-mappings. " Plugin key-mappings.
function! neosnippet#expand_or_jump_impl() function! neosnippet#expand_or_jump_impl()
return s:trigger(s:SID_PREFIX().'snippets_expand_or_jump') return s:trigger(s:SID_PREFIX().'snippets_expand_or_jump')

View File

@ -77,3 +77,11 @@ options head
autocmd! autocmd!
autocmd ${2:event} autocmd ${2:event}
augroup END augroup END
snippet redir
abbr redir => var
options head
redir => ${1}
${2:}
redir END

View File

@ -456,6 +456,7 @@ CHANGELOG *neosnippet-changelog*
2012-10-27 2012-10-27
- Fixed for :SnippetEdit. - Fixed for :SnippetEdit.
- Improved g:neosnippet#disable_select_mode_mappings behavior.
2012-10-26 2012-10-26
- Improved javascript snippet file. - Improved javascript snippet file.