Snippets and vim updates and such, oh my
git-svn-id: http://photonzero.com/dotfiles/trunk@33 23f722f6-122a-0410-8cef-c75bd312dd78
This commit is contained in:
parent
a0995d6be5
commit
9d2548e8a9
56 changed files with 13433 additions and 129 deletions
|
|
@ -50,7 +50,7 @@ alias dvtm="dvtm -m \"^w\""
|
|||
#Cosmetic/useful
|
||||
#alias naim="naim --noscreen"
|
||||
alias wallall="wallall -p"
|
||||
alias cal="cal -3"
|
||||
#alias cal="cal -3"
|
||||
alias google='surfraw google'
|
||||
alias hd='od -Ax -tx1z -v'
|
||||
|
||||
|
|
|
|||
35
.vim/after/plugin/snipMate.vim
Normal file
35
.vim/after/plugin/snipMate.vim
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
" 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
|
||||
|
||||
ino <silent> <tab> <c-r>=TriggerSnippet()<cr>
|
||||
snor <silent> <tab> <esc>i<right><c-r>=TriggerSnippet()<cr>
|
||||
ino <silent> <s-tab> <c-r>=BackwardsSnippet()<cr>
|
||||
snor <silent> <s-tab> <esc>i<right><c-r>=BackwardsSnippet()<cr>
|
||||
ino <silent> <c-r><tab> <c-r>=ShowAvailableSnips()<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
|
||||
|
||||
call GetSnippets(snippets_dir, '_') " Get global snippets
|
||||
|
||||
au FileType * if &ft != 'help' | call GetSnippets(snippets_dir, &ft) | endif
|
||||
" vim:noet:sw=4:ts=4:ft=vim
|
||||
28
.vim/after/syntax/cocoa_keywords.vim
Normal file
28
.vim/after/syntax/cocoa_keywords.vim
Normal file
File diff suppressed because one or more lines are too long
59
.vim/after/syntax/objc_enhanced.vim
Normal file
59
.vim/after/syntax/objc_enhanced.vim
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
" Author: Michael Sanders (msanders42 [at] gmail [dot] com)
|
||||
" Description: Better syntax highlighting for Objective-C files (part of the
|
||||
" cocoa.vim plugin).
|
||||
" Last Updated: June 23, 2009
|
||||
|
||||
" NOTE: This next file (cocoa_keywords.vim) is rather large and may slow
|
||||
" things down. Loading it seems to take less than 0.5 microseconds
|
||||
" on my machine, but I'm not sure of the consequences; if it is slow
|
||||
" for you, just comment out the next line.
|
||||
ru after/syntax/cocoa_keywords.vim
|
||||
|
||||
syn match objcDirective '@synthesize\|@property' display
|
||||
syn keyword objcType IBOutlet IBAction Method
|
||||
syn keyword objcConstant YES NO TRUE FALSE
|
||||
|
||||
syn region objcImp start='@implementation' end='@end' transparent
|
||||
syn region objcHeader start='@interface' end='@end' transparent
|
||||
|
||||
" I make this typo sometimes so it's nice to have it highlighted.
|
||||
syn match objcError '\v(NSLogv=\(\s*)@<=[^@]=["'].*'me=e-1
|
||||
|
||||
syn match objcSubclass '\(@implementation\|@interface\)\@<=\s*\k\+' display contained containedin=objcImp,objcHeader
|
||||
syn match objcSuperclass '\(@\(implementation\|interface\)\s*\k\+\s*:\)\@<=\s*\k*' display contained containedin=objcImp,objcHeader
|
||||
|
||||
" Matches "- (void) foo: (int) bar and: (float) foobar"
|
||||
syn match objcMethod '^\s*[-+]\s*\_.\{-}[\{;]'me=e-1 transparent contains=cParen,objcInstMethod,objcFactMethod
|
||||
" Matches "bar & foobar" in above
|
||||
syn match objcMethodArg ')\@<=\s*\k\+' contained containedin=objcMethod
|
||||
" Matches "foo:" & "and:" in above
|
||||
syn match objcMethodName '\(^\s*[-+]\s*(\_[^)]*)\)\@<=\_\s*\_\k\+' contained containedin=objcMethod
|
||||
syn match objcMethodColon '\k\+\s*:' contained containedin=objcMethod
|
||||
" Don't match these groups in cParen "(...)"
|
||||
syn cluster cParenGroup add=objcMethodName,objcMethodArg,objcMethodColon
|
||||
" This fixes a bug with completion inside parens (e.g. if ([NSString ]))
|
||||
syn cluster cParenGroup remove=objcMessage
|
||||
|
||||
" Matches "bar" in "[NSObject bar]" or "bar" in "[[NSObject foo: baz] bar]",
|
||||
" but NOT "bar" in "[NSObject foo: bar]".
|
||||
syn match objcMessageName '\(\[\s*\k\+\s\+\|\]\s*\)\@<=\k*\s*\]'me=e-1 display contained containedin=objcMessage
|
||||
" Matches "foo:" in "[NSObject foo: bar]" or "[[NSObject new] foo: bar]"
|
||||
syn match objcMessageColon '\(\_\S\+\_\s\+\)\@<=\k\+\s*:' display contained containedin=objcMessage
|
||||
|
||||
" Don't match these in this strange group for edge cases...
|
||||
syn cluster cMultiGroup add=objcMessageColon,objcMessageName,objcMethodName,objcMethodArg,objcMethodColon
|
||||
|
||||
" You may want to customize this one. I couldn't find a default group to suit
|
||||
" it, but you can modify your colorscheme to make this a different color.
|
||||
hi link objcMethodName Special
|
||||
hi link objcMethodColon objcMethodName
|
||||
|
||||
hi link objcMethodArg Identifier
|
||||
|
||||
hi link objcMessageName objcMethodArg
|
||||
hi link objcMessageColon objcMessageName
|
||||
|
||||
hi link objcSubclass objcMethodName
|
||||
hi link objcSuperclass String
|
||||
|
||||
hi link objcError Error
|
||||
1954
.vim/autoload/genutils.vim
Executable file
1954
.vim/autoload/genutils.vim
Executable file
File diff suppressed because it is too large
Load diff
472
.vim/autoload/lookupfile.vim
Executable file
472
.vim/autoload/lookupfile.vim
Executable file
|
|
@ -0,0 +1,472 @@
|
|||
" lookupfile.vim: See plugin/lookupfile.vim
|
||||
|
||||
" Make sure line-continuations won't cause any problem. This will be restored
|
||||
" at the end
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" Some onetime initialization of variables
|
||||
if !exists('s:myBufNum')
|
||||
let s:windowName = '[Lookup File]'
|
||||
let s:myBufNum = -1
|
||||
let s:popupIsHidden = 0
|
||||
endif
|
||||
let g:lookupfile#lastPattern = ""
|
||||
let g:lookupfile#lastResults = []
|
||||
let g:lookupfile#lastStatsMsg = []
|
||||
let g:lookupfile#recentFiles = []
|
||||
|
||||
function! lookupfile#OpenWindow(bang, initPat)
|
||||
let origWinnr = winnr()
|
||||
let _isf = &isfname
|
||||
let _splitbelow = &splitbelow
|
||||
set nosplitbelow
|
||||
try
|
||||
if s:myBufNum == -1
|
||||
" Temporarily modify isfname to avoid treating the name as a pattern.
|
||||
set isfname-=\
|
||||
set isfname-=[
|
||||
if exists('+shellslash')
|
||||
call genutils#OpenWinNoEa("1sp \\\\". escape(s:windowName, ' '))
|
||||
else
|
||||
call genutils#OpenWinNoEa("1sp \\". escape(s:windowName, ' '))
|
||||
endif
|
||||
let s:myBufNum = bufnr('%')
|
||||
else
|
||||
let winnr = bufwinnr(s:myBufNum)
|
||||
if winnr == -1
|
||||
call genutils#OpenWinNoEa('1sb '. s:myBufNum)
|
||||
else
|
||||
let wasVisible = 1
|
||||
exec winnr 'wincmd w'
|
||||
endif
|
||||
endif
|
||||
finally
|
||||
let &isfname = _isf
|
||||
let &splitbelow = _splitbelow
|
||||
endtry
|
||||
|
||||
call s:SetupBuf()
|
||||
let initPat = ''
|
||||
if a:bang != ''
|
||||
let initPat = ''
|
||||
elseif a:initPat != ''
|
||||
let initPat = a:initPat
|
||||
elseif g:lookupfile#lastPattern != '' && g:LookupFile_PreserveLastPattern
|
||||
let initPat = g:lookupfile#lastPattern
|
||||
endif
|
||||
$
|
||||
if getline('.') !=# initPat
|
||||
silent! put=''
|
||||
call setline('.', initPat)
|
||||
endif
|
||||
startinsert!
|
||||
if !g:LookupFile_OnCursorMovedI
|
||||
" This is a hack to bring up the popup immediately, while reopening the
|
||||
" window, just for a better response.
|
||||
aug LookupFileCursorHoldImm
|
||||
au!
|
||||
au CursorMovedI <buffer> nested exec 'doautocmd LookupFile CursorHoldI' |
|
||||
\ au! LookupFileCursorHoldImm
|
||||
aug END
|
||||
endif
|
||||
call s:LookupFileSet()
|
||||
aug LookupFileReset
|
||||
au!
|
||||
au CursorMovedI <buffer> call <SID>LookupFileSet()
|
||||
au CursorMoved <buffer> call <SID>LookupFileSet()
|
||||
au WinEnter <buffer> call <SID>LookupFileSet()
|
||||
au TabEnter <buffer> call <SID>LookupFileSet()
|
||||
au WinEnter * call <SID>LookupFileReset(0)
|
||||
au TabEnter * call <SID>LookupFileReset(0)
|
||||
au CursorMoved * call <SID>LookupFileReset(0)
|
||||
" Better be safe than sorry.
|
||||
au BufHidden <buffer> call <SID>LookupFileReset(1)
|
||||
aug END
|
||||
endfunction
|
||||
|
||||
function! lookupfile#CloseWindow()
|
||||
if bufnr('%') != s:myBufNum
|
||||
return
|
||||
endif
|
||||
|
||||
call s:LookupFileReset(1)
|
||||
close
|
||||
endfunction
|
||||
|
||||
function! lookupfile#ClearCache()
|
||||
let g:lookupfile#lastPattern = ""
|
||||
let g:lookupfile#lastResults = []
|
||||
endfunction
|
||||
|
||||
function! s:LookupFileSet()
|
||||
if bufnr('%') != s:myBufNum || exists('s:_backspace')
|
||||
return
|
||||
endif
|
||||
let s:_backspace = &backspace
|
||||
set backspace=start
|
||||
let s:_completeopt = &completeopt
|
||||
set completeopt+=menuone
|
||||
let s:_updatetime = &updatetime
|
||||
let &updatetime = g:LookupFile_UpdateTime
|
||||
endfunction
|
||||
|
||||
function! s:LookupFileReset(force)
|
||||
if a:force
|
||||
aug LookupFileReset
|
||||
au!
|
||||
aug END
|
||||
endif
|
||||
" Ignore the event while in the same buffer.
|
||||
if exists('s:_backspace') && (a:force || (bufnr('%') != s:myBufNum))
|
||||
let &backspace = s:_backspace
|
||||
let &completeopt = s:_completeopt
|
||||
let &updatetime = s:_updatetime
|
||||
unlet s:_backspace s:_completeopt s:_updatetime
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:HidePopup()
|
||||
let s:popupIsHidden = 1
|
||||
return "\<C-E>"
|
||||
endfunction
|
||||
|
||||
function! lookupfile#IsPopupHidden()
|
||||
return s:popupIsHidden
|
||||
endfunction
|
||||
|
||||
function! s:SetupBuf()
|
||||
call genutils#SetupScratchBuffer()
|
||||
resize 1
|
||||
setlocal wrap
|
||||
setlocal bufhidden=hide
|
||||
setlocal winfixheight
|
||||
setlocal wrapmargin=0
|
||||
setlocal textwidth=0
|
||||
setlocal completefunc=lookupfile#Complete
|
||||
syn clear
|
||||
set ft=lookupfile
|
||||
" Setup maps to open the file.
|
||||
inoremap <silent> <buffer> <expr> <C-E> <SID>HidePopup()
|
||||
inoremap <silent> <buffer> <expr> <CR> <SID>AcceptFile(0, "\<CR>")
|
||||
inoremap <silent> <buffer> <expr> <C-O> <SID>AcceptFile(1, "\<C-O>")
|
||||
" This prevents the "Whole line completion" from getting triggered with <BS>,
|
||||
" however this might make the dropdown kind of flash.
|
||||
inoremap <buffer> <expr> <BS> pumvisible()?"\<C-E>\<BS>":"\<BS>"
|
||||
inoremap <buffer> <expr> <S-BS> pumvisible()?"\<C-E>\<BS>":"\<BS>"
|
||||
" Make <C-Y> behave just like <CR>
|
||||
imap <buffer> <C-Y> <CR>
|
||||
if g:LookupFile_EscCancelsPopup
|
||||
inoremap <buffer> <expr> <Esc> pumvisible()?"\<C-E>\<C-C>":"\<Esc>"
|
||||
endif
|
||||
inoremap <buffer> <expr> <silent> <Down> <SID>GetCommand(1, 1, "\<C-N>",
|
||||
\ "\"\\<Lt>C-N>\"")
|
||||
inoremap <buffer> <expr> <silent> <Up> <SID>GetCommand(1, 1, "\<C-P>",
|
||||
\ "\"\\<Lt>C-P>\"")
|
||||
inoremap <buffer> <expr> <silent> <PageDown> <SID>GetCommand(1, 0,
|
||||
\ "\<PageDown>", '')
|
||||
inoremap <buffer> <expr> <silent> <PageUp> <SID>GetCommand(1, 0,
|
||||
\ "\<PageUp>", '')
|
||||
nnoremap <silent> <buffer> o :OpenFile<CR>
|
||||
nnoremap <silent> <buffer> O :OpenFile!<CR>
|
||||
command! -buffer -nargs=0 -bang OpenFile
|
||||
\ :call <SID>OpenCurFile('<bang>' != '')
|
||||
command! -buffer -nargs=0 -bang AddPattern :call <SID>AddPattern()
|
||||
nnoremap <buffer> <silent> <Plug>LookupFile :call lookupfile#CloseWindow()<CR>
|
||||
inoremap <buffer> <silent> <Plug>LookupFile <C-E><C-C>:call lookupfile#CloseWindow()<CR>
|
||||
|
||||
aug LookupFile
|
||||
au!
|
||||
if g:LookupFile_ShowFiller
|
||||
exec 'au' (g:LookupFile_OnCursorMovedI ? 'CursorMovedI' : 'CursorHoldI')
|
||||
\ '<buffer> call <SID>ShowFiller()'
|
||||
endif
|
||||
exec 'au' (g:LookupFile_OnCursorMovedI ? 'CursorMovedI' : 'CursorHoldI')
|
||||
\ '<buffer> call lookupfile#LookupFile(0)'
|
||||
aug END
|
||||
endfunction
|
||||
|
||||
function! s:GetCommand(withPopupTrigger, withSkipPat, actCmd, innerCmd)
|
||||
let cmd = ''
|
||||
if a:withPopupTrigger && !pumvisible()
|
||||
let cmd .= "\<C-X>\<C-U>"
|
||||
endif
|
||||
let cmd .= a:actCmd. "\<C-R>=(getline('.') == lookupfile#lastPattern) ? ".
|
||||
\ a:innerCmd." : ''\<CR>"
|
||||
return cmd
|
||||
endfunction
|
||||
|
||||
function! s:AddPattern()
|
||||
if g:LookupFile_PreservePatternHistory
|
||||
silent! put! =g:lookupfile#lastPattern
|
||||
$
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:AcceptFile(splitWin, key)
|
||||
if s:popupIsHidden
|
||||
return a:key
|
||||
endif
|
||||
if !pumvisible()
|
||||
call lookupfile#LookupFile(0, 1)
|
||||
endif
|
||||
let acceptCmd = ''
|
||||
if type(g:LookupFile_LookupAcceptFunc) == 2 ||
|
||||
\ (type(g:LookupFile_LookupAcceptFunc) == 1 &&
|
||||
\ substitute(g:LookupFile_LookupAcceptFunc, '\s', '', 'g') != '')
|
||||
let acceptCmd = call(g:LookupFile_LookupAcceptFunc, [a:splitWin, a:key])
|
||||
else
|
||||
let acceptCmd = lookupfile#AcceptFile(a:splitWin, a:key)
|
||||
endif
|
||||
|
||||
return (!pumvisible() ? "\<C-X>\<C-U>" : '').acceptCmd
|
||||
endfunction
|
||||
|
||||
function! s:IsValid(fileName)
|
||||
if bufnr('%') != s:myBufNum || a:fileName == ''
|
||||
return 0
|
||||
endif
|
||||
if !filereadable(a:fileName) && !isdirectory(a:fileName)
|
||||
if g:LookupFile_AllowNewFiles
|
||||
" Check if the parent directory exists, then we can create a new buffer
|
||||
" (Ido feature)
|
||||
let parent = fnamemodify(a:fileName, ':h')
|
||||
if parent == '' || (parent != '' && !isdirectory(parent))
|
||||
return 1
|
||||
endif
|
||||
endif
|
||||
return 0
|
||||
endif
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
function! lookupfile#AcceptFile(splitWin, key)
|
||||
if len(g:lookupfile#lastResults) == 0 && !s:IsValid(getline('.'))
|
||||
return "\<C-O>:echohl ErrorMsg | echo 'No such file or directory' | echohl NONE\<CR>"
|
||||
endif
|
||||
|
||||
" Skip the first match, which is essentially the same as pattern.
|
||||
let nextCmd = "\<C-N>\<C-R>=(getline('.') == lookupfile#lastPattern)?\"\\<C-N>\":''\<CR>"
|
||||
let acceptCmd = "\<C-Y>\<Esc>:AddPattern\<CR>:OpenFile".(a:splitWin?'!':'').
|
||||
\ "\<CR>"
|
||||
if getline('.') ==# g:lookupfile#lastPattern
|
||||
if len(g:lookupfile#lastResults) == 0
|
||||
" FIXME: shouldn't this be an error?
|
||||
let acceptCmd = acceptCmd
|
||||
elseif len(g:lookupfile#lastResults) == 1 || g:LookupFile_AlwaysAcceptFirst
|
||||
" If there is only one file, we will also select it (if not already
|
||||
" selected)
|
||||
let acceptCmd = nextCmd.acceptCmd
|
||||
else
|
||||
let acceptCmd = nextCmd
|
||||
endif
|
||||
endif
|
||||
|
||||
return acceptCmd
|
||||
endfunction
|
||||
|
||||
function! s:OpenCurFile(splitWin)
|
||||
let fileName = getline('.')
|
||||
if fileName =~ '^\s*$'
|
||||
return
|
||||
endif
|
||||
if !s:IsValid(fileName)
|
||||
echohl ErrorMsg | echo 'No such file or directory' | echohl NONE
|
||||
endif
|
||||
|
||||
if type(g:LookupFile_LookupNotifyFunc) == 2 ||
|
||||
\ (type(g:LookupFile_LookupNotifyFunc) == 1 &&
|
||||
\ substitute(g:LookupFile_LookupNotifyFunc, '\s', '', 'g') != '')
|
||||
call call(g:LookupFile_LookupNotifyFunc, [])
|
||||
endif
|
||||
call lookupfile#CloseWindow()
|
||||
|
||||
" Update the recent files list.
|
||||
if g:LookupFile_RecentFileListSize > 0
|
||||
let curPos = index(g:lookupfile#recentFiles, fileName)
|
||||
call add(g:lookupfile#recentFiles, fileName)
|
||||
if curPos != -1
|
||||
call remove(g:lookupfile#recentFiles, curPos)
|
||||
elseif len(g:lookupfile#recentFiles) > g:LookupFile_RecentFileListSize
|
||||
let g:lookupfile#recentFiles = g:lookupfile#recentFiles[
|
||||
\ -g:LookupFile_RecentFileListSize :]
|
||||
endif
|
||||
endif
|
||||
|
||||
let bufnr = genutils#FindBufferForName(fileName)
|
||||
let winnr = bufwinnr(bufnr)
|
||||
if winnr == -1 && g:LookupFile_SearchForBufsInTabs
|
||||
for i in range(tabpagenr('$'))
|
||||
if index(tabpagebuflist(i+1), bufnr) != -1
|
||||
" Switch to the tab and set winnr.
|
||||
exec 'tabnext' (i+1)
|
||||
let winnr = bufwinnr(bufnr)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
if winnr != -1
|
||||
exec winnr.'wincmd w'
|
||||
else
|
||||
let splitOpen = 0
|
||||
if &switchbuf ==# 'split' || a:splitWin
|
||||
let splitOpen = 1
|
||||
endif
|
||||
" First try opening as a buffer, if it fails, we will open as a file.
|
||||
try
|
||||
if bufnr == -1
|
||||
throw ''
|
||||
endif
|
||||
exec (splitOpen?'s':'').'buffer' bufnr
|
||||
catch /^Vim\%((\a\+)\)\=:E325/
|
||||
" Ignore, this anyway means the file was found.
|
||||
catch
|
||||
try
|
||||
exec (splitOpen?'split':'edit') fileName
|
||||
catch /^Vim\%((\a\+)\)\=:E325/
|
||||
" Ignore, this anyway means the file was found.
|
||||
endtry
|
||||
endtry
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:ShowFiller()
|
||||
return lookupfile#LookupFile(1)
|
||||
endfunction
|
||||
|
||||
function! lookupfile#Complete(findstart, base)
|
||||
if a:findstart
|
||||
return 0
|
||||
else
|
||||
call lookupfile#LookupFile(0, 1, a:base)
|
||||
return g:lookupfile#lastStatsMsg+g:lookupfile#lastResults
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! lookupfile#LookupFile(showingFiller, ...)
|
||||
let generateMode = (a:0 == 0 ? 0 : a:1)
|
||||
if generateMode
|
||||
let pattern = (a:0 > 1) ? a:2 : getline('.')
|
||||
else
|
||||
let pattern = getline('.')
|
||||
" The normal completion behavior is to stop completion when cursor is moved.
|
||||
if col('.') == 1 || (col('.') != col('$'))
|
||||
return ''
|
||||
endif
|
||||
endif
|
||||
if pattern == '' || (pattern ==# g:lookupfile#lastPattern && pumvisible())
|
||||
return ''
|
||||
endif
|
||||
|
||||
if s:popupIsHidden && g:lookupfile#lastPattern ==# pattern
|
||||
return ''
|
||||
endif
|
||||
let s:popupIsHidden = 0
|
||||
|
||||
let statusMsg = ''
|
||||
if pattern == ' '
|
||||
if len(g:lookupfile#recentFiles) == 0
|
||||
let statusMsg = '<<< No recent files >>>'
|
||||
let files = []
|
||||
else
|
||||
let statusMsg = '<<< Showing '.len(g:lookupfile#recentFiles).' recent files >>>'
|
||||
let files = reverse(copy(g:lookupfile#recentFiles))
|
||||
endif
|
||||
elseif strlen(pattern) < g:LookupFile_MinPatLength
|
||||
let statusMsg = '<<< Type at least '.g:LookupFile_MinPatLength.
|
||||
\ ' characters >>>'
|
||||
let files = []
|
||||
" We ignore filler when we have the result in hand.
|
||||
elseif g:lookupfile#lastPattern ==# pattern
|
||||
" This helps at every startup as we start with the previous pattern.
|
||||
let files = g:lookupfile#lastResults
|
||||
elseif a:showingFiller
|
||||
" Just show a filler and return. We could return this as the only match, but
|
||||
" unless 'completeopt' has "menuone", menu doesn't get shown.
|
||||
let statusMsg = '<<< Looking up files... hit ^C to break >>>'
|
||||
let files = []
|
||||
else
|
||||
if type(g:LookupFile_LookupFunc) == 2 ||
|
||||
\ (type(g:LookupFile_LookupFunc) == 1 &&
|
||||
\ substitute(g:LookupFile_LookupFunc, '\s', '', 'g') != '')
|
||||
let files = call(g:LookupFile_LookupFunc, [pattern])
|
||||
else
|
||||
let _tags = &tags
|
||||
try
|
||||
let &tags = eval(g:LookupFile_TagExpr)
|
||||
let taglist = taglist(g:LookupFile_TagsExpandCamelCase ?
|
||||
\ lookupfile#ExpandCamelCase(pattern) : pattern)
|
||||
catch
|
||||
echohl ErrorMsg | echo "Exception: " . v:exception | echohl NONE
|
||||
return ''
|
||||
finally
|
||||
let &tags = _tags
|
||||
endtry
|
||||
|
||||
" Show the matches for what is typed so far.
|
||||
if g:LookupFile_UsingSpecializedTags
|
||||
let files = map(taglist, '{'.
|
||||
\ '"word": fnamemodify(v:val["filename"], ":p"), '.
|
||||
\ '"abbr": v:val["name"], '.
|
||||
\ '"menu": fnamemodify(v:val["filename"], ":h"), '.
|
||||
\ '"dup": 1, '.
|
||||
\ '}')
|
||||
else
|
||||
let files = map(taglist, 'fnamemodify(v:val["filename"], ":p")')
|
||||
endif
|
||||
endif
|
||||
|
||||
let pat = g:LookupFile_FileFilter
|
||||
if pat != ''
|
||||
call filter(files, '(type(v:val) == 4) ? v:val["word"] !~ pat : v:val !~ pat')
|
||||
endif
|
||||
|
||||
if g:LookupFile_SortMethod ==# 'alpha'
|
||||
" When UsingSpecializedTags, sort by the actual name (Timothy, Guo
|
||||
" (firemeteor dot guo at gmail dot com)).
|
||||
if type(get(files, 0)) == 4
|
||||
call sort(files, "s:CmpByName")
|
||||
else
|
||||
call sort(files)
|
||||
endif
|
||||
endif
|
||||
let g:lookupfile#lastPattern = pattern
|
||||
let g:lookupfile#lastResults = files
|
||||
endif
|
||||
if statusMsg == ''
|
||||
if len(files) > 0
|
||||
let statusMsg = '<<< '.len(files).' Matching >>>'
|
||||
else
|
||||
let statusMsg = '<<< None Matching >>>'
|
||||
endif
|
||||
endif
|
||||
let msgLine = [{'word': pattern, 'abbr': statusMsg, 'menu': pattern}]
|
||||
let g:lookupfile#lastStatsMsg = msgLine
|
||||
if !generateMode
|
||||
call complete(1, msgLine+files)
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! lookupfile#ExpandCamelCase(str)
|
||||
let pat = a:str
|
||||
" Check if there are at least two consecutive uppercase letters to turn on
|
||||
" the CamelCase expansion.
|
||||
if match(a:str, '\u\u') != -1
|
||||
let pat = '\C'.substitute(a:str, '\u\+',
|
||||
\ '\=substitute(submatch(0), ".", '."'".'&\\U*'."'".', "g")', 'g')
|
||||
let @*=pat
|
||||
endif
|
||||
return pat
|
||||
endfunction
|
||||
|
||||
function! s:CmpByName(i1, i2)
|
||||
let ileft = a:i1["abbr"]
|
||||
let iright = a:i2["abbr"]
|
||||
return ileft == iright ? 0 : ileft > iright ? 1 : -1
|
||||
endfunc
|
||||
|
||||
" Restore cpo.
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim6:fdm=marker et sw=2
|
||||
215
.vim/autoload/objc/cocoacomplete.vim
Normal file
215
.vim/autoload/objc/cocoacomplete.vim
Normal file
|
|
@ -0,0 +1,215 @@
|
|||
" File: cocoacomplete.vim (part of the cocoa.vim plugin)
|
||||
" Author: Michael Sanders (msanders42 [at] gmail [dot] com)
|
||||
" Last Updated: June 30, 2009
|
||||
" Description: An omni-completion plugin for Cocoa/Objective-C.
|
||||
|
||||
let s:lib_dir = fnameescape($HOME.'/.vim/lib/')
|
||||
let s:cocoa_indexes = s:lib_dir.'cocoa_indexes/'
|
||||
|
||||
if !isdirectory(s:cocoa_indexes)
|
||||
echom 'Error in cocoacomplete.vim: could not find ~/.vim/lib/cocoa_indexes directory'
|
||||
endif
|
||||
|
||||
fun! objc#cocoacomplete#Complete(findstart, base)
|
||||
if a:findstart
|
||||
" Column where completion starts:
|
||||
return match(getline('.'), '\k\+\%'.col('.').'c')
|
||||
else
|
||||
let matches = []
|
||||
let complete_type = s:GetCompleteType(line('.'), col('.') - 1)
|
||||
|
||||
if complete_type == 'methods'
|
||||
call s:Complete(a:base, ['alloc', 'init', 'retain', 'release',
|
||||
\ 'autorelease', 'retainCount',
|
||||
\ 'description', 'class', 'superclass',
|
||||
\ 'self', 'zone', 'isProxy', 'hash'])
|
||||
let obj_pos = s:GetObjPos(line('.'), col('.'))
|
||||
call extend(matches, s:CompleteMethod(line('.'), obj_pos, a:base))
|
||||
elseif complete_type == 'types' || complete_type == 'returntypes'
|
||||
let opt_types = complete_type == 'returntypes' ? ['IBAction'] : []
|
||||
call s:Complete(a:base, opt_types + ['void', 'id', 'BOOL', 'int',
|
||||
\ 'double', 'float', 'char'])
|
||||
call extend(matches, s:CompleteCocoa(a:base, 'classes', 'types',
|
||||
\ 'notifications'))
|
||||
elseif complete_type != ''
|
||||
if complete_type =~ 'function_params$'
|
||||
let complete_type = substitute(complete_type, 'function_params$', '', '')
|
||||
let functions = s:CompleteFunction(a:base)
|
||||
endif
|
||||
|
||||
" Mimic vim's dot syntax for other complete types (see :h ft).
|
||||
let word = a:base == '' ? 'NS' : a:base
|
||||
let args = [word] + split(complete_type, '\.')
|
||||
call extend(matches, call('s:CompleteCocoa', args))
|
||||
|
||||
" List functions after the other items in the menu.
|
||||
if exists('functions') | call extend(matches, functions) | endif
|
||||
endif
|
||||
return matches
|
||||
endif
|
||||
endf
|
||||
|
||||
fun s:GetCompleteType(lnum, col)
|
||||
let scopelist = map(synstack(a:lnum, a:col), 'synIDattr(v:val, "name")')
|
||||
if empty(scopelist) | return 'types' | endif
|
||||
|
||||
let current_scope = scopelist[-1]
|
||||
let beforeCursor = strpart(getline(a:lnum), 0, a:col)
|
||||
|
||||
" Completing a function name:
|
||||
if getline(a:lnum) =~ '\%'.(a:col + 1).'c\s*('
|
||||
return 'functions'
|
||||
elseif current_scope == 'objcSuperclass'
|
||||
return 'classes'
|
||||
" Inside brackets "[ ... ]":
|
||||
elseif index(scopelist, 'objcMessage') != -1
|
||||
return beforeCursor =~ '\[\k*$' ? 'classes' : 'methods'
|
||||
" Inside parentheses "( ... )":
|
||||
elseif current_scope == 'cParen'
|
||||
" Inside parentheses for method definition:
|
||||
if beforeCursor =~ '^\s*[-+]\s*([^{;]*'
|
||||
return beforeCursor =~ '^\s*[-+]\s*([^)]*$' ? 'returntypes' : 'types'
|
||||
" Inside function, loop, or conditional:
|
||||
else
|
||||
return 'classes.types.constants.function_params'
|
||||
endif
|
||||
" Inside braces "{ ... }" or after equals "=":
|
||||
elseif current_scope == 'cBlock' || current_scope == 'objcAssign' || current_scope == ''
|
||||
let type = current_scope == 'cBlock' ? 'types.constants.' : ''
|
||||
let type = 'classes.'.type.'function_params'
|
||||
|
||||
if beforeCursor =~ 'IBOutlet' | return 'classes' | endif
|
||||
return beforeCursor =~ '\v(^|[{};=\])]|return)\s*\k*$'? type : 'methods'
|
||||
" Directly inside "@implementation ... @end" or "@interface ... @end"
|
||||
elseif current_scope == 'objcImp' || current_scope == 'objcHeader'
|
||||
" TODO: Complete delegate/subclass methods
|
||||
endif
|
||||
return ''
|
||||
endf
|
||||
|
||||
" Adds item to the completion menu if they match the base.
|
||||
fun s:Complete(base, items)
|
||||
for item in a:items
|
||||
if item =~ '^'.a:base | call complete_add(item) | endif
|
||||
endfor
|
||||
endf
|
||||
|
||||
" Returns position of "foo" in "[foo bar]" or "[baz bar: [foo bar]]".
|
||||
fun s:GetObjPos(lnum, col)
|
||||
let beforeCursor = strpart(getline(a:lnum), 0, a:col)
|
||||
return match(beforeCursor, '\v.*(^|[\[=;])\s*\[*\zs[A-Za-z0-9_@]+') + 1
|
||||
endf
|
||||
|
||||
" Completes a method given the position of the object and the method
|
||||
" being completed.
|
||||
fun s:CompleteMethod(lnum, col, method)
|
||||
let class = s:GetCocoaClass(a:lnum, a:col)
|
||||
if class == ''
|
||||
let object = matchstr(getline(a:lnum), '\%'.a:col.'c\k\+')
|
||||
let class = s:GetDeclWord(object)
|
||||
if class == '' | return [] | endif
|
||||
endif
|
||||
let method = s:GetMethodName(a:lnum, a:col, a:method)
|
||||
let matches = split(system(s:lib_dir.'get_methods.sh '.class.
|
||||
\ '|grep "^'.method.'"'), "\n")
|
||||
if exists('g:loaded_snips') " Use snipMate if it's installed
|
||||
call objc#pum_snippet#Map()
|
||||
else " Otherwise, only complete the method name.
|
||||
call map(matches, 'substitute(v:val, ''\v:\zs.{-}\ze(\w+:|$)'', " ", "g")')
|
||||
endif
|
||||
|
||||
" If dealing with a partial method name, only complete past it. E.g., in
|
||||
" "[NSString stringWithCharacters:baz l|]" (where | is the cursor),
|
||||
" only return "length", not "stringWithCharacters:length:".
|
||||
if stridx(method, ':') != -1
|
||||
let method = substitute(method, a:method.'$', '\\\\zs&', '')
|
||||
call map(matches, 'matchstr(v:val, "'.method.'.*")')
|
||||
endif
|
||||
return matches
|
||||
endf
|
||||
|
||||
" Returns the Cocoa class at a given position if it exists, or
|
||||
" an empty string "" if it doesn't.
|
||||
fun s:GetCocoaClass(lnum, col)
|
||||
let class = matchstr(getline(a:lnum), '\%'.a:col.'c[A-Za-z0-9_"@]\+')
|
||||
if class =~ '^@"' | return 'NSString' | endif " Treat @"..." as an NSString
|
||||
let v:errmsg = ''
|
||||
sil! hi cocoaClass
|
||||
if v:errmsg == '' && synIDattr(synID(a:lnum, a:col, 0), 'name') == 'cocoaClass'
|
||||
return class " If cocoaClass is defined, try using that.
|
||||
endif
|
||||
return system('grep ^'.class.' '.s:cocoa_indexes.'classes.txt') != ''
|
||||
\ ? class : '' " Use grep as a fallback.
|
||||
endf
|
||||
|
||||
" Returns the word before a variable declaration.
|
||||
fun s:GetDeclWord(var)
|
||||
let startpos = [line('.'), col('.')]
|
||||
let line_found = searchdecl(a:var) != 0 ? 0 : line('.')
|
||||
call cursor(startpos)
|
||||
let matchstr = '\v(IBOutlet\s+)=\zs\k+\s*\ze\**\s*'
|
||||
|
||||
" If the declaration was not found in the implementation file, check
|
||||
" the header.
|
||||
if !line_found && expand('%:e') == 'm'
|
||||
let header_path = expand('%:p:r').'.h'
|
||||
if filereadable(header_path)
|
||||
for line in readfile(header_path)
|
||||
if line =~ '^\s*\(IBOutlet\)\=\s*\k*\s*\ze\**\s*'.a:var.'\s*'
|
||||
return matchstr(line, matchstr)
|
||||
endif
|
||||
endfor
|
||||
return ''
|
||||
endif
|
||||
endif
|
||||
|
||||
return matchstr(getline(line_found), matchstr.a:var)
|
||||
endf
|
||||
|
||||
fun s:SearchList(list, regex)
|
||||
for line in a:list
|
||||
if line =~ a:regex
|
||||
return line
|
||||
endif
|
||||
endfor
|
||||
return ''
|
||||
endf
|
||||
|
||||
" Returns the method name, ready to be searched by grep.
|
||||
" The "base" word needs to be passed in separately, because
|
||||
" Vim apparently removes it from the line during completions.
|
||||
fun s:GetMethodName(lnum, col, base)
|
||||
let line = getline(a:lnum)
|
||||
let col = matchend(line, '\%'.a:col.'c\S\+\s\+') + 1 " Skip past class name.
|
||||
if line =~ '\%'.col.'c\k\+:'
|
||||
let base = a:base == '' ? '' : ' '.a:base
|
||||
let method = matchstr(line, '\%'.col.'c.\{-}\ze]').base
|
||||
return substitute(method, '\v\k+:\zs.{-}\ze(\s*\k+:|'.base.'$)', '[^:]*', 'g')
|
||||
else
|
||||
return a:base
|
||||
endif
|
||||
endf
|
||||
|
||||
" Completes Cocoa functions, using snippets for the parameters if possible.
|
||||
fun s:CompleteFunction(word)
|
||||
let files = s:cocoa_indexes.'functions.txt' " TODO: Add C functions.
|
||||
let matches = split(system('zgrep -h "^'.a:word.'" '.files), "\n")
|
||||
if exists('g:loaded_snips') " Use snipMate if it's installed
|
||||
call objc#pum_snippet#Map()
|
||||
else " Otherwise, just complete the function name
|
||||
call map(matches, "{'word':matchstr(v:val, '^\\k\\+'), 'abbr':v:val}")
|
||||
endif
|
||||
return matches
|
||||
endf
|
||||
|
||||
" Completes word for Cocoa "classes", "types", "notifications", or "constants".
|
||||
" (supplied as the optional parameters).
|
||||
fun s:CompleteCocoa(word, file, ...)
|
||||
let files = ''
|
||||
for file in [a:file] + a:000
|
||||
let files .= ' '.s:cocoa_indexes.file.'.txt'
|
||||
endfor
|
||||
|
||||
return split(system('grep -ho "^'.a:word.'[A-Za-z0-9_]*" '.files), "\n")
|
||||
endf
|
||||
" vim:noet:sw=4:ts=4:ft=vim
|
||||
160
.vim/autoload/objc/man.vim
Normal file
160
.vim/autoload/objc/man.vim
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
" File: objc#man.vim (part of the cocoa.vim plugin)
|
||||
" Author: Michael Sanders (msanders42 [at] gmail [dot] com)
|
||||
" Description: Allows you to look up Cocoa API docs in Vim.
|
||||
" Last Updated: June 30, 2009
|
||||
" NOTE: See http://mymacinations.com/2008/02/06/changing-the-systems-default-settings-for-html-files-safe/
|
||||
" for removing the annoying security alert in Leopard.
|
||||
|
||||
" Return all matches in for ":CocoaDoc <tab>" sorted by length.
|
||||
fun objc#man#Completion(ArgLead, CmdLine, CursorPos)
|
||||
return system('grep -ho "^'.a:ArgLead.'\w*" ~/.vim/lib/cocoa_indexes/*.txt'.
|
||||
\ "| perl -e 'print sort {length $a <=> length $b} <>'")
|
||||
endf
|
||||
|
||||
let s:docsets = []
|
||||
for path in ['/Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset',
|
||||
\ '/Developer/Platforms/iPhoneOS.platform/Developer/Documentation/DocSets/com.apple.adc.documentation.AppleiPhone3_0.iPhoneLibrary.docset']
|
||||
if isdirectory(path)
|
||||
call add(s:docsets, path)
|
||||
endif
|
||||
endfor
|
||||
|
||||
let s:docset_cmd = '/Developer/usr/bin/docsetutil search -skip-text -query '
|
||||
|
||||
fun s:OpenFile(file)
|
||||
if a:file =~ '/.*/man/'
|
||||
exe ':!'.substitute(&kp, '^man -s', 'man', '').' '.a:file
|
||||
else
|
||||
" /usr/bin/open strips the #fragments in file:// URLs, which we need,
|
||||
" so I'm using applescript instead.
|
||||
call system('osascript -e ''open location "file://'.a:file.'"'' &')
|
||||
endif
|
||||
endf
|
||||
|
||||
fun objc#man#ShowDoc(...)
|
||||
let word = a:0 ? a:1 : matchstr(getline('.'), '\<\w*\%'.col('.').'c\w\+:\=')
|
||||
|
||||
" Look up the whole method if it takes multiple arguments.
|
||||
if !a:0 && word[len(word) - 1] == ':'
|
||||
let word = s:GetMethodName()
|
||||
endif
|
||||
|
||||
if word == ''
|
||||
if !a:0 " Mimic K if using it as such
|
||||
echoh ErrorMsg
|
||||
echo 'E349: No identifier under cursor'
|
||||
echoh None
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
let references = {}
|
||||
|
||||
" First check Cocoa docs for word using docsetutil
|
||||
for docset in s:docsets
|
||||
let response = split(system(s:docset_cmd.word.' '.docset), "\n")
|
||||
let docset .= '/Contents/Resources/Documents/' " Actual path of files
|
||||
for line in response
|
||||
" Format string is: " Language/type/class/word path"
|
||||
let path = matchstr(line, '\S*$')
|
||||
if path[0] != '/' | let path = docset.path | endif
|
||||
if has_key(references, path) | continue | endif " Ignore duplicate entries
|
||||
|
||||
let [lang, type, class] = split(matchstr(line, '^ \zs*\S*'), '/')[:2]
|
||||
" If no class if given use type instead
|
||||
if class == '-' | let class = type | endif
|
||||
let references[path] = {'lang': lang, 'class': class}
|
||||
endfor
|
||||
endfor
|
||||
|
||||
" Then try man
|
||||
let man = system('man -S2:3 -aW '.word)
|
||||
if man !~ '^No manual entry'
|
||||
for path in split(man, "\n")
|
||||
if !has_key(references, path)
|
||||
let references[path] = {'lang': 'C', 'class': 'man'}
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
if len(references) == 1
|
||||
return s:OpenFile(keys(references)[0])
|
||||
elseif !empty(references)
|
||||
echoh ModeMsg | echo word | echoh None
|
||||
return s:ChooseFrom(references)
|
||||
else
|
||||
echoh WarningMsg
|
||||
echo "Can't find documentation for ".word
|
||||
echoh None
|
||||
endif
|
||||
endf
|
||||
|
||||
fun s:ChooseFrom(references)
|
||||
let type_abbr = {'cl' : 'Class', 'intf' : 'Protocol', 'cat' : 'Category',
|
||||
\ 'intfm' : 'Method', 'instm' : 'Method', 'econst' : 'Enum',
|
||||
\ 'tdef' : 'Typedef', 'macro' : 'Macro', 'data' : 'Data',
|
||||
\ 'func' : 'Function'}
|
||||
let inputlist = []
|
||||
" Don't display "Objective-C" if all items are objc
|
||||
let show_lang = !AllKeysEqual(values(a:references), 'lang', 'Objective-C')
|
||||
let i = 1
|
||||
for ref in values(a:references)
|
||||
let class = ref.class
|
||||
if has_key(type_abbr, class) | let class = type_abbr[class] | endif
|
||||
call add(inputlist, i.'. '.(show_lang ? ref['lang'].' ' : '').class)
|
||||
let i += 1
|
||||
endfor
|
||||
let num = inputlist(inputlist)
|
||||
return num ? s:OpenFile(keys(a:references)[num - 1]) : -1
|
||||
endf
|
||||
|
||||
fun AllKeysEqual(list, key, item)
|
||||
for item in a:list
|
||||
if item[a:key] != a:item
|
||||
return 0
|
||||
endif
|
||||
endfor
|
||||
return 1
|
||||
endf
|
||||
|
||||
fun s:GetMethodName()
|
||||
let pos = [line('.'), col('.')]
|
||||
let startpos = searchpos('\v^\s*-.{-}\w+:|\[\s*\w+\s+\w+:|\]\s*\w+:', 'cbW')
|
||||
|
||||
" Method declaration (- (foo) bar:)
|
||||
if getline(startpos[0]) =~ '^\s*-.\{-}\w\+:'
|
||||
let endpos = searchpos('{', 'W')
|
||||
" Message inside brackets ([foo bar: baz])
|
||||
else
|
||||
let endpos = searchpairpos('\[', '', '\]', 'W')
|
||||
endif
|
||||
call cursor(pos)
|
||||
|
||||
if startpos[0] == 0 || endpos[0] == 0 | return '' | endif
|
||||
let lines = getline(startpos[0], endpos[0])
|
||||
|
||||
let lines[0] = strpart(lines[0], startpos[1] - 1)
|
||||
let lines[-1] = strpart(lines[-1], 0, endpos[1])
|
||||
|
||||
" Ignore outer brackets
|
||||
let message = substitute(join(lines), '^\[\|\]$', '', '')
|
||||
" Ignore nested messages [...]
|
||||
let message = substitute(message, '\[.\{-}\]', '', 'g')
|
||||
" Ignore strings (could contain colons)
|
||||
let message = substitute(message, '".\{-}"', '', 'g')
|
||||
" Ignore @selector(...)
|
||||
let message = substitute(message, '@selector(.\{-})', '', 'g')
|
||||
|
||||
return s:MatchAll(message, '\w\+:')
|
||||
endf
|
||||
|
||||
fun s:MatchAll(haystack, needle)
|
||||
let matches = matchstr(a:haystack, a:needle)
|
||||
let index = matchend(a:haystack, a:needle)
|
||||
while index != -1
|
||||
let matches .= matchstr(a:haystack, a:needle, index + 1)
|
||||
let index = matchend(a:haystack, a:needle, index + 1)
|
||||
endw
|
||||
return matches
|
||||
endf
|
||||
" vim:noet:sw=4:ts=4:ft=vim
|
||||
124
.vim/autoload/objc/method_builder.vim
Normal file
124
.vim/autoload/objc/method_builder.vim
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
" File: objc#method_builder.vim (part of the cocoa.vim plugin)
|
||||
" Author: Michael Sanders (msanders42 [at] gmail [dot] com)
|
||||
" Description: Builds an empty implementation (*.m) file given a header (*.h)
|
||||
" file. When called with no arguments (simply ":BuildMethods"),
|
||||
" it looks for the corresponding header file of the current *.m
|
||||
" file (e.g. "foo.m" -> "foo.h").
|
||||
" Last Updated: June 03, 2009
|
||||
" - make sure you're not in a comment
|
||||
|
||||
" TODO: Relative pathnames
|
||||
fun objc#method_builder#Completion(ArgLead, CmdLine, CursorPos)
|
||||
let dir = stridx(a:ArgLead, '/') == -1 ? getcwd() : fnamemodify(a:ArgLead, ':h')
|
||||
let search = fnamemodify(a:ArgLead, ':t')
|
||||
let files = split(glob(dir.'/'.search.'*.h')
|
||||
\ ."\n".glob(dir.'/'.search.'*/'), "\n")
|
||||
call map(files, 'fnameescape(fnamemodify(v:val, ":."))')
|
||||
return files
|
||||
endf
|
||||
|
||||
fun s:Error(msg)
|
||||
echoh ErrorMsg | echo a:msg | echoh None
|
||||
return -1
|
||||
endf
|
||||
|
||||
fun s:GetDeclarations(file)
|
||||
let header = readfile(a:file)
|
||||
let template = []
|
||||
let in_comment = 0
|
||||
let in_header = 0
|
||||
let looking_for_semi = 0
|
||||
|
||||
for line in header
|
||||
if in_comment
|
||||
if stridx(line, '*/') != -1 | let in_comment = 0 | endif
|
||||
continue " Ignore declarations inside multi-line comments
|
||||
elseif stridx(line, '/*') != -1
|
||||
let in_comment = 1 | continue
|
||||
endif
|
||||
|
||||
if stridx(line, '@interface') != -1
|
||||
let in_header = 1
|
||||
let template += ['@implementation'.matchstr(line, '@interface\zs\s\+\w\+'), '']
|
||||
continue
|
||||
elseif in_header && stridx(line, '@end') != -1
|
||||
let in_header = 0
|
||||
call add(template, '@end')
|
||||
break " Only process one @interface at a time, for now.
|
||||
endif
|
||||
if !in_header | continue | endif
|
||||
|
||||
let first_char = strpart(line, 0, 1)
|
||||
if first_char == '-' || first_char == '+' || looking_for_semi
|
||||
let semi_pos = stridx(line, ';')
|
||||
let looking_for_semi = semi_pos == -1
|
||||
if looking_for_semi
|
||||
call add(template, line)
|
||||
else
|
||||
call add(template, strpart(line, 0, semi_pos))
|
||||
let template += ['{', "\t", '}', '']
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
return template
|
||||
endf
|
||||
|
||||
fun objc#method_builder#Build(header)
|
||||
let headerfile = a:header == '' ? expand('%:p:r').'.h' : a:header
|
||||
if expand('%:e') != 'm'
|
||||
return s:Error('Not in an implementation file.')
|
||||
elseif !filereadable(headerfile)
|
||||
return s:Error('Could not read header file.')
|
||||
endif
|
||||
|
||||
let declarations = s:GetDeclarations(headerfile)
|
||||
|
||||
if empty(declarations)
|
||||
return s:Error('Header file has no method declarations!')
|
||||
endif
|
||||
|
||||
let len = len(declarations)
|
||||
let last_change = line('.')
|
||||
|
||||
if search('\V'.substitute(declarations[0], '\s\+', '\\s\\+', ''))
|
||||
if !searchpair('@implementation', '', '@end', 'W')
|
||||
return s:Error('Missing @end declaration.')
|
||||
endif
|
||||
let i = 2 " Skip past the @implementation line & blank line
|
||||
let len -= 1 " Skip past @end declaration
|
||||
let lnum = line('.') - 1
|
||||
else
|
||||
let i = 0
|
||||
let lnum = line('.')
|
||||
endif
|
||||
let start_line = lnum
|
||||
|
||||
while i < len
|
||||
let is_method = declarations[i][0] =~ '@\|+\|-'
|
||||
if !is_method || !search('\V'.substitute(escape(declarations[i], '\'),
|
||||
\ 'void\|IBAction', '\\(void\\|IBAction\\)', 'g'), 'n')
|
||||
call append(lnum, declarations[i])
|
||||
let lnum += 1
|
||||
if is_method | let last_change = lnum | endif
|
||||
else " Skip method declaration if it is already declared.
|
||||
if declarations[i][0] == '@'
|
||||
let i += 1
|
||||
else
|
||||
while declarations[i] != '}' && i < len
|
||||
let i += 1
|
||||
endw
|
||||
let i += 1
|
||||
endif
|
||||
endif
|
||||
let i += 1
|
||||
endw
|
||||
call cursor(last_change, 1)
|
||||
|
||||
if lnum == start_line
|
||||
echoh WarningMsg
|
||||
let class = matchstr(declarations[0], '@implementation\s\+\zs.*')
|
||||
echo 'The methods for the "'.class.'" class have already been declared.'
|
||||
echoh None
|
||||
endif
|
||||
endf
|
||||
" vim:noet:sw=4:ts=4:ft=vim
|
||||
115
.vim/autoload/objc/method_list.vim
Normal file
115
.vim/autoload/objc/method_list.vim
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
" File: objc#method_list.vim (part of the cocoa.vim plugin)
|
||||
" Author: Michael Sanders (msanders42 [at] gmail [dot] com)
|
||||
" Description: Opens a split window containing the methods of the current file.
|
||||
" Last Updated: July 13, 2009
|
||||
|
||||
au WinLeave Method\ List call<SID>LeaveMethodList()
|
||||
au WinEnter Method\ List call objc#method_list#Activate(0)
|
||||
|
||||
fun objc#method_list#Activate(update)
|
||||
let s:opt = {'is':&is, 'hls': &hls} " Save current options.
|
||||
let s:last_search = @/
|
||||
set is nohls
|
||||
" If methodlist has already been opened, reactivate it.
|
||||
if exists('s:mlist_buffer') && bufexists(s:mlist_buffer)
|
||||
let mlist_win = bufwinnr(s:mlist_buffer)
|
||||
if mlist_win == -1
|
||||
sil exe 'belowright sbuf '.s:mlist_buffer
|
||||
if a:update | call s:UpdateMethodList() | endif
|
||||
elseif winbufnr(2) == -1
|
||||
quit " If no other windows are open, close the method list automatically.
|
||||
else " If method list is out of focus, bring it back into focus.
|
||||
exe mlist_win.'winc w'
|
||||
endif
|
||||
else " Otherwise, create the method list.
|
||||
call s:CreateMethodList()
|
||||
call s:UpdateMethodList()
|
||||
endif
|
||||
endf
|
||||
|
||||
fun s:CreateMethodList()
|
||||
botright new
|
||||
|
||||
let s:sortPref = 0
|
||||
let s:mlist_buffer = bufnr('%')
|
||||
|
||||
sil file Method\ List
|
||||
setl bt=nofile bh=wipe noswf nobl nonu nowrap syn=objc
|
||||
syn match objcPragmark '^[^-+@].*$'
|
||||
hi objcPragmark gui=italic term=underline
|
||||
|
||||
nn <silent> <buffer> <cr> :cal<SID>SelectMethod()<cr>
|
||||
nn <buffer> q <c-w>q
|
||||
nn <buffer> p <c-w>p
|
||||
nm <buffer> l p
|
||||
nm <buffer> <2-leftmouse> <cr>
|
||||
endf
|
||||
|
||||
" Returns the lines of all the matches in a dictionary
|
||||
fun s:GetAllMatches(needle)
|
||||
let startpos = [line('.'), col('.')]
|
||||
call cursor(1, 1)
|
||||
|
||||
let results = {}
|
||||
let line = search(a:needle, 'Wc')
|
||||
let key = matchstr(getline(line), a:needle)
|
||||
if !s:InComment(line, 1) && key != ''
|
||||
let results[key] = line
|
||||
endif
|
||||
|
||||
while 1
|
||||
let line = search(a:needle, 'W')
|
||||
if !line | break | endif
|
||||
let key = matchstr(getline(line), a:needle)
|
||||
if !s:InComment(line, 1) && key != ''
|
||||
let results[key] = line
|
||||
endif
|
||||
endw
|
||||
|
||||
call cursor(startpos)
|
||||
return results
|
||||
endf
|
||||
|
||||
fun s:InComment(line, col)
|
||||
return stridx(synIDattr(synID(a:line, a:col, 0), 'name'), 'omment') != -1
|
||||
endf
|
||||
|
||||
fun s:UpdateMethodList()
|
||||
winc p " Go to source file window
|
||||
let s:methods = s:GetAllMatches('^\v(\@(implementation|interface) \w+|'.
|
||||
\ '\s*(\+|-).*|#pragma\s+mark\s+\zs.+)')
|
||||
winc p " Go to method window
|
||||
|
||||
if empty(s:methods)
|
||||
winc q
|
||||
echoh WarningMsg
|
||||
echo 'There are no methods in this file!'
|
||||
echoh None
|
||||
return
|
||||
endif
|
||||
|
||||
call setline(1, sort(keys(s:methods), 's:SortByLineNum'))
|
||||
exe "norm! \<c-w>".line('$').'_'
|
||||
endf
|
||||
|
||||
fun s:SortByLineNum(i1, i2)
|
||||
let line1 = s:methods[a:i1]
|
||||
let line2 = s:methods[a:i2]
|
||||
return line1 == line2 ? 0 : line1 > line2 ? 1 : -1
|
||||
endf
|
||||
|
||||
fun s:SelectMethod()
|
||||
let number = s:methods[getline('.')]
|
||||
winc q
|
||||
winc p
|
||||
call cursor(number, 1)
|
||||
endf
|
||||
|
||||
fun s:LeaveMethodList()
|
||||
for [option, value] in items(s:opt)
|
||||
exe 'let &'.option.'='.value
|
||||
endfor
|
||||
let @/ = s:last_search == '' ? '' : s:last_search
|
||||
unl s:opt s:last_search
|
||||
endf
|
||||
" vim:noet:sw=4:ts=4:ft=vim
|
||||
87
.vim/autoload/objc/pum_snippet.vim
Normal file
87
.vim/autoload/objc/pum_snippet.vim
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
" File: pum_snippet.vim
|
||||
" Author: Michael Sanders (msanders42 [at] gmail [dot] com)
|
||||
" Last Updated: June 12, 2009
|
||||
" Description: Uses snipMate to jump through function or method objc
|
||||
" parameters when autocompleting. Used in cocoacomplete.vim.
|
||||
|
||||
" This function is invoked whenever pum_snippet is to be used; the keys are
|
||||
" only mapped when used as the trigger, and then immediately unmapped to avoid
|
||||
" breaking abbreviations, as well as other things.
|
||||
fun! objc#pum_snippet#Map()
|
||||
ino <silent> <buffer> <space> <c-r>=objc#pum_snippet#Trigger(' ')<cr>
|
||||
if !exists('g:SuperTabMappingForward') " Only map tab if not using supertab.
|
||||
\ || (g:SuperTabMappingForward != '<tab>' && g:SuperTabMappingForward != '<tab>')
|
||||
ino <silent> <buffer> <tab> <c-r>=objc#pum_snippet#Trigger("\t")<cr>
|
||||
endif
|
||||
ino <silent> <buffer> <return> <c-r>=objc#pum_snippet#Trigger("\n")<cr>
|
||||
let s:start = col('.')
|
||||
" Completion menu can only be detected when the popup menu is visible, so
|
||||
" 'menuone' needs to be temporarily set:
|
||||
let s:cot = &cot
|
||||
set cot+=menuone
|
||||
endf
|
||||
|
||||
fun! objc#pum_snippet#Unmap()
|
||||
call s:UnmapKey('<space>')
|
||||
call s:UnmapKey('<tab>')
|
||||
call s:UnmapKey('<return>')
|
||||
endf
|
||||
|
||||
fun s:UnmapKey(key)
|
||||
if maparg(a:key, 'i') =~? '^<C-R>=objc#pum_snippet#Trigger('
|
||||
sil exe 'iunmap <buffer> '.a:key
|
||||
endif
|
||||
endf
|
||||
|
||||
fun! objc#pum_snippet#Trigger(key)
|
||||
call objc#pum_snippet#Unmap()
|
||||
if pumvisible()
|
||||
let line = getline('.')
|
||||
let col = col('.')
|
||||
let word = matchstr(line, '\%'.s:start.'c\k\+(.\{-})\%'.col.'c')
|
||||
if word != ''
|
||||
let ConvertWord = function('s:ConvertFunction')
|
||||
elseif match(line, '\%'.s:start.'c\k\+[^()]*:[^()]*\%'.col.'c') != -1
|
||||
let word = matchstr(line, '\%'.s:start.'c\k\+[^()]*\%'.col.'c')
|
||||
let ConvertWord = function('s:ConvertMethod')
|
||||
endif
|
||||
if word != ''
|
||||
call s:ResetOptions()
|
||||
let col -= len(word)
|
||||
sil exe 's/\V'.escape(word, '\/').'\%#//'
|
||||
return snipMate#expandSnip(ConvertWord(word), col)
|
||||
endif
|
||||
endif
|
||||
call s:ResetOptions()
|
||||
return a:key
|
||||
endf
|
||||
|
||||
fun s:ResetOptions()
|
||||
let &cot = s:cot
|
||||
unl s:start s:cot
|
||||
endf
|
||||
|
||||
fun s:ConvertFunction(function)
|
||||
let name = matchstr(a:function, '^\k\+')
|
||||
let params = matchstr(a:function, '^\k\+(\zs.*')
|
||||
let snippet = name.'('.substitute(params, '\v(.{-1})(, |\))', '${0:\1}\2', 'g').'${0}'
|
||||
return s:OrderSnippet(snippet)
|
||||
endf
|
||||
|
||||
fun s:ConvertMethod(method)
|
||||
if stridx(a:method, ':') == -1 | return a:method | endif
|
||||
let snippet = substitute(a:method, '\v\k+:\zs.{-}\ze(\s*\k+:|$)', '${0:&}', 'g')
|
||||
return s:OrderSnippet(snippet)
|
||||
endf
|
||||
|
||||
" Converts "${0} foo ${0} bar ..." to "${1} foo ${2} bar", etc.
|
||||
fun s:OrderSnippet(snippet)
|
||||
let snippet = a:snippet
|
||||
let i = 1
|
||||
while stridx(snippet, '${0') != -1
|
||||
let snippet = substitute(snippet, '${0', '${'.i, '')
|
||||
let i += 1
|
||||
endw
|
||||
return snippet
|
||||
endf
|
||||
" vim:noet:sw=4:ts=4:ft=vim
|
||||
433
.vim/autoload/snipMate.vim
Normal file
433
.vim/autoload/snipMate.vim
Normal file
|
|
@ -0,0 +1,433 @@
|
|||
fun! Filename(...)
|
||||
let filename = expand('%:t:r')
|
||||
if filename == '' | return a:0 == 2 ? a:2 : '' | endif
|
||||
return !a:0 || a:1 == '' ? filename : substitute(a:1, '$1', filename, 'g')
|
||||
endf
|
||||
|
||||
fun s:RemoveSnippet()
|
||||
unl! g:snipPos s:curPos s:snipLen s:endCol s:endLine s:prevLen
|
||||
\ s:lastBuf s:oldWord
|
||||
if exists('s:update')
|
||||
unl s:startCol s:origWordLen s:update
|
||||
if exists('s:oldVars') | unl s:oldVars s:oldEndCol | endif
|
||||
endif
|
||||
aug! snipMateAutocmds
|
||||
endf
|
||||
|
||||
fun snipMate#expandSnip(snip, col)
|
||||
let lnum = line('.') | let col = a:col
|
||||
|
||||
let snippet = s:ProcessSnippet(a:snip)
|
||||
" Avoid error if eval evaluates to nothing
|
||||
if snippet == '' | return '' | endif
|
||||
|
||||
" Expand snippet onto current position with the tab stops removed
|
||||
let snipLines = split(substitute(snippet, '$\d\+\|${\d\+.\{-}}', '', 'g'), "\n", 1)
|
||||
|
||||
let line = getline(lnum)
|
||||
let afterCursor = strpart(line, col - 1)
|
||||
" Keep text after the cursor
|
||||
if afterCursor != "\t" && afterCursor != ' '
|
||||
let line = strpart(line, 0, col - 1)
|
||||
let snipLines[-1] .= afterCursor
|
||||
else
|
||||
let afterCursor = ''
|
||||
" For some reason the cursor needs to move one right after this
|
||||
if line != '' && col == 1 && &ve != 'all' && &ve != 'onemore'
|
||||
let col += 1
|
||||
endif
|
||||
endif
|
||||
|
||||
call setline(lnum, line.snipLines[0])
|
||||
|
||||
" Autoindent snippet according to previous indentation
|
||||
let indent = matchend(line, '^.\{-}\ze\(\S\|$\)') + 1
|
||||
call append(lnum, map(snipLines[1:], "'".strpart(line, 0, indent - 1)."'.v:val"))
|
||||
|
||||
" Open any folds snippet expands into
|
||||
if &fen | sil! exe lnum.','.(lnum + len(snipLines) - 1).'foldopen' | endif
|
||||
|
||||
let [g:snipPos, s:snipLen] = s:BuildTabStops(snippet, lnum, col - indent, indent)
|
||||
|
||||
if s:snipLen
|
||||
aug snipMateAutocmds
|
||||
au CursorMovedI * call s:UpdateChangedSnip(0)
|
||||
au InsertEnter * call s:UpdateChangedSnip(1)
|
||||
aug END
|
||||
let s:lastBuf = bufnr(0) " Only expand snippet while in current buffer
|
||||
let s:curPos = 0
|
||||
let s:endCol = g:snipPos[s:curPos][1]
|
||||
let s:endLine = g:snipPos[s:curPos][0]
|
||||
|
||||
call cursor(g:snipPos[s:curPos][0], g:snipPos[s:curPos][1])
|
||||
let s:prevLen = [line('$'), col('$')]
|
||||
if g:snipPos[s:curPos][2] != -1 | return s:SelectWord() | endif
|
||||
else
|
||||
unl g:snipPos s:snipLen
|
||||
" Place cursor at end of snippet if no tab stop is given
|
||||
let newlines = len(snipLines) - 1
|
||||
call cursor(lnum + newlines, indent + len(snipLines[-1]) - len(afterCursor)
|
||||
\ + (newlines ? 0: col - 1))
|
||||
endif
|
||||
return ''
|
||||
endf
|
||||
|
||||
" Prepare snippet to be processed by s:BuildTabStops
|
||||
fun s:ProcessSnippet(snip)
|
||||
let snippet = a:snip
|
||||
" Evaluate eval (`...`) expressions.
|
||||
" Using a loop here instead of a regex fixes a bug with nested "\=".
|
||||
if stridx(snippet, '`') != -1
|
||||
while match(snippet, '`.\{-}`') != -1
|
||||
let snippet = substitute(snippet, '`.\{-}`',
|
||||
\ substitute(eval(matchstr(snippet, '`\zs.\{-}\ze`')),
|
||||
\ "\n\\%$", '', ''), '')
|
||||
endw
|
||||
let snippet = substitute(snippet, "\r", "\n", 'g')
|
||||
endif
|
||||
|
||||
" Place all text after a colon in a tab stop after the tab stop
|
||||
" (e.g. "${#:foo}" becomes "${:foo}foo").
|
||||
" This helps tell the position of the tab stops later.
|
||||
let snippet = substitute(snippet, '${\d\+:\(.\{-}\)}', '&\1', 'g')
|
||||
|
||||
" Update the a:snip so that all the $# become the text after
|
||||
" the colon in their associated ${#}.
|
||||
" (e.g. "${1:foo}" turns all "$1"'s into "foo")
|
||||
let i = 1
|
||||
while stridx(snippet, '${'.i) != -1
|
||||
let s = matchstr(snippet, '${'.i.':\zs.\{-}\ze}')
|
||||
if s != ''
|
||||
let snippet = substitute(snippet, '$'.i, s.'&', 'g')
|
||||
endif
|
||||
let i += 1
|
||||
endw
|
||||
|
||||
if &et " Expand tabs to spaces if 'expandtab' is set.
|
||||
return substitute(snippet, '\t', repeat(' ', &sts ? &sts : &sw), 'g')
|
||||
endif
|
||||
return snippet
|
||||
endf
|
||||
|
||||
" Counts occurences of haystack in needle
|
||||
fun s:Count(haystack, needle)
|
||||
let counter = 0
|
||||
let index = stridx(a:haystack, a:needle)
|
||||
while index != -1
|
||||
let index = stridx(a:haystack, a:needle, index+1)
|
||||
let counter += 1
|
||||
endw
|
||||
return counter
|
||||
endf
|
||||
|
||||
" Builds a list of a list of each tab stop in the snippet containing:
|
||||
" 1.) The tab stop's line number.
|
||||
" 2.) The tab stop's column number
|
||||
" (by getting the length of the string between the last "\n" and the
|
||||
" tab stop).
|
||||
" 3.) The length of the text after the colon for the current tab stop
|
||||
" (e.g. "${1:foo}" would return 3). If there is no text, -1 is returned.
|
||||
" 4.) If the "${#:}" construct is given, another list containing all
|
||||
" the matches of "$#", to be replaced with the placeholder. This list is
|
||||
" composed the same way as the parent; the first item is the line number,
|
||||
" and the second is the column.
|
||||
fun s:BuildTabStops(snip, lnum, col, indent)
|
||||
let snipPos = []
|
||||
let i = 1
|
||||
let withoutVars = substitute(a:snip, '$\d\+', '', 'g')
|
||||
while stridx(a:snip, '${'.i) != -1
|
||||
let beforeTabStop = matchstr(withoutVars, '^.*\ze${'.i.'\D')
|
||||
let withoutOthers = substitute(withoutVars, '${\('.i.'\D\)\@!\d\+.\{-}}', '', 'g')
|
||||
|
||||
let j = i - 1
|
||||
call add(snipPos, [0, 0, -1])
|
||||
let snipPos[j][0] = a:lnum + s:Count(beforeTabStop, "\n")
|
||||
let snipPos[j][1] = a:indent + len(matchstr(withoutOthers, '.*\(\n\|^\)\zs.*\ze${'.i.'\D'))
|
||||
if snipPos[j][0] == a:lnum | let snipPos[j][1] += a:col | endif
|
||||
|
||||
" Get all $# matches in another list, if ${#:name} is given
|
||||
if stridx(withoutVars, '${'.i.':') != -1
|
||||
let snipPos[j][2] = len(matchstr(withoutVars, '${'.i.':\zs.\{-}\ze}'))
|
||||
let dots = repeat('.', snipPos[j][2])
|
||||
call add(snipPos[j], [])
|
||||
let withoutOthers = substitute(a:snip, '${\d\+.\{-}}\|$'.i.'\@!\d\+', '', 'g')
|
||||
while match(withoutOthers, '$'.i.'\(\D\|$\)') != -1
|
||||
let beforeMark = matchstr(withoutOthers, '^.\{-}\ze'.dots.'$'.i.'\(\D\|$\)')
|
||||
call add(snipPos[j][3], [0, 0])
|
||||
let snipPos[j][3][-1][0] = a:lnum + s:Count(beforeMark, "\n")
|
||||
let snipPos[j][3][-1][1] = a:indent + (snipPos[j][3][-1][0] > a:lnum
|
||||
\ ? len(matchstr(beforeMark, '.*\n\zs.*'))
|
||||
\ : a:col + len(beforeMark))
|
||||
let withoutOthers = substitute(withoutOthers, '$'.i.'\ze\(\D\|$\)', '', '')
|
||||
endw
|
||||
endif
|
||||
let i += 1
|
||||
endw
|
||||
return [snipPos, i - 1]
|
||||
endf
|
||||
|
||||
fun snipMate#jumpTabStop(backwards)
|
||||
let leftPlaceholder = exists('s:origWordLen')
|
||||
\ && s:origWordLen != g:snipPos[s:curPos][2]
|
||||
if leftPlaceholder && exists('s:oldEndCol')
|
||||
let startPlaceholder = s:oldEndCol + 1
|
||||
endif
|
||||
|
||||
if exists('s:update')
|
||||
call s:UpdatePlaceholderTabStops()
|
||||
else
|
||||
call s:UpdateTabStops()
|
||||
endif
|
||||
|
||||
" Don't reselect placeholder if it has been modified
|
||||
if leftPlaceholder && g:snipPos[s:curPos][2] != -1
|
||||
if exists('startPlaceholder')
|
||||
let g:snipPos[s:curPos][1] = startPlaceholder
|
||||
else
|
||||
let g:snipPos[s:curPos][1] = col('.')
|
||||
let g:snipPos[s:curPos][2] = 0
|
||||
endif
|
||||
endif
|
||||
|
||||
let s:curPos += a:backwards ? -1 : 1
|
||||
" Loop over the snippet when going backwards from the beginning
|
||||
if s:curPos < 0 | let s:curPos = s:snipLen - 1 | endif
|
||||
|
||||
if s:curPos == s:snipLen
|
||||
let sMode = s:endCol == g:snipPos[s:curPos-1][1]+g:snipPos[s:curPos-1][2]
|
||||
call s:RemoveSnippet()
|
||||
return sMode ? "\<tab>" : TriggerSnippet()
|
||||
endif
|
||||
|
||||
call cursor(g:snipPos[s:curPos][0], g:snipPos[s:curPos][1])
|
||||
|
||||
let s:endLine = g:snipPos[s:curPos][0]
|
||||
let s:endCol = g:snipPos[s:curPos][1]
|
||||
let s:prevLen = [line('$'), col('$')]
|
||||
|
||||
return g:snipPos[s:curPos][2] == -1 ? '' : s:SelectWord()
|
||||
endf
|
||||
|
||||
fun s:UpdatePlaceholderTabStops()
|
||||
let changeLen = s:origWordLen - g:snipPos[s:curPos][2]
|
||||
unl s:startCol s:origWordLen s:update
|
||||
if !exists('s:oldVars') | return | endif
|
||||
" Update tab stops in snippet if text has been added via "$#"
|
||||
" (e.g., in "${1:foo}bar$1${2}").
|
||||
if changeLen != 0
|
||||
let curLine = line('.')
|
||||
|
||||
for pos in g:snipPos
|
||||
if pos == g:snipPos[s:curPos] | continue | endif
|
||||
let changed = pos[0] == curLine && pos[1] > s:oldEndCol
|
||||
let changedVars = 0
|
||||
let endPlaceholder = pos[2] - 1 + pos[1]
|
||||
" Subtract changeLen from each tab stop that was after any of
|
||||
" the current tab stop's placeholders.
|
||||
for [lnum, col] in s:oldVars
|
||||
if lnum > pos[0] | break | endif
|
||||
if pos[0] == lnum
|
||||
if pos[1] > col || (pos[2] == -1 && pos[1] == col)
|
||||
let changed += 1
|
||||
elseif col < endPlaceholder
|
||||
let changedVars += 1
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
let pos[1] -= changeLen * changed
|
||||
let pos[2] -= changeLen * changedVars " Parse variables within placeholders
|
||||
" e.g., "${1:foo} ${2:$1bar}"
|
||||
|
||||
if pos[2] == -1 | continue | endif
|
||||
" Do the same to any placeholders in the other tab stops.
|
||||
for nPos in pos[3]
|
||||
let changed = nPos[0] == curLine && nPos[1] > s:oldEndCol
|
||||
for [lnum, col] in s:oldVars
|
||||
if lnum > nPos[0] | break | endif
|
||||
if nPos[0] == lnum && nPos[1] > col
|
||||
let changed += 1
|
||||
endif
|
||||
endfor
|
||||
let nPos[1] -= changeLen * changed
|
||||
endfor
|
||||
endfor
|
||||
endif
|
||||
unl s:endCol s:oldVars s:oldEndCol
|
||||
endf
|
||||
|
||||
fun s:UpdateTabStops()
|
||||
let changeLine = s:endLine - g:snipPos[s:curPos][0]
|
||||
let changeCol = s:endCol - g:snipPos[s:curPos][1]
|
||||
if exists('s:origWordLen')
|
||||
let changeCol -= s:origWordLen
|
||||
unl s:origWordLen
|
||||
endif
|
||||
let lnum = g:snipPos[s:curPos][0]
|
||||
let col = g:snipPos[s:curPos][1]
|
||||
" Update the line number of all proceeding tab stops if <cr> has
|
||||
" been inserted.
|
||||
if changeLine != 0
|
||||
let changeLine -= 1
|
||||
for pos in g:snipPos
|
||||
if pos[0] >= lnum
|
||||
if pos[0] == lnum | let pos[1] += changeCol | endif
|
||||
let pos[0] += changeLine
|
||||
endif
|
||||
if pos[2] == -1 | continue | endif
|
||||
for nPos in pos[3]
|
||||
if nPos[0] >= lnum
|
||||
if nPos[0] == lnum | let nPos[1] += changeCol | endif
|
||||
let nPos[0] += changeLine
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
elseif changeCol != 0
|
||||
" Update the column of all proceeding tab stops if text has
|
||||
" been inserted/deleted in the current line.
|
||||
for pos in g:snipPos
|
||||
if pos[1] >= col && pos[0] == lnum
|
||||
let pos[1] += changeCol
|
||||
endif
|
||||
if pos[2] == -1 | continue | endif
|
||||
for nPos in pos[3]
|
||||
if nPos[0] > lnum | break | endif
|
||||
if nPos[0] == lnum && nPos[1] >= col
|
||||
let nPos[1] += changeCol
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endif
|
||||
endf
|
||||
|
||||
fun s:SelectWord()
|
||||
let s:origWordLen = g:snipPos[s:curPos][2]
|
||||
let s:oldWord = strpart(getline('.'), g:snipPos[s:curPos][1] - 1,
|
||||
\ s:origWordLen)
|
||||
let s:prevLen[1] -= s:origWordLen
|
||||
if !empty(g:snipPos[s:curPos][3])
|
||||
let s:update = 1
|
||||
let s:endCol = -1
|
||||
let s:startCol = g:snipPos[s:curPos][1] - 1
|
||||
endif
|
||||
if !s:origWordLen | return '' | endif
|
||||
let l = col('.') != 1 ? 'l' : ''
|
||||
if &sel == 'exclusive'
|
||||
return "\<esc>".l.'v'.s:origWordLen."l\<c-g>"
|
||||
endif
|
||||
return s:origWordLen == 1 ? "\<esc>".l.'gh'
|
||||
\ : "\<esc>".l.'v'.(s:origWordLen - 1)."l\<c-g>"
|
||||
endf
|
||||
|
||||
" This updates the snippet as you type when text needs to be inserted
|
||||
" into multiple places (e.g. in "${1:default text}foo$1bar$1",
|
||||
" "default text" would be highlighted, and if the user types something,
|
||||
" UpdateChangedSnip() would be called so that the text after "foo" & "bar"
|
||||
" are updated accordingly)
|
||||
"
|
||||
" It also automatically quits the snippet if the cursor is moved out of it
|
||||
" while in insert mode.
|
||||
fun s:UpdateChangedSnip(entering)
|
||||
if exists('g:snipPos') && bufnr(0) != s:lastBuf
|
||||
call s:RemoveSnippet()
|
||||
elseif exists('s:update') " If modifying a placeholder
|
||||
if !exists('s:oldVars') && s:curPos + 1 < s:snipLen
|
||||
" Save the old snippet & word length before it's updated
|
||||
" s:startCol must be saved too, in case text is added
|
||||
" before the snippet (e.g. in "foo$1${2}bar${1:foo}").
|
||||
let s:oldEndCol = s:startCol
|
||||
let s:oldVars = deepcopy(g:snipPos[s:curPos][3])
|
||||
endif
|
||||
let col = col('.') - 1
|
||||
|
||||
if s:endCol != -1
|
||||
let changeLen = col('$') - s:prevLen[1]
|
||||
let s:endCol += changeLen
|
||||
else " When being updated the first time, after leaving select mode
|
||||
if a:entering | return | endif
|
||||
let s:endCol = col - 1
|
||||
endif
|
||||
|
||||
" If the cursor moves outside the snippet, quit it
|
||||
if line('.') != g:snipPos[s:curPos][0] || col < s:startCol ||
|
||||
\ col - 1 > s:endCol
|
||||
unl! s:startCol s:origWordLen s:oldVars s:update
|
||||
return s:RemoveSnippet()
|
||||
endif
|
||||
|
||||
call s:UpdateVars()
|
||||
let s:prevLen[1] = col('$')
|
||||
elseif exists('g:snipPos')
|
||||
if !a:entering && g:snipPos[s:curPos][2] != -1
|
||||
let g:snipPos[s:curPos][2] = -2
|
||||
endif
|
||||
|
||||
let col = col('.')
|
||||
let lnum = line('.')
|
||||
let changeLine = line('$') - s:prevLen[0]
|
||||
|
||||
if lnum == s:endLine
|
||||
let s:endCol += col('$') - s:prevLen[1]
|
||||
let s:prevLen = [line('$'), col('$')]
|
||||
endif
|
||||
if changeLine != 0
|
||||
let s:endLine += changeLine
|
||||
let s:endCol = col
|
||||
endif
|
||||
|
||||
" Delete snippet if cursor moves out of it in insert mode
|
||||
if (lnum == s:endLine && (col > s:endCol || col < g:snipPos[s:curPos][1]))
|
||||
\ || lnum > s:endLine || lnum < g:snipPos[s:curPos][0]
|
||||
call s:RemoveSnippet()
|
||||
endif
|
||||
endif
|
||||
endf
|
||||
|
||||
" This updates the variables in a snippet when a placeholder has been edited.
|
||||
" (e.g., each "$1" in "${1:foo} $1bar $1bar")
|
||||
fun s:UpdateVars()
|
||||
let newWordLen = s:endCol - s:startCol + 1
|
||||
let newWord = strpart(getline('.'), s:startCol, newWordLen)
|
||||
if newWord == s:oldWord || empty(g:snipPos[s:curPos][3])
|
||||
return
|
||||
endif
|
||||
|
||||
let changeLen = g:snipPos[s:curPos][2] - newWordLen
|
||||
let curLine = line('.')
|
||||
let startCol = col('.')
|
||||
let oldStartSnip = s:startCol
|
||||
let updateTabStops = changeLen != 0
|
||||
let i = 0
|
||||
|
||||
for [lnum, col] in g:snipPos[s:curPos][3]
|
||||
if updateTabStops
|
||||
let start = s:startCol
|
||||
if lnum == curLine && col <= start
|
||||
let s:startCol -= changeLen
|
||||
let s:endCol -= changeLen
|
||||
endif
|
||||
for nPos in g:snipPos[s:curPos][3][(i):]
|
||||
" This list is in ascending order, so quit if we've gone too far.
|
||||
if nPos[0] > lnum | break | endif
|
||||
if nPos[0] == lnum && nPos[1] > col
|
||||
let nPos[1] -= changeLen
|
||||
endif
|
||||
endfor
|
||||
if lnum == curLine && col > start
|
||||
let col -= changeLen
|
||||
let g:snipPos[s:curPos][3][i][1] = col
|
||||
endif
|
||||
let i += 1
|
||||
endif
|
||||
|
||||
" "Very nomagic" is used here to allow special characters.
|
||||
call setline(lnum, substitute(getline(lnum), '\%'.col.'c\V'.
|
||||
\ escape(s:oldWord, '\'), escape(newWord, '\&'), ''))
|
||||
endfor
|
||||
if oldStartSnip != s:startCol
|
||||
call cursor(0, startCol + s:startCol - oldStartSnip)
|
||||
endif
|
||||
|
||||
let s:oldWord = newWord
|
||||
let g:snipPos[s:curPos][2] = newWordLen
|
||||
endf
|
||||
" vim:noet:sw=4:ts=4:ft=vim
|
||||
|
|
@ -36,7 +36,8 @@ hi DiffChange term=bold ctermbg=darkmagenta guibg=maroon
|
|||
hi DiffDelete term=bold cterm=bold ctermfg=lightblue ctermbg=cyan gui=bold guifg=lightblue guibg=cyan4
|
||||
hi DiffText term=reverse cterm=bold ctermbg=red gui=bold guibg=red3
|
||||
hi Cursor guifg=bg guibg=fg
|
||||
hi lCursor guifg=bg guibg=fg
|
||||
hi CursorLine term=NONE cterm=bold guibg=grey20
|
||||
"hi lCursor guifg=bg guibg=fg
|
||||
hi StatusLine term=reverse cterm=reverse gui=reverse guifg=gray60
|
||||
hi StatusLineNC term=reverse cterm=reverse gui=reverse guifg=gray40
|
||||
hi VertSplit term=reverse cterm=reverse gui=bold,reverse guifg=gray40
|
||||
|
|
|
|||
1077
.vim/doc/NERD_tree.txt
Normal file
1077
.vim/doc/NERD_tree.txt
Normal file
File diff suppressed because it is too large
Load diff
151
.vim/doc/cocoa.txt
Normal file
151
.vim/doc/cocoa.txt
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
*cocoa.txt* Plugin for Cocoa/Objective-C development.
|
||||
|
||||
cocoa.vim *cocoa*
|
||||
Last Change: September 08, 2009
|
||||
Author: Michael Sanders
|
||||
|
||||
|cocoa-introduction| Introduction
|
||||
|cocoa-installation| Installation
|
||||
|cocoa-overview| Overview of features
|
||||
|cocoa-mappings| Mappings
|
||||
|cocoa-commands| Commands
|
||||
|cocoa-license| License
|
||||
|cocoa-contact| Contact
|
||||
|
||||
For Vim version 7.0 or later.
|
||||
This plugin only works if 'compatible' is not set.
|
||||
{Vi does not have any of these features.}
|
||||
|
||||
==============================================================================
|
||||
INTRODUCTION *cocoa-intro*
|
||||
|
||||
Cocoa.vim is a collection of scripts designed to make it easier to develop
|
||||
Cocoa/Objective-C applications. It includes enhanced syntax highlighting, code
|
||||
completion, documentation lookup, as well as a number of other features that
|
||||
can be used to integrate Vim with Xcode, allowing you to essentially replace
|
||||
Xcode's editor with Vim.
|
||||
|
||||
==============================================================================
|
||||
INSTALLATION *cocoa-installation*
|
||||
|
||||
Documentation lookup and code completion for Cocoa.vim are currently
|
||||
Leopard-only (although the other parts should work on any platform). To
|
||||
install, simply unzip cocoa.zip to your home vim directory (typically ~/.vim).
|
||||
|
||||
*cocoa-suggested-plugins*
|
||||
The code completion in cocoa.vim uses snipMate, if you have it installed, to
|
||||
allow you to conveniently <tab> over the parameters in functions and
|
||||
methods. If you like cocoa.vim, you may also find objc_matchbracket.vim
|
||||
useful.
|
||||
|
||||
*leopard-security-alert*
|
||||
Documentation works by showing the page in your default browser, which
|
||||
apparently causes Leopard to warn you of opening an html file for every word
|
||||
you look up. To fix this, see this page: http://tinyurl.com/remove-annoying-alert
|
||||
|
||||
==============================================================================
|
||||
FEATURE OVERVIEW *cocoa-features*
|
||||
|
||||
1. Enhanced syntax highlighting; Vim's syntax highlighting for
|
||||
Objective-C seemed a bit incomplete to me, so I have added a few
|
||||
niceties, such as highlighting Cocoa keywords and differentiating
|
||||
the method name and passed objects in method calls and definitions.
|
||||
2. Xcode-like mappings; mappings such as <d-r> (where "d" is "command")
|
||||
to build & run and <d-0> to switch to the project window help to
|
||||
integrate Xcode and Vim. For a complete list of the mappings in
|
||||
cocoa.vim, see |cocoa-mappings|.
|
||||
3. Methods for the current file can be listed and navigated to with
|
||||
the |:ListMethods| command.
|
||||
4. A template of methods declared in a header file (.h) can be built
|
||||
in an implementation file (.m) with |:BuildMethods|.
|
||||
5. Cocoa/C Documentation can be looked up with the |:CocoaDoc| command,
|
||||
or simply with Vim's |K|.
|
||||
6. Code completion for classes, methods, functions, constants, types,
|
||||
and notifications can be invoked with <c-x><c-o>. Parameters for
|
||||
methods and functions are automatically converted to snippets to
|
||||
<tab> over if you have snipMate installed.
|
||||
|
||||
==============================================================================
|
||||
MAPPINGS *cocoa-mappings* *g:objc_man_key*
|
||||
|
||||
Cocoa.vim maps the following keys, some for convenience and others to
|
||||
integrate with Xcode:
|
||||
(Disclaimer: Sorry, I could not use the swirly symbols because vim/git was
|
||||
having encoding issues. Just pretend that e.g. <d-r> means cmd-r.)
|
||||
|
||||
|<Leader>|A - Alternate between header (.h) and implementation (.m) file
|
||||
K - Look up documentation for word under cursor[1]
|
||||
<d-m-up> - <Leader>A
|
||||
<d-r> - Build & Run (Go)
|
||||
<d-cr> - CMD-R
|
||||
<d-b> - Build
|
||||
<shift-k> - Clean
|
||||
<d-0> - Go to Project
|
||||
<d-2> - :ListMethods
|
||||
<F5> (in insert mode) - Show omnicompletion menu
|
||||
|
||||
([1] This can be customized by the variable g:objc_man_key.)
|
||||
|
||||
==============================================================================
|
||||
COMMANDS *cocoa-commands*
|
||||
|
||||
*:ListMethods*
|
||||
:ListMethods Open a split window containing the methods, functions,
|
||||
and #pragma marks of the current file.
|
||||
*:BuildMethods*
|
||||
:BuildMethods [headerfile]
|
||||
Build a template of methods in an implementation (.m)
|
||||
from a list declared in a header file (.h). If no
|
||||
argument is given, the corresponding header file is
|
||||
used (e.g. "foo.m" -> "foo.h").
|
||||
|
||||
==============================================================================
|
||||
CODE COMPLETION *cocoa-completion*
|
||||
|
||||
When cocoa.vim is installed the 'omnifunc' is automatically set to
|
||||
'cocoacomplete#Complete'. This allows you to complete classes, functions,
|
||||
methods, etc. with <c-x><c-o>. These keywords are saved from header files in
|
||||
~/.vim/lib/cocoa_indexes; they have been built for you, although you can build
|
||||
them again by running ~/.vim/lib/extras/cocoa_definitions.py.
|
||||
|
||||
Completions with parameters (i.e., functions and methods) are automatically
|
||||
converted to |snipMate| if it is installed. To invoke the snippet, simply
|
||||
press a whitespace character (space, tab, or return), and then navigate the
|
||||
snippet as you would in snipMate.
|
||||
|
||||
==============================================================================
|
||||
LICENSE *cocoa-license*
|
||||
|
||||
Cocoa.vim is released under the MIT license:
|
||||
|
||||
Copyright © 2009 Michael Sanders. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
The software is provided "as is", without warranty of any kind, express or
|
||||
implied, including but not limited to the warranties of merchantability,
|
||||
fitness for a particular purpose and noninfringement. In no event shall the
|
||||
authors or copyright holders be liable for any claim, damages or other
|
||||
liability, whether in an action of contract, tort or otherwise, arising from,
|
||||
out of or in connection with the software or the use or other dealings in the
|
||||
software.
|
||||
|
||||
==============================================================================
|
||||
CONTACT *cocoa-contact* *cocoa-author*
|
||||
|
||||
To contact the author (Michael Sanders), you may email:
|
||||
|
||||
msanders42+cocoa.vim <at> gmail <dot> com
|
||||
|
||||
Thanks for your interest in the script!
|
||||
|
||||
==============================================================================
|
||||
vim:tw=78:ts=8:ft=help:norl:enc=utf-8:
|
||||
286
.vim/doc/snipMate.txt
Normal file
286
.vim/doc/snipMate.txt
Normal file
|
|
@ -0,0 +1,286 @@
|
|||
*snipMate.txt* Plugin for using TextMate-style snippets in Vim.
|
||||
|
||||
snipMate *snippet* *snippets* *snipMate*
|
||||
Last Change: July 13, 2009
|
||||
|
||||
|snipMate-description| Description
|
||||
|snipMate-syntax| Snippet syntax
|
||||
|snipMate-usage| Usage
|
||||
|snipMate-settings| Settings
|
||||
|snipMate-features| Features
|
||||
|snipMate-disadvantages| Disadvantages to TextMate
|
||||
|snipMate-contact| Contact
|
||||
|
||||
For Vim version 7.0 or later.
|
||||
This plugin only works if 'compatible' is not set.
|
||||
{Vi does not have any of these features.}
|
||||
|
||||
==============================================================================
|
||||
DESCRIPTION *snipMate-description*
|
||||
|
||||
snipMate.vim implements some of TextMate's snippets features in Vim. A
|
||||
snippet is a piece of often-typed text that you can insert into your
|
||||
document using a trigger word followed by a <tab>.
|
||||
|
||||
For instance, in a C file using the default installation of snipMate.vim, if
|
||||
you type "for<tab>" in insert mode, it will expand a typical for loop in C: >
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
To go to the next item in the loop, simply <tab> over to it; if there is
|
||||
repeated code, such as the "i" variable in this example, you can simply
|
||||
start typing once it's highlighted and all the matches specified in the
|
||||
snippet will be updated. To go in reverse, use <shift-tab>.
|
||||
|
||||
==============================================================================
|
||||
SYNTAX *snippet-syntax*
|
||||
|
||||
Snippets can be defined in two ways. They can be in their own file, named
|
||||
after their trigger in 'snippets/<filetype>/<trigger>.snippet', or they can be
|
||||
defined together in a 'snippets/<filetype>.snippets' file. Note that dotted
|
||||
'filetype' syntax is supported -- e.g., you can use >
|
||||
|
||||
:set ft=html.eruby
|
||||
|
||||
to activate snippets for both HTML and eRuby for the current file.
|
||||
|
||||
The syntax for snippets in *.snippets files is the following: >
|
||||
|
||||
snippet trigger
|
||||
expanded text
|
||||
more expanded text
|
||||
|
||||
Note that the first hard tab after the snippet trigger is required, and not
|
||||
expanded in the actual snippet. The syntax for *.snippet files is the same,
|
||||
only without the trigger declaration and starting indentation.
|
||||
|
||||
Also note that snippets must be defined using hard tabs. They can be expanded
|
||||
to spaces later if desired (see |snipMate-indenting|).
|
||||
|
||||
"#" is used as a line-comment character in *.snippets files; however, they can
|
||||
only be used outside of a snippet declaration. E.g.: >
|
||||
|
||||
# this is a correct comment
|
||||
snippet trigger
|
||||
expanded text
|
||||
snippet another_trigger
|
||||
# this isn't a comment!
|
||||
expanded text
|
||||
<
|
||||
This should hopefully be obvious with the included syntax highlighting.
|
||||
|
||||
*snipMate-${#}*
|
||||
Tab stops ~
|
||||
|
||||
By default, the cursor is placed at the end of a snippet. To specify where the
|
||||
cursor is to be placed next, use "${#}", where the # is the number of the tab
|
||||
stop. E.g., to place the cursor first on the id of a <div> tag, and then allow
|
||||
the user to press <tab> to go to the middle of it:
|
||||
>
|
||||
snippet div
|
||||
<div id="${1}">
|
||||
${2}
|
||||
</div>
|
||||
<
|
||||
*snipMate-placeholders* *snipMate-${#:}* *snipMate-$#*
|
||||
Placeholders ~
|
||||
|
||||
Placeholder text can be supplied using "${#:text}", where # is the number of
|
||||
the tab stop. This text then can be copied throughout the snippet using "$#",
|
||||
given # is the same number as used before. So, to make a C for loop: >
|
||||
|
||||
snippet for
|
||||
for (${2:i}; $2 < ${1:count}; $1++) {
|
||||
${4}
|
||||
}
|
||||
|
||||
This will cause "count" to first be selected and change if the user starts
|
||||
typing. When <tab> is pressed, the "i" in ${2}'s position will be selected;
|
||||
all $2 variables will default to "i" and automatically be updated if the user
|
||||
starts typing.
|
||||
NOTE: "$#" syntax is used only for variables, not for tab stops as in TextMate.
|
||||
|
||||
Variables within variables are also possible. For instance: >
|
||||
|
||||
snippet opt
|
||||
<option value="${1:option}">${2:$1}</option>
|
||||
|
||||
Will, as usual, cause "option" to first be selected and update all the $1
|
||||
variables if the user starts typing. Since one of these variables is inside of
|
||||
${2}, this text will then be used as a placeholder for the next tab stop,
|
||||
allowing the user to change it if he wishes.
|
||||
|
||||
To copy a value throughout a snippet without supplying default text, simply
|
||||
use the "${#:}" construct without the text; e.g.: >
|
||||
|
||||
snippet foo
|
||||
${1:}bar$1
|
||||
< *snipMate-commands*
|
||||
Interpolated Vim Script ~
|
||||
|
||||
Snippets can also contain Vim script commands that are executed (via |eval()|)
|
||||
when the snippet is inserted. Commands are given inside backticks (`...`); for
|
||||
TextMates's functionality, use the |system()| function. E.g.: >
|
||||
|
||||
snippet date
|
||||
`system("date +%Y-%m-%d")`
|
||||
|
||||
will insert the current date, assuming you are on a Unix system. Note that you
|
||||
can also (and should) use |strftime()| for this example.
|
||||
|
||||
Filename([{expr}] [, {defaultText}]) *snipMate-filename* *Filename()*
|
||||
|
||||
Since the current filename is used often in snippets, a default function
|
||||
has been defined for it in snipMate.vim, appropriately called Filename().
|
||||
|
||||
With no arguments, the default filename without an extension is returned;
|
||||
the first argument specifies what to place before or after the filename,
|
||||
and the second argument supplies the default text to be used if the file
|
||||
has not been named. "$1" in the first argument is replaced with the filename;
|
||||
if you only want the filename to be returned, the first argument can be left
|
||||
blank. Examples: >
|
||||
|
||||
snippet filename
|
||||
`Filename()`
|
||||
snippet filename_with_default
|
||||
`Filename('', 'name')`
|
||||
snippet filename_foo
|
||||
`filename('$1_foo')`
|
||||
|
||||
The first example returns the filename if it the file has been named, and an
|
||||
empty string if it hasn't. The second returns the filename if it's been named,
|
||||
and "name" if it hasn't. The third returns the filename followed by "_foo" if
|
||||
it has been named, and an empty string if it hasn't.
|
||||
|
||||
*multi_snip*
|
||||
To specify that a snippet can have multiple matches in a *.snippets file, use
|
||||
this syntax: >
|
||||
|
||||
snippet trigger A description of snippet #1
|
||||
expand this text
|
||||
snippet trigger A description of snippet #2
|
||||
expand THIS text!
|
||||
|
||||
In this example, when "trigger<tab>" is typed, a numbered menu containing all
|
||||
of the descriptions of the "trigger" will be shown; when the user presses the
|
||||
corresponding number, that snippet will then be expanded.
|
||||
|
||||
To create a snippet with multiple matches using *.snippet files,
|
||||
simply place all the snippets in a subdirectory with the trigger name:
|
||||
'snippets/<filetype>/<trigger>/<name>.snippet'.
|
||||
|
||||
==============================================================================
|
||||
USAGE *snipMate-usage*
|
||||
|
||||
*'snippets'* *g:snippets_dir*
|
||||
Snippets are by default looked for any 'snippets' directory in your
|
||||
'runtimepath'. Typically, it is located at '~/.vim/snippets/' on *nix or
|
||||
'$HOME\vimfiles\snippets\' on Windows. To change that location or add another
|
||||
one, change the g:snippets_dir variable in your |.vimrc| to your preferred
|
||||
directory, or use the |ExtractSnips()|function. This will be used by the
|
||||
|globpath()| function, and so accepts the same syntax as it (e.g.,
|
||||
comma-separated paths).
|
||||
|
||||
ExtractSnipsFile({directory}, {filetype}) *ExtractSnipsFile()* *.snippets*
|
||||
|
||||
ExtractSnipsFile() extracts the specified *.snippets file for the given
|
||||
filetype. A .snippets file contains multiple snippet declarations for the
|
||||
filetype. It is further explained above, in |snippet-syntax|.
|
||||
|
||||
ExtractSnips({directory}, {filetype}) *ExtractSnips()* *.snippet*
|
||||
|
||||
ExtractSnips() extracts *.snippet files from the specified directory and
|
||||
defines them as snippets for the given filetype. The directory tree should
|
||||
look like this: 'snippets/<filetype>/<trigger>.snippet'. If the snippet has
|
||||
multiple matches, it should look like this:
|
||||
'snippets/<filetype>/<trigger>/<name>.snippet' (see |multi_snip|).
|
||||
|
||||
*ResetSnippets()*
|
||||
The ResetSnippets() function removes all snippets from memory. This is useful
|
||||
to put at the top of a snippet setup file for if you would like to |:source|
|
||||
it multiple times.
|
||||
|
||||
*list-snippets* *i_CTRL-R_<Tab>*
|
||||
If you would like to see what snippets are available, simply type <c-r><tab>
|
||||
in the current buffer to show a list via |popupmenu-completion|.
|
||||
|
||||
==============================================================================
|
||||
SETTINGS *snipMate-settings* *g:snips_author*
|
||||
|
||||
The g:snips_author string (similar to $TM_FULLNAME in TextMate) should be set
|
||||
to your name; it can then be used in snippets to automatically add it. E.g.: >
|
||||
|
||||
let g:snips_author = 'Hubert Farnsworth'
|
||||
snippet name
|
||||
`g:snips_author`
|
||||
<
|
||||
*snipMate-expandtab* *snipMate-indenting*
|
||||
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-remap*
|
||||
snipMate does not come with a setting to customize the trigger key, but you
|
||||
can remap it easily in the two lines it's defined in the 'after' directory
|
||||
under 'plugin/snipMate.vim'. For instance, to change the trigger key
|
||||
to CTRL-J, just change this: >
|
||||
|
||||
ino <tab> <c-r>=TriggerSnippet()<cr>
|
||||
snor <tab> <esc>i<right><c-r>=TriggerSnippet()<cr>
|
||||
|
||||
to this: >
|
||||
ino <c-j> <c-r>=TriggerSnippet()<cr>
|
||||
snor <c-j> <esc>i<right><c-r>=TriggerSnippet()<cr>
|
||||
|
||||
==============================================================================
|
||||
FEATURES *snipMate-features*
|
||||
|
||||
snipMate.vim has the following features among others:
|
||||
- The syntax of snippets is very similar to TextMate's, allowing
|
||||
easy conversion.
|
||||
- The position of the snippet is kept transparently (i.e. it does not use
|
||||
markers/placeholders written to the buffer), which allows you to escape
|
||||
out of an incomplete snippet, something particularly useful in Vim.
|
||||
- Variables in snippets are updated as-you-type.
|
||||
- Snippets can have multiple matches.
|
||||
- Snippets can be out of order. For instance, in a do...while loop, the
|
||||
condition can be added before the code.
|
||||
- [New] File-based snippets are supported.
|
||||
- [New] Triggers after non-word delimiters are expanded, e.g. "foo"
|
||||
in "bar.foo".
|
||||
- [New] <shift-tab> can now be used to jump tab stops in reverse order.
|
||||
|
||||
==============================================================================
|
||||
DISADVANTAGES *snipMate-disadvantages*
|
||||
|
||||
snipMate.vim currently has the following disadvantages to TextMate's snippets:
|
||||
- There is no $0; the order of tab stops must be explicitly stated.
|
||||
- Placeholders within placeholders are not possible. E.g.: >
|
||||
|
||||
'<div${1: id="${2:some_id}}">${3}</div>'
|
||||
<
|
||||
In TextMate this would first highlight ' id="some_id"', and if
|
||||
you hit delete it would automatically skip ${2} and go to ${3}
|
||||
on the next <tab>, but if you didn't delete it it would highlight
|
||||
"some_id" first. You cannot do this in snipMate.vim.
|
||||
- Regex cannot be performed on variables, such as "${1/.*/\U&}"
|
||||
- Placeholders cannot span multiple lines.
|
||||
- Activating snippets in different scopes of the same file is
|
||||
not possible.
|
||||
|
||||
Perhaps some of these features will be added in a later release.
|
||||
|
||||
==============================================================================
|
||||
CONTACT *snipMate-contact* *snipMate-author*
|
||||
|
||||
To contact the author (Michael Sanders), please email:
|
||||
msanders42+snipmate <at> gmail <dot> com
|
||||
|
||||
I greatly appreciate any suggestions or improvements offered for the script.
|
||||
|
||||
==============================================================================
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
193
.vim/doc/tags
193
.vim/doc/tags
|
|
@ -1,3 +1,26 @@
|
|||
'NERDChristmasTree' NERD_tree.txt /*'NERDChristmasTree'*
|
||||
'NERDTreeAutoCenter' NERD_tree.txt /*'NERDTreeAutoCenter'*
|
||||
'NERDTreeAutoCenterThreshold' NERD_tree.txt /*'NERDTreeAutoCenterThreshold'*
|
||||
'NERDTreeBookmarksFile' NERD_tree.txt /*'NERDTreeBookmarksFile'*
|
||||
'NERDTreeCaseSensitiveSort' NERD_tree.txt /*'NERDTreeCaseSensitiveSort'*
|
||||
'NERDTreeChDirMode' NERD_tree.txt /*'NERDTreeChDirMode'*
|
||||
'NERDTreeHighlightCursorline' NERD_tree.txt /*'NERDTreeHighlightCursorline'*
|
||||
'NERDTreeHijackNetrw' NERD_tree.txt /*'NERDTreeHijackNetrw'*
|
||||
'NERDTreeIgnore' NERD_tree.txt /*'NERDTreeIgnore'*
|
||||
'NERDTreeMouseMode' NERD_tree.txt /*'NERDTreeMouseMode'*
|
||||
'NERDTreeQuitOnOpen' NERD_tree.txt /*'NERDTreeQuitOnOpen'*
|
||||
'NERDTreeShowBookmarks' NERD_tree.txt /*'NERDTreeShowBookmarks'*
|
||||
'NERDTreeShowFiles' NERD_tree.txt /*'NERDTreeShowFiles'*
|
||||
'NERDTreeShowHidden' NERD_tree.txt /*'NERDTreeShowHidden'*
|
||||
'NERDTreeShowLineNumbers' NERD_tree.txt /*'NERDTreeShowLineNumbers'*
|
||||
'NERDTreeSortOrder' NERD_tree.txt /*'NERDTreeSortOrder'*
|
||||
'NERDTreeStatusline' NERD_tree.txt /*'NERDTreeStatusline'*
|
||||
'NERDTreeWinPos' NERD_tree.txt /*'NERDTreeWinPos'*
|
||||
'NERDTreeWinSize' NERD_tree.txt /*'NERDTreeWinSize'*
|
||||
'loaded_nerd_tree' NERD_tree.txt /*'loaded_nerd_tree'*
|
||||
'snippets' snipMate.txt /*'snippets'*
|
||||
.snippet snipMate.txt /*.snippet*
|
||||
.snippets snipMate.txt /*.snippets*
|
||||
:CVSEdit vcscommand.txt /*:CVSEdit*
|
||||
:CVSEditors vcscommand.txt /*:CVSEditors*
|
||||
:CVSUnedit vcscommand.txt /*:CVSUnedit*
|
||||
|
|
@ -7,7 +30,17 @@
|
|||
:CVSWatchOn vcscommand.txt /*:CVSWatchOn*
|
||||
:CVSWatchRemove vcscommand.txt /*:CVSWatchRemove*
|
||||
:CVSWatchers vcscommand.txt /*:CVSWatchers*
|
||||
:LUBufs lookupfile.txt /*:LUBufs*
|
||||
:LUPath lookupfile.txt /*:LUPath*
|
||||
:LUTags lookupfile.txt /*:LUTags*
|
||||
:LUWalk lookupfile.txt /*:LUWalk*
|
||||
:LookupFile lookupfile.txt /*:LookupFile*
|
||||
:MatchDebug matchit.txt /*:MatchDebug*
|
||||
:NERDTree NERD_tree.txt /*:NERDTree*
|
||||
:NERDTreeClose NERD_tree.txt /*:NERDTreeClose*
|
||||
:NERDTreeFromBookmark NERD_tree.txt /*:NERDTreeFromBookmark*
|
||||
:NERDTreeMirror NERD_tree.txt /*:NERDTreeMirror*
|
||||
:NERDTreeToggle NERD_tree.txt /*:NERDTreeToggle*
|
||||
:VCSAdd vcscommand.txt /*:VCSAdd*
|
||||
:VCSAnnotate vcscommand.txt /*:VCSAnnotate*
|
||||
:VCSBlame vcscommand.txt /*:VCSBlame*
|
||||
|
|
@ -25,7 +58,90 @@
|
|||
:VCSUnlock vcscommand.txt /*:VCSUnlock*
|
||||
:VCSUpdate vcscommand.txt /*:VCSUpdate*
|
||||
:VCSVimDiff vcscommand.txt /*:VCSVimDiff*
|
||||
ExtractSnips() snipMate.txt /*ExtractSnips()*
|
||||
ExtractSnipsFile() snipMate.txt /*ExtractSnipsFile()*
|
||||
Filename() snipMate.txt /*Filename()*
|
||||
LookupFile-command lookupfile.txt /*LookupFile-command*
|
||||
LookupFile_AllowNewFiles lookupfile.txt /*LookupFile_AllowNewFiles*
|
||||
LookupFile_AlwaysAcceptFirst lookupfile.txt /*LookupFile_AlwaysAcceptFirst*
|
||||
LookupFile_Bufs_BufListExpr lookupfile.txt /*LookupFile_Bufs_BufListExpr*
|
||||
LookupFile_Bufs_LikeBufCmd lookupfile.txt /*LookupFile_Bufs_LikeBufCmd*
|
||||
LookupFile_Bufs_SkipUnlisted lookupfile.txt /*LookupFile_Bufs_SkipUnlisted*
|
||||
LookupFile_DefaultCmd lookupfile.txt /*LookupFile_DefaultCmd*
|
||||
LookupFile_DisableDefaultMap lookupfile.txt /*LookupFile_DisableDefaultMap*
|
||||
LookupFile_EnableRemapCmd lookupfile.txt /*LookupFile_EnableRemapCmd*
|
||||
LookupFile_EscCancelsPopup lookupfile.txt /*LookupFile_EscCancelsPopup*
|
||||
LookupFile_FileFilter lookupfile.txt /*LookupFile_FileFilter*
|
||||
LookupFile_LookupAcceptFunc lookupfile.txt /*LookupFile_LookupAcceptFunc*
|
||||
LookupFile_LookupFunc lookupfile.txt /*LookupFile_LookupFunc*
|
||||
LookupFile_LookupNotifyFunc lookupfile.txt /*LookupFile_LookupNotifyFunc*
|
||||
LookupFile_MinPatLength lookupfile.txt /*LookupFile_MinPatLength*
|
||||
LookupFile_PreserveLastPattern lookupfile.txt /*LookupFile_PreserveLastPattern*
|
||||
LookupFile_PreservePatternHistory lookupfile.txt /*LookupFile_PreservePatternHistory*
|
||||
LookupFile_RecentFileListSize lookupfile.txt /*LookupFile_RecentFileListSize*
|
||||
LookupFile_SearchForBufsInTabs lookupfile.txt /*LookupFile_SearchForBufsInTabs*
|
||||
LookupFile_ShowFiller lookupfile.txt /*LookupFile_ShowFiller*
|
||||
LookupFile_SortMethod lookupfile.txt /*LookupFile_SortMethod*
|
||||
LookupFile_TagExpr lookupfile.txt /*LookupFile_TagExpr*
|
||||
LookupFile_TagsExpandCamelCase lookupfile.txt /*LookupFile_TagsExpandCamelCase*
|
||||
LookupFile_UpdateTime lookupfile.txt /*LookupFile_UpdateTime*
|
||||
LookupFile_UsingSpecializedTags lookupfile.txt /*LookupFile_UsingSpecializedTags*
|
||||
LookupFile_ignorecase lookupfile.txt /*LookupFile_ignorecase*
|
||||
LookupFile_smartcase lookupfile.txt /*LookupFile_smartcase*
|
||||
LookupFile_switchbuf lookupfile.txt /*LookupFile_switchbuf*
|
||||
MatchError matchit.txt /*MatchError*
|
||||
NERDTree NERD_tree.txt /*NERDTree*
|
||||
NERDTree-! NERD_tree.txt /*NERDTree-!*
|
||||
NERDTree-? NERD_tree.txt /*NERDTree-?*
|
||||
NERDTree-B NERD_tree.txt /*NERDTree-B*
|
||||
NERDTree-C NERD_tree.txt /*NERDTree-C*
|
||||
NERDTree-D NERD_tree.txt /*NERDTree-D*
|
||||
NERDTree-F NERD_tree.txt /*NERDTree-F*
|
||||
NERDTree-I NERD_tree.txt /*NERDTree-I*
|
||||
NERDTree-J NERD_tree.txt /*NERDTree-J*
|
||||
NERDTree-K NERD_tree.txt /*NERDTree-K*
|
||||
NERDTree-O NERD_tree.txt /*NERDTree-O*
|
||||
NERDTree-P NERD_tree.txt /*NERDTree-P*
|
||||
NERDTree-R NERD_tree.txt /*NERDTree-R*
|
||||
NERDTree-T NERD_tree.txt /*NERDTree-T*
|
||||
NERDTree-U NERD_tree.txt /*NERDTree-U*
|
||||
NERDTree-X NERD_tree.txt /*NERDTree-X*
|
||||
NERDTree-c-j NERD_tree.txt /*NERDTree-c-j*
|
||||
NERDTree-c-k NERD_tree.txt /*NERDTree-c-k*
|
||||
NERDTree-contents NERD_tree.txt /*NERDTree-contents*
|
||||
NERDTree-e NERD_tree.txt /*NERDTree-e*
|
||||
NERDTree-f NERD_tree.txt /*NERDTree-f*
|
||||
NERDTree-gi NERD_tree.txt /*NERDTree-gi*
|
||||
NERDTree-go NERD_tree.txt /*NERDTree-go*
|
||||
NERDTree-gs NERD_tree.txt /*NERDTree-gs*
|
||||
NERDTree-i NERD_tree.txt /*NERDTree-i*
|
||||
NERDTree-m NERD_tree.txt /*NERDTree-m*
|
||||
NERDTree-o NERD_tree.txt /*NERDTree-o*
|
||||
NERDTree-p NERD_tree.txt /*NERDTree-p*
|
||||
NERDTree-q NERD_tree.txt /*NERDTree-q*
|
||||
NERDTree-r NERD_tree.txt /*NERDTree-r*
|
||||
NERDTree-s NERD_tree.txt /*NERDTree-s*
|
||||
NERDTree-t NERD_tree.txt /*NERDTree-t*
|
||||
NERDTree-u NERD_tree.txt /*NERDTree-u*
|
||||
NERDTree-x NERD_tree.txt /*NERDTree-x*
|
||||
NERDTreeAbout NERD_tree.txt /*NERDTreeAbout*
|
||||
NERDTreeBookmarkCommands NERD_tree.txt /*NERDTreeBookmarkCommands*
|
||||
NERDTreeBookmarkTable NERD_tree.txt /*NERDTreeBookmarkTable*
|
||||
NERDTreeBookmarks NERD_tree.txt /*NERDTreeBookmarks*
|
||||
NERDTreeChangelog NERD_tree.txt /*NERDTreeChangelog*
|
||||
NERDTreeCredits NERD_tree.txt /*NERDTreeCredits*
|
||||
NERDTreeFilesysMenu NERD_tree.txt /*NERDTreeFilesysMenu*
|
||||
NERDTreeFunctionality NERD_tree.txt /*NERDTreeFunctionality*
|
||||
NERDTreeGlobalCommands NERD_tree.txt /*NERDTreeGlobalCommands*
|
||||
NERDTreeHacking NERD_tree.txt /*NERDTreeHacking*
|
||||
NERDTreeInvalidBookmarks NERD_tree.txt /*NERDTreeInvalidBookmarks*
|
||||
NERDTreeLicense NERD_tree.txt /*NERDTreeLicense*
|
||||
NERDTreeMappings NERD_tree.txt /*NERDTreeMappings*
|
||||
NERDTreeOptionDetails NERD_tree.txt /*NERDTreeOptionDetails*
|
||||
NERDTreeOptionSummary NERD_tree.txt /*NERDTreeOptionSummary*
|
||||
NERDTreeOptions NERD_tree.txt /*NERDTreeOptions*
|
||||
NERD_tree.txt NERD_tree.txt /*NERD_tree.txt*
|
||||
ResetSnippets() snipMate.txt /*ResetSnippets()*
|
||||
VCSCommandCVSDiffOpt vcscommand.txt /*VCSCommandCVSDiffOpt*
|
||||
VCSCommandCVSExec vcscommand.txt /*VCSCommandCVSExec*
|
||||
VCSCommandCommitOnWrite vcscommand.txt /*VCSCommandCommitOnWrite*
|
||||
|
|
@ -61,6 +177,15 @@ b:match_tail matchit.txt /*b:match_tail*
|
|||
b:match_wholeBR matchit.txt /*b:match_wholeBR*
|
||||
b:match_word matchit.txt /*b:match_word*
|
||||
b:match_words matchit.txt /*b:match_words*
|
||||
bufexplorer bufexplorer.txt /*bufexplorer*
|
||||
bufexplorer-changelog bufexplorer.txt /*bufexplorer-changelog*
|
||||
bufexplorer-credits bufexplorer.txt /*bufexplorer-credits*
|
||||
bufexplorer-customization bufexplorer.txt /*bufexplorer-customization*
|
||||
bufexplorer-installation bufexplorer.txt /*bufexplorer-installation*
|
||||
bufexplorer-todo bufexplorer.txt /*bufexplorer-todo*
|
||||
bufexplorer-usage bufexplorer.txt /*bufexplorer-usage*
|
||||
bufexplorer.txt bufexplorer.txt /*bufexplorer.txt*
|
||||
buffer-explorer bufexplorer.txt /*buffer-explorer*
|
||||
cs surround.txt /*cs*
|
||||
cvscommand-changes vcscommand.txt /*cvscommand-changes*
|
||||
drawit DrawIt.txt /*drawit*
|
||||
|
|
@ -92,9 +217,55 @@ drawit-visblock DrawIt.txt /*drawit-visblock*
|
|||
drawit.txt DrawIt.txt /*drawit.txt*
|
||||
ds surround.txt /*ds*
|
||||
g% matchit.txt /*g%*
|
||||
g:bufExplorerDefaultHelp bufexplorer.txt /*g:bufExplorerDefaultHelp*
|
||||
g:bufExplorerDetailedHelp bufexplorer.txt /*g:bufExplorerDetailedHelp*
|
||||
g:bufExplorerFindActive bufexplorer.txt /*g:bufExplorerFindActive*
|
||||
g:bufExplorerReverseSort bufexplorer.txt /*g:bufExplorerReverseSort*
|
||||
g:bufExplorerShowDirectories bufexplorer.txt /*g:bufExplorerShowDirectories*
|
||||
g:bufExplorerShowRelativePath bufexplorer.txt /*g:bufExplorerShowRelativePath*
|
||||
g:bufExplorerShowUnlisted bufexplorer.txt /*g:bufExplorerShowUnlisted*
|
||||
g:bufExplorerSortBy bufexplorer.txt /*g:bufExplorerSortBy*
|
||||
g:bufExplorerSplitBelow bufexplorer.txt /*g:bufExplorerSplitBelow*
|
||||
g:bufExplorerSplitOutPathName bufexplorer.txt /*g:bufExplorerSplitOutPathName*
|
||||
g:bufExplorerSplitRight bufexplorer.txt /*g:bufExplorerSplitRight*
|
||||
g:drawit_insertmode DrawIt.txt /*g:drawit_insertmode*
|
||||
g:snippets_dir snipMate.txt /*g:snippets_dir*
|
||||
g:snips_author snipMate.txt /*g:snips_author*
|
||||
i_CTRL-G_S surround.txt /*i_CTRL-G_S*
|
||||
i_CTRL-G_s surround.txt /*i_CTRL-G_s*
|
||||
i_CTRL-R_<Tab> snipMate.txt /*i_CTRL-R_<Tab>*
|
||||
list-snippets snipMate.txt /*list-snippets*
|
||||
lookupfile-acknowledgements lookupfile.txt /*lookupfile-acknowledgements*
|
||||
lookupfile-buffer-cmd-alternative lookupfile.txt /*lookupfile-buffer-cmd-alternative*
|
||||
lookupfile-changes lookupfile.txt /*lookupfile-changes*
|
||||
lookupfile-changes-1.1 lookupfile.txt /*lookupfile-changes-1.1*
|
||||
lookupfile-changes-1.2 lookupfile.txt /*lookupfile-changes-1.2*
|
||||
lookupfile-changes-1.3 lookupfile.txt /*lookupfile-changes-1.3*
|
||||
lookupfile-changes-1.4 lookupfile.txt /*lookupfile-changes-1.4*
|
||||
lookupfile-changes-1.5 lookupfile.txt /*lookupfile-changes-1.5*
|
||||
lookupfile-changes-1.6 lookupfile.txt /*lookupfile-changes-1.6*
|
||||
lookupfile-changes-1.7 lookupfile.txt /*lookupfile-changes-1.7*
|
||||
lookupfile-changes-1.8 lookupfile.txt /*lookupfile-changes-1.8*
|
||||
lookupfile-default-cmd lookupfile.txt /*lookupfile-default-cmd*
|
||||
lookupfile-extend lookupfile.txt /*lookupfile-extend*
|
||||
lookupfile-find-cmd-alternative lookupfile.txt /*lookupfile-find-cmd-alternative*
|
||||
lookupfile-from-tags-files lookupfile.txt /*lookupfile-from-tags-files*
|
||||
lookupfile-ido lookupfile.txt /*lookupfile-ido*
|
||||
lookupfile-installation lookupfile.txt /*lookupfile-installation*
|
||||
lookupfile-introduction lookupfile.txt /*lookupfile-introduction*
|
||||
lookupfile-known-issues lookupfile.txt /*lookupfile-known-issues*
|
||||
lookupfile-map lookupfile.txt /*lookupfile-map*
|
||||
lookupfile-maps lookupfile.txt /*lookupfile-maps*
|
||||
lookupfile-overview lookupfile.txt /*lookupfile-overview*
|
||||
lookupfile-plugin lookupfile.txt /*lookupfile-plugin*
|
||||
lookupfile-recent-files lookupfile.txt /*lookupfile-recent-files*
|
||||
lookupfile-settings lookupfile.txt /*lookupfile-settings*
|
||||
lookupfile-tags lookupfile.txt /*lookupfile-tags*
|
||||
lookupfile-tips lookupfile.txt /*lookupfile-tips*
|
||||
lookupfile-usage lookupfile.txt /*lookupfile-usage*
|
||||
lookupfile-walk-path lookupfile.txt /*lookupfile-walk-path*
|
||||
lookupfile-wishlist lookupfile.txt /*lookupfile-wishlist*
|
||||
lookupfile.txt lookupfile.txt /*lookupfile.txt*
|
||||
matchit matchit.txt /*matchit*
|
||||
matchit-% matchit.txt /*matchit-%*
|
||||
matchit-\1 matchit.txt /*matchit-\\1*
|
||||
|
|
@ -120,6 +291,7 @@ matchit-troubleshoot matchit.txt /*matchit-troubleshoot*
|
|||
matchit-v_% matchit.txt /*matchit-v_%*
|
||||
matchit.txt matchit.txt /*matchit.txt*
|
||||
matchit.vim matchit.txt /*matchit.vim*
|
||||
multi_snip snipMate.txt /*multi_snip*
|
||||
o_[% matchit.txt /*o_[%*
|
||||
o_]% matchit.txt /*o_]%*
|
||||
o_g% matchit.txt /*o_g%*
|
||||
|
|
@ -163,6 +335,27 @@ psc_statement_different_from_type ps_color.txt /*psc_statement_different_from_ty
|
|||
psc_style ps_color.txt /*psc_style*
|
||||
psc_use_default_for_cterm ps_color.txt /*psc_use_default_for_cterm*
|
||||
pscolor ps_color.txt /*pscolor*
|
||||
snipMate snipMate.txt /*snipMate*
|
||||
snipMate-$# snipMate.txt /*snipMate-$#*
|
||||
snipMate-${#:} snipMate.txt /*snipMate-${#:}*
|
||||
snipMate-${#} snipMate.txt /*snipMate-${#}*
|
||||
snipMate-author snipMate.txt /*snipMate-author*
|
||||
snipMate-commands snipMate.txt /*snipMate-commands*
|
||||
snipMate-contact snipMate.txt /*snipMate-contact*
|
||||
snipMate-description snipMate.txt /*snipMate-description*
|
||||
snipMate-disadvantages snipMate.txt /*snipMate-disadvantages*
|
||||
snipMate-expandtab snipMate.txt /*snipMate-expandtab*
|
||||
snipMate-features snipMate.txt /*snipMate-features*
|
||||
snipMate-filename snipMate.txt /*snipMate-filename*
|
||||
snipMate-indenting snipMate.txt /*snipMate-indenting*
|
||||
snipMate-placeholders snipMate.txt /*snipMate-placeholders*
|
||||
snipMate-remap snipMate.txt /*snipMate-remap*
|
||||
snipMate-settings snipMate.txt /*snipMate-settings*
|
||||
snipMate-usage snipMate.txt /*snipMate-usage*
|
||||
snipMate.txt snipMate.txt /*snipMate.txt*
|
||||
snippet snipMate.txt /*snippet*
|
||||
snippet-syntax snipMate.txt /*snippet-syntax*
|
||||
snippets snipMate.txt /*snippets*
|
||||
surround surround.txt /*surround*
|
||||
surround-author surround.txt /*surround-author*
|
||||
surround-customizing surround.txt /*surround-customizing*
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ This command adds the current file to source control. Please note, this does
|
|||
not commit the newly-added file. All parameters to the command are passed to
|
||||
the underlying VCS.
|
||||
|
||||
:VCSAnnotate *:VCSAnnotate*
|
||||
:VCSAnnotate[!] *:VCSAnnotate*
|
||||
|
||||
This command displays the current file with each line annotated with the
|
||||
version in which it was most recently changed. If an argument is given, the
|
||||
|
|
@ -140,16 +140,20 @@ it uses the most recent version of the file (on the current branch, if under
|
|||
CVS control). Additionally, if the current buffer is a VCSAnnotate buffer
|
||||
already, the version number on the current line is used.
|
||||
|
||||
If '!' is used, the view of the annotated buffer is split so that the
|
||||
annotation is in a separate window from the content, and each is highlighted
|
||||
separately.
|
||||
|
||||
For CVS buffers, the 'VCSCommandCVSAnnotateParent' option, if set to non-zero,
|
||||
will cause the above behavior to change. Instead of annotating the version on
|
||||
the current line, the parent revision is used instead, crossing branches if
|
||||
necessary.
|
||||
|
||||
The filetype of the vcscommand scratch buffer is set to one of 'CVSAnnotate',
|
||||
'SVNAnnotate', or 'SVKAnnotate' as appropriate, to take advantage of the
|
||||
'SVNAnnotate', 'SVKAnnotate' or 'gitAnnotate' as appropriate, to take advantage of the
|
||||
bundled syntax files.
|
||||
|
||||
:VCSBlame *:VCSBlame*
|
||||
:VCSBlame[!] *:VCSBlame*
|
||||
|
||||
Alias for |:VCSAnnotate|.
|
||||
|
||||
|
|
@ -327,6 +331,7 @@ default (no-argument) form of each command.
|
|||
|
||||
<Leader>ca VCSAdd
|
||||
<Leader>cn VCSAnnotate
|
||||
<Leader>cN VCSAnnotate!
|
||||
<Leader>cc VCSCommit
|
||||
<Leader>cD VCSDelete
|
||||
<Leader>cd VCSDiff
|
||||
|
|
@ -354,16 +359,26 @@ Only for CVS buffers:
|
|||
|
||||
*vcscommand-mappings-override*
|
||||
|
||||
The default mappings can be overriden by user-provided instead by mapping to
|
||||
The default mappings can be overridden by user-provided instead by mapping to
|
||||
<Plug>CommandName. This is especially useful when these mappings collide with
|
||||
other existing mappings (vim will warn of this during plugin initialization,
|
||||
but will not clobber the existing mappings).
|
||||
|
||||
For instance, to override the default mapping for :VCSAdd to set it to '\add',
|
||||
add the following to the vimrc:
|
||||
There are three methods for controlling mapping:
|
||||
|
||||
First, maps can be overriden for individual commands. For instance, to
|
||||
override the default mapping for :VCSAdd to set it to '\add', add the
|
||||
following to the vimrc:
|
||||
|
||||
nmap \add <Plug>VCSAdd
|
||||
|
||||
Second, the default map prefix ('<Leader>c') can be overridden by defining the
|
||||
|VCSCommandMapPrefix| variable.
|
||||
|
||||
Third, the entire set of default maps can be overridden by defining the
|
||||
|VCSCommandMappings| variable.
|
||||
|
||||
|
||||
4.3 Automatic buffer variables *vcscommand-buffer-variables*
|
||||
|
||||
Several buffer variables are defined in each vcscommand result buffer. These
|
||||
|
|
@ -414,10 +429,13 @@ The following variables are available:
|
|||
|VCSCommandCVSExec|
|
||||
|VCSCommandDeleteOnHide|
|
||||
|VCSCommandDiffSplit|
|
||||
|VCSCommandDisableAll|
|
||||
|VCSCommandDisableMappings|
|
||||
|VCSCommandDisableExtensionMappings|
|
||||
|VCSCommandEdit|
|
||||
|VCSCommandEnableBufferSetup|
|
||||
|VCSCommandMappings|
|
||||
|VCSCommandMapPrefix|
|
||||
|VCSCommandResultBufferNameExtension|
|
||||
|VCSCommandResultBufferNameFunction|
|
||||
|VCSCommandSplit|
|
||||
|
|
@ -425,6 +443,7 @@ The following variables are available:
|
|||
|VCSCommandSVNDiffExt|
|
||||
|VCSCommandSVNDiffOpt|
|
||||
|VCSCommandSVNExec|
|
||||
|VCSCommandVCSTypeOverride|
|
||||
|
||||
VCSCommandCommitOnWrite *VCSCommandCommitOnWrite*
|
||||
|
||||
|
|
@ -453,6 +472,12 @@ VCSCommandDiffSplit *VCSCommandDiffSplit*
|
|||
This variable overrides the |VCSCommandSplit| variable, but only for buffers
|
||||
created with |:VCSVimDiff|.
|
||||
|
||||
VCSCommandDisableAll *VCSCommandDisableAll*
|
||||
|
||||
This variable, if set, prevents the plugin or any extensions from loading at
|
||||
all. This is useful when a single runtime distribution is used on multiple
|
||||
systems with varying versions.
|
||||
|
||||
VCSCommandDisableMappings *VCSCommandDisableMappings*
|
||||
|
||||
This variable, if set to a non-zero value, prevents the default command
|
||||
|
|
@ -477,6 +502,19 @@ mode see (|vcscommand-buffer-management|). This mode means that the
|
|||
is VCS-controlled. This is useful for displaying version information in the
|
||||
status bar.
|
||||
|
||||
VCSCommandMappings *VCSCommandMappings*
|
||||
|
||||
This variable, if set, overrides the default mappings used for shortcuts. It
|
||||
should be a List of 2-element Lists, each containing a shortcut and function
|
||||
name pair. The value of the '|VCSCommandMapPrefix|' variable will be added to
|
||||
each shortcut.
|
||||
|
||||
VCSCommandMapPrefix *VCSCommandMapPrefix*
|
||||
|
||||
This variable, if set, overrides the default mapping prefix ('<Leader>c').
|
||||
This allows customization of the mapping space used by the vcscommand
|
||||
shortcuts.
|
||||
|
||||
VCSCommandResultBufferNameExtension *VCSCommandResultBufferNameExtension*
|
||||
|
||||
This variable, if set to a non-blank value, is appended to the name of the VCS
|
||||
|
|
@ -507,7 +545,8 @@ may occur.
|
|||
If set to 'horizontal', the resulting windows will be on stacked on top of
|
||||
one another. If set to 'vertical', the resulting windows will be
|
||||
side-by-side. If not set, it defaults to 'horizontal' for all but
|
||||
VCSVimDiff windows.
|
||||
VCSVimDiff windows. VCSVimDiff windows default to the user's 'diffopt'
|
||||
setting, if set, otherwise 'vertical'.
|
||||
|
||||
VCSCommandSVKExec *VCSCommandSVKExec*
|
||||
|
||||
|
|
@ -529,6 +568,15 @@ VCSCommandSVNExec *VCSCommandSVNExec*
|
|||
This variable controls the executable used for all SVN commands If not set,
|
||||
it defaults to "svn".
|
||||
|
||||
VCSCommandVCSTypeOverride *VCSCommandVCSTypeOverride*
|
||||
|
||||
This variable allows the VCS type detection to be overridden on a path-by-path
|
||||
basis. The value of this variable is expected to be a List of Lists. Each
|
||||
item in the high-level List is a List containing two elements. The first
|
||||
element is a regular expression that will be matched against the full file
|
||||
name of a given buffer. If it matches, the second element will be used as the
|
||||
VCS type.
|
||||
|
||||
5.2 VCSCommand events *vcscommand-events*
|
||||
|
||||
For additional customization, vcscommand can trigger user-defined events.
|
||||
|
|
@ -540,7 +588,7 @@ For instance, the following could be added to the vimrc to provide a 'q'
|
|||
mapping to quit a vcscommand scratch buffer:
|
||||
|
||||
augroup VCSCommand
|
||||
au User VCSBufferCreated silent! nmap <unique> <buffer> q: bwipeout<cr>
|
||||
au User VCSBufferCreated silent! nmap <unique> <buffer> q :bwipeout<cr>
|
||||
augroup END
|
||||
|
||||
The following hooks are available:
|
||||
|
|
@ -712,7 +760,7 @@ too often.
|
|||
|
||||
==============================================================================
|
||||
|
||||
7. Changes from cvscommandi *cvscommand-changes*
|
||||
7. Changes from cvscommand *cvscommand-changes*
|
||||
|
||||
1. Require Vim 7 in order to leverage several convenient features; also
|
||||
because I wanted to play with Vim 7.
|
||||
|
|
|
|||
10
.vim/ftplugin/html_snip_helper.vim
Normal file
10
.vim/ftplugin/html_snip_helper.vim
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
" Helper function for (x)html snippets
|
||||
if exists('s:did_snip_helper') || &cp || !exists('loaded_snips')
|
||||
finish
|
||||
endif
|
||||
let s:did_snip_helper = 1
|
||||
|
||||
" Automatically closes tag if in xhtml
|
||||
fun! Close()
|
||||
return stridx(&ft, 'xhtml') == -1 ? '' : ' /'
|
||||
endf
|
||||
70
.vim/ftplugin/objc_cocoa_mappings.vim
Normal file
70
.vim/ftplugin/objc_cocoa_mappings.vim
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
" File: objc_cocoa_mappings.vim
|
||||
" Author: Michael Sanders (msanders42 [at] gmail [dot] com)
|
||||
" Description: Sets up mappings for cocoa.vim.
|
||||
" Last Updated: September 08, 2009
|
||||
|
||||
if exists('b:cocoa_proj') || &cp || version < 700
|
||||
finish
|
||||
endif
|
||||
let b:cocoa_proj = fnameescape(globpath(expand('<afile>:p:h'), '*.xcodeproj'))
|
||||
|
||||
com! -buffer ListMethods call objc#method_list#Activate(1)
|
||||
com! -buffer -nargs=? -complete=customlist,objc#method_builder#Completion BuildMethods call objc#method_builder#Build('<args>')
|
||||
com! -buffer -nargs=? -complete=custom,objc#man#Completion CocoaDoc call objc#man#ShowDoc('<args>')
|
||||
com! -buffer -nargs=? Alternate call <SID>AlternateFile()
|
||||
|
||||
let objc_man_key = exists('objc_man_key') ? objc_man_key : 'K'
|
||||
exe 'nn <buffer> <silent> '.objc_man_key.' :<c-u>call objc#man#ShowDoc()<cr>'
|
||||
|
||||
nn <buffer> <silent> <leader>A :cal<SID>AlternateFile()<cr>
|
||||
|
||||
" Mimic some of Xcode's mappings.
|
||||
nn <buffer> <silent> <d-r> :w<bar>cal<SID>BuildAnd('launch')<cr>
|
||||
nn <buffer> <silent> <d-b> :w<bar>cal<SID>XcodeRun('build')<cr>
|
||||
nn <buffer> <silent> <d-K> :w<bar>cal<SID>XcodeRun('clean')<cr>
|
||||
" TODO: Add this
|
||||
" nn <buffer> <silent> <d-y> :w<bar>cal<SID>BuildAnd('debug')<cr>
|
||||
nn <buffer> <silent> <d-m-up> :cal<SID>AlternateFile()<cr>
|
||||
nn <buffer> <silent> <d-0> :call system('open -a Xcode '.b:cocoa_proj)<cr>
|
||||
nn <buffer> <silent> <d-2> :<c-u>ListMethods<cr>
|
||||
nm <buffer> <silent> <d-cr> <d-r>
|
||||
ino <buffer> <silent> <f5> <c-x><c-o>
|
||||
|
||||
if exists('*s:AlternateFile') | finish | endif
|
||||
|
||||
" Switch from header file to implementation file (and vice versa).
|
||||
fun s:AlternateFile()
|
||||
let path = expand('%:p:r').'.'
|
||||
if expand('%:e') == 'h'
|
||||
if filereadable(path.'m')
|
||||
exe 'e'.fnameescape(path.'m')
|
||||
return
|
||||
elseif filereadable(path.'c')
|
||||
exe 'e'.fnameescape(path.'c')
|
||||
return
|
||||
endif
|
||||
else
|
||||
if filereadable(path.'h')
|
||||
exe 'e'.fnameescape(path.'h')
|
||||
return
|
||||
endif
|
||||
endif
|
||||
echoh ErrorMsg | echo 'Alternate file not readable.' | echoh None
|
||||
endf
|
||||
|
||||
" Opens Xcode and runs Applescript commands, splitting them onto newlines
|
||||
" if needed.
|
||||
fun s:XcodeRun(command)
|
||||
call system("open -a Xcode ".b:cocoa_proj." && osascript -e 'tell app "
|
||||
\ .'"Xcode" to '.a:command."' &")
|
||||
endf
|
||||
|
||||
fun s:BuildAnd(command)
|
||||
call system("open -a Xcode ".b:cocoa_proj." && osascript -e 'tell app "
|
||||
\ ."\"Xcode\"' -e '"
|
||||
\ .'set target_ to project of active project document '
|
||||
\ ."' -e '"
|
||||
\ .'if (build target_) starts with "Build succeeded" then '
|
||||
\ .a:command.' target_'
|
||||
\ ."' -e 'end tell'")
|
||||
endf
|
||||
3796
.vim/plugin/NERD_tree.vim
Normal file
3796
.vim/plugin/NERD_tree.vim
Normal file
File diff suppressed because it is too large
Load diff
16
.vim/plugin/cocoa.vim
Normal file
16
.vim/plugin/cocoa.vim
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
" File: cocoa.vim
|
||||
" Author: Michael Sanders msanders [at] gmail [dot] com
|
||||
if exists('s:did_cocoa') || &cp || version < 700
|
||||
finish
|
||||
endif
|
||||
let s:did_cocoa = 1
|
||||
|
||||
" These have to load after the normal ftplugins to override the defaults; I'd
|
||||
" like to put this in ftplugin/objc_cocoa_mappings.vim, but that doesn't seem
|
||||
" to work..
|
||||
au FileType objc ru after/syntax/objc_enhanced.vim
|
||||
\| let b:match_words = '@\(implementation\|interface\):@end'
|
||||
\| setl inc=^\s*#\s*import omnifunc=objc#cocoacomplete#Complete
|
||||
\| if globpath(expand('<afile>:p:h'), '*.xcodeproj') != '' |
|
||||
\ setl makeprg=open\ -a\ xcode\ &&\ osascript\ -e\ 'tell\ app\ \"Xcode\"\ to\ build'
|
||||
\| endif
|
||||
996
.vim/plugin/genutils.vim
Executable file
996
.vim/plugin/genutils.vim
Executable file
File diff suppressed because it is too large
Load diff
32
.vim/plugin/slime.vim
Normal file
32
.vim/plugin/slime.vim
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
function Send_to_Screen(text)
|
||||
if !exists("g:screen_sessionname") || !exists("g:screen_windowname")
|
||||
call Screen_Vars()
|
||||
end
|
||||
|
||||
echo system("screen -S " . g:screen_sessionname . " -p " . g:screen_windowname . " -X stuff '" . substitute(a:text, "'", "'\\\\''", 'g') . "'")
|
||||
endfunction
|
||||
|
||||
function Screen_Session_Names(A,L,P)
|
||||
return system("screen -ls | awk '/Attached/ {print $1}'")
|
||||
endfunction
|
||||
|
||||
function Screen_Vars()
|
||||
if !exists("g:screen_sessionname") || !exists("g:screen_windowname")
|
||||
let g:screen_sessionname = ""
|
||||
let g:screen_windowname = "0"
|
||||
end
|
||||
|
||||
let g:screen_sessionname = input("session name: ", "", "custom,Screen_Session_Names")
|
||||
let g:screen_windowname = input("window name: ", g:screen_windowname)
|
||||
endfunction
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
vmap <C-c><C-c> "ry :call Send_to_Screen(@r)<CR>
|
||||
nmap <C-c><C-c> vip<C-c><C-c>
|
||||
|
||||
nmap <C-c>v :call Screen_Vars()<CR>
|
||||
|
||||
247
.vim/plugin/snipMate.vim
Normal file
247
.vim/plugin/snipMate.vim
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
" File: snipMate.vim
|
||||
" Author: Michael Sanders
|
||||
" Last Updated: July 13, 2009
|
||||
" Version: 0.83
|
||||
" Description: snipMate.vim implements some of TextMate's snippets features in
|
||||
" Vim. A snippet is a piece of often-typed text that you can
|
||||
" insert into your document using a trigger word followed by a "<tab>".
|
||||
"
|
||||
" For more help see snipMate.txt; you can do this by using:
|
||||
" :helptags ~/.vim/doc
|
||||
" :h snipMate.txt
|
||||
|
||||
if exists('loaded_snips') || &cp || version < 700
|
||||
finish
|
||||
endif
|
||||
let loaded_snips = 1
|
||||
if !exists('snips_author') | let snips_author = 'Me' | endif
|
||||
|
||||
au BufRead,BufNewFile *.snippets\= set ft=snippet
|
||||
au FileType snippet setl noet fdm=indent
|
||||
|
||||
let s:snippets = {} | let s:multi_snips = {}
|
||||
|
||||
if !exists('snippets_dir')
|
||||
let snippets_dir = substitute(globpath(&rtp, 'snippets/'), "\n", ',', 'g')
|
||||
endif
|
||||
|
||||
fun! MakeSnip(scope, trigger, content, ...)
|
||||
let multisnip = a:0 && a:1 != ''
|
||||
let var = multisnip ? 's:multi_snips' : 's:snippets'
|
||||
if !has_key({var}, a:scope) | let {var}[a:scope] = {} | endif
|
||||
if !has_key({var}[a:scope], a:trigger)
|
||||
let {var}[a:scope][a:trigger] = multisnip ? [[a:1, a:content]] : a:content
|
||||
elseif multisnip | let {var}[a:scope][a:trigger] += [[a:1, a:content]]
|
||||
else
|
||||
echom 'Warning in snipMate.vim: Snippet '.a:trigger.' is already defined.'
|
||||
\ .' See :h multi_snip for help on snippets with multiple matches.'
|
||||
endif
|
||||
endf
|
||||
|
||||
fun! ExtractSnips(dir, ft)
|
||||
for path in split(globpath(a:dir, '*'), "\n")
|
||||
if isdirectory(path)
|
||||
let pathname = fnamemodify(path, ':t')
|
||||
for snipFile in split(globpath(path, '*.snippet'), "\n")
|
||||
call s:ProcessFile(snipFile, a:ft, pathname)
|
||||
endfor
|
||||
elseif fnamemodify(path, ':e') == 'snippet'
|
||||
call s:ProcessFile(path, a:ft)
|
||||
endif
|
||||
endfor
|
||||
endf
|
||||
|
||||
" Processes a single-snippet file; optionally add the name of the parent
|
||||
" directory for a snippet with multiple matches.
|
||||
fun s:ProcessFile(file, ft, ...)
|
||||
let keyword = fnamemodify(a:file, ':t:r')
|
||||
if keyword == '' | return | endif
|
||||
try
|
||||
let text = join(readfile(a:file), "\n")
|
||||
catch /E484/
|
||||
echom "Error in snipMate.vim: couldn't read file: ".a:file
|
||||
endtry
|
||||
return a:0 ? MakeSnip(a:ft, a:1, text, keyword)
|
||||
\ : MakeSnip(a:ft, keyword, text)
|
||||
endf
|
||||
|
||||
fun! ExtractSnipsFile(file, ft)
|
||||
if !filereadable(a:file) | return | endif
|
||||
let text = readfile(a:file)
|
||||
let inSnip = 0
|
||||
for line in text + ["\n"]
|
||||
if inSnip && (line[0] == "\t" || line == '')
|
||||
let content .= strpart(line, 1)."\n"
|
||||
continue
|
||||
elseif inSnip
|
||||
call MakeSnip(a:ft, trigger, content[:-2], name)
|
||||
let inSnip = 0
|
||||
endif
|
||||
|
||||
if line[:6] == 'snippet'
|
||||
let inSnip = 1
|
||||
let trigger = strpart(line, 8)
|
||||
let name = ''
|
||||
let space = stridx(trigger, ' ') + 1
|
||||
if space " Process multi snip
|
||||
let name = strpart(trigger, space)
|
||||
let trigger = strpart(trigger, 0, space - 1)
|
||||
endif
|
||||
let content = ''
|
||||
endif
|
||||
endfor
|
||||
endf
|
||||
|
||||
fun! ResetSnippets()
|
||||
let s:snippets = {} | let s:multi_snips = {} | let g:did_ft = {}
|
||||
endf
|
||||
|
||||
let g:did_ft = {}
|
||||
fun! GetSnippets(dir, filetypes)
|
||||
for ft in split(a:filetypes, '\.')
|
||||
if has_key(g:did_ft, ft) | continue | endif
|
||||
call s:DefineSnips(a:dir, ft, ft)
|
||||
if ft == 'objc' || ft == 'cpp' || ft == 'cs'
|
||||
call s:DefineSnips(a:dir, 'c', ft)
|
||||
elseif ft == 'xhtml'
|
||||
call s:DefineSnips(a:dir, 'html', 'xhtml')
|
||||
endif
|
||||
let g:did_ft[ft] = 1
|
||||
endfor
|
||||
endf
|
||||
|
||||
" Define "aliasft" snippets for the filetype "realft".
|
||||
fun s:DefineSnips(dir, aliasft, realft)
|
||||
for path in split(globpath(a:dir, a:aliasft.'/')."\n".
|
||||
\ globpath(a:dir, a:aliasft.'-*/'), "\n")
|
||||
call ExtractSnips(path, a:realft)
|
||||
endfor
|
||||
for path in split(globpath(a:dir, a:aliasft.'.snippets')."\n".
|
||||
\ globpath(a:dir, a:aliasft.'-*.snippets'), "\n")
|
||||
call ExtractSnipsFile(path, a:realft)
|
||||
endfor
|
||||
endf
|
||||
|
||||
fun! TriggerSnippet()
|
||||
if exists('g:SuperTabMappingForward')
|
||||
if g:SuperTabMappingForward == "<tab>"
|
||||
let SuperTabKey = "\<c-n>"
|
||||
elseif g:SuperTabMappingBackward == "<tab>"
|
||||
let SuperTabKey = "\<c-p>"
|
||||
endif
|
||||
endif
|
||||
|
||||
if pumvisible() " Update snippet if completion is used, or deal with supertab
|
||||
if exists('SuperTabKey')
|
||||
call feedkeys(SuperTabKey) | return ''
|
||||
endif
|
||||
call feedkeys("\<esc>a", 'n') " Close completion menu
|
||||
call feedkeys("\<tab>") | return ''
|
||||
endif
|
||||
|
||||
if exists('g:snipPos') | return snipMate#jumpTabStop(0) | endif
|
||||
|
||||
let word = matchstr(getline('.'), '\S\+\%'.col('.').'c')
|
||||
for scope in [bufnr('%')] + split(&ft, '\.') + ['_']
|
||||
let [trigger, snippet] = s:GetSnippet(word, scope)
|
||||
" If word is a trigger for a snippet, delete the trigger & expand
|
||||
" the snippet.
|
||||
if snippet != ''
|
||||
let col = col('.') - len(trigger)
|
||||
sil exe 's/\V'.escape(trigger, '/.').'\%#//'
|
||||
return snipMate#expandSnip(snippet, col)
|
||||
endif
|
||||
endfor
|
||||
|
||||
if exists('SuperTabKey')
|
||||
call feedkeys(SuperTabKey)
|
||||
return ''
|
||||
endif
|
||||
return "\<tab>"
|
||||
endf
|
||||
|
||||
fun! BackwardsSnippet()
|
||||
if exists('g:snipPos') | return snipMate#jumpTabStop(1) | endif
|
||||
|
||||
if exists('g:SuperTabMappingForward')
|
||||
if g:SuperTabMappingBackward == "<s-tab>"
|
||||
let SuperTabKey = "\<c-p>"
|
||||
elseif g:SuperTabMappingForward == "<s-tab>"
|
||||
let SuperTabKey = "\<c-n>"
|
||||
endif
|
||||
endif
|
||||
if exists('SuperTabKey')
|
||||
call feedkeys(SuperTabKey)
|
||||
return ''
|
||||
endif
|
||||
return "\<s-tab>"
|
||||
endf
|
||||
|
||||
" Check if word under cursor is snippet trigger; if it isn't, try checking if
|
||||
" the text after non-word characters is (e.g. check for "foo" in "bar.foo")
|
||||
fun s:GetSnippet(word, scope)
|
||||
let word = a:word | let snippet = ''
|
||||
while snippet == ''
|
||||
if exists('s:snippets["'.a:scope.'"]["'.escape(word, '\"').'"]')
|
||||
let snippet = s:snippets[a:scope][word]
|
||||
elseif exists('s:multi_snips["'.a:scope.'"]["'.escape(word, '\"').'"]')
|
||||
let snippet = s:ChooseSnippet(a:scope, word)
|
||||
if snippet == '' | break | endif
|
||||
else
|
||||
if match(word, '\W') == -1 | break | endif
|
||||
let word = substitute(word, '.\{-}\W', '', '')
|
||||
endif
|
||||
endw
|
||||
if word == '' && a:word != '.' && stridx(a:word, '.') != -1
|
||||
let [word, snippet] = s:GetSnippet('.', a:scope)
|
||||
endif
|
||||
return [word, snippet]
|
||||
endf
|
||||
|
||||
fun s:ChooseSnippet(scope, trigger)
|
||||
let snippet = []
|
||||
let i = 1
|
||||
for snip in s:multi_snips[a:scope][a:trigger]
|
||||
let snippet += [i.'. '.snip[0]]
|
||||
let i += 1
|
||||
endfor
|
||||
if i == 2 | return s:multi_snips[a:scope][a:trigger][0][1] | endif
|
||||
let num = inputlist(snippet) - 1
|
||||
return num == -1 ? '' : s:multi_snips[a:scope][a:trigger][num][1]
|
||||
endf
|
||||
|
||||
fun! ShowAvailableSnips()
|
||||
let line = getline('.')
|
||||
let col = col('.')
|
||||
let word = matchstr(getline('.'), '\S\+\%'.col.'c')
|
||||
let words = [word]
|
||||
if stridx(word, '.')
|
||||
let words += split(word, '\.', 1)
|
||||
endif
|
||||
let matchlen = 0
|
||||
let matches = []
|
||||
for scope in [bufnr('%')] + split(&ft, '\.') + ['_']
|
||||
let triggers = has_key(s:snippets, scope) ? keys(s:snippets[scope]) : []
|
||||
if has_key(s:multi_snips, scope)
|
||||
let triggers += keys(s:multi_snips[scope])
|
||||
endif
|
||||
for trigger in triggers
|
||||
for word in words
|
||||
if word == ''
|
||||
let matches += [trigger] " Show all matches if word is empty
|
||||
elseif trigger =~ '^'.word
|
||||
let matches += [trigger]
|
||||
let len = len(word)
|
||||
if len > matchlen | let matchlen = len | endif
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endfor
|
||||
|
||||
" This is to avoid a bug with Vim when using complete(col - matchlen, matches)
|
||||
" (Issue#46 on the Google Code snipMate issue tracker).
|
||||
call setline(line('.'), substitute(line, repeat('.', matchlen).'\%'.col.'c', '', ''))
|
||||
call complete(col, matches)
|
||||
return ''
|
||||
endf
|
||||
" vim:noet:sw=4:ts=4:ft=vim
|
||||
254
.vim/plugin/vcsbzr.vim
Normal file
254
.vim/plugin/vcsbzr.vim
Normal file
|
|
@ -0,0 +1,254 @@
|
|||
" vim600: set foldmethod=marker:
|
||||
"
|
||||
" BZR extension for VCSCommand.
|
||||
"
|
||||
" Version: VCS development
|
||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
||||
" License:
|
||||
" Copyright (c) 2009 Bob Hiestand
|
||||
"
|
||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
" of this software and associated documentation files (the "Software"), to
|
||||
" deal in the Software without restriction, including without limitation the
|
||||
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
" sell copies of the Software, and to permit persons to whom the Software is
|
||||
" furnished to do so, subject to the following conditions:
|
||||
"
|
||||
" The above copyright notice and this permission notice shall be included in
|
||||
" all copies or substantial portions of the Software.
|
||||
"
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
" IN THE SOFTWARE.
|
||||
"
|
||||
" Section: Documentation {{{1
|
||||
"
|
||||
" Options documentation: {{{2
|
||||
"
|
||||
" VCSCommandBZRExec
|
||||
" This variable specifies the BZR executable. If not set, it defaults to
|
||||
" 'bzr' executed from the user's executable path.
|
||||
|
||||
" Section: Plugin header {{{1
|
||||
|
||||
if v:version < 700
|
||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo=&cpo
|
||||
set cpo&vim
|
||||
|
||||
runtime plugin/vcscommand.vim
|
||||
|
||||
if !executable(VCSCommandGetOption('VCSCommandBZRExec', 'bzr'))
|
||||
" BZR is not installed
|
||||
finish
|
||||
endif
|
||||
|
||||
" Section: Variable initialization {{{1
|
||||
|
||||
let s:bzrFunctions = {}
|
||||
|
||||
" Section: Utility functions {{{1
|
||||
|
||||
" Function: s:DoCommand(cmd, cmdName, statusText) {{{2
|
||||
" Wrapper to VCSCommandDoCommand to add the name of the BZR executable to the
|
||||
" command argument.
|
||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
||||
if VCSCommandGetVCSType(expand('%')) == 'BZR'
|
||||
let fullCmd = VCSCommandGetOption('VCSCommandBZRExec', 'bzr') . ' ' . a:cmd
|
||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
||||
else
|
||||
throw 'BZR VCSCommand plugin called on non-BZR item.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Section: VCS function implementations {{{1
|
||||
|
||||
" Function: s:bzrFunctions.Identify(buffer) {{{2
|
||||
function! s:bzrFunctions.Identify(buffer)
|
||||
let fileName = resolve(bufname(a:buffer))
|
||||
let statusText = system(VCSCommandGetOption('VCSCommandBZRExec', 'bzr') . ' info "' . fileName . '"')
|
||||
if(v:shell_error)
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Add() {{{2
|
||||
function! s:bzrFunctions.Add(argList)
|
||||
return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Annotate(argList) {{{2
|
||||
function! s:bzrFunctions.Annotate(argList)
|
||||
if len(a:argList) == 0
|
||||
if &filetype == 'BZRAnnotate'
|
||||
" Perform annotation of the version indicated by the current line.
|
||||
let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
|
||||
let options = ' -r' . caption
|
||||
else
|
||||
let caption = ''
|
||||
let options = ''
|
||||
endif
|
||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
||||
let caption = a:argList[0]
|
||||
let options = ' -r' . caption
|
||||
else
|
||||
let caption = join(a:argList, ' ')
|
||||
let options = ' ' . caption
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption, {})
|
||||
if resultBuffer > 0
|
||||
normal 1G2dd
|
||||
set filetype=BZRAnnotate
|
||||
endif
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Commit(argList) {{{2
|
||||
function! s:bzrFunctions.Commit(argList)
|
||||
let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
|
||||
if resultBuffer == 0
|
||||
echomsg 'No commit needed.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Delete() {{{2
|
||||
function! s:bzrFunctions.Delete(argList)
|
||||
return s:DoCommand(join(['rm'] + a:argList, ' '), 'rm', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Diff(argList) {{{2
|
||||
function! s:bzrFunctions.Diff(argList)
|
||||
if len(a:argList) == 0
|
||||
let revOptions = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let revOptions = ['-r' . join(a:argList, '..')]
|
||||
let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
|
||||
else
|
||||
" Pass-through
|
||||
let caption = join(a:argList, ' ')
|
||||
let revOptions = a:argList
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand(join(['diff'] + revOptions), 'diff', caption, {'allowNonZeroExit': 1})
|
||||
if resultBuffer > 0
|
||||
set filetype=diff
|
||||
else
|
||||
echomsg 'No differences found'
|
||||
endif
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.GetBufferInfo() {{{2
|
||||
" Provides version control details for the current file. Current version
|
||||
" number and current repository version number are required to be returned by
|
||||
" the vcscommand plugin.
|
||||
" Returns: List of results: [revision, repository]
|
||||
|
||||
function! s:bzrFunctions.GetBufferInfo()
|
||||
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
|
||||
let fileName = resolve(bufname(originalBuffer))
|
||||
let statusText = system(VCSCommandGetOption('VCSCommandBZRExec', 'bzr') . ' status -S "' . fileName . '"')
|
||||
let revision = system(VCSCommandGetOption('VCSCommandBZRExec', 'bzr') . ' revno "' . fileName . '"')
|
||||
if(v:shell_error)
|
||||
return []
|
||||
endif
|
||||
|
||||
" File not under BZR control.
|
||||
if statusText =~ '^?'
|
||||
return ['Unknown']
|
||||
endif
|
||||
|
||||
let [flags, repository] = matchlist(statusText, '^\(.\{3}\)\s\+\(\S\+\)')[1:2]
|
||||
if revision == ''
|
||||
" Error
|
||||
return ['Unknown']
|
||||
elseif flags =~ '^A'
|
||||
return ['New', 'New']
|
||||
else
|
||||
return [revision, repository]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Info(argList) {{{2
|
||||
function! s:bzrFunctions.Info(argList)
|
||||
return s:DoCommand(join(['version-info'] + a:argList, ' '), 'version-info', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Lock(argList) {{{2
|
||||
function! s:bzrFunctions.Lock(argList)
|
||||
echomsg 'bzr lock is not necessary'
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Log() {{{2
|
||||
function! s:bzrFunctions.Log(argList)
|
||||
if len(a:argList) == 0
|
||||
let options = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let options = ['-r' . join(a:argList, ':')]
|
||||
let caption = options[0]
|
||||
else
|
||||
" Pass-through
|
||||
let options = a:argList
|
||||
let caption = join(a:argList, ' ')
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption, {})
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Revert(argList) {{{2
|
||||
function! s:bzrFunctions.Revert(argList)
|
||||
return s:DoCommand('revert', 'revert', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Review(argList) {{{2
|
||||
function! s:bzrFunctions.Review(argList)
|
||||
if len(a:argList) == 0
|
||||
let versiontag = '(current)'
|
||||
let versionOption = ''
|
||||
else
|
||||
let versiontag = a:argList[0]
|
||||
let versionOption = ' -r ' . versiontag . ' '
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand('cat' . versionOption, 'review', versiontag, {})
|
||||
if resultBuffer > 0
|
||||
let &filetype=getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
|
||||
endif
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Status(argList) {{{2
|
||||
function! s:bzrFunctions.Status(argList)
|
||||
let options = ['-S']
|
||||
if len(a:argList) == 0
|
||||
let options = a:argList
|
||||
endif
|
||||
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Unlock(argList) {{{2
|
||||
function! s:bzrFunctions.Unlock(argList)
|
||||
echomsg 'bzr unlock is not necessary'
|
||||
endfunction
|
||||
" Function: s:bzrFunctions.Update(argList) {{{2
|
||||
function! s:bzrFunctions.Update(argList)
|
||||
return s:DoCommand('update', 'update', '', {})
|
||||
endfunction
|
||||
|
||||
" Section: Plugin Registration {{{1
|
||||
call VCSCommandRegisterModule('BZR', expand('<sfile>'), s:bzrFunctions, [])
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
" vim600: set foldmethod=marker:
|
||||
"
|
||||
" Vim plugin to assist in working with files under control of CVS or SVN.
|
||||
" Vim plugin to assist in working with files under control of various Version
|
||||
" Control Systems, such as CVS, SVN, SVK, and git.
|
||||
"
|
||||
" Version: Beta 22
|
||||
" Version: 1.99.31
|
||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
||||
" License:
|
||||
" Copyright (c) 2007 Bob Hiestand
|
||||
" Copyright (c) 2008 Bob Hiestand
|
||||
"
|
||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
" of this software and associated documentation files (the "Software"), to
|
||||
|
|
@ -43,7 +44,7 @@
|
|||
"
|
||||
" VCSAdd Adds the current file to source control.
|
||||
"
|
||||
" VCSAnnotate Displays the current file with each line annotated with the
|
||||
" VCSAnnotate[!] Displays the current file with each line annotated with the
|
||||
" version in which it was most recently changed. If an
|
||||
" argument is given, the argument is used as a revision
|
||||
" number to display. If not given an argument, it uses the
|
||||
|
|
@ -51,6 +52,10 @@
|
|||
" Additionally, if the current buffer is a VCSAnnotate buffer
|
||||
" already, the version number on the current line is used.
|
||||
"
|
||||
" If '!' is used, the view of the annotated buffer is split
|
||||
" so that the annotation is in a separate window from the
|
||||
" content, and each is highlighted separately.
|
||||
"
|
||||
" VCSBlame Alias for 'VCSAnnotate'.
|
||||
"
|
||||
" VCSCommit[!] Commits changes to the current file to source control.
|
||||
|
|
@ -151,6 +156,7 @@
|
|||
"
|
||||
" <Leader>ca VCSAdd
|
||||
" <Leader>cn VCSAnnotate
|
||||
" <Leader>cN VCSAnnotate!
|
||||
" <Leader>cc VCSCommit
|
||||
" <Leader>cD VCSDelete
|
||||
" <Leader>cd VCSDiff
|
||||
|
|
@ -187,6 +193,11 @@
|
|||
" This variable overrides the VCSCommandSplit variable, but only for buffers
|
||||
" created with VCSVimDiff.
|
||||
"
|
||||
" VCSCommandDisableAll
|
||||
" This variable, if set, prevents the plugin or any extensions from loading
|
||||
" at all. This is useful when a single runtime distribution is used on
|
||||
" multiple systems with varying versions.
|
||||
"
|
||||
" VCSCommandDisableMappings
|
||||
" This variable, if set to a non-zero value, prevents the default command
|
||||
" mappings from being set.
|
||||
|
|
@ -207,6 +218,16 @@
|
|||
" information in the status bar. Additional options may be set by
|
||||
" individual VCS plugins.
|
||||
"
|
||||
" VCSCommandMappings
|
||||
" This variable, if set, overrides the default mappings used for shortcuts.
|
||||
" It should be a List of 2-element Lists, each containing a shortcut and
|
||||
" function name pair.
|
||||
"
|
||||
" VCSCommandMapPrefix
|
||||
" This variable, if set, overrides the default mapping prefix ('<Leader>c').
|
||||
" This allows customization of the mapping space used by the vcscommand
|
||||
" shortcuts.
|
||||
"
|
||||
" VCSCommandResultBufferNameExtension
|
||||
" This variable, if set to a non-blank value, is appended to the name of the
|
||||
" VCS command output buffers. For example, '.vcs'. Using this option may
|
||||
|
|
@ -235,6 +256,14 @@
|
|||
" side-by-side. If not set, it defaults to 'horizontal' for all but
|
||||
" VCSVimDiff windows.
|
||||
"
|
||||
" VCSCommandVCSTypeOverride
|
||||
" This variable allows the VCS type detection to be overridden on a
|
||||
" path-by-path basis. The value of this variable is expected to be a List
|
||||
" of Lists. Each high-level List item is a List containing two elements.
|
||||
" The first element is a regular expression that will be matched against the
|
||||
" full file name of a given buffer. If it matches, the second element will
|
||||
" be used as the VCS type.
|
||||
"
|
||||
" Event documentation {{{2
|
||||
" For additional customization, VCSCommand.vim uses User event autocommand
|
||||
" hooks. Each event is in the VCSCommand group, and different patterns
|
||||
|
|
@ -272,6 +301,10 @@
|
|||
" completes. This allows various actions to only be taken by functions after
|
||||
" system initialization.
|
||||
|
||||
if exists('VCSCommandDisableAll')
|
||||
finish
|
||||
endif
|
||||
|
||||
if exists('loaded_VCSCommand')
|
||||
finish
|
||||
endif
|
||||
|
|
@ -331,6 +364,27 @@ function! s:ReportError(error)
|
|||
echohl WarningMsg|echomsg 'VCSCommand: ' . a:error|echohl None
|
||||
endfunction
|
||||
|
||||
|
||||
" Function: s:CreateMapping(shortcut, expansion, display) {{{2
|
||||
" Creates the given mapping by prepending the contents of
|
||||
" 'VCSCommandMapPrefix' (by default '<Leader>c') to the given shortcut and
|
||||
" mapping it to the given plugin function. If a mapping exists for the
|
||||
" specified shortcut + prefix, emit an error but continue. If a mapping
|
||||
" exists for the specified function, do nothing.
|
||||
|
||||
function! s:CreateMapping(shortcut, expansion, display)
|
||||
let lhs = VCSCommandGetOption('VCSCommandMapPrefix', '<Leader>c') . a:shortcut
|
||||
if !hasmapto(a:expansion)
|
||||
try
|
||||
execute 'nmap <silent> <unique>' lhs a:expansion
|
||||
catch /^Vim(.*):E227:/
|
||||
if(&verbose != 0)
|
||||
echohl WarningMsg|echomsg 'VCSCommand: mapping ''' . lhs . ''' already exists, refusing to overwrite. The mapping for ' . a:display . ' will not be available.'|echohl None
|
||||
endif
|
||||
endtry
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:ExecuteExtensionMapping(mapping) {{{2
|
||||
" Invokes the appropriate extension mapping depending on the type of the
|
||||
" current buffer.
|
||||
|
|
@ -431,15 +485,6 @@ endfunction
|
|||
function! s:EditFile(command, originalBuffer, statusText)
|
||||
let vcsType = getbufvar(a:originalBuffer, 'VCSCommandVCSType')
|
||||
|
||||
let nameExtension = VCSCommandGetOption('VCSCommandResultBufferNameExtension', '')
|
||||
if nameExtension == ''
|
||||
let nameFunction = VCSCommandGetOption('VCSCommandResultBufferNameFunction', 's:GenerateResultBufferName')
|
||||
else
|
||||
let nameFunction = VCSCommandGetOption('VCSCommandResultBufferNameFunction', 's:GenerateResultBufferNameWithExtension')
|
||||
endif
|
||||
|
||||
let resultBufferName = call(nameFunction, [a:command, a:originalBuffer, vcsType, a:statusText])
|
||||
|
||||
" Protect against useless buffer set-up
|
||||
let s:isEditFileRunning += 1
|
||||
try
|
||||
|
|
@ -451,27 +496,46 @@ function! s:EditFile(command, originalBuffer, statusText)
|
|||
vert rightbelow split
|
||||
endif
|
||||
endif
|
||||
edit `=resultBufferName`
|
||||
let b:VCSCommandCommand = a:command
|
||||
let b:VCSCommandOriginalBuffer = a:originalBuffer
|
||||
let b:VCSCommandSourceFile = bufname(a:originalBuffer)
|
||||
let b:VCSCommandVCSType = vcsType
|
||||
|
||||
set buftype=nofile
|
||||
set noswapfile
|
||||
let &filetype = vcsType . a:command
|
||||
enew
|
||||
|
||||
if a:statusText != ''
|
||||
let b:VCSCommandStatusText = a:statusText
|
||||
endif
|
||||
call s:SetupScratchBuffer(a:command, vcsType, a:originalBuffer, a:statusText)
|
||||
|
||||
if VCSCommandGetOption('VCSCommandDeleteOnHide', 0)
|
||||
set bufhidden=delete
|
||||
endif
|
||||
finally
|
||||
let s:isEditFileRunning -= 1
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" Function: s:SetupScratchBuffer(command, vcsType, originalBuffer, statusText) {{{2
|
||||
" Creates convenience buffer variables and the name of a vcscommand result
|
||||
" buffer.
|
||||
|
||||
function! s:SetupScratchBuffer(command, vcsType, originalBuffer, statusText)
|
||||
let nameExtension = VCSCommandGetOption('VCSCommandResultBufferNameExtension', '')
|
||||
if nameExtension == ''
|
||||
let nameFunction = VCSCommandGetOption('VCSCommandResultBufferNameFunction', 's:GenerateResultBufferName')
|
||||
else
|
||||
let nameFunction = VCSCommandGetOption('VCSCommandResultBufferNameFunction', 's:GenerateResultBufferNameWithExtension')
|
||||
endif
|
||||
|
||||
let name = call(nameFunction, [a:command, a:originalBuffer, a:vcsType, a:statusText])
|
||||
|
||||
let b:VCSCommandCommand = a:command
|
||||
let b:VCSCommandOriginalBuffer = a:originalBuffer
|
||||
let b:VCSCommandSourceFile = bufname(a:originalBuffer)
|
||||
let b:VCSCommandVCSType = a:vcsType
|
||||
if a:statusText != ''
|
||||
let b:VCSCommandStatusText = a:statusText
|
||||
endif
|
||||
|
||||
setlocal buftype=nofile
|
||||
setlocal noswapfile
|
||||
let &filetype = a:vcsType . a:command
|
||||
|
||||
if VCSCommandGetOption('VCSCommandDeleteOnHide', 0)
|
||||
setlocal bufhidden=delete
|
||||
endif
|
||||
silent noautocmd file `=name`
|
||||
endfunction
|
||||
|
||||
" Function: s:SetupBuffer() {{{2
|
||||
|
|
@ -616,6 +680,43 @@ endfunction
|
|||
|
||||
" Section: Generic VCS command functions {{{1
|
||||
|
||||
" Function: s:VCSAnnotate(...) {{{2
|
||||
function! s:VCSAnnotate(bang, ...)
|
||||
try
|
||||
let annotateBuffer = s:ExecuteVCSCommand('Annotate', a:000)
|
||||
if annotateBuffer == -1
|
||||
return -1
|
||||
endif
|
||||
if a:bang == '!' && VCSCommandGetOption('VCSCommandDisableSplitAnnotate', 0) == 0
|
||||
let vcsType = VCSCommandGetVCSType(annotateBuffer)
|
||||
let functionMap = s:plugins[vcsType][1]
|
||||
let splitRegex = ''
|
||||
if has_key(s:plugins[vcsType][1], 'AnnotateSplitRegex')
|
||||
let splitRegex = s:plugins[vcsType][1]['AnnotateSplitRegex']
|
||||
endif
|
||||
let splitRegex = VCSCommandGetOption('VCSCommand' . vcsType . 'AnnotateSplitRegex', splitRegex)
|
||||
if splitRegex == ''
|
||||
return annotateBuffer
|
||||
endif
|
||||
let originalBuffer = VCSCommandGetOriginalBuffer(annotateBuffer)
|
||||
let originalFileType = getbufvar(originalBuffer, '&ft')
|
||||
let annotateFileType = getbufvar(annotateBuffer, '&ft')
|
||||
execute "normal 0zR\<c-v>G/" . splitRegex . "/e\<cr>d"
|
||||
call setbufvar('%', '&filetype', getbufvar(originalBuffer, '&filetype'))
|
||||
set scrollbind
|
||||
leftabove vert new
|
||||
normal 0P
|
||||
execute "normal" . col('$') . "\<c-w>|"
|
||||
call s:SetupScratchBuffer('annotate', vcsType, originalBuffer, 'header')
|
||||
wincmd l
|
||||
endif
|
||||
return annotateBuffer
|
||||
catch
|
||||
call s:ReportError(v:exception)
|
||||
return -1
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" Function: s:VCSCommit() {{{2
|
||||
function! s:VCSCommit(bang, message)
|
||||
try
|
||||
|
|
@ -635,7 +736,7 @@ function! s:VCSCommit(bang, message)
|
|||
endif
|
||||
|
||||
call s:EditFile('commitlog', originalBuffer, '')
|
||||
set ft=vcscommit
|
||||
setlocal ft=vcscommit
|
||||
|
||||
" Create a commit mapping.
|
||||
|
||||
|
|
@ -646,14 +747,14 @@ function! s:VCSCommit(bang, message)
|
|||
silent put ='VCS: To finish the commit, Type <leader>cc (or your own <Plug>VCSCommit mapping)'
|
||||
|
||||
if VCSCommandGetOption('VCSCommandCommitOnWrite', 1) == 1
|
||||
set buftype=acwrite
|
||||
setlocal buftype=acwrite
|
||||
au VCSCommandCommit BufWriteCmd <buffer> call s:VCSFinishCommitWithBuffer()
|
||||
silent put ='VCS: or write this buffer'
|
||||
endif
|
||||
|
||||
silent put ='VCS: ----------------------------------------------------------------------'
|
||||
$
|
||||
set nomodified
|
||||
setlocal nomodified
|
||||
catch
|
||||
call s:ReportError(v:exception)
|
||||
return -1
|
||||
|
|
@ -665,7 +766,7 @@ endfunction
|
|||
" which removes all lines starting with 'VCS:'.
|
||||
|
||||
function! s:VCSFinishCommitWithBuffer()
|
||||
set nomodified
|
||||
setlocal nomodified
|
||||
let currentBuffer = bufnr('%')
|
||||
let logMessageList = getbufline('%', 1, '$')
|
||||
call filter(logMessageList, 'v:val !~ ''^\s*VCS:''')
|
||||
|
|
@ -738,6 +839,10 @@ function! s:VCSVimDiff(...)
|
|||
call s:WipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff')
|
||||
endif
|
||||
|
||||
let orientation = &diffopt =~ 'horizontal' ? 'horizontal' : 'vertical'
|
||||
let orientation = VCSCommandGetOption('VCSCommandSplit', orientation)
|
||||
let orientation = VCSCommandGetOption('VCSCommandDiffSplit', orientation)
|
||||
|
||||
" Split and diff
|
||||
if(a:0 == 2)
|
||||
" Reset the vimdiff system, as 2 explicit versions were provided.
|
||||
|
|
@ -754,7 +859,7 @@ function! s:VCSVimDiff(...)
|
|||
let s:vimDiffScratchList = [resultBuffer]
|
||||
" If no split method is defined, cheat, and set it to vertical.
|
||||
try
|
||||
call s:OverrideOption('VCSCommandSplit', VCSCommandGetOption('VCSCommandDiffSplit', VCSCommandGetOption('VCSCommandSplit', 'vertical')))
|
||||
call s:OverrideOption('VCSCommandSplit', orientation)
|
||||
let resultBuffer = s:plugins[vcsType][1].Review([a:2])
|
||||
finally
|
||||
call s:OverrideOption('VCSCommandSplit')
|
||||
|
|
@ -771,7 +876,7 @@ function! s:VCSVimDiff(...)
|
|||
call s:OverrideOption('VCSCommandEdit', 'split')
|
||||
try
|
||||
" Force splitting behavior, otherwise why use vimdiff?
|
||||
call s:OverrideOption('VCSCommandSplit', VCSCommandGetOption('VCSCommandDiffSplit', VCSCommandGetOption('VCSCommandSplit', 'vertical')))
|
||||
call s:OverrideOption('VCSCommandSplit', orientation)
|
||||
try
|
||||
if(a:0 == 0)
|
||||
let resultBuffer = s:plugins[vcsType][1].Review([])
|
||||
|
|
@ -856,6 +961,15 @@ function! VCSCommandGetVCSType(buffer)
|
|||
if strlen(vcsType) > 0
|
||||
return vcsType
|
||||
endif
|
||||
if exists("g:VCSCommandVCSTypeOverride")
|
||||
let fullpath = fnamemodify(bufname(a:buffer), ':p')
|
||||
for [path, vcsType] in g:VCSCommandVCSTypeOverride
|
||||
if match(fullpath, path) > -1
|
||||
call setbufvar(a:buffer, 'VCSCommandVCSType', vcsType)
|
||||
return vcsType
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
let matches = []
|
||||
for vcsType in keys(s:plugins)
|
||||
let identified = s:plugins[vcsType][1].Identify(a:buffer)
|
||||
|
|
@ -928,8 +1042,9 @@ function! VCSCommandRegisterModule(name, path, commandMap, mappingMap)
|
|||
if !empty(a:mappingMap)
|
||||
\ && !VCSCommandGetOption('VCSCommandDisableMappings', 0)
|
||||
\ && !VCSCommandGetOption('VCSCommandDisableExtensionMappings', 0)
|
||||
for mapname in keys(a:mappingMap)
|
||||
execute 'noremap <silent> <Leader>' . mapname ':call <SID>ExecuteExtensionMapping(''' . mapname . ''')<CR>'
|
||||
for shortcut in keys(a:mappingMap)
|
||||
let expansion = ":call <SID>ExecuteExtensionMapping('" . shortcut . "')<CR>"
|
||||
call s:CreateMapping(shortcut, expansion, a:name . " extension mapping " . shortcut)
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
|
@ -1098,8 +1213,8 @@ endfunction
|
|||
" Section: Command definitions {{{1
|
||||
" Section: Primary commands {{{2
|
||||
com! -nargs=* VCSAdd call s:MarkOrigBufferForSetup(s:ExecuteVCSCommand('Add', [<f-args>]))
|
||||
com! -nargs=* VCSAnnotate call s:ExecuteVCSCommand('Annotate', [<f-args>])
|
||||
com! -nargs=* VCSBlame call s:ExecuteVCSCommand('Annotate', [<f-args>])
|
||||
com! -nargs=* -bang VCSAnnotate call s:VCSAnnotate(<q-bang>, <f-args>)
|
||||
com! -nargs=* -bang VCSBlame call s:VCSAnnotate(<q-bang>, <f-args>)
|
||||
com! -nargs=? -bang VCSCommit call s:VCSCommit(<q-bang>, <q-args>)
|
||||
com! -nargs=* VCSDelete call s:ExecuteVCSCommand('Delete', [<f-args>])
|
||||
com! -nargs=* VCSDiff call s:ExecuteVCSCommand('Diff', [<f-args>])
|
||||
|
|
@ -1135,6 +1250,7 @@ nnoremap <silent> <Plug>VCSLock :VCSLock<CR>
|
|||
nnoremap <silent> <Plug>VCSLog :VCSLog<CR>
|
||||
nnoremap <silent> <Plug>VCSRevert :VCSRevert<CR>
|
||||
nnoremap <silent> <Plug>VCSReview :VCSReview<CR>
|
||||
nnoremap <silent> <Plug>VCSSplitAnnotate :VCSAnnotate!<CR>
|
||||
nnoremap <silent> <Plug>VCSStatus :VCSStatus<CR>
|
||||
nnoremap <silent> <Plug>VCSUnlock :VCSUnlock<CR>
|
||||
nnoremap <silent> <Plug>VCSUpdate :VCSUpdate<CR>
|
||||
|
|
@ -1142,55 +1258,30 @@ nnoremap <silent> <Plug>VCSVimDiff :VCSVimDiff<CR>
|
|||
|
||||
" Section: Default mappings {{{1
|
||||
|
||||
let s:defaultMappings = [
|
||||
\['a', 'VCSAdd'],
|
||||
\['c', 'VCSCommit'],
|
||||
\['D', 'VCSDelete'],
|
||||
\['d', 'VCSDiff'],
|
||||
\['G', 'VCSClearAndGotoOriginal'],
|
||||
\['g', 'VCSGotoOriginal'],
|
||||
\['i', 'VCSInfo'],
|
||||
\['L', 'VCSLock'],
|
||||
\['l', 'VCSLog'],
|
||||
\['N', 'VCSSplitAnnotate'],
|
||||
\['n', 'VCSAnnotate'],
|
||||
\['q', 'VCSRevert'],
|
||||
\['r', 'VCSReview'],
|
||||
\['s', 'VCSStatus'],
|
||||
\['U', 'VCSUnlock'],
|
||||
\['u', 'VCSUpdate'],
|
||||
\['v', 'VCSVimDiff'],
|
||||
\]
|
||||
|
||||
if !VCSCommandGetOption('VCSCommandDisableMappings', 0)
|
||||
if !hasmapto('<Plug>VCSAdd')
|
||||
nmap <unique> <Leader>ca <Plug>VCSAdd
|
||||
endif
|
||||
if !hasmapto('<Plug>VCSAnnotate')
|
||||
nmap <unique> <Leader>cn <Plug>VCSAnnotate
|
||||
endif
|
||||
if !hasmapto('<Plug>VCSClearAndGotoOriginal')
|
||||
nmap <unique> <Leader>cG <Plug>VCSClearAndGotoOriginal
|
||||
endif
|
||||
if !hasmapto('<Plug>VCSCommit')
|
||||
nmap <unique> <Leader>cc <Plug>VCSCommit
|
||||
endif
|
||||
if !hasmapto('<Plug>VCSDelete')
|
||||
nmap <unique> <Leader>cD <Plug>VCSDelete
|
||||
endif
|
||||
if !hasmapto('<Plug>VCSDiff')
|
||||
nmap <unique> <Leader>cd <Plug>VCSDiff
|
||||
endif
|
||||
if !hasmapto('<Plug>VCSGotoOriginal')
|
||||
nmap <unique> <Leader>cg <Plug>VCSGotoOriginal
|
||||
endif
|
||||
if !hasmapto('<Plug>VCSInfo')
|
||||
nmap <unique> <Leader>ci <Plug>VCSInfo
|
||||
endif
|
||||
if !hasmapto('<Plug>VCSLock')
|
||||
nmap <unique> <Leader>cL <Plug>VCSLock
|
||||
endif
|
||||
if !hasmapto('<Plug>VCSLog')
|
||||
nmap <unique> <Leader>cl <Plug>VCSLog
|
||||
endif
|
||||
if !hasmapto('<Plug>VCSRevert')
|
||||
nmap <unique> <Leader>cq <Plug>VCSRevert
|
||||
endif
|
||||
if !hasmapto('<Plug>VCSReview')
|
||||
nmap <unique> <Leader>cr <Plug>VCSReview
|
||||
endif
|
||||
if !hasmapto('<Plug>VCSStatus')
|
||||
nmap <unique> <Leader>cs <Plug>VCSStatus
|
||||
endif
|
||||
if !hasmapto('<Plug>VCSUnlock')
|
||||
nmap <unique> <Leader>cU <Plug>VCSUnlock
|
||||
endif
|
||||
if !hasmapto('<Plug>VCSUpdate')
|
||||
nmap <unique> <Leader>cu <Plug>VCSUpdate
|
||||
endif
|
||||
if !hasmapto('<Plug>VCSVimDiff')
|
||||
nmap <unique> <Leader>cv <Plug>VCSVimDiff
|
||||
endif
|
||||
for [shortcut, vcsFunction] in VCSCommandGetOption('VCSCommandMappings', s:defaultMappings)
|
||||
call s:CreateMapping(shortcut, '<Plug>' . vcsFunction, '''' . vcsFunction . '''')
|
||||
endfor
|
||||
endif
|
||||
|
||||
" Section: Menu items {{{1
|
||||
|
|
|
|||
|
|
@ -81,6 +81,10 @@
|
|||
|
||||
" Section: Plugin header {{{1
|
||||
|
||||
if exists('VCSCommandDisableAll')
|
||||
finish
|
||||
endif
|
||||
|
||||
if v:version < 700
|
||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
||||
finish
|
||||
|
|
@ -108,7 +112,17 @@ let s:cvsFunctions = {}
|
|||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
||||
if VCSCommandGetVCSType(expand('%')) == 'CVS'
|
||||
let fullCmd = VCSCommandGetOption('VCSCommandCVSExec', 'cvs') . ' ' . a:cmd
|
||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
||||
let ret = VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
||||
|
||||
if ret > 0
|
||||
if getline(line('$')) =~ '^cvs \w\+: closing down connection'
|
||||
$d
|
||||
1
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
return ret
|
||||
else
|
||||
throw 'CVS VCSCommand plugin called on non-CVS item.'
|
||||
endif
|
||||
|
|
@ -387,6 +401,9 @@ function! s:CVSWatchers()
|
|||
return s:DoCommand('watchers', 'cvswatchers', '', {})
|
||||
endfunction
|
||||
|
||||
" Annotate setting {{{2
|
||||
let s:cvsFunctions.AnnotateSplitRegex = '): '
|
||||
|
||||
" Section: Command definitions {{{1
|
||||
" Section: Primary commands {{{2
|
||||
com! CVSEdit call s:CVSEdit()
|
||||
|
|
@ -403,14 +420,14 @@ com! CVSWatchers call s:CVSWatchers()
|
|||
|
||||
let s:cvsExtensionMappings = {}
|
||||
let mappingInfo = [
|
||||
\['CVSEdit', 'CVSEdit', 'ce'],
|
||||
\['CVSEditors', 'CVSEditors', 'cE'],
|
||||
\['CVSUnedit', 'CVSUnedit', 'ct'],
|
||||
\['CVSWatchers', 'CVSWatchers', 'cwv'],
|
||||
\['CVSWatchAdd', 'CVSWatch add', 'cwa'],
|
||||
\['CVSWatchOff', 'CVSWatch off', 'cwf'],
|
||||
\['CVSWatchOn', 'CVSWatch on', 'cwn'],
|
||||
\['CVSWatchRemove', 'CVSWatch remove', 'cwr']
|
||||
\['CVSEdit', 'CVSEdit', 'e'],
|
||||
\['CVSEditors', 'CVSEditors', 'E'],
|
||||
\['CVSUnedit', 'CVSUnedit', 't'],
|
||||
\['CVSWatchers', 'CVSWatchers', 'wv'],
|
||||
\['CVSWatchAdd', 'CVSWatch add', 'wa'],
|
||||
\['CVSWatchOff', 'CVSWatch off', 'wf'],
|
||||
\['CVSWatchOn', 'CVSWatch on', 'wn'],
|
||||
\['CVSWatchRemove', 'CVSWatch remove', 'wr']
|
||||
\]
|
||||
|
||||
for [pluginName, commandText, shortCut] in mappingInfo
|
||||
|
|
@ -421,7 +438,6 @@ for [pluginName, commandText, shortCut] in mappingInfo
|
|||
endfor
|
||||
|
||||
" Section: Menu items {{{1
|
||||
silent! aunmenu Plugin.VCS.CVS
|
||||
amenu <silent> &Plugin.VCS.CVS.&Edit <Plug>CVSEdit
|
||||
amenu <silent> &Plugin.VCS.CVS.Ed&itors <Plug>CVSEditors
|
||||
amenu <silent> &Plugin.VCS.CVS.Unedi&t <Plug>CVSUnedit
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
" Version: VCS development
|
||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
||||
" License:
|
||||
" Copyright (c) 2007 Bob Hiestand
|
||||
" Copyright (c) 2008 Bob Hiestand
|
||||
"
|
||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
" of this software and associated documentation files (the "Software"), to
|
||||
|
|
@ -40,6 +40,10 @@
|
|||
|
||||
" Section: Plugin header {{{1
|
||||
|
||||
if exists('VCSCommandDisableAll')
|
||||
finish
|
||||
endif
|
||||
|
||||
if v:version < 700
|
||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
||||
finish
|
||||
|
|
@ -221,7 +225,7 @@ function! s:gitFunctions.Review(argList)
|
|||
let revision = a:argList[0]
|
||||
endif
|
||||
|
||||
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname('%')))
|
||||
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(VCSCommandGetOriginalBuffer('%'))))
|
||||
try
|
||||
let prefix = system(VCSCommandGetOption('VCSCommandGitExec', 'git') . ' rev-parse --show-prefix')
|
||||
finally
|
||||
|
|
@ -229,7 +233,7 @@ function! s:gitFunctions.Review(argList)
|
|||
endtry
|
||||
|
||||
let prefix = substitute(prefix, '\n$', '', '')
|
||||
let blob = revision . ':' . prefix . '<VCSCOMMANDFILE>'
|
||||
let blob = '"' . revision . ':' . prefix . '<VCSCOMMANDFILE>"'
|
||||
let resultBuffer = s:DoCommand('show ' . blob, 'review', revision, {})
|
||||
if resultBuffer > 0
|
||||
let &filetype=getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
|
||||
|
|
@ -239,7 +243,7 @@ endfunction
|
|||
|
||||
" Function: s:gitFunctions.Status(argList) {{{2
|
||||
function! s:gitFunctions.Status(argList)
|
||||
return s:DoCommand(join(['status'] + a:argList), 'log', join(a:argList), {'allowNonZeroExit': 1})
|
||||
return s:DoCommand(join(['status'] + a:argList), 'status', join(a:argList), {'allowNonZeroExit': 1})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Update(argList) {{{2
|
||||
|
|
@ -247,6 +251,8 @@ function! s:gitFunctions.Update(argList)
|
|||
throw "This command is not implemented for git because file-by-file update doesn't make much sense in that context. If you have an idea for what it should do, please let me know."
|
||||
endfunction
|
||||
|
||||
" Annotate setting {{{2
|
||||
let s:gitFunctions.AnnotateSplitRegex = ') '
|
||||
|
||||
" Section: Plugin Registration {{{1
|
||||
call VCSCommandRegisterModule('git', expand('<sfile>'), s:gitFunctions, [])
|
||||
|
|
|
|||
275
.vim/plugin/vcshg.vim
Executable file
275
.vim/plugin/vcshg.vim
Executable file
|
|
@ -0,0 +1,275 @@
|
|||
" vim600: set foldmethod=marker:
|
||||
"
|
||||
" Mercurial extension for VCSCommand.
|
||||
"
|
||||
" Version: VCS development
|
||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
||||
" License:
|
||||
" Copyright (c) 2009 Bob Hiestand
|
||||
"
|
||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
" of this software and associated documentation files (the "Software"), to
|
||||
" deal in the Software without restriction, including without limitation the
|
||||
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
" sell copies of the Software, and to permit persons to whom the Software is
|
||||
" furnished to do so, subject to the following conditions:
|
||||
"
|
||||
" The above copyright notice and this permission notice shall be included in
|
||||
" all copies or substantial portions of the Software.
|
||||
"
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
" IN THE SOFTWARE.
|
||||
"
|
||||
" Section: Documentation {{{1
|
||||
"
|
||||
" Options documentation: {{{2
|
||||
"
|
||||
" VCSCommandHGExec
|
||||
" This variable specifies the mercurial executable. If not set, it defaults
|
||||
" to 'hg' executed from the user's executable path.
|
||||
"
|
||||
" VCSCommandHGDiffExt
|
||||
" This variable, if set, sets the external diff program used by Subversion.
|
||||
"
|
||||
" VCSCommandHGDiffOpt
|
||||
" This variable, if set, determines the options passed to the hg diff
|
||||
" command (such as 'u', 'w', or 'b').
|
||||
|
||||
" Section: Plugin header {{{1
|
||||
|
||||
if exists('VCSCommandDisableAll')
|
||||
finish
|
||||
endif
|
||||
|
||||
if v:version < 700
|
||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime plugin/vcscommand.vim
|
||||
|
||||
if !executable(VCSCommandGetOption('VCSCommandHGExec', 'hg'))
|
||||
" HG is not installed
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo=&cpo
|
||||
set cpo&vim
|
||||
|
||||
" Section: Variable initialization {{{1
|
||||
|
||||
let s:hgFunctions = {}
|
||||
|
||||
" Section: Utility functions {{{1
|
||||
|
||||
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
|
||||
" Wrapper to VCSCommandDoCommand to add the name of the HG executable to the
|
||||
" command argument.
|
||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
||||
if VCSCommandGetVCSType(expand('%')) == 'HG'
|
||||
let fullCmd = VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' ' . a:cmd
|
||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
||||
else
|
||||
throw 'HG VCSCommand plugin called on non-HG item.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Section: VCS function implementations {{{1
|
||||
|
||||
" Function: s:hgFunctions.Identify(buffer) {{{2
|
||||
function! s:hgFunctions.Identify(buffer)
|
||||
call system(VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' root')
|
||||
if(v:shell_error)
|
||||
return 0
|
||||
else
|
||||
return g:VCSCOMMAND_IDENTIFY_INEXACT
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Add() {{{2
|
||||
function! s:hgFunctions.Add(argList)
|
||||
return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Annotate(argList) {{{2
|
||||
function! s:hgFunctions.Annotate(argList)
|
||||
if len(a:argList) == 0
|
||||
if &filetype == 'HGAnnotate'
|
||||
" Perform annotation of the version indicated by the current line.
|
||||
let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
|
||||
let options = ' -r' . caption
|
||||
else
|
||||
let caption = ''
|
||||
let options = ''
|
||||
endif
|
||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
||||
let caption = a:argList[0]
|
||||
let options = ' -r' . caption
|
||||
else
|
||||
let caption = join(a:argList, ' ')
|
||||
let options = ' ' . caption
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption, {})
|
||||
if resultBuffer > 0
|
||||
set filetype=HGAnnotate
|
||||
endif
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Commit(argList) {{{2
|
||||
function! s:hgFunctions.Commit(argList)
|
||||
let resultBuffer = s:DoCommand('commit -l "' . a:argList[0] . '"', 'commit', '', {})
|
||||
if resultBuffer == 0
|
||||
echomsg 'No commit needed.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Delete() {{{2
|
||||
function! s:hgFunctions.Delete(argList)
|
||||
return s:DoCommand(join(['remove'] + a:argList, ' '), 'remove', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Diff(argList) {{{2
|
||||
function! s:hgFunctions.Diff(argList)
|
||||
if len(a:argList) == 0
|
||||
let revOptions = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let revOptions = ['-r' . join(a:argList, ':')]
|
||||
let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
|
||||
else
|
||||
" Pass-through
|
||||
let caption = join(a:argList, ' ')
|
||||
let revOptions = a:argList
|
||||
endif
|
||||
|
||||
let hgDiffExt = VCSCommandGetOption('VCSCommandHGDiffExt', '')
|
||||
if hgDiffExt == ''
|
||||
let diffExt = []
|
||||
else
|
||||
let diffExt = ['--diff-cmd ' . hgDiffExt]
|
||||
endif
|
||||
|
||||
let hgDiffOpt = VCSCommandGetOption('VCSCommandHGDiffOpt', '')
|
||||
if hgDiffOpt == ''
|
||||
let diffOptions = []
|
||||
else
|
||||
let diffOptions = ['-x -' . hgDiffOpt]
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand(join(['diff'] + diffExt + diffOptions + revOptions), 'diff', caption, {})
|
||||
if resultBuffer > 0
|
||||
set filetype=diff
|
||||
else
|
||||
if hgDiffExt == ''
|
||||
echomsg 'No differences found'
|
||||
endif
|
||||
endif
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Info(argList) {{{2
|
||||
function! s:hgFunctions.Info(argList)
|
||||
return s:DoCommand(join(['log --limit 1'] + a:argList, ' '), 'log', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.GetBufferInfo() {{{2
|
||||
" Provides version control details for the current file. Current version
|
||||
" number and current repository version number are required to be returned by
|
||||
" the vcscommand plugin.
|
||||
" Returns: List of results: [revision, repository, branch]
|
||||
|
||||
function! s:hgFunctions.GetBufferInfo()
|
||||
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
|
||||
let fileName = bufname(originalBuffer)
|
||||
let statusText = system(VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' status "' . fileName . '"')
|
||||
if(v:shell_error)
|
||||
return []
|
||||
endif
|
||||
|
||||
" File not under HG control.
|
||||
if statusText =~ '^?'
|
||||
return ['Unknown']
|
||||
endif
|
||||
|
||||
let parentsText = system(VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' parents "' . fileName . '"')
|
||||
let [revision] = matchlist(parentsText, '^changeset:\s\+\(\S\+\)\n')[1]
|
||||
|
||||
let logText = system(VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' log "' . fileName . '"')
|
||||
let [repository] = matchlist(logText, '^changeset:\s\+\(\S\+\)\n')[1]
|
||||
|
||||
if revision == ''
|
||||
" Error
|
||||
return ['Unknown']
|
||||
elseif statusText =~ '^A'
|
||||
return ['New', 'New']
|
||||
else
|
||||
return [revision, repository]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Log(argList) {{{2
|
||||
function! s:hgFunctions.Log(argList)
|
||||
if len(a:argList) == 0
|
||||
let options = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let options = ['-r' . join(a:argList, ':')]
|
||||
let caption = options[0]
|
||||
else
|
||||
" Pass-through
|
||||
let options = a:argList
|
||||
let caption = join(a:argList, ' ')
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption, {})
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Revert(argList) {{{2
|
||||
function! s:hgFunctions.Revert(argList)
|
||||
return s:DoCommand('revert', 'revert', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Review(argList) {{{2
|
||||
function! s:hgFunctions.Review(argList)
|
||||
if len(a:argList) == 0
|
||||
let versiontag = '(current)'
|
||||
let versionOption = ''
|
||||
else
|
||||
let versiontag = a:argList[0]
|
||||
let versionOption = ' -r ' . versiontag . ' '
|
||||
endif
|
||||
|
||||
" let resultBuffer = s:DoCommand('cat --non-interactive' . versionOption, 'review', versiontag, {})
|
||||
let resultBuffer = s:DoCommand('cat' . versionOption, 'review', versiontag, {})
|
||||
if resultBuffer > 0
|
||||
let &filetype = getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
|
||||
endif
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Status(argList) {{{2
|
||||
function! s:hgFunctions.Status(argList)
|
||||
let options = ['-u', '-v']
|
||||
if len(a:argList) == 0
|
||||
let options = a:argList
|
||||
endif
|
||||
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Update(argList) {{{2
|
||||
function! s:hgFunctions.Update(argList)
|
||||
return s:DoCommand('update', 'update', '', {})
|
||||
endfunction
|
||||
|
||||
" Section: Plugin Registration {{{1
|
||||
call VCSCommandRegisterModule('HG', expand('<sfile>'), s:hgFunctions, [])
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
|
|
@ -35,6 +35,10 @@
|
|||
|
||||
" Section: Plugin header {{{1
|
||||
|
||||
if exists('VCSCommandDisableAll')
|
||||
finish
|
||||
endif
|
||||
|
||||
if v:version < 700
|
||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
||||
finish
|
||||
|
|
|
|||
|
|
@ -42,6 +42,10 @@
|
|||
|
||||
" Section: Plugin header {{{1
|
||||
|
||||
if exists('VCSCommandDisableAll')
|
||||
finish
|
||||
endif
|
||||
|
||||
if v:version < 700
|
||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
||||
finish
|
||||
|
|
@ -121,7 +125,7 @@ function! s:svnFunctions.Annotate(argList)
|
|||
let options = ' ' . caption
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption, {})
|
||||
let resultBuffer = s:DoCommand('blame --non-interactive' . options, 'annotate', caption, {})
|
||||
if resultBuffer > 0
|
||||
set filetype=SVNAnnotate
|
||||
endif
|
||||
|
|
@ -130,7 +134,7 @@ endfunction
|
|||
|
||||
" Function: s:svnFunctions.Commit(argList) {{{2
|
||||
function! s:svnFunctions.Commit(argList)
|
||||
let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
|
||||
let resultBuffer = s:DoCommand('commit --non-interactive -F "' . a:argList[0] . '"', 'commit', '', {})
|
||||
if resultBuffer == 0
|
||||
echomsg 'No commit needed.'
|
||||
endif
|
||||
|
|
@ -138,7 +142,7 @@ endfunction
|
|||
|
||||
" Function: s:svnFunctions.Delete() {{{2
|
||||
function! s:svnFunctions.Delete(argList)
|
||||
return s:DoCommand(join(['delete'] + a:argList, ' '), 'delete', join(a:argList, ' '), {})
|
||||
return s:DoCommand(join(['delete --non-interactive'] + a:argList, ' '), 'delete', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Diff(argList) {{{2
|
||||
|
|
@ -169,7 +173,7 @@ function! s:svnFunctions.Diff(argList)
|
|||
let diffOptions = ['-x -' . svnDiffOpt]
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand(join(['diff'] + diffExt + diffOptions + revOptions), 'diff', caption, {})
|
||||
let resultBuffer = s:DoCommand(join(['diff --non-interactive'] + diffExt + diffOptions + revOptions), 'diff', caption, {})
|
||||
if resultBuffer > 0
|
||||
set filetype=diff
|
||||
else
|
||||
|
|
@ -189,7 +193,7 @@ endfunction
|
|||
function! s:svnFunctions.GetBufferInfo()
|
||||
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
|
||||
let fileName = bufname(originalBuffer)
|
||||
let statusText = system(VCSCommandGetOption('VCSCommandSVNExec', 'svn') . ' status -vu "' . fileName . '"')
|
||||
let statusText = system(VCSCommandGetOption('VCSCommandSVNExec', 'svn') . ' status --non-interactive -vu "' . fileName . '"')
|
||||
if(v:shell_error)
|
||||
return []
|
||||
endif
|
||||
|
|
@ -212,12 +216,12 @@ endfunction
|
|||
|
||||
" Function: s:svnFunctions.Info(argList) {{{2
|
||||
function! s:svnFunctions.Info(argList)
|
||||
return s:DoCommand(join(['info'] + a:argList, ' '), 'info', join(a:argList, ' '), {})
|
||||
return s:DoCommand(join(['info --non-interactive'] + a:argList, ' '), 'info', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Lock(argList) {{{2
|
||||
function! s:svnFunctions.Lock(argList)
|
||||
return s:DoCommand(join(['lock'] + a:argList, ' '), 'lock', join(a:argList, ' '), {})
|
||||
return s:DoCommand(join(['lock --non-interactive'] + a:argList, ' '), 'lock', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Log(argList) {{{2
|
||||
|
|
@ -234,7 +238,7 @@ function! s:svnFunctions.Log(argList)
|
|||
let caption = join(a:argList, ' ')
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption, {})
|
||||
let resultBuffer = s:DoCommand(join(['log --non-interactive', '-v'] + options), 'log', caption, {})
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
|
|
@ -253,7 +257,7 @@ function! s:svnFunctions.Review(argList)
|
|||
let versionOption = ' -r ' . versiontag . ' '
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand('cat' . versionOption, 'review', versiontag, {})
|
||||
let resultBuffer = s:DoCommand('cat --non-interactive' . versionOption, 'review', versiontag, {})
|
||||
if resultBuffer > 0
|
||||
let &filetype = getbufvar(b:VCSCommandOriginalBuffer, '&filetype')
|
||||
endif
|
||||
|
|
@ -266,18 +270,22 @@ function! s:svnFunctions.Status(argList)
|
|||
if len(a:argList) == 0
|
||||
let options = a:argList
|
||||
endif
|
||||
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})
|
||||
return s:DoCommand(join(['status --non-interactive'] + options, ' '), 'status', join(options, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Unlock(argList) {{{2
|
||||
function! s:svnFunctions.Unlock(argList)
|
||||
return s:DoCommand(join(['unlock'] + a:argList, ' '), 'unlock', join(a:argList, ' '), {})
|
||||
return s:DoCommand(join(['unlock --non-interactive'] + a:argList, ' '), 'unlock', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Update(argList) {{{2
|
||||
function! s:svnFunctions.Update(argList)
|
||||
return s:DoCommand('update', 'update', '', {})
|
||||
return s:DoCommand('update --non-interactive', 'update', '', {})
|
||||
endfunction
|
||||
|
||||
" Annotate setting {{{2
|
||||
let s:svnFunctions.AnnotateSplitRegex = '\s\+\S\+\s\+\S\+ '
|
||||
|
||||
" Section: Plugin Registration {{{1
|
||||
call VCSCommandRegisterModule('SVN', expand('<sfile>'), s:svnFunctions, [])
|
||||
|
||||
|
|
|
|||
7
.vim/snippets/_.snippets
Normal file
7
.vim/snippets/_.snippets
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# Global snippets
|
||||
|
||||
# (c) holds no legal value ;)
|
||||
snippet c)
|
||||
`&enc[:2] == "utf" ? "©" : "(c)"` Copyright `strftime("%Y")` ${1:`g:snips_author`}. All Rights Reserved.${2}
|
||||
snippet date
|
||||
`strftime("%Y-%m-%d")`
|
||||
66
.vim/snippets/autoit.snippets
Normal file
66
.vim/snippets/autoit.snippets
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
snippet if
|
||||
If ${1:condition} Then
|
||||
${2:; True code}
|
||||
EndIf
|
||||
snippet el
|
||||
Else
|
||||
${1}
|
||||
snippet elif
|
||||
ElseIf ${1:condition} Then
|
||||
${2:; True code}
|
||||
# If/Else block
|
||||
snippet ifel
|
||||
If ${1:condition} Then
|
||||
${2:; True code}
|
||||
Else
|
||||
${3:; Else code}
|
||||
EndIf
|
||||
# If/ElseIf/Else block
|
||||
snippet ifelif
|
||||
If ${1:condition 1} Then
|
||||
${2:; True code}
|
||||
ElseIf ${3:condition 2} Then
|
||||
${4:; True code}
|
||||
Else
|
||||
${5:; Else code}
|
||||
EndIf
|
||||
# Switch block
|
||||
snippet switch
|
||||
Switch (${1:condition})
|
||||
Case {$2:case1}:
|
||||
{$3:; Case 1 code}
|
||||
Case Else:
|
||||
{$4:; Else code}
|
||||
EndSwitch
|
||||
# Select block
|
||||
snippet select
|
||||
Select (${1:condition})
|
||||
Case {$2:case1}:
|
||||
{$3:; Case 1 code}
|
||||
Case Else:
|
||||
{$4:; Else code}
|
||||
EndSelect
|
||||
# While loop
|
||||
snippet while
|
||||
While (${1:condition})
|
||||
${2:; code...}
|
||||
WEnd
|
||||
# For loop
|
||||
snippet for
|
||||
For ${1:n} = ${3:1} to ${2:count}
|
||||
${4:; code...}
|
||||
Next
|
||||
# New Function
|
||||
snippet func
|
||||
Func ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
||||
${4:Return}
|
||||
EndFunc
|
||||
# Message box
|
||||
snippet msg
|
||||
MsgBox(${3:MsgType}, ${1:"Title"}, ${2:"Message Text"})
|
||||
# Debug Message
|
||||
snippet debug
|
||||
MsgBox(0, "Debug", ${1:"Debug Message"})
|
||||
# Show Variable Debug Message
|
||||
snippet showvar
|
||||
MsgBox(0, "${1:VarName}", $1)
|
||||
2
.vim/snippets/c-barak.snippets
Normal file
2
.vim/snippets/c-barak.snippets
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
snippet spr
|
||||
sprintf(${1:/* char * */}, "${2:%s}\n"${3});${4}
|
||||
117
.vim/snippets/c.snippets
Normal file
117
.vim/snippets/c.snippets
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
# main()
|
||||
snippet main
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
${1}
|
||||
return 0;
|
||||
}
|
||||
# #include <...>
|
||||
snippet inc
|
||||
#include <${1:stdio}.h>${2}
|
||||
# #include "..."
|
||||
snippet Inc
|
||||
#include "${1:`Filename("$1.h")`}"${2}
|
||||
# #ifndef ... #define ... #endif
|
||||
snippet Def
|
||||
#ifndef $1
|
||||
#define ${1:SYMBOL} ${2:value}
|
||||
#endif${3}
|
||||
snippet def
|
||||
#define
|
||||
snippet ifdef
|
||||
#ifdef ${1:FOO}
|
||||
${2:#define }
|
||||
#endif
|
||||
snippet #if
|
||||
#if ${1:FOO}
|
||||
${2}
|
||||
#endif
|
||||
# Header Include-Guard
|
||||
# (the randomizer code is taken directly from TextMate; it could probably be
|
||||
# cleaner, I don't know how to do it in vim script)
|
||||
snippet once
|
||||
#ifndef ${1:`toupper(Filename('', 'UNTITLED').'_'.system("/usr/bin/ruby -e 'print (rand * 2821109907455).round.to_s(36)'"))`}
|
||||
|
||||
#define $1
|
||||
|
||||
${2}
|
||||
|
||||
#endif /* end of include guard: $1 */
|
||||
# If Condition
|
||||
snippet if
|
||||
if (${1:/* condition */})
|
||||
{
|
||||
${2:/* code */}
|
||||
}
|
||||
snippet el
|
||||
else
|
||||
{
|
||||
${1}
|
||||
}
|
||||
|
||||
# Tertiary conditional
|
||||
snippet t
|
||||
${1:/* condition */} ? ${2:a} : ${3:b}
|
||||
# Do While Loop
|
||||
snippet do
|
||||
do
|
||||
{
|
||||
${2:/* code */}
|
||||
} while (${1:/* condition */});
|
||||
# While Loop
|
||||
snippet wh
|
||||
while (${1:/* condition */})
|
||||
{
|
||||
${2:/* code */}
|
||||
}
|
||||
# For Loop
|
||||
snippet for
|
||||
for (${2:i} = 0; $2 < ${1:count}; $2${3:++})
|
||||
{
|
||||
${4:/* code */}
|
||||
}
|
||||
# Custom For Loop
|
||||
snippet forr
|
||||
for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++})
|
||||
{
|
||||
${5:/* code */}
|
||||
}
|
||||
# Function
|
||||
snippet fun
|
||||
${1:void} ${2:function_name}(${3})
|
||||
{
|
||||
${4:/* code */}
|
||||
}
|
||||
# Function Declaration
|
||||
snippet fund
|
||||
${1:void} ${2:function_name}(${3});${4}
|
||||
# Typedef
|
||||
snippet td
|
||||
typedef ${1:int} ${2:MyCustomType};${3}
|
||||
# Struct
|
||||
snippet st
|
||||
struct ${1:`Filename('$1_t', 'name')`} {
|
||||
${2:/* data */}
|
||||
}${3: /* optional variable list */};${4}
|
||||
# Typedef struct
|
||||
snippet tds
|
||||
typedef struct ${2:_$1 }{
|
||||
${3:/* data */}
|
||||
} ${1:`Filename('$1_t', 'name')`};
|
||||
# Typdef enum
|
||||
snippet tde
|
||||
typedef enum {
|
||||
${1:/* data */}
|
||||
} ${2:foo};
|
||||
# printf
|
||||
# unfortunately version this isn't as nice as TextMates's, given the lack of a
|
||||
# dynamic `...`
|
||||
snippet pr
|
||||
printf("${1:%s}\n"${2});${3}
|
||||
# fprintf (again, this isn't as nice as TextMate's version, but it works)
|
||||
snippet fpr
|
||||
fprintf(${1:stderr}, "${2:%s}\n"${3});${4}
|
||||
snippet .
|
||||
[${1}]${2}
|
||||
snippet un
|
||||
unsigned
|
||||
30
.vim/snippets/cpp.snippets
Normal file
30
.vim/snippets/cpp.snippets
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# Read File Into Vector
|
||||
snippet readfile
|
||||
std::vector<char> v;
|
||||
if (FILE *${2:fp} = fopen(${1:"filename"}, "r")) {
|
||||
char buf[1024];
|
||||
while (size_t len = fread(buf, 1, sizeof(buf), $2))
|
||||
v.insert(v.end(), buf, buf + len);
|
||||
fclose($2);
|
||||
}${3}
|
||||
# std::map
|
||||
snippet map
|
||||
std::map<${1:key}, ${2:value}> map${3};
|
||||
# std::vector
|
||||
snippet vector
|
||||
std::vector<${1:char}> v${2};
|
||||
# Namespace
|
||||
snippet ns
|
||||
namespace ${1:`Filename('', 'my')`} {
|
||||
${2}
|
||||
} /* $1 */
|
||||
# Class
|
||||
snippet cl
|
||||
class ${1:`Filename('$1_t', 'name')`} {
|
||||
public:
|
||||
$1 (${2:arguments});
|
||||
virtual ~$1 ();
|
||||
|
||||
private:
|
||||
${3:/* data */}
|
||||
};
|
||||
190
.vim/snippets/html.snippets
Normal file
190
.vim/snippets/html.snippets
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
# Some useful Unicode entities
|
||||
# Non-Breaking Space
|
||||
snippet nbs
|
||||
|
||||
# ←
|
||||
snippet left
|
||||
←
|
||||
# →
|
||||
snippet right
|
||||
→
|
||||
# ↑
|
||||
snippet up
|
||||
↑
|
||||
# ↓
|
||||
snippet down
|
||||
↓
|
||||
# ↩
|
||||
snippet return
|
||||
↩
|
||||
# ⇤
|
||||
snippet backtab
|
||||
⇤
|
||||
# ⇥
|
||||
snippet tab
|
||||
⇥
|
||||
# ⇧
|
||||
snippet shift
|
||||
⇧
|
||||
# ⌃
|
||||
snippet control
|
||||
⌃
|
||||
# ⌅
|
||||
snippet enter
|
||||
⌅
|
||||
# ⌘
|
||||
snippet command
|
||||
⌘
|
||||
# ⌥
|
||||
snippet option
|
||||
⌥
|
||||
# ⌦
|
||||
snippet delete
|
||||
⌦
|
||||
# ⌫
|
||||
snippet backspace
|
||||
⌫
|
||||
# ⎋
|
||||
snippet escape
|
||||
⎋
|
||||
# Generic Doctype
|
||||
snippet doctype HTML 4.01 Strict
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
snippet doctype HTML 4.01 Transitional
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
snippet doctype HTML 5
|
||||
<!DOCTYPE HTML>
|
||||
snippet doctype XHTML 1.0 Frameset
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
snippet doctype XHTML 1.0 Strict
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
snippet doctype XHTML 1.0 Transitional
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
snippet doctype XHTML 1.1
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
# HTML Doctype 4.01 Strict
|
||||
snippet docts
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
# HTML Doctype 4.01 Transitional
|
||||
snippet doct
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
# HTML Doctype 5
|
||||
snippet doct5
|
||||
<!DOCTYPE HTML>
|
||||
# XHTML Doctype 1.0 Frameset
|
||||
snippet docxf
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
||||
# XHTML Doctype 1.0 Strict
|
||||
snippet docxs
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
# XHTML Doctype 1.0 Transitional
|
||||
snippet docxt
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
# XHTML Doctype 1.1
|
||||
snippet docx
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
snippet html
|
||||
<html>
|
||||
${1}
|
||||
</html>
|
||||
snippet xhtml
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
${1}
|
||||
</html>
|
||||
snippet body
|
||||
<body>
|
||||
${1}
|
||||
</body>
|
||||
snippet head
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8"`Close()`>
|
||||
|
||||
<title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
|
||||
${2}
|
||||
</head>
|
||||
snippet title
|
||||
<title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title>${2}
|
||||
snippet script
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
${1}
|
||||
</script>${2}
|
||||
snippet scriptsrc
|
||||
<script src="${1}.js" type="text/javascript" charset="utf-8"></script>${2}
|
||||
snippet style
|
||||
<style type="text/css" media="${1:screen}">
|
||||
${2}
|
||||
</style>${3}
|
||||
snippet base
|
||||
<base href="${1}" target="${2}"`Close()`>
|
||||
snippet r
|
||||
<br`Close()[1:]`>
|
||||
snippet div
|
||||
<div id="${1:name}">
|
||||
${2}
|
||||
</div>
|
||||
# Embed QT Movie
|
||||
snippet movie
|
||||
<object width="$2" height="$3" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
|
||||
codebase="http://www.apple.com/qtactivex/qtplugin.cab">
|
||||
<param name="src" value="$1"`Close()`>
|
||||
<param name="controller" value="$4"`Close()`>
|
||||
<param name="autoplay" value="$5"`Close()`>
|
||||
<embed src="${1:movie.mov}"
|
||||
width="${2:320}" height="${3:240}"
|
||||
controller="${4:true}" autoplay="${5:true}"
|
||||
scale="tofit" cache="true"
|
||||
pluginspage="http://www.apple.com/quicktime/download/"
|
||||
`Close()[1:]`>
|
||||
</object>${6}
|
||||
snippet fieldset
|
||||
<fieldset id="$1">
|
||||
<legend>${1:name}</legend>
|
||||
|
||||
${3}
|
||||
</fieldset>
|
||||
snippet form
|
||||
<form action="${1:`Filename('$1_submit')`}" method="${2:get}" accept-charset="utf-8">
|
||||
${3}
|
||||
|
||||
|
||||
<p><input type="submit" value="Continue →"`Close()`></p>
|
||||
</form>
|
||||
snippet h1
|
||||
<h1 id="${1:heading}">${2:$1}</h1>
|
||||
snippet input
|
||||
<input type="${1:text/submit/hidden/button}" name="${2:some_name}" value="${3}"`Close()`>${4}
|
||||
snippet label
|
||||
<label for="${2:$1}">${1:name}</label><input type="${3:text/submit/hidden/button}" name="${4:$2}" value="${5}" id="${6:$2}"`Close()`>${7}
|
||||
snippet link
|
||||
<link rel="${1:stylesheet}" href="${2:/css/master.css}" type="text/css" media="${3:screen}" charset="utf-8"`Close()`>${4}
|
||||
snippet mailto
|
||||
<a href="mailto:${1:joe@example.com}?subject=${2:feedback}">${3:email me}</a>
|
||||
snippet meta
|
||||
<meta name="${1:name}" content="${2:content}"`Close()`>${3}
|
||||
snippet opt
|
||||
<option value="${1:option}">${2:$1}</option>${3}
|
||||
snippet optt
|
||||
<option>${1:option}</option>${2}
|
||||
snippet select
|
||||
<select name="${1:some_name}" id="${2:$1}">
|
||||
<option value="${3:option}">${4:$3}</option>
|
||||
</select>${5}
|
||||
snippet table
|
||||
<table border="${1:0}">
|
||||
<tr><th>${2:Header}</th></tr>
|
||||
<tr><th>${3:Data}</th></tr>
|
||||
</table>${4}
|
||||
snippet textarea
|
||||
<textarea name="${1:Name}" rows="${2:8}" cols="${3:40}">${4}</textarea>${5}
|
||||
78
.vim/snippets/java.snippets
Normal file
78
.vim/snippets/java.snippets
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
snippet main
|
||||
public static void main (String [] args)
|
||||
{
|
||||
${1:/* code */}
|
||||
}
|
||||
snippet pu
|
||||
public
|
||||
snippet po
|
||||
protected
|
||||
snippet pr
|
||||
private
|
||||
snippet st
|
||||
static
|
||||
snippet fi
|
||||
final
|
||||
snippet ab
|
||||
abstract
|
||||
snippet re
|
||||
return
|
||||
snippet br
|
||||
break;
|
||||
snippet de
|
||||
default:
|
||||
${1}
|
||||
snippet ca
|
||||
catch(${1:Exception} ${2:e}) ${3}
|
||||
snippet th
|
||||
throw
|
||||
snippet sy
|
||||
synchronized
|
||||
snippet im
|
||||
import
|
||||
snippet j.u
|
||||
java.util
|
||||
snippet j.i
|
||||
java.io.
|
||||
snippet j.b
|
||||
java.beans.
|
||||
snippet j.n
|
||||
java.net.
|
||||
snippet j.m
|
||||
java.math.
|
||||
snippet if
|
||||
if (${1}) ${2}
|
||||
snippet el
|
||||
else
|
||||
snippet elif
|
||||
else if (${1}) ${2}
|
||||
snippet wh
|
||||
while (${1}) ${2}
|
||||
snippet for
|
||||
for (${1}; ${2}; ${3}) ${4}
|
||||
snippet fore
|
||||
for (${1} : ${2}) ${3}
|
||||
snippet sw
|
||||
switch (${1}) ${2}
|
||||
snippet cs
|
||||
case ${1}:
|
||||
${2}
|
||||
${3}
|
||||
snippet tc
|
||||
public class ${1:`Filename()`} extends ${2:TestCase}
|
||||
snippet t
|
||||
public void test${1:Name}() throws Exception ${2}
|
||||
snippet cl
|
||||
class ${1:`Filename("", "untitled")`} ${2}
|
||||
snippet in
|
||||
interface ${1:`Filename("", "untitled")`} ${2:extends Parent}${3}
|
||||
snippet m
|
||||
${1:void} ${2:method}(${3}) ${4:throws }${5}
|
||||
snippet v
|
||||
${1:String} ${2:var}${3: = null}${4};${5}
|
||||
snippet co
|
||||
static public final ${1:String} ${2:var} = ${3};${4}
|
||||
snippet cos
|
||||
static public final String ${1:var} = "${2}";${3}
|
||||
snippet as
|
||||
assert ${1:test} : "${2:Failure message}";${3}
|
||||
74
.vim/snippets/javascript.snippets
Normal file
74
.vim/snippets/javascript.snippets
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
# Prototype
|
||||
snippet proto
|
||||
${1:class_name}.prototype.${2:method_name} =
|
||||
function(${3:first_argument}) {
|
||||
${4:// body...}
|
||||
};
|
||||
# Function
|
||||
snippet fun
|
||||
function ${1:function_name} (${2:argument}) {
|
||||
${3:// body...}
|
||||
}
|
||||
# Anonymous Function
|
||||
snippet f
|
||||
function(${1}) {${2}};
|
||||
# if
|
||||
snippet if
|
||||
if (${1:true}) {${2}};
|
||||
# if ... else
|
||||
snippet ife
|
||||
if (${1:true}) {${2}}
|
||||
else{${3}};
|
||||
# tertiary conditional
|
||||
snippet t
|
||||
${1:/* condition */} ? ${2:a} : ${3:b}
|
||||
# switch
|
||||
snippet switch
|
||||
switch(${1:expression}) {
|
||||
case '${3:case}':
|
||||
${4:// code}
|
||||
break;
|
||||
${5}
|
||||
default:
|
||||
${2:// code}
|
||||
}
|
||||
# case
|
||||
snippet case
|
||||
case '${1:case}':
|
||||
${2:// code}
|
||||
break;
|
||||
${3}
|
||||
# for (...) {...}
|
||||
snippet for
|
||||
for (var ${2:i} = 0; $2 < ${1:Things}.length; $2${3:++}) {
|
||||
${4:$1[$2]}
|
||||
};
|
||||
# for (...) {...} (Improved Native For-Loop)
|
||||
snippet forr
|
||||
for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2${3:--}) {
|
||||
${4:$1[$2]}
|
||||
};
|
||||
# while (...) {...}
|
||||
snippet wh
|
||||
while (${1:/* condition */}) {
|
||||
${2:/* code */}
|
||||
}
|
||||
# do...while
|
||||
snippet do
|
||||
do {
|
||||
${2:/* code */}
|
||||
} while (${1:/* condition */});
|
||||
# Object Method
|
||||
snippet :f
|
||||
${1:method_name}: function(${2:attribute}) {
|
||||
${4}
|
||||
}${3:,}
|
||||
# setTimeout function
|
||||
snippet timeout
|
||||
setTimeout(function() {${3}}${2}, ${1:10};
|
||||
# Get Elements
|
||||
snippet get
|
||||
getElementsBy${1:TagName}('${2}')${3}
|
||||
# Get Element
|
||||
snippet gett
|
||||
getElementBy${1:Id}('${2}')${3}
|
||||
54
.vim/snippets/mako.snippets
Normal file
54
.vim/snippets/mako.snippets
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
snippet def
|
||||
<%def name="${1:name}">
|
||||
${2:}
|
||||
</%def>
|
||||
snippet call
|
||||
<%call expr="${1:name}">
|
||||
${2:}
|
||||
</%call>
|
||||
snippet doc
|
||||
<%doc>
|
||||
${1:}
|
||||
</%doc>
|
||||
snippet text
|
||||
<%text>
|
||||
${1:}
|
||||
</%text>
|
||||
snippet for
|
||||
% for ${1:i} in ${2:iter}:
|
||||
${3:}
|
||||
% endfor
|
||||
snippet if if
|
||||
% if ${1:condition}:
|
||||
${2:}
|
||||
% endif
|
||||
snippet if if/else
|
||||
% if ${1:condition}:
|
||||
${2:}
|
||||
% else:
|
||||
${3:}
|
||||
% endif
|
||||
snippet try
|
||||
% try:
|
||||
${1:}
|
||||
% except${2:}:
|
||||
${3:pass}
|
||||
% endtry
|
||||
snippet wh
|
||||
% while ${1:}:
|
||||
${2:}
|
||||
% endwhile
|
||||
snippet $
|
||||
${ ${1:} }
|
||||
snippet <%
|
||||
<% ${1:} %>
|
||||
snippet <!%
|
||||
<!% ${1:} %>
|
||||
snippet inherit
|
||||
<%inherit file="${1:filename}" />
|
||||
snippet include
|
||||
<%include file="${1:filename}" />
|
||||
snippet namespace
|
||||
<%namespace file="${1:name}" />
|
||||
snippet page
|
||||
<%page args="${1:}" />
|
||||
184
.vim/snippets/objc.snippets
Normal file
184
.vim/snippets/objc.snippets
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
# #import <...>
|
||||
snippet Imp
|
||||
#import <${1:Cocoa/Cocoa.h}>${2}
|
||||
# #import "..."
|
||||
snippet imp
|
||||
#import "${1:`Filename()`.h}"${2}
|
||||
# @selector(...)
|
||||
snippet sel
|
||||
@selector(${1:method}:)${3}
|
||||
# @"..." string
|
||||
snippet s
|
||||
@"${1}"${2}
|
||||
# Object
|
||||
snippet o
|
||||
${1:NSObject} *${2:foo} = [${3:$1 alloc}]${4};${5}
|
||||
# NSLog(...)
|
||||
snippet log
|
||||
NSLog(@"${1:%@}"${2});${3}
|
||||
# Class
|
||||
snippet objc
|
||||
@interface ${1:`Filename('', 'someClass')`} : ${2:NSObject}
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation $1
|
||||
${3}
|
||||
@end
|
||||
# Class Interface
|
||||
snippet int
|
||||
@interface ${1:`Filename('', 'someClass')`} : ${2:NSObject}
|
||||
{${3}
|
||||
}
|
||||
${4}
|
||||
@end
|
||||
# Class Implementation
|
||||
snippet impl
|
||||
@implementation ${1:`Filename('', 'someClass')`}
|
||||
${2}
|
||||
@end
|
||||
snippet init
|
||||
- (id)init
|
||||
{
|
||||
[super init];
|
||||
return self;
|
||||
}
|
||||
snippet ifself
|
||||
if (self = [super init]) {
|
||||
${1:/* code */}
|
||||
}
|
||||
return self;
|
||||
snippet ibo
|
||||
IBOutlet ${1:NSSomeClass} *${2:$1};${3}
|
||||
# Category
|
||||
snippet cat
|
||||
@interface ${1:NSObject} (${2:Category})
|
||||
@end
|
||||
|
||||
@implementation $1 ($2)
|
||||
${3}
|
||||
@end
|
||||
# Category Interface
|
||||
snippet cath
|
||||
@interface ${1:NSObject} (${2:Category})
|
||||
${3}
|
||||
@end
|
||||
# NSArray
|
||||
snippet array
|
||||
NSMutableArray *${1:array} = [NSMutable array];${2}
|
||||
# NSDictionary
|
||||
snippet dict
|
||||
NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary];${2}
|
||||
# NSBezierPath
|
||||
snippet bez
|
||||
NSBezierPath *${1:path} = [NSBezierPath bezierPath];${2}
|
||||
# Method
|
||||
snippet m
|
||||
- (${1:id})${2:method}
|
||||
{
|
||||
${3}
|
||||
}
|
||||
# Method declaration
|
||||
snippet md
|
||||
- (${1:id})${2:method};${3}
|
||||
# IBAction declaration
|
||||
snippet ibad
|
||||
- (IBAction)${1:method}:(${2:id})sender;${3}
|
||||
# IBAction method
|
||||
snippet iba
|
||||
- (IBAction)${1:method}:(${2:id})sender
|
||||
{
|
||||
${3}
|
||||
}
|
||||
# awakeFromNib method
|
||||
snippet wake
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
${1}
|
||||
}
|
||||
# Class Method
|
||||
snippet M
|
||||
+ (${1:id})${2:method}
|
||||
{${3}
|
||||
return nil;
|
||||
}
|
||||
# Sub-method (Call super)
|
||||
snippet sm
|
||||
- (${1:id})${2:method}
|
||||
{
|
||||
[super $2];${3}
|
||||
return self;
|
||||
}
|
||||
# Method: Initialize
|
||||
snippet I
|
||||
+ (void) initialize
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWIthObjectsAndKeys:
|
||||
${1}@"value", @"key",
|
||||
nil]];
|
||||
}
|
||||
# Accessor Methods For:
|
||||
# Object
|
||||
snippet objacc
|
||||
- (${1:id})${2:thing}
|
||||
{
|
||||
return $2;
|
||||
}
|
||||
|
||||
- (void)set$2:($1)${3:new$2}
|
||||
{
|
||||
[$3 retain];
|
||||
[$2 release];
|
||||
$2 = $3;
|
||||
}${4}
|
||||
# for (object in array)
|
||||
snippet forin
|
||||
for (${1:Class} *${2:some$1} in ${3:array}) {
|
||||
${4}
|
||||
}
|
||||
snippet forarray
|
||||
unsigned int ${1:object}Count = [${2:array} count];
|
||||
|
||||
for (unsigned int index = 0; index < $1Count; index++) {
|
||||
${3:id} $1 = [$2 $1AtIndex:index];
|
||||
${4}
|
||||
}
|
||||
# IBOutlet
|
||||
# @property (Objective-C 2.0)
|
||||
snippet prop
|
||||
@property (${1:retain}) ${2:NSSomeClass} ${3:*$2};${4}
|
||||
# @synthesize (Objective-C 2.0)
|
||||
snippet syn
|
||||
@synthesize ${1:property};${2}
|
||||
# [[ alloc] init]
|
||||
snippet alloc
|
||||
[[${1:foo} alloc] init${2}];${3}
|
||||
# retain
|
||||
snippet ret
|
||||
[${1:foo} retain];${2}
|
||||
# release
|
||||
snippet rel
|
||||
[${1:foo} release];
|
||||
${2:$1 = nil;}
|
||||
# autorelease
|
||||
snippet arel
|
||||
[${1:foo} autorelease];
|
||||
# autorelease pool
|
||||
snippet pool
|
||||
NSAutoreleasePool *${1:pool} = [[NSAutoreleasePool alloc] init];
|
||||
${2:/* code */}
|
||||
[$1 drain];
|
||||
# Throw an exception
|
||||
snippet except
|
||||
NSException *${1:badness};
|
||||
$1 = [NSException exceptionWithName:@"${2:$1Name}"
|
||||
reason:@"${3}"
|
||||
userInfo:nil];
|
||||
[$1 raise];
|
||||
snippet prag
|
||||
#pragma mark ${1:foo}
|
||||
snippet cl
|
||||
@class ${1:Foo};${2}
|
||||
snippet color
|
||||
[[NSColor ${1:blackColor}] set];
|
||||
91
.vim/snippets/perl.snippets
Normal file
91
.vim/snippets/perl.snippets
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
# #!/usr/bin/perl
|
||||
snippet #!
|
||||
#!/usr/bin/perl
|
||||
|
||||
# Hash Pointer
|
||||
snippet .
|
||||
=>
|
||||
# Function
|
||||
snippet sub
|
||||
sub ${1:function_name} {
|
||||
${2:#body ...}
|
||||
}
|
||||
# Conditional
|
||||
snippet if
|
||||
if (${1}) {
|
||||
${2:# body...}
|
||||
}
|
||||
# Conditional if..else
|
||||
snippet ife
|
||||
if (${1}) {
|
||||
${2:# body...}
|
||||
} else {
|
||||
${3:# else...}
|
||||
}
|
||||
# Conditional if..elsif..else
|
||||
snippet ifee
|
||||
if (${1}) {
|
||||
${2:# body...}
|
||||
} elsif (${3}) {
|
||||
${4:# elsif...}
|
||||
} else {
|
||||
${5:# else...}
|
||||
}
|
||||
# Conditional One-line
|
||||
snippet xif
|
||||
${1:expression} if ${2:condition};${3}
|
||||
# Unless conditional
|
||||
snippet unless
|
||||
unless (${1}) {
|
||||
${2:# body...}
|
||||
}
|
||||
# Unless conditional One-line
|
||||
snippet xunless
|
||||
${1:expression} unless ${2:condition};${3}
|
||||
# Try/Except
|
||||
snippet eval
|
||||
eval {
|
||||
${1:# do something risky...}
|
||||
};
|
||||
if ($@) {
|
||||
${2:# handle failure...}
|
||||
}
|
||||
# While Loop
|
||||
snippet wh
|
||||
while (${1}) {
|
||||
${2:# body...}
|
||||
}
|
||||
# While Loop One-line
|
||||
snippet xwh
|
||||
${1:expression} while ${2:condition};${3}
|
||||
# For Loop
|
||||
snippet for
|
||||
for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) {
|
||||
${4:# body...}
|
||||
}
|
||||
# Foreach Loop
|
||||
snippet fore
|
||||
foreach my $${1:x} (@${2:array}) {
|
||||
${3:# body...}
|
||||
}
|
||||
# Foreach Loop One-line
|
||||
snippet xfore
|
||||
${1:expression} foreach @${2:array};${3}
|
||||
# Package
|
||||
snippet cl
|
||||
package ${1:ClassName};
|
||||
|
||||
use base qw(${2:ParentClass});
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
$class = ref $class if ref $class;
|
||||
my $self = bless {}, $class;
|
||||
$self;
|
||||
}
|
||||
|
||||
1;${3}
|
||||
# Read File
|
||||
snippet slurp
|
||||
my $${1:var};
|
||||
{ local $/ = undef; local *FILE; open FILE, "<${2:file}"; $$1 = <FILE>; close FILE }${3}
|
||||
216
.vim/snippets/php.snippets
Normal file
216
.vim/snippets/php.snippets
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
snippet php
|
||||
<?php
|
||||
${1}
|
||||
?>
|
||||
snippet ec
|
||||
echo "${1:string}"${2};
|
||||
snippet inc
|
||||
include '${1:file}';${2}
|
||||
snippet inc1
|
||||
include_once '${1:file}';${2}
|
||||
snippet req
|
||||
require '${1:file}';${2}
|
||||
snippet req1
|
||||
require_once '${1:file}';${2}
|
||||
# $GLOBALS['...']
|
||||
snippet globals
|
||||
$GLOBALS['${1:variable}']${2: = }${3:something}${4:;}${5}
|
||||
snippet $_ COOKIE['...']
|
||||
$_COOKIE['${1:variable}']${2}
|
||||
snippet $_ ENV['...']
|
||||
$_ENV['${1:variable}']${2}
|
||||
snippet $_ FILES['...']
|
||||
$_FILES['${1:variable}']${2}
|
||||
snippet $_ Get['...']
|
||||
$_GET['${1:variable}']${2}
|
||||
snippet $_ POST['...']
|
||||
$_POST['${1:variable}']${2}
|
||||
snippet $_ REQUEST['...']
|
||||
$_REQUEST['${1:variable}']${2}
|
||||
snippet $_ SERVER['...']
|
||||
$_SERVER['${1:variable}']${2}
|
||||
snippet $_ SESSION['...']
|
||||
$_SESSION['${1:variable}']${2}
|
||||
# Start Docblock
|
||||
snippet /*
|
||||
/**
|
||||
* ${1}
|
||||
**/
|
||||
# Class - post doc
|
||||
snippet doc_cp
|
||||
/**
|
||||
* ${1:undocumented class}
|
||||
*
|
||||
* @package ${2:default}
|
||||
* @author ${3:`g:snips_author`}
|
||||
**/${4}
|
||||
# Class Variable - post doc
|
||||
snippet doc_vp
|
||||
/**
|
||||
* ${1:undocumented class variable}
|
||||
*
|
||||
* @var ${2:string}
|
||||
**/${3}
|
||||
# Class Variable
|
||||
snippet doc_v
|
||||
/**
|
||||
* ${3:undocumented class variable}
|
||||
*
|
||||
* @var ${4:string}
|
||||
**/
|
||||
${1:var} $${2};${5}
|
||||
# Class
|
||||
snippet doc_c
|
||||
/**
|
||||
* ${3:undocumented class}
|
||||
*
|
||||
* @packaged ${4:default}
|
||||
* @author ${5:`g:snips_author`}
|
||||
**/
|
||||
${1:}class ${2:}
|
||||
{${6}
|
||||
} // END $1class $2
|
||||
# Constant Definition - post doc
|
||||
snippet doc_dp
|
||||
/**
|
||||
* ${1:undocumented constant}
|
||||
**/${2}
|
||||
# Constant Definition
|
||||
snippet doc_d
|
||||
/**
|
||||
* ${3:undocumented constant}
|
||||
**/
|
||||
define(${1}, ${2});${4}
|
||||
# Function - post doc
|
||||
snippet doc_fp
|
||||
/**
|
||||
* ${1:undocumented function}
|
||||
*
|
||||
* @return ${2:void}
|
||||
* @author ${3:`g:snips_author`}
|
||||
**/${4}
|
||||
# Function signature
|
||||
snippet doc_s
|
||||
/**
|
||||
* ${4:undocumented function}
|
||||
*
|
||||
* @return ${5:void}
|
||||
* @author ${6:`g:snips_author`}
|
||||
**/
|
||||
${1}function ${2}(${3});${7}
|
||||
# Function
|
||||
snippet doc_f
|
||||
/**
|
||||
* ${4:undocumented function}
|
||||
*
|
||||
* @return ${5:void}
|
||||
* @author ${6:`g:snips_author`}
|
||||
**/
|
||||
${1}function ${2}(${3})
|
||||
{${7}
|
||||
}
|
||||
# Header
|
||||
snippet doc_h
|
||||
/**
|
||||
* ${1}
|
||||
*
|
||||
* @author ${2:`g:snips_author`}
|
||||
* @version ${3:$Id$}
|
||||
* @copyright ${4:$2}, `strftime('%d %B, %Y')`
|
||||
* @package ${5:default}
|
||||
**/
|
||||
|
||||
/**
|
||||
* Define DocBlock
|
||||
*//
|
||||
# Interface
|
||||
snippet doc_i
|
||||
/**
|
||||
* ${2:undocumented class}
|
||||
*
|
||||
* @package ${3:default}
|
||||
* @author ${4:`g:snips_author`}
|
||||
**/
|
||||
interface ${1:}
|
||||
{${5}
|
||||
} // END interface $1
|
||||
# class ...
|
||||
snippet class
|
||||
/**
|
||||
* ${1}
|
||||
**/
|
||||
class ${2:ClassName}
|
||||
{
|
||||
${3}
|
||||
function ${4:__construct}(${5:argument})
|
||||
{
|
||||
${6:// code...}
|
||||
}
|
||||
}
|
||||
# define(...)
|
||||
snippet def
|
||||
define('${1}'${2});${3}
|
||||
# defined(...)
|
||||
snippet def?
|
||||
${1}defined('${2}')${3}
|
||||
snippet wh
|
||||
while (${1:/* condition */}) {
|
||||
${2:// code...}
|
||||
}
|
||||
# do ... while
|
||||
snippet do
|
||||
do {
|
||||
${2:// code... }
|
||||
} while (${1:/* condition */});
|
||||
snippet if
|
||||
if (${1:/* condition */}) {
|
||||
${2:// code...}
|
||||
}
|
||||
snippet ife
|
||||
if (${1:/* condition */}) {
|
||||
${2:// code...}
|
||||
} else {
|
||||
${3:// code...}
|
||||
}
|
||||
${4}
|
||||
snippet else
|
||||
else {
|
||||
${1:// code...}
|
||||
}
|
||||
snippet elseif
|
||||
elseif (${1:/* condition */}) {
|
||||
${2:// code...}
|
||||
}
|
||||
# Tertiary conditional
|
||||
snippet t
|
||||
$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5}
|
||||
snippet switch
|
||||
switch ($${1:variable}) {
|
||||
case '${2:value}':
|
||||
${3:// code...}
|
||||
break;
|
||||
${5}
|
||||
default:
|
||||
${4:// code...}
|
||||
break;
|
||||
}
|
||||
snippet case
|
||||
case '${1:value}':
|
||||
${2:// code...}
|
||||
break;${3}
|
||||
snippet for
|
||||
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
|
||||
${4: // code...}
|
||||
}
|
||||
snippet foreach
|
||||
foreach ($${1:variable} as $${2:key}) {
|
||||
${3:// code...}
|
||||
}
|
||||
snippet fun
|
||||
${1:public }function ${2:FunctionName}(${3})
|
||||
{
|
||||
${4:// code...}
|
||||
}
|
||||
# $... = array (...)
|
||||
snippet array
|
||||
$${1:arrayName} = array('${2}' => ${3});${4}
|
||||
86
.vim/snippets/python.snippets
Normal file
86
.vim/snippets/python.snippets
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
snippet #!
|
||||
#!/usr/bin/python
|
||||
|
||||
snippet imp
|
||||
import ${1:module}
|
||||
# Module Docstring
|
||||
snippet docs
|
||||
'''
|
||||
File: ${1:`Filename('$1.py', 'foo.py')`}
|
||||
Author: ${2:`g:snips_author`}
|
||||
Description: ${3}
|
||||
'''
|
||||
snippet wh
|
||||
while ${1:condition}:
|
||||
${2:# code...}
|
||||
snippet for
|
||||
for ${1:needle} in ${2:haystack}:
|
||||
${3:# code...}
|
||||
# New Class
|
||||
snippet cl
|
||||
class ${1:ClassName}(${2:object}):
|
||||
"""${3:docstring for $1}"""
|
||||
def __init__(self, ${4:arg}):
|
||||
${5:super($1, self).__init__()}
|
||||
self.$4 = $4
|
||||
${6}
|
||||
# New Function
|
||||
snippet def
|
||||
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
||||
"""${3:docstring for $1}"""
|
||||
${4:pass}
|
||||
snippet deff
|
||||
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
||||
${3}
|
||||
# New Method
|
||||
snippet defs
|
||||
def ${1:mname}(self, ${2:arg}):
|
||||
${3:pass}
|
||||
# New Property
|
||||
snippet property
|
||||
def ${1:foo}():
|
||||
doc = "${2:The $1 property.}"
|
||||
def fget(self):
|
||||
${3:return self._$1}
|
||||
def fset(self, value):
|
||||
${4:self._$1 = value}
|
||||
# Lambda
|
||||
snippet ld
|
||||
${1:var} = lambda ${2:vars} : ${3:action}
|
||||
snippet .
|
||||
self.
|
||||
snippet try Try/Except
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
snippet try Try/Except/Else
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
else:
|
||||
${5:pass}
|
||||
snippet try Try/Except/Finally
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
finally:
|
||||
${5:pass}
|
||||
snippet try Try/Except/Else/Finally
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
else:
|
||||
${5:pass}
|
||||
finally:
|
||||
${6:pass}
|
||||
# if __name__ == '__main__':
|
||||
snippet ifmain
|
||||
if __name__ == '__main__':
|
||||
${1:main()}
|
||||
# __magic__
|
||||
snippet _
|
||||
__${1:init}__${2}
|
||||
420
.vim/snippets/ruby.snippets
Normal file
420
.vim/snippets/ruby.snippets
Normal file
|
|
@ -0,0 +1,420 @@
|
|||
# #!/usr/bin/ruby
|
||||
snippet #!
|
||||
#!/usr/bin/ruby
|
||||
|
||||
# New Block
|
||||
snippet =b
|
||||
=begin rdoc
|
||||
${1}
|
||||
=end
|
||||
snippet y
|
||||
:yields: ${1:arguments}
|
||||
snippet rb
|
||||
#!/usr/bin/env ruby -wKU
|
||||
|
||||
snippet req
|
||||
require "${1}"${2}
|
||||
snippet #
|
||||
# =>
|
||||
snippet end
|
||||
__END__
|
||||
snippet case
|
||||
case ${1:object}
|
||||
when ${2:condition}
|
||||
${3}
|
||||
end
|
||||
snippet when
|
||||
when ${1:condition}
|
||||
${2}
|
||||
snippet def
|
||||
def ${1:method_name}
|
||||
${2}
|
||||
end
|
||||
snippet deft
|
||||
def test_${1:case_name}
|
||||
${2}
|
||||
end
|
||||
snippet if
|
||||
if ${1:condition}
|
||||
${2}
|
||||
end
|
||||
snippet ife
|
||||
if ${1:condition}
|
||||
${2}
|
||||
else
|
||||
${3}
|
||||
end
|
||||
snippet elsif
|
||||
elsif ${1:condition}
|
||||
${2}
|
||||
snippet unless
|
||||
unless ${1:condition}
|
||||
${2}
|
||||
end
|
||||
snippet while
|
||||
while ${1:condition}
|
||||
${2}
|
||||
end
|
||||
snippet until
|
||||
until ${1:condition}
|
||||
${2}
|
||||
end
|
||||
snippet cla class .. end
|
||||
class ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||
${2}
|
||||
end
|
||||
snippet cla class .. initialize .. end
|
||||
class ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||
def initialize(${2:args})
|
||||
${3}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
snippet cla class .. < ParentClass .. initialize .. end
|
||||
class ${1:`substitute(Filename(), '^.', '\u&', '')`} < ${2:ParentClass}
|
||||
def initialize(${3:args})
|
||||
${4}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
snippet cla ClassName = Struct .. do .. end
|
||||
${1:`substitute(Filename(), '^.', '\u&', '')`} = Struct.new(:${2:attr_names}) do
|
||||
def ${3:method_name}
|
||||
${4}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
snippet cla class BlankSlate .. initialize .. end
|
||||
class ${1:BlankSlate}
|
||||
instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ }
|
||||
snippet cla class << self .. end
|
||||
class << ${1:self}
|
||||
${2}
|
||||
end
|
||||
# class .. < DelegateClass .. initialize .. end
|
||||
snippet cla-
|
||||
class ${1:`substitute(Filename(), '^.', '\u&', '')`} < DelegateClass(${2:ParentClass})
|
||||
def initialize(${3:args})
|
||||
super(${4:del_obj})
|
||||
|
||||
${5}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
snippet mod module .. end
|
||||
module ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||
${2}
|
||||
end
|
||||
snippet mod module .. module_function .. end
|
||||
module ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||
module_function
|
||||
|
||||
${2}
|
||||
end
|
||||
snippet mod module .. ClassMethods .. end
|
||||
module ${1:`substitute(Filename(), '^.', '\u&', '')`}
|
||||
module ClassMethods
|
||||
${2}
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
|
||||
end
|
||||
|
||||
def self.included(receiver)
|
||||
receiver.extend ClassMethods
|
||||
receiver.send :include, InstanceMethods
|
||||
end
|
||||
end
|
||||
# attr_reader
|
||||
snippet r
|
||||
attr_reader :${1:attr_names}
|
||||
# attr_writer
|
||||
snippet w
|
||||
attr_writer :${1:attr_names}
|
||||
# attr_accessor
|
||||
snippet rw
|
||||
attr_accessor :${1:attr_names}
|
||||
# include Enumerable
|
||||
snippet Enum
|
||||
include Enumerable
|
||||
|
||||
def each(&block)
|
||||
${1}
|
||||
end
|
||||
# include Comparable
|
||||
snippet Comp
|
||||
include Comparable
|
||||
|
||||
def <=>(other)
|
||||
${1}
|
||||
end
|
||||
# extend Forwardable
|
||||
snippet Forw-
|
||||
extend Forwardable
|
||||
# def self
|
||||
snippet defs
|
||||
def self.${1:class_method_name}
|
||||
${2}
|
||||
end
|
||||
# def method_missing
|
||||
snippet defmm
|
||||
def method_missing(meth, *args, &blk)
|
||||
${1}
|
||||
end
|
||||
snippet defd
|
||||
def_delegator :${1:@del_obj}, :${2:del_meth}, :${3:new_name}
|
||||
snippet defds
|
||||
def_delegators :${1:@del_obj}, :${2:del_methods}
|
||||
snippet am
|
||||
alias_method :${1:new_name}, :${2:old_name}
|
||||
snippet app
|
||||
if __FILE__ == $PROGRAM_NAME
|
||||
${1}
|
||||
end
|
||||
# usage_if()
|
||||
snippet usai
|
||||
if ARGV.${1}
|
||||
abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3}
|
||||
end
|
||||
# usage_unless()
|
||||
snippet usau
|
||||
unless ARGV.${1}
|
||||
abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3}
|
||||
end
|
||||
snippet array
|
||||
Array.new(${1:10}) { |${2:i}| ${3} }
|
||||
snippet hash
|
||||
Hash.new { |${1:hash}, ${2:key}| $1[$2] = ${3} }
|
||||
snippet file File.foreach() { |line| .. }
|
||||
File.foreach(${1:"path/to/file"}) { |${2:line}| ${3} }
|
||||
snippet file File.read()
|
||||
File.read(${1:"path/to/file"})${2}
|
||||
snippet Dir Dir.global() { |file| .. }
|
||||
Dir.glob(${1:"dir/glob/*"}) { |${2:file}| ${3} }
|
||||
snippet Dir Dir[".."]
|
||||
Dir[${1:"glob/**/*.rb"}]${2}
|
||||
snippet dir
|
||||
Filename.dirname(__FILE__)
|
||||
snippet deli
|
||||
delete_if { |${1:e}| ${2} }
|
||||
snippet fil
|
||||
fill(${1:range}) { |${2:i}| ${3} }
|
||||
# flatten_once()
|
||||
snippet flao
|
||||
inject(Array.new) { |${1:arr}, ${2:a}| $1.push(*$2)}${3}
|
||||
snippet zip
|
||||
zip(${1:enums}) { |${2:row}| ${3} }
|
||||
# downto(0) { |n| .. }
|
||||
snippet dow
|
||||
downto(${1:0}) { |${2:n}| ${3} }
|
||||
snippet ste
|
||||
step(${1:2}) { |${2:n}| ${3} }
|
||||
snippet tim
|
||||
times { |${1:n}| ${2} }
|
||||
snippet upt
|
||||
upto(${1:1.0/0.0}) { |${2:n}| ${3} }
|
||||
snippet loo
|
||||
loop { ${1} }
|
||||
snippet ea
|
||||
each { |${1:e}| ${2} }
|
||||
snippet eab
|
||||
each_byte { |${1:byte}| ${2} }
|
||||
snippet eac- each_char { |chr| .. }
|
||||
each_char { |${1:chr}| ${2} }
|
||||
snippet eac- each_cons(..) { |group| .. }
|
||||
each_cons(${1:2}) { |${2:group}| ${3} }
|
||||
snippet eai
|
||||
each_index { |${1:i}| ${2} }
|
||||
snippet eak
|
||||
each_key { |${1:key}| ${2} }
|
||||
snippet eal
|
||||
each_line { |${1:line}| ${2} }
|
||||
snippet eap
|
||||
each_pair { |${1:name}, ${2:val}| ${3} }
|
||||
snippet eas-
|
||||
each_slice(${1:2}) { |${2:group}| ${3} }
|
||||
snippet eav
|
||||
each_value { |${1:val}| ${2} }
|
||||
snippet eawi
|
||||
each_with_index { |${1:e}, ${2:i}| ${3} }
|
||||
snippet reve
|
||||
reverse_each { |${1:e}| ${2} }
|
||||
snippet inj
|
||||
inject(${1:init}) { |${2:mem}, ${3:var}| ${4} }
|
||||
snippet map
|
||||
map { |${1:e}| ${2} }
|
||||
snippet mapwi-
|
||||
enum_with_index.map { |${1:e}, ${2:i}| ${3} }
|
||||
snippet sor
|
||||
sort { |a, b| ${1} }
|
||||
snippet sorb
|
||||
sort_by { |${1:e}| ${2} }
|
||||
snippet ran
|
||||
sort_by { rand }
|
||||
snippet all
|
||||
all? { |${1:e}| ${2} }
|
||||
snippet any
|
||||
any? { |${1:e}| ${2} }
|
||||
snippet cl
|
||||
classify { |${1:e}| ${2} }
|
||||
snippet col
|
||||
collect { |${1:e}| ${2} }
|
||||
snippet det
|
||||
detect { |${1:e}| ${2} }
|
||||
snippet fet
|
||||
fetch(${1:name}) { |${2:key}| ${3} }
|
||||
snippet fin
|
||||
find { |${1:e}| ${2} }
|
||||
snippet fina
|
||||
find_all { |${1:e}| ${2} }
|
||||
snippet gre
|
||||
grep(${1:/pattern/}) { |${2:match}| ${3} }
|
||||
snippet sub
|
||||
${1:g}sub(${2:/pattern/}) { |${3:match}| ${4} }
|
||||
snippet sca
|
||||
scan(${1:/pattern/}) { |${2:match}| ${3} }
|
||||
snippet max
|
||||
max { |a, b|, ${1} }
|
||||
snippet min
|
||||
min { |a, b|, ${1} }
|
||||
snippet par
|
||||
partition { |${1:e}|, ${2} }
|
||||
snippet rej
|
||||
reject { |${1:e}|, ${2} }
|
||||
snippet sel
|
||||
select { |${1:e}|, ${2} }
|
||||
snippet lam
|
||||
lambda { |${1:args}| ${2} }
|
||||
snippet do
|
||||
do |${1:variable}|
|
||||
${2}
|
||||
end
|
||||
snippet :
|
||||
:${1:key} => ${2:"value"}${3}
|
||||
snippet ope
|
||||
open(${1:"path/or/url/or/pipe"}, "${2:w}") { |${3:io}| ${4} }
|
||||
# path_from_here()
|
||||
snippet patfh
|
||||
File.join(File.dirname(__FILE__), *%2[${1:rel path here}])${2}
|
||||
# unix_filter {}
|
||||
snippet unif
|
||||
ARGF.each_line${1} do |${2:line}|
|
||||
${3}
|
||||
end
|
||||
# option_parse {}
|
||||
snippet optp
|
||||
require "optparse"
|
||||
|
||||
options = {${1:default => "args"}}
|
||||
|
||||
ARGV.options do |opts|
|
||||
opts.banner = "Usage: #{File.basename($PROGRAM_NAME)}
|
||||
snippet opt
|
||||
opts.on( "-${1:o}", "--${2:long-option-name}", ${3:String},
|
||||
"${4:Option description.}") do |${5:opt}|
|
||||
${6}
|
||||
end
|
||||
snippet tc
|
||||
require "test/unit"
|
||||
|
||||
require "${1:library_file_name}"
|
||||
|
||||
class Test${2:$1} < Test::Unit::TestCase
|
||||
def test_${3:case_name}
|
||||
${4}
|
||||
end
|
||||
end
|
||||
snippet ts
|
||||
require "test/unit"
|
||||
|
||||
require "tc_${1:test_case_file}"
|
||||
require "tc_${2:test_case_file}"${3}
|
||||
snippet as
|
||||
assert(${1:test}, "${2:Failure message.}")${3}
|
||||
snippet ase
|
||||
assert_equal(${1:expected}, ${2:actual})${3}
|
||||
snippet asne
|
||||
assert_not_equal(${1:unexpected}, ${2:actual})${3}
|
||||
snippet asid
|
||||
assert_in_delta(${1:expected_float}, ${2:actual_float}, ${3:2 ** -20})${4}
|
||||
snippet asio
|
||||
assert_instance_of(${1:ExpectedClass}, ${2:actual_instance})${3}
|
||||
snippet asko
|
||||
assert_kind_of(${1:ExpectedKind}, ${2:actual_instance})${3}
|
||||
snippet asn
|
||||
assert_nil(${1:instance})${2}
|
||||
snippet asnn
|
||||
assert_not_nil(${1:instance})${2}
|
||||
snippet asm
|
||||
assert_match(/${1:expected_pattern}/, ${2:actual_string})${3}
|
||||
snippet asnm
|
||||
assert_no_match(/${1:unexpected_pattern}/, ${2:actual_string})${3}
|
||||
snippet aso
|
||||
assert_operator(${1:left}, :${2:operator}, ${3:right})${4}
|
||||
snippet asr
|
||||
assert_raise(${1:Exception}) { ${2} }
|
||||
snippet asnr
|
||||
assert_nothing_raised(${1:Exception}) { ${2} }
|
||||
snippet asrt
|
||||
assert_respond_to(${1:object}, :${2:method})${3}
|
||||
snippet ass assert_same(..)
|
||||
assert_same(${1:expected}, ${2:actual})${3}
|
||||
snippet ass assert_send(..)
|
||||
assert_send([${1:object}, :${2:message}, ${3:args}])${4}
|
||||
snippet asns
|
||||
assert_not_same(${1:unexpected}, ${2:actual})${3}
|
||||
snippet ast
|
||||
assert_throws(:${1:expected}) { ${2} }
|
||||
snippet asnt
|
||||
assert_nothing_thrown { ${1} }
|
||||
snippet fl
|
||||
flunk("${1:Failure message.}")${2}
|
||||
# Benchmark.bmbm do .. end
|
||||
snippet bm-
|
||||
TESTS = ${1:10_000}
|
||||
Benchmark.bmbm do |results|
|
||||
${2}
|
||||
end
|
||||
snippet rep
|
||||
results.report("${1:name}:") { TESTS.times { ${2} }}
|
||||
# Marshal.dump(.., file)
|
||||
snippet Md
|
||||
File.open(${1:"path/to/file.dump"}, "wb") { |${2:file}| Marshal.dump(${3:obj}, $2) }${4}
|
||||
# Mashal.load(obj)
|
||||
snippet Ml
|
||||
File.open(${1:"path/to/file.dump"}, "rb") { |${2:file}| Marshal.load($2) }${3}
|
||||
# deep_copy(..)
|
||||
snippet deec
|
||||
Marshal.load(Marshal.dump(${1:obj_to_copy}))${2}
|
||||
snippet Pn-
|
||||
PStore.new(${1:"file_name.pstore"})${2}
|
||||
snippet tra
|
||||
transaction(${1:true}) { ${2} }
|
||||
# xmlread(..)
|
||||
snippet xml-
|
||||
REXML::Document.new(File.read(${1:"path/to/file"}))${2}
|
||||
# xpath(..) { .. }
|
||||
snippet xpa
|
||||
elements.each(${1:"//Xpath"}) do |${2:node}|
|
||||
${3}
|
||||
end
|
||||
# class_from_name()
|
||||
snippet clafn
|
||||
split("::").inject(Object) { |par, const| par.const_get(const) }
|
||||
# singleton_class()
|
||||
snippet sinc
|
||||
class << self; self end
|
||||
snippet nam
|
||||
namespace :${1:`Filename()`} do
|
||||
${2}
|
||||
end
|
||||
snippet tas
|
||||
desc "${1:Task description\}"
|
||||
task :${2:task_name => [:dependent, :tasks]} do
|
||||
${3}
|
||||
end
|
||||
28
.vim/snippets/sh.snippets
Normal file
28
.vim/snippets/sh.snippets
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# #!/bin/bash
|
||||
snippet #!
|
||||
#!/bin/bash
|
||||
|
||||
snippet if
|
||||
if [[ ${1:condition} ]]; then
|
||||
${2:#statements}
|
||||
fi
|
||||
snippet elif
|
||||
elif [[ ${1:condition} ]]; then
|
||||
${2:#statements}
|
||||
snippet for
|
||||
for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do
|
||||
${3:#statements}
|
||||
done
|
||||
snippet wh
|
||||
while [[ ${1:condition} ]]; do
|
||||
${2:#statements}
|
||||
done
|
||||
snippet until
|
||||
until [[ ${1:condition} ]]; do
|
||||
${2:#statements}
|
||||
done
|
||||
snippet case
|
||||
case ${1:word} in
|
||||
${2:pattern})
|
||||
${3};;
|
||||
esac
|
||||
7
.vim/snippets/snippet.snippets
Normal file
7
.vim/snippets/snippet.snippets
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# snippets for making snippets :)
|
||||
snippet snip
|
||||
snippet ${1:trigger}
|
||||
${2}
|
||||
snippet msnip
|
||||
snippet ${1:trigger} ${2:description}
|
||||
${3}
|
||||
92
.vim/snippets/tcl.snippets
Normal file
92
.vim/snippets/tcl.snippets
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
# #!/usr/bin/tclsh
|
||||
snippet #!
|
||||
#!/usr/bin/tclsh
|
||||
|
||||
# Process
|
||||
snippet pro
|
||||
proc ${1:function_name} {${2:args}} {
|
||||
${3:#body ...}
|
||||
}
|
||||
#xif
|
||||
snippet xif
|
||||
${1:expr}? ${2:true} : ${3:false}
|
||||
# Conditional
|
||||
snippet if
|
||||
if {${1}} {
|
||||
${2:# body...}
|
||||
}
|
||||
# Conditional if..else
|
||||
snippet ife
|
||||
if {${1}} {
|
||||
${2:# body...}
|
||||
} else {
|
||||
${3:# else...}
|
||||
}
|
||||
# Conditional if..elsif..else
|
||||
snippet ifee
|
||||
if {${1}} {
|
||||
${2:# body...}
|
||||
} elseif {${3}} {
|
||||
${4:# elsif...}
|
||||
} else {
|
||||
${5:# else...}
|
||||
}
|
||||
# If catch then
|
||||
snippet ifc
|
||||
if { [catch {${1:#do something...}} ${2:err}] } {
|
||||
${3:# handle failure...}
|
||||
}
|
||||
# Catch
|
||||
snippet catch
|
||||
catch {${1}} ${2:err} ${3:options}
|
||||
# While Loop
|
||||
snippet wh
|
||||
while {${1}} {
|
||||
${2:# body...}
|
||||
}
|
||||
# For Loop
|
||||
snippet for
|
||||
for {set ${2:var} 0} {$$2 < ${1:count}} {${3:incr} $2} {
|
||||
${4:# body...}
|
||||
}
|
||||
# Foreach Loop
|
||||
snippet fore
|
||||
foreach ${1:x} {${2:#list}} {
|
||||
${3:# body...}
|
||||
}
|
||||
# after ms script...
|
||||
snippet af
|
||||
after ${1:ms} ${2:#do something}
|
||||
# after cancel id
|
||||
snippet afc
|
||||
after cancel ${1:id or script}
|
||||
# after idle
|
||||
snippet afi
|
||||
after idle ${1:script}
|
||||
# after info id
|
||||
snippet afin
|
||||
after info ${1:id}
|
||||
# Expr
|
||||
snippet exp
|
||||
expr {${1:#expression here}}
|
||||
# Switch
|
||||
snippet sw
|
||||
switch ${1:var} {
|
||||
${3:pattern 1} {
|
||||
${4:#do something}
|
||||
}
|
||||
default {
|
||||
${2:#do something}
|
||||
}
|
||||
}
|
||||
# Case
|
||||
snippet ca
|
||||
${1:pattern} {
|
||||
${2:#do something}
|
||||
}${3}
|
||||
# Namespace eval
|
||||
snippet ns
|
||||
namespace eval ${1:path} {${2:#script...}}
|
||||
# Namespace current
|
||||
snippet nsc
|
||||
namespace current
|
||||
115
.vim/snippets/tex.snippets
Normal file
115
.vim/snippets/tex.snippets
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
# \begin{}...\end{}
|
||||
snippet begin
|
||||
\begin{${1:env}}
|
||||
${2}
|
||||
\end{$1}
|
||||
# Tabular
|
||||
snippet tab
|
||||
\begin{${1:tabular}}{${2:c}}
|
||||
${3}
|
||||
\end{$1}
|
||||
# Align(ed)
|
||||
snippet ali
|
||||
\begin{align${1:ed}}
|
||||
${2}
|
||||
\end{align$1}
|
||||
# Gather(ed)
|
||||
snippet gat
|
||||
\begin{gather${1:ed}}
|
||||
${2}
|
||||
\end{gather$1}
|
||||
# Equation
|
||||
snippet eq
|
||||
\begin{equation}
|
||||
${1}
|
||||
\end{equation}
|
||||
# Unnumbered Equation
|
||||
snippet \
|
||||
\\[
|
||||
${1}
|
||||
\\]
|
||||
# Enumerate
|
||||
snippet enum
|
||||
\begin{enumerate}
|
||||
\item ${1}
|
||||
\end{enumerate}
|
||||
# Itemize
|
||||
snippet item
|
||||
\begin{itemize}
|
||||
\item ${1}
|
||||
\end{itemize}
|
||||
# Description
|
||||
snippet desc
|
||||
\begin{description}
|
||||
\item[${1}] ${2}
|
||||
\end{description}
|
||||
# Matrix
|
||||
snippet mat
|
||||
\begin{${1:p/b/v/V/B/small}matrix}
|
||||
${2}
|
||||
\end{$1matrix}
|
||||
# Cases
|
||||
snippet cas
|
||||
\begin{cases}
|
||||
${1:equation}, &\text{ if }${2:case}\\
|
||||
${3}
|
||||
\end{cases}
|
||||
# Split
|
||||
snippet spl
|
||||
\begin{split}
|
||||
${1}
|
||||
\end{split}
|
||||
# Part
|
||||
snippet part
|
||||
\part{${1:part name}} % (fold)
|
||||
\label{prt:${2:$1}}
|
||||
${3}
|
||||
% part $2 (end)
|
||||
# Chapter
|
||||
snippet cha
|
||||
\chapter{${1:chapter name}} % (fold)
|
||||
\label{cha:${2:$1}}
|
||||
${3}
|
||||
% chapter $2 (end)
|
||||
# Section
|
||||
snippet sec
|
||||
\section{${1:section name}} % (fold)
|
||||
\label{sec:${2:$1}}
|
||||
${3}
|
||||
% section $2 (end)
|
||||
# Sub Section
|
||||
snippet sub
|
||||
\subsection{${1:subsection name}} % (fold)
|
||||
\label{sub:${2:$1}}
|
||||
${3}
|
||||
% subsection $2 (end)
|
||||
# Sub Sub Section
|
||||
snippet subs
|
||||
\subsubsection{${1:subsubsection name}} % (fold)
|
||||
\label{ssub:${2:$1}}
|
||||
${3}
|
||||
% subsubsection $2 (end)
|
||||
# Paragraph
|
||||
snippet par
|
||||
\paragraph{${1:paragraph name}} % (fold)
|
||||
\label{par:${2:$1}}
|
||||
${3}
|
||||
% paragraph $2 (end)
|
||||
# Sub Paragraph
|
||||
snippet subp
|
||||
\subparagraph{${1:subparagraph name}} % (fold)
|
||||
\label{subp:${2:$1}}
|
||||
${3}
|
||||
% subparagraph $2 (end)
|
||||
snippet itd
|
||||
\item[${1:description}] ${2:item}
|
||||
snippet figure
|
||||
${1:Figure}~\ref{${2:fig:}}${3}
|
||||
snippet table
|
||||
${1:Table}~\ref{${2:tab:}}${3}
|
||||
snippet listing
|
||||
${1:Listing}~\ref{${2:list}}${3}
|
||||
snippet section
|
||||
${1:Section}~\ref{${2:sec:}}${3}
|
||||
snippet page
|
||||
${1:page}~\pageref{${2}}${3}
|
||||
32
.vim/snippets/vim.snippets
Normal file
32
.vim/snippets/vim.snippets
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
snippet header
|
||||
" File: ${1:`expand('%:t')`}
|
||||
" Author: ${2:`g:snips_author`}
|
||||
" Description: ${3}
|
||||
${4:" Last Modified: `strftime("%B %d, %Y")`}
|
||||
snippet guard
|
||||
if exists('${1:did_`Filename()`}') || &cp${2: || version < 700}
|
||||
finish
|
||||
endif
|
||||
let $1 = 1${3}
|
||||
snippet f
|
||||
fun ${1:function_name}(${2})
|
||||
${3:" code}
|
||||
endf
|
||||
snippet for
|
||||
for ${1:needle} in ${2:haystack}
|
||||
${3:" code}
|
||||
endfor
|
||||
snippet wh
|
||||
while ${1:condition}
|
||||
${2:" code}
|
||||
endw
|
||||
snippet if
|
||||
if ${1:condition}
|
||||
${2:" code}
|
||||
endif
|
||||
snippet ife
|
||||
if ${1:condition}
|
||||
${2}
|
||||
else
|
||||
${3}
|
||||
endif
|
||||
58
.vim/snippets/zsh.snippets
Normal file
58
.vim/snippets/zsh.snippets
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# #!/bin/zsh
|
||||
snippet #!
|
||||
#!/bin/zsh
|
||||
|
||||
snippet if
|
||||
if ${1:condition}; then
|
||||
${2:# statements}
|
||||
fi
|
||||
snippet ife
|
||||
if ${1:condition}; then
|
||||
${2:# statements}
|
||||
else
|
||||
${3:# statements}
|
||||
fi
|
||||
snippet elif
|
||||
elif ${1:condition} ; then
|
||||
${2:# statements}
|
||||
snippet for
|
||||
for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do
|
||||
${3:# statements}
|
||||
done
|
||||
snippet fore
|
||||
for ${1:item} in ${2:list}; do
|
||||
${3:# statements}
|
||||
done
|
||||
snippet wh
|
||||
while ${1:condition}; do
|
||||
${2:# statements}
|
||||
done
|
||||
snippet until
|
||||
until ${1:condition}; do
|
||||
${2:# statements}
|
||||
done
|
||||
snippet repeat
|
||||
repeat ${1:integer}; do
|
||||
${2:# statements}
|
||||
done
|
||||
snippet case
|
||||
case ${1:word} in
|
||||
${2:pattern})
|
||||
${3};;
|
||||
esac
|
||||
snippet select
|
||||
select ${1:answer} in ${2:choices}; do
|
||||
${3:# statements}
|
||||
done
|
||||
snippet (
|
||||
( ${1:#statements} )
|
||||
snippet {
|
||||
{ ${1:#statements} }
|
||||
snippet [
|
||||
[[ ${1:test} ]]
|
||||
snippet always
|
||||
{ ${1:try} } always { ${2:always} }
|
||||
snippet fun
|
||||
function ${1:name} (${2:args}) {
|
||||
${3:# body}
|
||||
}
|
||||
44
.vim/syntax/gitAnnotate.vim
Normal file
44
.vim/syntax/gitAnnotate.vim
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
" Vim syntax file
|
||||
" Language: git annotate output
|
||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
||||
" Remark: Used by the vcscommand plugin.
|
||||
" License:
|
||||
" Copyright (c) 2009 Bob Hiestand
|
||||
"
|
||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
" of this software and associated documentation files (the "Software"), to
|
||||
" deal in the Software without restriction, including without limitation the
|
||||
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
" sell copies of the Software, and to permit persons to whom the Software is
|
||||
" furnished to do so, subject to the following conditions:
|
||||
"
|
||||
" The above copyright notice and this permission notice shall be included in
|
||||
" all copies or substantial portions of the Software.
|
||||
"
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
" IN THE SOFTWARE.
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
syn region gitName start="(\@<=" end="\( \d\d\d\d-\)\@=" contained
|
||||
syn match gitCommit /^\x\+/ contained
|
||||
syn match gitDate /\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d [+-]\d\d\d\d/ contained
|
||||
syn match gitLineNumber /\d\+)\@=/ contained
|
||||
syn region gitAnnotation start="^" end=") " oneline keepend contains=gitCommit,gitLineNumber,gitDate,gitName
|
||||
|
||||
if !exists("did_gitannotate_syntax_inits")
|
||||
let did_gitannotate_syntax_inits = 1
|
||||
hi link gitName Type
|
||||
hi link gitCommit Statement
|
||||
hi link gitDate Comment
|
||||
hi link gitLineNumber Label
|
||||
endif
|
||||
|
||||
let b:current_syntax="gitAnnotate"
|
||||
19
.vim/syntax/snippet.vim
Normal file
19
.vim/syntax/snippet.vim
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
" Syntax highlighting for snippet files (used for snipMate.vim)
|
||||
" Hopefully this should make snippets a bit nicer to write!
|
||||
syn match snipComment '^#.*'
|
||||
syn match placeHolder '\${\d\+\(:.\{-}\)\=}' contains=snipCommand
|
||||
syn match tabStop '\$\d\+'
|
||||
syn match snipCommand '`.\{-}`'
|
||||
syn match snippet '^snippet.*' transparent contains=multiSnipText,snipKeyword
|
||||
syn match multiSnipText '\S\+ \zs.*' contained
|
||||
syn match snipKeyword '^snippet'me=s+8 contained
|
||||
syn match snipError "^[^#s\t].*$"
|
||||
|
||||
hi link snipComment Comment
|
||||
hi link multiSnipText String
|
||||
hi link snipKeyword Keyword
|
||||
hi link snipComment Comment
|
||||
hi link placeHolder Special
|
||||
hi link tabStop Special
|
||||
hi link snipCommand String
|
||||
hi link snipError Error
|
||||
47
.vimrc
47
.vimrc
|
|
@ -38,6 +38,8 @@ let g:Tb_MaxSize=0
|
|||
let g:Tb_MapCTabSwitchBufs = 1
|
||||
au Filetype html,xml,xsl source ~/.vim/closetag.vim
|
||||
|
||||
"filetype plugin on
|
||||
|
||||
|
||||
"MiniBufExplore Options
|
||||
"let g:miniBufExplMapWindowNavVim = 1
|
||||
|
|
@ -58,6 +60,7 @@ set t_Sb=ESC[4%dm
|
|||
"nnoremap gK :tabclose<CR>
|
||||
"nnoremap gn gt
|
||||
"nnoremap gp gT
|
||||
nmap gt :NERDTreeToggle<CR>
|
||||
nnoremap gK :bdelete<CR>
|
||||
nnoremap gn :bn<CR>
|
||||
nnoremap gp :bp<CR>
|
||||
|
|
@ -66,19 +69,19 @@ nnoremap gw g*
|
|||
nmap P o<Esc>p
|
||||
nnoremap j gj
|
||||
nnoremap k gk
|
||||
vnoremap j gj
|
||||
vnoremap k gk
|
||||
xnoremap j gj
|
||||
xnoremap k gk
|
||||
nnoremap <Down> gj
|
||||
nnoremap <Up> gk
|
||||
vnoremap <Down> gj
|
||||
vnoremap <Up> gk
|
||||
xnoremap <Down> gj
|
||||
xnoremap <Up> gk
|
||||
inoremap <Down> <C-o>gj
|
||||
inoremap <Up> <C-o>gk
|
||||
"nnoremap <C-i> <C-a>
|
||||
nnoremap <C-a> ^
|
||||
nnoremap <C-e> $
|
||||
vnoremap <C-a> ^
|
||||
vnoremap <C-e> $
|
||||
xnoremap <C-a> ^
|
||||
xnoremap <C-e> $
|
||||
inoremap <C-a> <C-O>^
|
||||
inoremap <C-e> <C-O>$
|
||||
imap <C-c> <Esc>
|
||||
|
|
@ -136,3 +139,35 @@ com! DiffSaved call s:DiffWithSaved()
|
|||
"inoremap ;a <esc>
|
||||
|
||||
"cd /mw/barak/gd-es-bug
|
||||
"
|
||||
function! Find(name)
|
||||
let l:_name = substitute(a:name, "\\s", "*", "g")
|
||||
"let l:list=system("find . -iname '*".l:_name."*' -not -name \"*.class\" -and -not -name \"*.swp\" | perl -ne 'print \"$.\\t$_\"'")
|
||||
let l:list=system("find . -path \"*/.svn\" -prune -o -iname '*".l:_name."*' -not -name \"*.class\" -and -not -name \"*.swp\" -print | perl -ne 'print \"$.\\t$_\"'")
|
||||
let l:num=strlen(substitute(l:list, "[^\n]", "", "g"))
|
||||
if l:num < 1
|
||||
echo "'".a:name."' not found"
|
||||
return
|
||||
endif
|
||||
if l:num != 1
|
||||
echo l:list
|
||||
let l:input=input("Which ? (<enter>=nothing)\n")
|
||||
if strlen(l:input)==0
|
||||
return
|
||||
endif
|
||||
if strlen(substitute(l:input, "[0-9]", "", "g"))>0
|
||||
echo "Not a number"
|
||||
return
|
||||
endif
|
||||
if l:input<1 || l:input>l:num
|
||||
echo "Out of range"
|
||||
return
|
||||
endif
|
||||
let l:line=matchstr("\n".l:list, "\n".l:input."\t[^\n]*")
|
||||
else
|
||||
let l:line=l:list
|
||||
endif
|
||||
let l:line=substitute(l:line, "^[^\t]*\t./", "", "")
|
||||
execute ":e ".l:line
|
||||
endfunction
|
||||
command! -nargs=1 Find :call Find("<args>")
|
||||
|
|
|
|||
2
.zshrc
2
.zshrc
|
|
@ -3,7 +3,7 @@ autoload -U compinit
|
|||
compinit
|
||||
setopt extended_glob
|
||||
bindkey -e
|
||||
ZLS_COLORS=$LS_COLORS
|
||||
#ZLS_COLORS=$LS_COLORS
|
||||
|
||||
|
||||
setopt prompt_subst
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue