1. kien
  2. ctrlp.vim

Commits

kien  committed 6554cf5 Draft

Don't check for CtrlPLinePre [...]

Use ts-prompt automatically when possible
Add a max results setting
Accept an optional bookmark name argument
tags for ocaml

  • Participants
  • Parent commits 3d0a0e2
  • Branches default

Comments (0)

Files changed (5)

File autoload/ctrlp.vim

View file
  • Ignore whitespace
 		\ s:mw =~ 'min:[^,]\+' ? str2nr(matchstr(s:mw, 'min:\zs\d\+')) : 1
 	let [s:mw_max, s:mw_min] = [max([s:mw_max, 1]), max([s:mw_min, 1])]
 	let s:mw_min = min([s:mw_min, s:mw_max])
+	let s:mw_res =
+		\ s:mw =~ 'results:[^,]\+' ? str2nr(matchstr(s:mw, 'results:\zs\d\+'))
+		\ : min([s:mw_max, &lines])
+	let s:mw_res = max([s:mw_res, 1])
 endf
 "}}}1
 " * Open & Close {{{1
 	let s:martcs = &scs && str =~ '\u' ? '\C' : ''
 	let pat = s:matcher == {} ? s:SplitPattern(str) : str
 	let lines = s:nolim == 1 && empty(str) ? copy(g:ctrlp_lines)
-		\ : s:MatchedItems(g:ctrlp_lines, pat, s:winmaxh)
+		\ : s:MatchedItems(g:ctrlp_lines, pat, s:mw_res)
 	cal s:Render(lines, pat)
 endf
 
 fu! ctrlp#syntax()
 	if ctrlp#nosy() | retu | en
 	for [ke, va] in items(s:hlgrps) | cal ctrlp#hicheck('CtrlP'.ke, va) | endfo
-	if !hlexists('CtrlPLinePre')
-		\ && synIDattr(synIDtrans(hlID('Normal')), 'bg') !~ '^-1$\|^$'
+	if synIDattr(synIDtrans(hlID('Normal')), 'bg') !~ '^-1$\|^$'
 		sil! exe 'hi CtrlPLinePre '.( has("gui_running") ? 'gui' : 'cterm' ).'fg=bg'
 	en
 	sy match CtrlPNoEntries '^ == NO ENTRIES ==$'

File autoload/ctrlp/bookmarkdir.vim

View file
  • Ignore whitespace
 	en
 endf
 
-fu! ctrlp#bookmarkdir#add(dir)
+fu! ctrlp#bookmarkdir#add(dir, ...)
 	let str = 'Directory to bookmark: '
 	let cwd = a:dir != '' ? a:dir : s:getinput(str, getcwd(), 'dir')
 	if cwd == '' | retu | en
 	let cwd = fnamemodify(cwd, ':p')
-	let name = s:getinput('Bookmark as: ', cwd)
+	let name = a:0 && a:1 != '' ? a:1 : s:getinput('Bookmark as: ', cwd)
 	if name == '' | retu | en
 	let name = tr(name, '	', ' ')
 	cal s:savebookmark(name, cwd)

File autoload/ctrlp/buffertag.vim

View file
  • Ignore whitespace
 	\ 'lisp'   : '%slisp%slisp%sf',
 	\ 'lua'    : '%slua%slua%sf',
 	\ 'make'   : '%smake%smake%sm',
+	\ 'ocaml'  : '%socaml%socaml%scmMvtfCre',
 	\ 'pascal' : '%spascal%spascal%sfp',
 	\ 'perl'   : '%sperl%sperl%sclps',
 	\ 'php'    : '%sphp%sphp%scdvf',

File autoload/ctrlp/tag.vim

View file
  • Ignore whitespace
 let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
 " Utilities {{{1
 fu! s:findcount(str)
-	let [tg, fname] = split(a:str, '\t\+\ze[^\t]\+$')
+	let [tg, ofname] = split(a:str, '\t\+\ze[^\t]\+$')
 	let tgs = taglist('^'.tg.'$')
 	if len(tgs) < 2
-		retu [1, 1]
+		retu [0, 0, 0, 0]
 	en
 	let bname = fnamemodify(bufname('%'), ':p')
