- Improved clear mappings.
This commit is contained in:
parent
3f4e7a6ea9
commit
c3ca7a9ae2
@ -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, '<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
|
||||
|
||||
" Define default select mode mappings.
|
||||
snoremap <CR> a<BS>
|
||||
snoremap <BS> a<BS>
|
||||
snoremap <Del> a<BS>
|
||||
snoremap <C-h> a<BS>
|
||||
endfunction"}}}
|
||||
|
||||
function! s:skip_next_auto_completion() "{{{
|
||||
" Skip next auto completion.
|
||||
if exists('*neocomplcache#skip_next_complete')
|
||||
|
@ -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() "{{{
|
||||
|
@ -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, '<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
|
||||
|
||||
" Define default select mode mappings.
|
||||
snoremap <CR> a<BS>
|
||||
snoremap <BS> a<BS>
|
||||
snoremap <Del> a<BS>
|
||||
snoremap <C-h> a<BS>
|
||||
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)
|
||||
|
@ -1,7 +1,7 @@
|
||||
*neosnippet.txt*
|
||||
The neo-snippet plugin contains snippet source
|
||||
|
||||
Version: 3.1
|
||||
Version: 4.0
|
||||
Author: Shougo <Shougo.Matsu@gmail.com>
|
||||
License: MIT license {{{
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
|
Loading…
Reference in New Issue
Block a user