Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The Vim Ctrlp plugin has a way to globally ignore certain folder names. Eg:

let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'

However, I have an ignore rule that's specific to one project. I would like something more like a .gitignore file.

Is there a way to ignore a specific folder in a specific project without modifying my global configuration?

share|improve this question
    
Did you try the plugin's issue tracker? –  romainl Sep 24 '13 at 20:16
add comment

1 Answer 1

Use a custom listing command

Ctrlp lets you tell it what command to use to get a list of files in the folder. So if you wanted to exclude anything named 'beets.txt', you could do:

let g:ctrlp_user_command = 'find %s -type f | grep -v "beets.txt"'

That's global, but it starts to point toward the answer: supply your own shell command.

Even better, Ctrlp lets you supply multiple shell commands with markers, meaning "if you see this marker in the root directory, use this command."

I found this in :help ctrlp, and modified slightly based on the author's comment on an issue.

let g:ctrlp_user_command = {
  \ 'types': {
    \ 1: ['.git', 'cd %s && git ls-files --cached --exclude-standard --others']
    \ 2: ['.hg', 'hg --cwd %s locate -I .'],
    \ },
  \ 'fallback': 'find %s -type f'
  \ }

This means: "If you see .git in the folder, use git ls-files.... Otherwise, if you see .hg... otherwise, use a regular find."

So, to ignore a specific folder in one project, devise a command that will ignore that folder, then place a unique marker in that project to let Ctrlp that you want to use your special command here.

(In my case, I actually wanted to ignore files that were in .gitignore, so the git ls-files command above works for me.)

share|improve this answer
    
That's awesome, thanks a lot for this answer. –  Denis Feb 20 at 13:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.