forked from msanders/snipmate.vim
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This deprecates g:snips_trigger_key(_backwards).
- Loading branch information
Showing
3 changed files
with
73 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,51 @@ | ||
" These are the mappings for snipMate.vim. Putting it here ensures that it | ||
" will be mapped after other plugins such as supertab.vim. | ||
if !exists('loaded_snips') || exists('s:did_snips_mappings') | ||
finish | ||
endif | ||
let s:did_snips_mappings = 1 | ||
" save and reset 'cpo' | ||
" snipMate maps | ||
" These maps are created here in order to make sure we can reliably create maps | ||
" after SuperTab. | ||
|
||
let s:save_cpo = &cpo | ||
set cpo&vim | ||
|
||
" This is put here in the 'after' directory in order for snipMate to override | ||
" other plugin mappings (e.g., supertab). | ||
" | ||
" To adjust the tirgger key see (:h snipMate-trigger) | ||
" | ||
if !exists('g:snips_trigger_key') | ||
let g:snips_trigger_key = '<tab>' | ||
endif | ||
|
||
if !exists('g:snips_trigger_key_backwards') | ||
let g:snips_trigger_key_backwards = '<s-' . substitute(g:snips_trigger_key, '[<>]', '', 'g') . '>' | ||
function! s:map_if_not_mapped(lhs, rhs, mode) | ||
let l:unique = s:overwrite ? '' : ' <unique>' | ||
if !hasmapto(a:rhs, a:mode) | ||
silent! exe a:mode . 'map' . l:unique a:lhs a:rhs | ||
endif | ||
endfunction | ||
|
||
if !exists('g:snips_no_mappings') || !g:snips_no_mappings | ||
if exists('g:snips_trigger_key') | ||
echom 'g:snips_trigger_key is deprecated. See :h snipMate-mappings' | ||
exec 'imap <unique>' g:snips_trigger_key '<Plug>snipMateTrigger' | ||
exec 'smap <unique>' g:snips_trigger_key '<Plug>snipMateSNext' | ||
exec 'xmap <unique>' g:snips_trigger_key '<Plug>snipMateVisual' | ||
else | ||
" Remove SuperTab map if it exists | ||
let s:overwrite = maparg('<Tab>', 'i') ==? '<Plug>SuperTabForward' | ||
call s:map_if_not_mapped('<Tab>', '<Plug>snipMateNextOrTrigger', 'i') | ||
call s:map_if_not_mapped('<Tab>', '<Plug>snipMateNextOrTrigger', 's') | ||
let s:overwrite = 0 | ||
call s:map_if_not_mapped('<Tab>', '<Plug>snipMateVisual', 'x') | ||
endif | ||
|
||
if exists('g:snips_trigger_key_backwards') | ||
echom 'g:snips_trigger_key_backwards is deprecated. See :h snipMate-mappings' | ||
exec 'imap <unique>' g:snips_trigger_key_backwards '<Plug>snipMateIBack' | ||
exec 'smap <unique>' g:snips_trigger_key_backwards '<Plug>snipMateSBack' | ||
else | ||
let s:overwrite = maparg('<S-Tab>', 'i') ==? '<Plug>SuperTabBackward' | ||
call s:map_if_not_mapped('<S-Tab>', '<Plug>snipMateBack', 'i') | ||
call s:map_if_not_mapped('<S-Tab>', '<Plug>snipMateBack', 's') | ||
let s:overwrite = 0 | ||
endif | ||
|
||
call s:map_if_not_mapped('<C-R><Tab>', '<Plug>snipMateShow', 'i') | ||
endif | ||
|
||
exec 'ino <silent> ' . g:snips_trigger_key . ' <c-r>=snipMate#TriggerSnippet()<cr>' | ||
exec 'snor <silent> ' . g:snips_trigger_key . ' <esc>i<right><c-r>=snipMate#TriggerSnippet()<cr>' | ||
exec 'ino <silent> ' . g:snips_trigger_key_backwards . ' <c-r>=snipMate#BackwardsSnippet()<cr>' | ||
exec 'snor <silent> ' . g:snips_trigger_key_backwards . ' <esc>i<right><c-r>=snipMate#BackwardsSnippet()<cr>' | ||
exec 'ino <silent> <c-r>' . g:snips_trigger_key . ' <c-r>=snipMate#ShowAvailableSnips()<cr>' | ||
|
||
" maybe there is a better way without polluting registers ? | ||
exec 'xnoremap ' . g:snips_trigger_key. ' s<c-o>:let<space>g:snipmate_content_visual=getreg('1')<cr>' | ||
|
||
" FIXME: Without this map, <BS> in select mode deletes the current selection and | ||
" returns to normal mode. This doesn't update placeholders. Ideally there's some | ||
" way to update the placeholders without this otherwise useless map. | ||
snor <bs> b<bs><Esc> | ||
" By default load snippets in snippets_dir | ||
if empty(snippets_dir) | ||
finish | ||
endif | ||
silent! snoremap <unique> <BS> b<BS><Esc> | ||
" restore 'cpo' | ||
let &cpo = s:save_cpo | ||
|
||
" vim:noet:sw=4:ts=4:ft=vim | ||
" vim:noet: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters