1
0
mirror of https://github.com/gryf/.vim.git synced 2025-12-18 03:50:30 +01:00

Plugins update

This commit is contained in:
2012-03-12 17:00:46 +01:00
parent c2500d764e
commit 7cbe6dca6d
37 changed files with 977 additions and 589 deletions

View File

@@ -198,17 +198,20 @@ fu! s:parseline(line)
endf
" Public {{{1
fu! ctrlp#buffertag#init(fname)
let fname = exists('s:bufname') ? s:bufname : a:fname
let bufs = exists('s:btmode') && s:btmode ? ctrlp#allbufs() : [fname]
let bufs = exists('s:btmode') && s:btmode
\ ? filter(ctrlp#buffers(), 'filereadable(v:val)')
\ : [exists('s:bufname') ? s:bufname : a:fname]
let lines = []
for each in bufs
let tftype = get(split(getbufvar(each, '&ft'), '\.'), 0, '')
cal extend(lines, s:process(each, tftype))
endfo
if !hlexists('CtrlPTabExtra')
hi link CtrlPTabExtra Comment
if has('syntax') && exists('g:syntax_on')
if !hlexists('CtrlPTabExtra')
hi link CtrlPTabExtra Comment
en
sy match CtrlPTabExtra '\zs\t.*\ze$'
en
sy match CtrlPTabExtra '\zs\t.*\ze$'
retu lines
endf

View File

@@ -0,0 +1,106 @@
" =============================================================================
" File: autoload/ctrlp/changes.vim
" Description: Change list extension - Jump to a recent change in any buffer
" Author: Kien Nguyen <github.com/kien>
" =============================================================================
" User Configuration {{{1
" Enable:
" let g:ctrlp_extensions += ['changes']
" Create Some Commands:
" " Single buffer
" com! -n=? -com=buffer CtrlPChange
" \ cal ctrlp#init(ctrlp#changes#cmd(0, <q-args>))
" " All listed buffers
" com! CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1))
"}}}
" Init {{{1
if exists('g:loaded_ctrlp_changes') && g:loaded_ctrlp_changes
fini
en
let g:loaded_ctrlp_changes = 1
let s:changes_var = {
\ 'init': 'ctrlp#changes#init(s:bufnr, s:crfile)',
\ 'accept': 'ctrlp#changes#accept',
\ 'lname': 'changes',
\ 'sname': 'chs',
\ 'exit': 'ctrlp#changes#exit()',
\ 'type': 'tabe',
\ }
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
\ ? add(g:ctrlp_ext_vars, s:changes_var) : [s:changes_var]
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
" Utilities {{{1
fu! s:changelist(bufnr)
sil! exe 'noa hid b' a:bufnr
redi => result
sil! changes
redi END
retu map(split(result, "\n")[1:], 'tr(v:val, " ", " ")')
endf
fu! s:process(clines, ...)
let [clines, evas] = [[], []]
for each in a:clines
let parts = matchlist(each, '\v^.\s*\d+\s+(\d+)\s+(\d+)\s(.*)$')
if !empty(parts)
if parts[3] == '' | let parts[3] = ' ' | en
cal add(clines, parts[3].' |'.a:1.':'.a:2.'|'.parts[1].':'.parts[2].'|')
en
endfo
retu reverse(filter(clines, 'count(clines, v:val) == 1'))
endf
" Public {{{1
fu! ctrlp#changes#init(original_bufnr, fname)
let fname = exists('s:bufname') ? s:bufname : a:fname
let bufs = exists('s:clmode') && s:clmode
\ ? filter(ctrlp#buffers(), 'filereadable(v:val)') : [fname]
let [swb, &swb] = [&swb, '']
let lines = []
for each in bufs
let [bufnr, fnamet] = [bufnr('^'.each.'$'), fnamemodify(each, ':t')]
if bufnr > 0
cal extend(lines, s:process(s:changelist(bufnr), bufnr, fnamet))
en
endfo
sil! exe 'noa hid b' a:original_bufnr
let &swb = swb
let g:ctrlp_nolimit = 1
if has('syntax') && exists('g:syntax_on')
cal ctrlp#syntax()
if !hlexists('CtrlPTabExtra')
hi link CtrlPTabExtra Comment
en
sy match CtrlPTabExtra '\zs\t.*\ze$'
en
retu lines
endf
fu! ctrlp#changes#accept(mode, str)
let info = matchlist(a:str, '\t|\(\d\+\):[^|]\+|\(\d\+\):\(\d\+\)|$')
let bufnr = str2nr(get(info, 1))
if bufnr
cal ctrlp#acceptfile(a:mode, fnamemodify(bufname(bufnr), ':p'))
cal cursor(get(info, 2), get(info, 3))
sil! norm! zvzz
en
endf
fu! ctrlp#changes#cmd(mode, ...)
let s:clmode = a:mode
if a:0 && !empty(a:1)
let s:bufname = fnamemodify(a:1, ':p')
en
retu s:id
endf
fu! ctrlp#changes#exit()
unl! s:clmode s:bufname
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@@ -31,30 +31,31 @@ let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
" Public {{{1
fu! ctrlp#line#init()
let [bufs, lines] = [ctrlp#allbufs(), []]
let [bufs, lines] = [filter(ctrlp#buffers(), 'filereadable(v:val)'), []]
for each in bufs
let from_file = readfile(each)
let [fnamet, from_file] = [fnamemodify(each, ':t'), readfile(each)]
cal map(from_file, 'tr(v:val, '' '', '' '')')
let [id, len_ff, bufnr] = [1, len(from_file), bufnr('^'.each.'$')]
wh id <= len_ff
let from_file[id-1] .= ' #:'.bufnr.':'.id
let from_file[id-1] .= ' |'.fnamet.'|'.bufnr.':'.id.'|'
let id += 1
endw
cal filter(from_file, 'v:val !~ ''^\s*\t#:\d\+:\d\+$''')
cal filter(from_file, 'v:val !~ ''^\s*\t|[^|]\+|\d\+:\d\+|$''')
cal extend(lines, from_file)
endfo
if !hlexists('CtrlPTabExtra')
hi link CtrlPTabExtra Comment
if has('syntax') && exists('g:syntax_on')
if !hlexists('CtrlPTabExtra')
hi link CtrlPTabExtra Comment
en
sy match CtrlPTabExtra '\zs\t.*\ze$'
en
sy match CtrlPTabExtra '\zs\t.*\ze$'
retu lines
endf
fu! ctrlp#line#accept(mode, str)
let info = get(split(a:str, '\t#:\ze\d\+:\d\+$'), 1, 0)
let bufnr = str2nr(get(split(info, ':'), 0, 0))
let linenr = get(split(info, ':'), 1, 0)
if bufnr
let info = matchlist(a:str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$')
let [bufnr, linenr] = [str2nr(get(info, 1)), get(info, 2)]
if bufnr > 0
cal ctrlp#acceptfile(a:mode, fnamemodify(bufname(bufnr), ':p'), linenr)
en
endf

View File

@@ -36,8 +36,13 @@ fu! ctrlp#mrufiles#list(bufnr, ...) "{{{1
let s:cafile = s:cadir.ctrlp#utils#lash().'cache.txt'
en
if a:0 && a:1 == 2
cal ctrlp#utils#writecache([], s:cadir, s:cafile)
retu []
let mrufs = []
if a:0 == 2
let mrufs = ctrlp#utils#readfile(s:cafile)
cal filter(mrufs, 'index(a:2, v:val) < 0')
en
cal ctrlp#utils#writecache(mrufs, s:cadir, s:cafile)
retu map(mrufs, 'fnamemodify(v:val, '':.'')')
en
" Get the list
let mrufs = ctrlp#utils#readfile(s:cafile)
@@ -52,15 +57,11 @@ fu! ctrlp#mrufiles#list(bufnr, ...) "{{{1
en
" Return the list with the active buffer removed
if bufnr == -1
let crf = fnamemodify(bufname(winbufnr(winnr('#'))), ':p')
let crf = exists('+ssl') ? tr(crf, '/', '\') : crf
let mrufs = empty(crf) ? mrufs : filter(mrufs, 'v:val !='.s:csen.' crf')
if s:re
let cwd = exists('+ssl') ? tr(getcwd(), '/', '\') : getcwd()
cal filter(mrufs, '!stridx(v:val, cwd)')
en
cal map(mrufs, 'fnamemodify(v:val, '':.'')')
retu mrufs
retu map(mrufs, 'fnamemodify(v:val, '':.'')')
en
" Remove old entry
cal filter(mrufs, 'v:val !='.s:csen.' fn')

View File

@@ -30,10 +30,12 @@ endf
" Public {{{1
fu! ctrlp#quickfix#init()
let g:ctrlp_nolimit = 1
if !hlexists('CtrlPqfLineCol')
hi link CtrlPqfLineCol Search
if has('syntax') && exists('g:syntax_on')
if !hlexists('CtrlPqfLineCol')
hi link CtrlPqfLineCol Search
en
sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|'
en
sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|'
retu map(getqflist(), 's:lineout(v:val)')
endf
@@ -48,6 +50,7 @@ fu! ctrlp#quickfix#accept(mode, str)
exe cmd ctrlp#fnesc(filpath)
cal cursor(items[2], items[3])
sil! norm! zvzz
cal ctrlp#setlcdir()
endf
fu! ctrlp#quickfix#id()

View File

@@ -23,14 +23,6 @@ let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
" Utilities {{{1
fu! s:nodup(items)
let dict = {}
for each in a:items
cal extend(dict, { each : 0 })
endfo
retu keys(dict)
endf
fu! s:findcount(str)
let [tg, fname] = split(a:str, '\t\+\ze[^\t]\+$')
let [fname, tgs] = [expand(fname, 1), taglist('^'.tg.'$')]
@@ -67,30 +59,32 @@ endf
" Public {{{1
fu! ctrlp#tag#init(tagfiles)
if empty(a:tagfiles) | retu [] | en
let [tagfiles, g:ctrlp_alltags] = [sort(s:nodup(a:tagfiles)), []]
let g:ctrlp_alltags = []
let tagfiles = sort(filter(a:tagfiles, 'count(a:tagfiles, v:val) == 1'))
for each in tagfiles
let alltags = s:filter(ctrlp#utils#readfile(each))
cal extend(g:ctrlp_alltags, alltags)
endfo
if !hlexists('CtrlPTabExtra')
hi link CtrlPTabExtra Comment
if has('syntax') && exists('g:syntax_on')
if !hlexists('CtrlPTabExtra')
hi link CtrlPTabExtra Comment
en
sy match CtrlPTabExtra '\zs\t.*\ze$'
en
sy match CtrlPTabExtra '\zs\t.*\ze$'
retu g:ctrlp_alltags
endf
fu! ctrlp#tag#accept(mode, str)
cal ctrlp#exit()
let str = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\ze\t')
let [md, tg] = [a:mode, split(str, '^[^\t]\+\zs\t')[0]]
let fnd = s:findcount(str)
let [tg, fnd] = [split(str, '^[^\t]\+\zs\t')[0], s:findcount(str)]
let cmds = {
\ 't': ['tab sp', 'tab stj'],
\ 'h': ['sp', 'stj'],
\ 'v': ['vs', 'vert stj'],
\ 'e': ['', 'tj'],
\ }
let cmd = fnd[0] == 1 ? cmds[md][0] : cmds[md][1]
let cmd = fnd[0] == 1 ? cmds[a:mode][0] : cmds[a:mode][1]
let cmd = cmd == 'tj' && &modified ? 'hid '.cmd : cmd
let cmd = cmd =~ '^tab' ? tabpagenr('$').cmd : cmd
if fnd[0] == 1
@@ -101,6 +95,7 @@ fu! ctrlp#tag#accept(mode, str)
el
exe cmd tg
en
cal ctrlp#setlcdir()
endf
fu! ctrlp#tag#id()

View File

@@ -13,7 +13,7 @@
" Init {{{1
if ( exists('g:loaded_ctrlp_undo') && g:loaded_ctrlp_undo )
\ || !( v:version > 702 && has('patch005') )
\ || !( v:version > 703 || ( v:version == 703 && has('patch005') ) )
fini
en
let g:loaded_ctrlp_undo = 1
@@ -102,7 +102,9 @@ endf
fu! ctrlp#undo#init(undo)
let entries = a:undo['entries']
if empty(entries) | retu [] | en
cal s:syntax()
if has('syntax') && exists('g:syntax_on')
cal s:syntax()
en
let g:ctrlp_nolimit = 1
let entries = sort(s:dict2list(s:flatten(entries)), 's:compval')
retu map(entries, 'v:val[1]." [".v:val[0]."]"')