Skip to content

Commit

Permalink
Version 0.8
Browse files Browse the repository at this point in the history
- overrides for the default mappings can now be lists of strings, allowing multiple mappings to be defined for any given action
- <Leader>t mapping only set up if no other map for |:CommandT| exists (patch from Scott Bronson)
- prevent folds from appearing in the match listing
- tweaks to avoid the likelihood of "Not enough room" errors when trying to open files
- watch out for "nil" windows when restoring window dimensions
- optimizations (avoid some repeated downcasing)
- move all Ruby files under the "command-t" subdirectory and avoid polluting the "Vim" module namespace
  • Loading branch information
wincent authored and vim-scripts committed Oct 18, 2010
1 parent 34df7d7 commit 345c7ca
Show file tree
Hide file tree
Showing 13 changed files with 295 additions and 155 deletions.
182 changes: 142 additions & 40 deletions doc/command-t.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
*command-t.txt* Command-T plug-in for VIM
*command-t.txt* Command-T plug-in for Vim *command-t*

CONTENTS *command-t-contents*

1. Introduction |command-t|
1. Introduction |command-t-intro|
2. Requirements |command-t-requirements|
3. Installation |command-t-installation|
3. Managing using Pathogen |command-t-pathogen|
4. Trouble-shooting |command-t-trouble-shooting|
5. Usage |command-t-usage|
6. Commands |command-t-commands|
Expand All @@ -17,7 +18,7 @@ CONTENTS *command-t-contents*
13. History |command-t-history|


INTRODUCTION *command-t*
INTRODUCTION *command-t-intro*

The Command-T plug-in provides an extremely fast, intuitive mechanism for
opening files with a minimal number of keystrokes. It's named "Command-T"
Expand All @@ -43,42 +44,54 @@ Screencasts demonstrating the plug-in can be viewed at:

REQUIREMENTS *command-t-requirements*

The plug-in requires VIM compiled with Ruby support, a compatible Ruby
The plug-in requires Vim compiled with Ruby support, a compatible Ruby
installation at the operating system level, and a C compiler to build
the Ruby extension.

1. VIM compiled with Ruby support
1. Vim compiled with Ruby support

You can check for Ruby support by launching VIM with the --version switch:
You can check for Ruby support by launching Vim with the --version switch:

vim --version

If "+ruby" appears in the version information then your version of VIM has
If "+ruby" appears in the version information then your version of Vim has
Ruby support.

Another way to check is to simply try using the :ruby command from within VIM
Another way to check is to simply try using the :ruby command from within Vim
itself:

:ruby 1

If your VIM lacks support you'll see an error message like this:
If your Vim lacks support you'll see an error message like this:

E319: Sorry, the command is not available in this version

The version of VIM distributed with Mac OS X does not include Ruby support,
The version of Vim distributed with Mac OS X does not include Ruby support,
while MacVim does; it is available from:

http://code.google.com/p/macvim/
http://github.com/b4winckler/macvim/downloads

For Windows users, the executable from www.vim.org does include Ruby support.

2. Ruby

In addition to having Ruby support in VIM, your system itself must have a
compatible Ruby install. In practice this usually means a version of Ruby from
the 1.8 series, as VIM's support for 1.9 is still not official.
In addition to having Ruby support in Vim, your system itself must have a
compatible Ruby install. "Compatible" means the same version as Vim itself
links against. If you use a different version then Command-T is unlikely
to work (see TROUBLE-SHOOTING below).

The current version of Mac OS X comes with Ruby 1.8.7.
On Mac OS X Snow Leopard, the system comes with Ruby 1.8.7 and all recent
versions of MacVim (the 7.2 snapshots and 7.3) are linked against it.

On Linux and similar platforms, the linked version of Ruby will depend on
your distribution. You can usually find this out by examining the
compilation and linking flags displayed by the |:version| command in Vim, and
by looking at the output of:

:ruby puts RUBY_VERSION

On Windows, Vim 7.3 links against Ruby 1.9.1, while previous versions linked
against Ruby 1.8.7.

