Skip to content

Commit b0e7f42

Browse files
intelfxairblade
authored andcommitted
Accept a native list for g:rooter_targets
1 parent 4a0df2f commit b0e7f42

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

README.mkd

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,19 @@ Rooter will unset `&autochdir` if it's set.
3030

3131
### Which buffers trigger Rooter
3232

33-
By default all files and directories trigger Rooter. Configure a comma separated list of patterns to specify which files trigger. Include `/` to trigger on directories. For example:
33+
By default all files and directories trigger Rooter. Alternatively, set `g:rooter_targets` to a list of file path patterns which should trigger Rooter. Use a literal `/` to match directory buffers. For example:
3434

3535
```viml
3636
" Everything (default)
37-
let g:rooter_targets = '/,*'
37+
let g:rooter_targets = ['/', '*']
3838
39+
" Directories and everything under /home
40+
let g:rooter_targets = ['/', '/home/*']
41+
```
42+
43+
Comma-separated lists are also accepted:
44+
45+
```viml
3946
" All files
4047
let g:rooter_targets = '*'
4148

doc/rooter.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,17 @@ Configuration *rooter-configuration*
5454

5555
Which buffers trigger Rooter *g:rooter_targets*
5656

57-
By default all files and directories trigger Rooter. Configure a comma
58-
separated list of patterns to specify which files trigger. Include "/" to
59-
trigger on directories. For example:
57+
By default all files and directories trigger Rooter. Alternatively, set
58+
`g:rooter_targets` to a list of file path patterns which should trigger
59+
Rooter. Use a literal `/` to match directory buffers. For example:
60+
>
61+
let g:rooter_targets = ['/', '/home/*']
62+
<
63+
A comma-separated list is also accepted instead of a native list:
6064
>
6165
let g:rooter_targets = '/,*.rb,*.haml,*.js'
6266
<
63-
Default: '/,*'
67+
Default: ['/', '*']
6468

6569
------------------------------------------------------------------------------
6670
Which buffer types trigger Rooter *g:rooter_buftypes*

plugin/rooter.vim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ if !exists('g:rooter_patterns')
3636
endif
3737

3838
if !exists('g:rooter_targets')
39-
let g:rooter_targets = '/,*'
39+
let g:rooter_targets = ['/', '*']
4040
endif
4141

4242
if !exists('g:rooter_change_directory_for_non_project_files')
@@ -102,7 +102,11 @@ endfunction
102102
function! s:activate()
103103
if index(g:rooter_buftypes, &buftype) == -1 | return 0 | endif
104104

105-
let patterns = split(g:rooter_targets, ',')
105+
if type(g:rooter_targets) == type([])
106+
let patterns = g:rooter_targets
107+
else
108+
let patterns = split(g:rooter_targets, ',')
109+
endif
106110
let fn = s:current_file()
107111

108112
" directory

0 commit comments

Comments
 (0)