shriek
shriek

Reputation: 5823

Command-T not searching in current working directory

I think the title says it all but just to give some context, I have this set on my .vimrc
set wildignore+=*.o,*.obj,**/.git/*,**/.svn/*,**/node_modules/**,node_modules/**,.git/*,svn/*

And from the readme:-

:CommandT

A prompt will appear at the bottom of the screen along with a file window
showing all of the files in the current directory (as returned by the
|:pwd| command).

It mentions that it should show all files in the current directory but even if I cd into any directory, Command-T still goes all the way up to my Desktop and lists all the files and folders which is not what I want. I just want to search on current working directory like it says in the readme.

I also tried checking if I was indeed in the right directory by doing :pwd and it's showing me I'm in the right directory and still lists out everything. However, if I have .git folder in my root directory then it seems to work.

Am I missing something? If it helps, I also have this in my .vimrc file:-

imap <C-t> <C-c>:CommandT<CR>
vmap <C-t> <C-c>:CommandT<CR>
nmap <C-t> :CommandT<CR>

Upvotes: 2

Views: 1058

Answers (2)

Che Huu
Che Huu

Reputation: 163

Add this line to .vimrc file

let g:CommandTTraverseSCM='pwd'

It will search in current directory instead of SCM root directory.

Upvotes: 2

Peter Rincker
Peter Rincker

Reputation: 45117

Warning: This is a non-answer answer to your question.

Please take @romainl's advice and look at the plugin's issue tracker.

Documentation

Command T and all good Vim plugins come with documentation. Please read all of it before asking questions. See :h command-t. The things you might have noticed if you had:

  • g:CommandTScanDotDirectories - basically the default config means CommandT will not search dot directories. Meaning your 'wildignore' probably doesn't need .git/.svn/... entries.

  • See :h command-t-wildignore for more information on CommandT and 'wildignore'

  • g:CommandTTraverseSCM dictates how CommandT find its root directory. The default looks for a SCM root marker, e.g. .git. If it can't find one it will fall back to the current directory. Please look at this option for more options. You may want to use let g:CommandTTraverseSCM = 'pwd'

Mappings

I have some concerns:

  • You should be using *noremap style mapping unless you are mapping to a <Plug>(something) or you really want recursive mappings (Hint: not usually).
  • Please use <esc> instead of <c-c> as they are not the same. Sure they are similar but they are not the same.
  • Overshadowing the <c-t> command in normal mode which pops the tag stack.
  • Overshadowing the <c-t> command in insert mode which increases indentation.
  • Probably should not even worry about creating mappings for any mode except normal mode because that is the Vim way.

My recommendation is to use the default CommandT mappings which are <leader>t and <leader>b (See :h command-t-mappings). The <leader> defaults to \ however this changes if you change the mapleader. See :h mapleader.

Upvotes: 1

Related Questions