forked from kien/ctrlp.vim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Allow running commands like `:diffthis` when opening multiple files. * Add experimental extensions: + undo.vim (requires v7.3.005+) + rtscript.vim (find vimscripts in runtimepath) * Include the workaround for <bs> and <c-h> for MS-Win. Resolve kien#62. * Mention custom_ignore in readme and on the homepage. Resolve kien#63. * Check the present of cwd in returned paths. Fix kien#64. * Trigger Vim to remove cwd from display-names. Fix kien#65. * Some internal changes and additions.
- Loading branch information
Showing
10 changed files
with
391 additions
and
135 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
" ============================================================================= | ||
" File: autoload/ctrlp/rtscript.vim | ||
" Description: Runtime scripts extension - Find vimscripts in runtimepath | ||
" Author: Kien Nguyen <github.com/kien> | ||
" ============================================================================= | ||
|
||
" User Configuration {{{1 | ||
" Enable: | ||
" let g:ctrlp_extensions += ['rtscript'] | ||
" Create A Command: | ||
" com! CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id()) | ||
"}}} | ||
|
||
" Init {{{1 | ||
if exists('g:loaded_ctrlp_rtscript') && g:loaded_ctrlp_rtscript | ||
fini | ||
en | ||
let [g:loaded_ctrlp_rtscript, g:ctrlp_newrts] = [1, 0] | ||
|
||
let s:rtscript_var = ['ctrlp#rtscript#init()', 'ctrlp#rtscript#accept', | ||
\ 'runtime scripts', 'rts'] | ||
|
||
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars) | ||
\ ? add(g:ctrlp_ext_vars, s:rtscript_var) : [s:rtscript_var] | ||
|
||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) | ||
" Public {{{1 | ||
fu! ctrlp#rtscript#init() | ||
if g:ctrlp_newrts || !exists('g:ctrlp_rtscache') | ||
let entries = split(globpath(&rtp, '**/*.\(vim\|txt\)'), "\n") | ||
let [g:ctrlp_rtscache, g:ctrlp_newrts] = [ctrlp#dirnfile(entries)[1], 0] | ||
en | ||
retu g:ctrlp_rtscache | ||
endf | ||
|
||
fu! ctrlp#rtscript#accept(mode, str) | ||
cal ctrlp#acceptfile(a:mode, a:str) | ||
endf | ||
|
||
fu! ctrlp#rtscript#id() | ||
retu s:id | ||
endf | ||
"}}} | ||
|
||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
" ============================================================================= | ||
" File: autoload/ctrlp/undo.vim | ||
" Description: Undo extension - Browse undo history (requires Vim 7.3.005+) | ||
" Author: Kien Nguyen <github.com/kien> | ||
" ============================================================================= | ||
|
||
" User Configuration {{{1 | ||
" Enable: | ||
" let g:ctrlp_extensions += ['undo'] | ||
" Create A Command: | ||
" com! CtrlPUndo cal ctrlp#init(ctrlp#undo#id()) | ||
"}}} | ||
|
||
" Init {{{1 | ||
if ( exists('g:loaded_ctrlp_undo') && g:loaded_ctrlp_undo ) | ||
\ || !( v:version > 702 && has('patch005') ) | ||
fini | ||
en | ||
let g:loaded_ctrlp_undo = 1 | ||
|
||
let s:undo_var = ['ctrlp#undo#init(s:undotree)', 'ctrlp#undo#accept', | ||
\ 'undo', 'udo'] | ||
|
||
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars) | ||
\ ? add(g:ctrlp_ext_vars, s:undo_var) : [s:undo_var] | ||
|
||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) | ||
" Utilities {{{1 | ||
fu! s:flatten(tree) | ||
let flatdict = {} | ||
for each in a:tree | ||
cal extend(flatdict, { each['seq'] : each['time'] }) | ||
if has_key(each, 'alt') | ||
cal extend(flatdict, s:flatten(each['alt'])) | ||
en | ||
endfo | ||
retu flatdict | ||
endf | ||
|
||
fu! s:humantime(nr) | ||
let elapsed = localtime() - a:nr | ||
let mins = elapsed / 60 | ||
let hrs = elapsed / 3600 | ||
let days = elapsed / 86400 | ||
let wks = elapsed / 604800 | ||
let mons = elapsed / 2592000 | ||
let yrs = elapsed / 31536000 | ||
let text = [ | ||
\ ' second ago', | ||
\ ' seconds ago', | ||
\ ' minutes ago', | ||
\ ' hours ago', | ||
\ ' days ago', | ||
\ ' weeks ago', | ||
\ ' months ago', | ||
\ ' years ago', | ||
\ ] | ||
if yrs > 1 | ||
retu yrs.text[7] | ||
elsei mons > 1 | ||
retu mons.text[6] | ||
elsei wks > 1 | ||
retu wks.text[5] | ||
elsei days > 1 | ||
retu days.text[4] | ||
elsei hrs > 1 | ||
retu hrs.text[3] | ||
elsei mins > 1 | ||
retu mins.text[2] | ||
elsei elapsed == 1 | ||
retu elapsed.text[0] | ||
elsei elapsed < 120 | ||
retu elapsed.text[1] | ||
en | ||
endf | ||
|
||
fu! s:syntax() | ||
sy match CtrlPUndoT '\d\+ \zs[^ ]\+\ze' | ||
sy match CtrlPUndoBr '\[\|\]' | ||
sy match CtrlPUndoNr '\[\d\+\]$' contains=CtrlPUndoBr | ||
hi link CtrlPUndoT Directory | ||
hi link CtrlPUndoBr Comment | ||
hi link CtrlPUndoNr String | ||
endf | ||
|
||
fu! s:dict2list(dict) | ||
let dict = map(a:dict, 's:humantime(v:val)') | ||
retu map(keys(dict), 'eval(''[v:val, dict[v:val]]'')') | ||
endf | ||
|
||
fu! s:compval(...) | ||
retu a:2[0] - a:1[0] | ||
endf | ||
" Public {{{1 | ||
fu! ctrlp#undo#init(undo) | ||
let entries = a:undo['entries'] | ||
if empty(entries) | retu [] | en | ||
cal s:syntax() | ||
let g:ctrlp_nolimit = 1 | ||
let entries = sort(s:dict2list(s:flatten(entries)), 's:compval') | ||
retu map(entries, 'v:val[1]." [".v:val[0]."]"') | ||
endf | ||
|
||
fu! ctrlp#undo#accept(mode, str) | ||
let undon = matchstr(a:str, '\[\zs\d\+\ze\]') | ||
if empty(undon) | retu | en | ||
cal ctrlp#exit() | ||
exe 'u' undon | ||
endf | ||
|
||
fu! ctrlp#undo#id() | ||
retu s:id | ||
endf | ||
"}}} | ||
|
||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 |
Oops, something went wrong.