Extend the nosplit option

* Accept filetypes in addition to bufnames.
This commit is contained in:
Kien N 2011-11-09 19:29:08 +07:00
parent b028010343
commit faff324fb7
2 changed files with 11 additions and 12 deletions

View File

@ -10,7 +10,7 @@ fu! s:opts()
let opts = {
\ 'g:ctrlp_by_filename': ['s:byfname', 0],
\ 'g:ctrlp_clear_cache_on_exit': ['s:cconex', 1],
\ 'g:ctrlp_dont_split': ['s:nosplit', []],
\ 'g:ctrlp_dont_split': ['s:nosplit', ''],
\ 'g:ctrlp_dotfiles': ['s:dotfiles', 1],
\ 'g:ctrlp_extensions': ['s:extensions', []],
\ 'g:ctrlp_highlight_match': ['s:mathi', [1, 'Identifier']],
@ -1031,15 +1031,13 @@ fu! s:normbuf()
endf
fu! s:normcmd(cmd)
if match([bufname('%'), &l:ft], s:nosplit) >=0 | retu a:cmd | en
" Find a regular buffer
let norwins = s:normbuf()
let norwin = empty(norwins) ? 0 : norwins[0]
" Don't split these
for each in s:nosplit | if match(bufname('%'), each) >= 0
retu a:cmd
en | endfo
" If there's at least 1 normal buffer
" If there's at least 1
if norwin
" But not the current one
" But not the current
if index(norwins, winnr()) < 0
exe norwin.'winc w'
en

View File

@ -266,12 +266,13 @@ all files, each in a vertical split.
*'g:ctrlp_dont_split'*
When opening a file with <cr>, |CtrlP| avoids opening it in windows created by
plugins, help or quickfix. Use this to setup some exceptions: >
let g:ctrlp_dont_split = []
plugins. Use this to setup some exceptions: >
let g:ctrlp_dont_split = ''
<
Accepted values are partial names of the special buffers.
Examples: >
let g:ctrlp_dont_split = ['Netrw']
Acceptable values are partial names or filetypes of the special buffers.
Use |regexp| to specify the pattern.
Example: >
let g:ctrlp_dont_split = 'netrw\|myplugin'
<