A suitable Ruby environment for Windows can be installed using RubyInstaller
available at:
Expand All @@ -87,7 +100,7 @@ available at:

If using RubyInstaller be sure to download the installer executable, not the
7-zip archive. When installing mark the checkbox "Add Ruby executables to your
PATH" so that VIM can find them.
PATH" so that Vim can find them.

3. C compiler

Expand All @@ -111,7 +124,7 @@ folder.
INSTALLATION *command-t-installation*

Command-T is distributed as a "vimball" which means that it can be installed
by opening it in VIM and then sourcing it:
by opening it in Vim and then sourcing it:

:e command-t.vba
:so %
Expand All @@ -129,22 +142,92 @@ you can build the extension with:
ruby extconf.rb
make

Note: If you are an RVM user, you must perform the build using the same
version of Ruby that Vim itself is linked against. This will often be the
system Ruby, which can be selected before issuing the "make" command with:

rvm use system


MANAGING USING PATHOGEN *command-t-pathogen*

Pathogen is a plugin that allows you to maintain plugin installations in
separate, isolated subdirectories under the "bundle" directory in your
|'runtimepath'|. The following examples assume that you already have
Pathogen installed and configured, and that you are installing into
~/.vim/bundle. For more information about Pathogen, see:

http://www.vim.org/scripts/script.php?script_id=2332

If you manage your entire ~/.vim folder using Git then you can add the
Command-T repository as a submodule:

cd ~/.vim
git submodule add git://git.wincent.com/command-t.git bundle/command-t
git submodule init

Or if you just wish to do a simple clone instead of using submodules:

cd ~/.vim
git clone git://git.wincent.com/command-t.git bundle/command-t

Once you have a local copy of the repository you can update it at any time
with:

cd ~/.vim/bundle/command-t
git pull

Or you can switch to a specific release with:

cd ~/.vim/bundle/command-t
git checkout 0.8b

After installing or updating you must build the extension:

cd ~/.vim/bundle/command-t
rake make

While the Vimball installation automatically generates the help tags, under
Pathogen it is necessary to do so explicitly from inside Vim:

:call pathogen#helptags()


TROUBLE-SHOOTING *command-t-trouble-shooting*

Most installation problems are caused by a mismatch between the version of
Ruby on the host operating system, and the version of Ruby that VIM itself
Ruby on the host operating system, and the version of Ruby that Vim itself
linked against at compile time. For example, if one is 32-bit and the other is
64-bit, or one is from the Ruby 1.9 series and the other is from the 1.8
series, then the plug-in is not likely to work.

As such, on Mac OS X, I recommend using the standard Ruby that comes with the
system (currently 1.8.7) along with the latest snapshot of MacVim (currently
snapshot 52).
system (currently 1.8.7) along with the latest version of MacVim (currently
version 7.3). If you wish to use custom builds of Ruby or of MacVim (not
recommmended) then you will have to take extra care to ensure that the exact
same Ruby environment is in effect when building Ruby, Vim and the Command-T
extension.

On Windows, I recommend using the version 1.8.7 RubyInstaller and the
On Windows, I recommend using the version 1.9.1 RubyInstaller and the
corresponding RubyInstaller Development Kit linked to above, along with the
standard (32-bit) version of VIM that can be downloaded from www.vim.org.
standard (32-bit) version of Vim 7.3 that can be downloaded from www.vim.org.
If you are still using Vim 7.2 then you should instead use version 1.8.7 of
RubyInstaller.

If a problem occurs the first thing you should do is inspect the output of:

ruby extconf.rb
make

During the installation, and:

vim --version

And compare the compilation and linker flags that were passed to the
extension and to Vim itself when they were built. If the Ruby-related
flags or architecture flags are different then it is likely that something
has changed in your Ruby environment and the extension may not work until
you eliminate the discrepancy.


USAGE *command-t-usage*
Expand All @@ -153,9 +236,9 @@ Bring up the Command-T match window by typing:

<Leader>t

