Skip to content

Commit 0fb2c58

Browse files
Merge pull request #182 from ludovicchabant/issue95
Add option `ctrlp_match_current_file` to include the current file in match results
2 parents 97490de + faf1dd5 commit 0fb2c58

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

autoload/ctrlp.vim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
9292
\ 'line_prefix': ['s:lineprefix', '> '],
9393
\ 'open_single_match': ['s:opensingle', []],
9494
\ 'brief_prompt': ['s:brfprt', 0],
95+
\ 'match_current_file': ['s:matchcrfile', 0],
9596
\ }, {
9697
\ 'open_multiple_files': 's:opmul',
9798
\ 'regexp': 's:regexp',
@@ -494,9 +495,12 @@ fu! s:MatchIt(items, pat, limit, exc)
494495
\ : s:martcs.a:pat
495496
for item in a:items
496497
let id += 1
497-
try | if !( s:ispath && item == a:exc ) && call(s:mfunc, [item, pat]) >= 0
498-
cal add(lines, item)
499-
en | cat | brea | endt
498+
try
499+
if (s:matchcrfile || !( s:ispath && item == a:exc )) &&
500+
\call(s:mfunc, [item, pat]) >= 0
501+
cal add(lines, item)
502+
en
503+
cat | brea | endt
500504
if a:limit > 0 && len(lines) >= a:limit | brea | en
501505
endfo
502506
let s:mdata = [s:dyncwd, s:itemtype, s:regexp, s:sublist(a:items, id, -1)]

doc/ctrlp.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Overview:~
6767
|ctrlp_line_prefix|...........Prefix for each line in ctrlp window.
6868
|ctrlp_open_single_match|.....Automatically accept when only one candidate.
6969
|ctrlp_brief_prompt|..........Exit CtrlP on empty prompt by <bs>.
70+
|ctrlp_match_current_file|....Include current file in match entries.
7071

7172
MRU mode:
7273
|ctrlp_mruf_max|..............Max MRU entries to remember.
@@ -448,6 +449,16 @@ as the default input: >
448449
<
449450
This option works well together with |g:ctrlp_open_single_match|
450451

452+
453+
*'g:ctrlp_match_current_file'*
454+
Includes the current file in the match entries:
455+
let g:ctrlp_match_current_file = 1
456+
457+
By default, the current file is excluded from the list.
458+
459+
Note: does not apply when |g:ctrlp_match_func| is used.
460+
461+
451462
*'g:ctrlp_abbrev'*
452463
Define input abbreviations that can be expanded (either internally or visibly)
453464
in the prompt: >

0 commit comments

Comments
 (0)