mirror of
https://github.com/amix/vimrc
synced 2025-06-16 09:35:01 +08:00
Updated vim plugins
This commit is contained in:
@ -14,7 +14,7 @@ In other words: upstream of snipmate is almost dead. (Better to say Marc Weber i
|
||||
:Author: `Michael Sanders`_
|
||||
:Maintainer: `Adnan Zafar`_ & `Rok Garbas`_ & `Marc Weber`_
|
||||
:Homepage: http://www.vim.org/scripts/script.php?script_id=2540
|
||||
:Contributors: `MarcWeber`_, `lilydjwg`_, `henrik`_, `steveno`_, `asymmetric`_, `jherdman`_, `ironcamel`_, `honza`_, `jb55`_, `robhudson`_, `kozo2`_, `MicahElliott`_, `darkwise`_, `redpill`_, `thisgeek`_, `sickill`_, `pose`_, `marutanm`_, `r00k`_, `jbernard`_, `holizz`_, `muffinresearch`_, `statik`_, `taq`_, `alderz`_, `pielgrzym`_
|
||||
:Contributors: `MarcWeber`_, `lilydjwg`_, `henrik`_, `steveno`_, `asymmetric`_, `jherdman`_, `ironcamel`_, `honza`_, `jb55`_, `robhudson`_, `kozo2`_, `MicahElliott`_, `darkwise`_, `redpill`_, `thisgeek`_, `sickill`_, `pose`_, `marutanm`_, `r00k`_, `jbernard`_, `holizz`_, `muffinresearch`_, `statik`_, `taq`_, `alderz`_, `radicalbit`_, `pielgrzym`_
|
||||
|
||||
|
||||
.. contents::
|
||||
@ -254,3 +254,4 @@ TODO / Future
|
||||
.. _`taq`: https://github.com/taq
|
||||
.. _`vim.org`: http://www.vim.org/scripts/script.php?script_id=2540
|
||||
.. _`GitHub`: http://github.com/msanders/snipmate.vim
|
||||
.. _`radicalbit`: https://github.com/radicalbit
|
||||
|
@ -1,54 +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>'
|
||||
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
|
||||
|
||||
if !exists('g:snips_trigger_key_backwards')
|
||||
let g:snips_trigger_key_backwards = '<s-' . substitute(g:snips_trigger_key, '[<>]', '', 'g') . '>'
|
||||
endif
|
||||
" 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.
|
||||
silent! snoremap <unique> <BS> b<BS><Esc>
|
||||
|
||||
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>'
|
||||
|
||||
" The default mappings for these are annoying & sometimes break snipMate.
|
||||
" You can change them back if you want, I've put them here for convenience.
|
||||
snor <bs> b<bs>
|
||||
snor <right> <esc>a
|
||||
snor <left> <esc>bi
|
||||
snor ' b<bs>'
|
||||
snor ` b<bs>`
|
||||
snor % b<bs>%
|
||||
snor U b<bs>U
|
||||
snor ^ b<bs>^
|
||||
snor \ b<bs>\
|
||||
snor <c-x> b<bs><c-x>
|
||||
|
||||
" By default load snippets in snippets_dir
|
||||
if empty(snippets_dir)
|
||||
finish
|
||||
endif
|
||||
|
||||
" restore 'cpo'
|
||||
let &cpo = s:save_cpo
|
||||
|
||||
" vim:noet:sw=4:ts=4:ft=vim
|
||||
" vim:noet:
|
||||
|
@ -339,7 +339,6 @@ function! s:state_proto.update_vars(change)
|
||||
let newWord = strpart(getline('.'), self.start_col - 1, newWordLen)
|
||||
let changeLen = a:change
|
||||
let curLine = line('.')
|
||||
let startCol = col('.')
|
||||
let oldStartSnip = self.start_col
|
||||
let updateTabStops = changeLen != 0
|
||||
let i = 0
|
||||
@ -370,6 +369,12 @@ function! s:state_proto.update_vars(change)
|
||||
" subtract another -1 to exclude the col'th element
|
||||
call setline(lnum, theline[0:(col-2)] . newWord . theline[(col+self.end_col-self.start_col-a:change-1):])
|
||||
endfor
|
||||
|
||||
" Reposition the cursor in case a var updates on the same line but before
|
||||
" the current tabstop
|
||||
if oldStartSnip != self.start_col
|
||||
call cursor(0, col('.') + self.start_col - oldStartSnip)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" should be moved to utils or such?
|
||||
|
@ -356,18 +356,28 @@ If you would like your snippets to be expanded using spaces instead of tabs,
|
||||
just enable 'expandtab' and set 'softtabstop' to your preferred amount of
|
||||
spaces. If 'softtabstop' is not set, 'shiftwidth' is used instead.
|
||||
|
||||
*snipMate-trigger*
|
||||
snipMate comes with a setting to configure the key that is used to trigger
|
||||
snipMate. To configure the key set g:snips_trigger_key to something other than
|
||||
<tab>,e.g. <c-space> use:
|
||||
*snipMate-mappings*
|
||||
The mappings snipMate uses can be customized with the |:map| commands. For
|
||||
example, to change the key that triggers snippets and moves to the next
|
||||
tabstop, >
|
||||
|
||||
let g:snips_trigger_key='<c-space>'
|
||||
:imap <C-J> <Plug>snipMateNextOrTrigger
|
||||
:smap <C-J> <Plug>snipMateNextOrTrigger
|
||||
<
|
||||
The list of possible <Plug> mappings is as follows:
|
||||
|
||||
snipMate will try to automatically configure backwards trigger to prepend shift
|
||||
key infront, e.g. <s-tab> or <s-c-space>. You can manually configure backward
|
||||
trigger using:
|
||||
<Plug>snipMateNextOrTrigger Jumps to the next tab stop or, if none exists,
|
||||
try to expand a snippet. Use in both insert
|
||||
and select modes.
|
||||
|
||||
let g:snips_trigger_key_backwards='<c-space>'
|
||||
<Plug>snipMateBack Jump to the previous tab stop, if it exists.
|
||||
Use in both insert and select modes.
|
||||
|
||||
<Plug>snipMateShow Show all available snippets (that start with
|
||||
the previous text, if it exists). Use in
|
||||
insert mode.
|
||||
|
||||
<Plug>snipMateVisual |snipMate-visual-selection-support|
|
||||
|
||||
==============================================================================
|
||||
FEATURES *snipMate-features*
|
||||
|
@ -14,6 +14,9 @@ if exists('loaded_snips') || &cp || version < 700
|
||||
endif
|
||||
let loaded_snips = 1
|
||||
if !exists('snips_author') | let snips_author = 'Me' | endif
|
||||
" save and reset 'cpo'
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
try
|
||||
call funcref#Function('')
|
||||
@ -33,6 +36,14 @@ au FileType snippet setl noet nospell
|
||||
au BufRead,BufNewFile *.snippets set ft=snippets
|
||||
au FileType snippets setl noet nospell fdm=expr fde=getline(v:lnum)!~'^\\t\\\\|^$'?'>1':1
|
||||
|
||||
inoremap <silent> <Plug>snipMateNextOrTrigger <C-R>=snipMate#TriggerSnippet()<CR>
|
||||
snoremap <silent> <Plug>snipMateNextOrTrigger <Esc>a<C-R>=snipMate#TriggerSnippet()<CR>
|
||||
inoremap <silent> <Plug>snipMateBack <C-R>=snipMate#BackwardsSnippet()<CR>
|
||||
snoremap <silent> <Plug>snipMateBack <Esc>a<C-R>=snipMate#BackwardsSnippet()<CR>
|
||||
inoremap <silent> <Plug>snipMateShow <C-R>=snipMate#ShowAvailableSnips()<CR>
|
||||
" FIXME: <Plug>snipMateVisual pollutes register(s)
|
||||
xnoremap <silent> <Plug>snipMateVisual s<C-O>:let g:snipmate_content_visual=getreg('1')<CR>
|
||||
|
||||
" config which can be overridden (shared lines)
|
||||
if !exists('g:snipMate')
|
||||
let g:snipMate = {}
|
||||
@ -80,4 +91,7 @@ fun! BackwardSnippet()
|
||||
return snipMate#BackwardsSnippet()
|
||||
endf
|
||||
|
||||
" restore 'cpo'
|
||||
let &cpo = s:save_cpo
|
||||
|
||||
" vim:noet:sw=4:ts=4:ft=vim
|
||||
|
Reference in New Issue
Block a user