If a mapping for <Leader>t already exists at the time the plug-in is loaded
then Command-T will not overwrite it. You can instead open the match window by
issuing the command:
This mapping is set up automatically for you, provided you do not already have
a mapping for <Leader>t or |:CommandT|. You can also bring up the match window
by issuing the command:

:CommandT

Expand Down Expand Up @@ -258,7 +341,7 @@ to define a different mapping use a line like this in your ~/.vimrc:
Replacing "<Leader>t" with your mapping of choice.

Note that in the case of MacVim you actually can map to Command-T (written
as <D-t> in VIM) in your ~/.gvimrc file if you first unmap the existing menu
as <D-t> in Vim) in your ~/.gvimrc file if you first unmap the existing menu
binding of Command-T to "New Tab":

if has("gui_macvim")
Expand All @@ -280,7 +363,7 @@ the plug-in. To set an option, you include a line like this in your ~/.vimrc:
let g:CommandTMaxFiles=20000

To have Command-T pick up new settings immediately (that is, without having
to restart VIM) you can issue the |:CommandTFlush| command after making
to restart Vim) you can issue the |:CommandTFlush| command after making
changes via |:let|.

Following is a list of all available options:
Expand Down Expand Up @@ -321,7 +404,7 @@ Following is a list of all available options:
contains a dot that could cause a dot-file to match. When set to a
non-zero value, this setting instructs Command-T to never show dot-files
under any circumstances. Note that it is contradictory to set both this
setting and |g:CommandTAlwaysShowDotFiles| to true, and if you do so VIM
setting and |g:CommandTAlwaysShowDotFiles| to true, and if you do so Vim
will suffer from headaches, nervous twitches, and sudden mood swings.

*g:CommandTScanDotDirectories*
Expand Down Expand Up @@ -360,7 +443,11 @@ window, you would add the following to your ~/.vimrc:

let g:CommandTCancelMap='<C-x>'

Following is a list of all map settings:
Multiple, alternative mappings may be specified using list syntax:

let g:CommandTCancelMap=['<C-x>', '<C-c>']

Following is a list of all map settings and their defaults:

Setting Default mapping(s)

Expand Down Expand Up @@ -417,13 +504,13 @@ Following is a list of all map settings:
*g:CommandTCursorStartMap*
|g:CommandTCursorStartMap| <C-a>

In addition to the options provided by Command-T itself, some of VIM's own
In addition to the options provided by Command-T itself, some of Vim's own
settings can be used to control behavior:

*command-t-wildignore*
|'wildignore'| string (default: '')

VIM's |'wildignore'| setting is used to determine which files should be
Vim's |'wildignore'| setting is used to determine which files should be
excluded from listings. This is a comma-separated list of glob patterns.
It defaults to the empty string, but common settings include "*.o,*.obj"
(to exclude object files) or ".git,.svn" (to exclude SCM metadata
Expand All @@ -445,15 +532,16 @@ Other contributors that have submitted patches include:

Lucas de Vries
Mike Lundy
Scott Bronson
Zak Johnson

As this was the first VIM plug-in I had ever written I was heavily influenced
As this was the first Vim plug-in I had ever written I was heavily influenced
by the design of the LustyExplorer plug-in by Stephen Bach, which I understand
is one of the largest Ruby-based VIM plug-ins to date.
is one of the largest Ruby-based Vim plug-ins to date.

While the Command-T codebase doesn't contain any code directly copied from
LustyExplorer, I did use it as a reference for answers to basic questions (like
"How do you do 'X' in a Ruby-based VIM plug-in?"), and also copied some basic
"How do you do 'X' in a Ruby-based Vim plug-in?"), and also copied some basic
architectural decisions (like the division of the code into Prompt, Settings
and MatchWindow classes).

Expand All @@ -475,7 +563,7 @@ browser at:

http://git.wincent.com/command-t.git

A copy of each release is also available from the official VIM scripts site
A copy of each release is also available from the official Vim scripts site
at:

http://www.vim.org/scripts/script.php?script_id=3025
Expand Down Expand Up @@ -522,15 +610,29 @@ POSSIBILITY OF SUCH DAMAGE.