-	let fname = expand(fnamemodify(simplify(fname), ':s?^[.\/]\+??:p:.'), 1)
-	let [fnd, ct, pos, idx] = [0, 0, 0, 0]
-	wh idx < len(tgs)
-		if bname == fnamemodify(tgs[idx]["filename"], ':p')
-			cal insert(tgs, remove(tgs, idx))
-			brea
-		en
-		let idx += 1
-	endw
-	for each in tgs
-		let ct += 1
-		let fulname = fnamemodify(each["filename"], ':p')
+	let fname = expand(fnamemodify(simplify(ofname), ':s?^[.\/]\+??:p:.'), 1)
+	let [fnd, cnt, pos, ctgs, otgs] = [0, 0, 0, [], []]
+	for tgi in tgs
+		let lst = bname == fnamemodify(tgi["filename"], ':p') ? 'ctgs' : 'otgs'
+		cal call('add', [{lst}, tgi])
+	endfo
+	let ntgs = ctgs + otgs
+	for tgi in ntgs
+		let cnt += 1
+		let fulname = fnamemodify(tgi["filename"], ':p')
 		if stridx(fulname, fname) >= 0
 			\ && strlen(fname) + stridx(fulname, fname) == strlen(fulname)
 			let fnd += 1
-			let pos = ct
+			let pos = cnt
 		en
-		if fnd > 1 | brea | en
 	endfo
-	retu [fnd, pos]
+	let cnt = 0
+	for tgi in ntgs
+		let cnt += 1
+		if tgi["filename"] == ofname
+			let [fnd, pos] = [0, cnt]
+		en
+	endfo
+	retu [1, fnd, pos, len(ctgs)]
 endf
 
 fu! s:filter(tags)
 fu! ctrlp#tag#accept(mode, str)
 	cal ctrlp#exit()
 	let str = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\ze\t')
-	let [tg, fnd] = [split(str, '^[^\t]\+\zs\t')[0], s:findcount(str)]
+	let [tg, fdcnt] = [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[a:mode][0] : cmds[a:mode][1]
+	let utg = fdcnt[3] < 2 && fdcnt[0] == 1 && fdcnt[1] == 1
+	let cmd = !fdcnt[0] || utg ? cmds[a:mode][0] : cmds[a:mode][1]
 	let cmd = a:mode == 'e' && ctrlp#modfilecond(!&aw)
 		\ ? ( cmd == 'tj' ? 'stj' : 'sp' ) : cmd
 	let cmd = a:mode == 't' ? ctrlp#tabcount().cmd : cmd
-	if fnd[0] == 1
+	if !fdcnt[0] || utg
 		if cmd != ''
 			exe cmd
 		en
 		let save_cst = &cst
 		set cst&
-		cal feedkeys(":".fnd[1]."ta ".tg."\r", 'nt')
+		cal feedkeys(":".( utg ? fdcnt[2] : "" )."ta ".tg."\r", 'nt')
 		let &cst = save_cst
 	el
-		cal feedkeys(":".cmd." ".tg."\r", 'nt')
+		let ext = ""
+		if fdcnt[1] < 2 && fdcnt[2]
+			let [sav_more, &more] = [&more, 0]
+			let ext = fdcnt[2]."\r".":let &more = ".sav_more."\r"
+		en
+		cal feedkeys(":".cmd." ".tg."\r".ext, 'nt')
 	en
 	cal ctrlp#setlcdir()
 endf

File doc/ctrlp.txt

View file
  • Ignore whitespace
   let g:ctrlp_match_window = ''
 <
 Example: >
-  let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10'
+  let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10,results:10'
 <
 The position: (default: bottom)
   top - show the match window at the top of the screen.
   min:{n} - show minimum {n} lines (default: 1).
   max:{n} - show maximum {n} lines (default: 10).
 
+The maximum number of results:
+  results:{n} - list maximum {n} results (default: sync with max height).
+
 Note: When a setting isn't set, its default value will be used.
 
                                                       *'g:ctrlp_switch_buffer'*
     * Christopher Fredén <github.com/icetan>
     * Zahary Karadjov <github.com/zah>
     * Jo De Boeck <github.com/grimpy>
+    * Rudi Grinberg <github.com/rgrinberg>
+    * Timothy Mellor <github.com/mellort>
 
 ===============================================================================
 CHANGELOG                                                     *ctrlp-changelog*