Skip to content

Commit

Permalink
Add g:cpsm_match_empty_query
Browse files Browse the repository at this point in the history
  • Loading branch information
nixprime committed Jan 26, 2016
1 parent e97b7c4 commit aed290f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@ All of the following options are set by adding

to your .vimrc.

- As shown below, cpsm will still attempt to perform matching on an empty query
based on the open file in the current buffer. This interacts badly with e.g.
CtrlPMRU. To disable all matching on empty queries, set
`g:cpsm_match_empty_query` to 0. If you want empty query matching to only be
disabled for MRU mode, it's recommended that you configure this in your
bindings, e.g.:

nnoremap <silent> <C-o> :let g:cpsm_match_empty_query = 0<CR>:CtrlPMRU<CR>
nnoremap <silent> <C-p> :let g:cpsm_match_empty_query = 1<CR>:CtrlP<CR>

Note that if you do the above, you may need to prevent CtrlP from overriding
your binding by setting `let g:ctrlp_map = ''`.

- `g:cpsm_highlight_mode` controls how matches are highlighted. Valid highlight
modes are:

Expand Down
12 changes: 10 additions & 2 deletions autoload/cpsm.vim
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
if !exists('g:cpsm_highlight_mode')
let g:cpsm_highlight_mode = 'detailed'
endif
if !exists('g:cpsm_match_empty_query')
let g:cpsm_match_empty_query = 1
endif
if !exists('g:cpsm_max_threads')
if has("win32unix")
" Synchronization primitives are extremely slow on Cygwin:
Expand All @@ -38,8 +41,13 @@ let s:script_dir = escape(expand('<sfile>:p:h'), '\')
execute 'pyfile ' . s:script_dir . '/cpsm.py'

function cpsm#CtrlPMatch(items, str, limit, mmode, ispath, crfile, regex)
let s:match_crfile = exists('g:ctrlp_match_current_file') ? g:ctrlp_match_current_file : 0
py ctrlp_match()
if empty(a:str) && g:cpsm_match_empty_query == 0
let s:results = a:items[0:(a:limit)]
let s:regexes = []
else
let s:match_crfile = exists('g:ctrlp_match_current_file') ? g:ctrlp_match_current_file : 0
py ctrlp_match()
endif
call clearmatches()
" Apply highlight regexes.
for r in s:regexes
Expand Down

0 comments on commit aed290f

Please sign in to comment.