Skip to content

Commit

Permalink
Change working_path_mode option's default value
Browse files Browse the repository at this point in the history
  • Loading branch information
kien committed Sep 6, 2012
1 parent 309d29d commit 4557b5e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
5 changes: 3 additions & 2 deletions autoload/ctrlp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ let [s:pref, s:opts, s:new_opts] = ['g:ctrlp_', {
\ 'use_caching': ['s:caching', 1],
\ 'use_migemo': ['s:migemo', 0],
\ 'user_command': ['s:usrcmd', ''],
\ 'working_path_mode': ['s:pathmode', 'rc'],
\ 'working_path_mode': ['s:pathmode', 'ra'],
\ }, {
\ 'open_multiple_files': 's:opmul',
\ 'regexp': 's:regexp',
Expand Down Expand Up @@ -827,7 +827,8 @@ fu! s:SetWD(args)
cal ctrlp#setdir(a:args['dir']) | retu
en
if s:crfile =~ '^.\+://' | retu | en
if pmode =~ 'c' || ( !type(pmode) && pmode )
if pmode =~ 'c' || ( pmode =~ 'a' && stridx(s:crfpath, s:cwd) < 0 )
\ || ( !type(pmode) && pmode )
if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en
cal ctrlp#setdir(s:crfpath)
en
Expand Down
9 changes: 5 additions & 4 deletions doc/ctrlp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,19 @@ Where to put the new tab page when opening one: >
*'g:ctrlp_working_path_mode'*
When starting up, CtrlP sets its local working directory according to this
variable: >
let g:ctrlp_working_path_mode = 'rc'
let g:ctrlp_working_path_mode = 'ra'
<
c - the directory of the current file.
r - the nearest ancestor that contains one of these directories or files:
.git .hg .svn .bzr _darcs
a - like c, but only if the current working directory outside of CtrlP is not
a direct ancestor of the directory of the current file.
0 or <empty-string> - don't manage working directory.

Note #1: you can use b:ctrlp_working_path_mode (a |b:var|) to set this option
on a per buffer basis.

Note #2: with both 'r' and 'c' in the option, when a root isn't found, use the
directory of the current file.
Note #2: with 'ra' or 'rc', use the behavior of a or c when a root isn't found.

*'g:ctrlp_root_markers'*
Use this to set your own root markers in addition to the default ones (.git,
Expand Down Expand Up @@ -673,7 +674,7 @@ COMMANDS *ctrlp-commands*

*:CtrlPRoot*
:CtrlPRoot
This acts like |:CtrlP| with |g:ctrlp_working_path_mode| = 'rc' and ignores
This acts like |:CtrlP| with |g:ctrlp_working_path_mode| = 'r' and ignores
the variable's current value.

*:CtrlPClearCache*
Expand Down
4 changes: 3 additions & 1 deletion plugin/ctrlp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ com! -bar ResetCtrlP cal ctrlp#reset()

com! -bar CtrlPCurWD cal ctrlp#init(0, { 'mode': '' })
com! -bar CtrlPCurFile cal ctrlp#init(0, { 'mode': 'c' })
com! -bar CtrlPRoot cal ctrlp#init(0, { 'mode': 'rc' })
com! -bar CtrlPRoot cal ctrlp#init(0, { 'mode': 'r' })

if g:ctrlp_map != '' && !hasmapto(':<c-u>'.g:ctrlp_cmd.'<cr>', 'n')
exe 'nn <silent>' g:ctrlp_map ':<c-u>'.g:ctrlp_cmd.'<cr>'
Expand Down Expand Up @@ -64,3 +64,5 @@ com! -bar CtrlPBookmarkDir cal ctrlp#init(ctrlp#bookmarkdir#id())

com! -n=? -com=dir CtrlPBookmarkDirAdd
\ cal ctrlp#call('ctrlp#bookmarkdir#add', <q-args>)

" vim:ts=2:sw=2:sts=2
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 fi
* When invoked, unless a starting directory is specified, CtrlP will set its local working directory according to this variable:

```vim
let g:ctrlp_working_path_mode = 'rc'
let g:ctrlp_working_path_mode = 'ra'
```

`'c'` - the directory of the current file.
`'r'` - the nearest ancestor that contains one of these directories or files:
`.git` `.hg` `.svn` `.bzr` `_darcs`
`0` or `''` (empty string) - don't manage working directory.
`'r'` - the nearest ancestor that contains one of these directories or files: `.git` `.hg` `.svn` `.bzr` `_darcs`
`'a'` - like c, but only if the current working directory outside of CtrlP is not a direct ancestor of the directory of the current file.
`0` or `''` (empty string) - disable this feature.

Define additional root markers with the `g:ctrlp_root_markers` option.

Expand Down

0 comments on commit 4557b5e

Please sign in to comment.