HISTORY *command-t-history*

0.8 (19 August 2010)

- overrides for the default mappings can now be lists of strings, allowing
multiple mappings to be defined for any given action
- <Leader>t mapping only set up if no other map for |:CommandT| exists
(patch from Scott Bronson)
- prevent folds from appearing in the match listing
- tweaks to avoid the likelihood of "Not enough room" errors when trying to
open files
- watch out for "nil" windows when restoring window dimensions
- optimizations (avoid some repeated downcasing)
- move all Ruby files under the "command-t" subdirectory and avoid polluting
the "Vim" module namespace

0.8b (11 July 2010)

- large overhaul if the scoring algorithm to make the ordering of returned
- large overhaul of the scoring algorithm to make the ordering of returned
results more intuitive; given the scope of the changes and room for
optimization of the new algorithm, this release is labelled as "beta"

0.7 (10 June 2010)

- handle more |'wildignore'| patterns by delegating to VIM's own |expand()|
- handle more |'wildignore'| patterns by delegating to Vim's own |expand()|
function; with this change it is now viable to exclude patterns such as
'vendor/rails/**' in addition to filename-only patterns like '*.o' and
'.git' (patch from Mike Lundy)
Expand All @@ -540,7 +642,7 @@ HISTORY *command-t-history*
0.6 (28 April 2010)

- |:CommandT| now accepts an optional parameter to specify the starting
directory, temporarily overriding the usual default of VIM's |:pwd|
directory, temporarily overriding the usual default of Vim's |:pwd|
- fix truncated paths when operating from root directory

0.5.1 (11 April 2010)
Expand All @@ -551,7 +653,7 @@ HISTORY *command-t-history*
0.5 (3 April 2010)

- |:CommandTFlush| now re-evaluates settings, allowing changes made via |let|
to be picked up without having to restart VIM
to be picked up without having to restart Vim
- fix premature abort when scanning very deep directory hierarchies
- remove broken |<Esc>| key mapping on vt100 and xterm terminals
- provide settings for overriding default mappings
Expand All @@ -570,7 +672,7 @@ HISTORY *command-t-history*
- fix bug where |'list'| setting might be inappropriately set after dismissing
Command-T
- compatibility fix for different behaviour of "autoload" under Ruby 1.9.1
- avoid "highlight group not found" warning when run under a version of VIM
- avoid "highlight group not found" warning when run under a version of Vim
that does not have syntax highlighting support
- open in split when opening normally would fail due to |'hidden'| and
|'modified'| values
Expand Down
11 changes: 7 additions & 4 deletions plugin/command-t.vim
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ let g:command_t_loaded = 1
command -nargs=? -complete=dir CommandT call <SID>CommandTShow(<q-args>)
command CommandTFlush call <SID>CommandTFlush()

silent! nmap <unique> <silent> <Leader>t :CommandT<CR>
if !hasmapto('CommandT')
silent! nmap <unique> <silent> <Leader>t :CommandT<CR>
endif

function s:CommandTRubyWarning()
echohl WarningMsg
Expand Down Expand Up @@ -127,12 +129,12 @@ ruby << EOF
# require Ruby files
begin
# prepare controller
require 'vim'
require 'command-t/vim'
require 'command-t/controller'
$command_t = CommandT::Controller.new
rescue LoadError
load_path_modified = false
VIM::evaluate('&runtimepath').to_s.split(',').each do |path|
::VIM::evaluate('&runtimepath').to_s.split(',').each do |path|
lib = "#{path}/ruby"
if !$LOAD_PATH.include?(lib) and File.exist?(lib)
$LOAD_PATH << lib
Expand All @@ -141,7 +143,8 @@ ruby << EOF
end
retry if load_path_modified

# could get here if C extension was not compiled
# could get here if C extension was not compiled, or was compiled
# for the wrong architecture or Ruby version
require 'command-t/stub'
$command_t = CommandT::Stub.new
end
Expand Down
Loading

0 comments on commit 345c7ca

Please sign in to comment.