From c3ca7a9ae2088c50452c73e5a9ba2a6a4d058cea Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Tue, 19 Nov 2013 16:07:04 +0900 Subject: [PATCH] - Improved clear mappings. --- autoload/neosnippet.vim | 26 ------------------- autoload/neosnippet/init.vim | 4 +-- autoload/neosnippet/mappings.vim | 44 +++++++++++++++++++++++++------- doc/neosnippet.txt | 2 +- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/autoload/neosnippet.vim b/autoload/neosnippet.vim index 1420143..f5909ef 100644 --- a/autoload/neosnippet.vim +++ b/autoload/neosnippet.vim @@ -1155,32 +1155,6 @@ function! neosnippet#substitute_selected_text(type, text) "{{{ endtry endfunction"}}} -function! neosnippet#clear_select_mode_mappings() "{{{ - if !g:neosnippet#disable_select_mode_mappings - return - endif - - redir => mappings - silent! smap - redir END - - for line in map(filter(split(mappings, '\n'), - \ "v:val !~# '^s'"), - \ "substitute(v:val, '', '', 'g')") - let map = matchstr(line, '^\a*\s*\zs\S\+') - let map = substitute(map, '', '', 'g') - - silent! execute 'sunmap' map - silent! execute 'sunmap ' map - endfor - - " Define default select mode mappings. - snoremap a - snoremap a - snoremap a - snoremap a -endfunction"}}} - function! s:skip_next_auto_completion() "{{{ " Skip next auto completion. if exists('*neocomplcache#skip_next_complete') diff --git a/autoload/neosnippet/init.vim b/autoload/neosnippet/init.vim index d437b2a..3e30f0b 100644 --- a/autoload/neosnippet/init.vim +++ b/autoload/neosnippet/init.vim @@ -83,7 +83,7 @@ function! s:initialize_others() "{{{ autocmd BufWritePost *.snip,*.snippets \ call neosnippet#recaching() autocmd BufEnter * - \ call neosnippet#clear_select_mode_mappings() + \ call neosnippet#mappings#_clear_select_mode_mappings() autocmd InsertLeave * call s:on_insert_leave() augroup END"}}} @@ -112,7 +112,7 @@ function! s:initialize_others() "{{{ call echodoc#register('snippets_complete', s:doc_dict) endif - call neosnippet#clear_select_mode_mappings() + call neosnippet#mappings#_clear_select_mode_mappings() endfunction"}}} function! s:on_insert_leave() "{{{ diff --git a/autoload/neosnippet/mappings.vim b/autoload/neosnippet/mappings.vim index adeb0af..85fdbf0 100644 --- a/autoload/neosnippet/mappings.vim +++ b/autoload/neosnippet/mappings.vim @@ -27,15 +27,6 @@ let s:save_cpo = &cpo set cpo&vim -function! s:snippets_expand(cur_text, col) "{{{ - let cur_word = neosnippet#get_cursor_snippet( - \ neosnippet#get_snippets(), - \ a:cur_text) - - call neosnippet#expand( - \ a:cur_text, a:col, cur_word) -endfunction"}}} - function! neosnippet#mappings#_get_cursor_snippet(snippets, cur_text) "{{{ let cur_word = matchstr(a:cur_text, '\S\+$') if cur_word != '' && has_key(a:snippets, cur_word) @@ -54,6 +45,41 @@ function! neosnippet#mappings#_get_cursor_snippet(snippets, cur_text) "{{{ return cur_word endfunction"}}} +function! neosnippet#mappings#_clear_select_mode_mappings() "{{{ + if !g:neosnippet#disable_select_mode_mappings + return + endif + + redir => mappings + silent! smap + redir END + + for line in map(filter(split(mappings, '\n'), + \ "v:val !~# '^s'"), + \ "substitute(v:val, '', '', 'g')") + let map = matchstr(line, '^\a*\s*\zs\S\+') + let map = substitute(map, '', '', 'g') + + silent! execute 'sunmap' map + silent! execute 'sunmap ' map + endfor + + " Define default select mode mappings. + snoremap a + snoremap a + snoremap a + snoremap a +endfunction"}}} + +function! s:snippets_expand(cur_text, col) "{{{ + let cur_word = neosnippet#get_cursor_snippet( + \ neosnippet#get_snippets(), + \ a:cur_text) + + call neosnippet#expand( + \ a:cur_text, a:col, cur_word) +endfunction"}}} + function! s:snippets_expand_or_jump(cur_text, col) "{{{ let cur_word = neosnippet#get_cursor_snippet( \ neosnippet#get_snippets(), a:cur_text) diff --git a/doc/neosnippet.txt b/doc/neosnippet.txt index d686553..c714441 100755 --- a/doc/neosnippet.txt +++ b/doc/neosnippet.txt @@ -1,7 +1,7 @@ *neosnippet.txt* The neo-snippet plugin contains snippet source -Version: 3.1 +Version: 4.0 Author: Shougo License: MIT license {{{ Permission is hereby granted, free of charge, to any person obtaining