command-t 1.2.1 → 1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.txt CHANGED
@@ -332,6 +332,14 @@ COMMANDS *command-t-commands*
332
332
  except that the selection is limited to files that
333
333
  you already have open in buffers.
334
334
 
335
+ *:CommandTJumps*
336
+ |:CommandTJump| Brings up the Command-T jumplist window.
337
+ This works exactly like the standard file window,
338
+ except that the selection is limited to files that
339
+ you already have in the jumplist. Note that jumps
340
+ can persist across Vim sessions (see Vim's |jumplist|
341
+ documentation for more info).
342
+
335
343
  *:CommandTFlush*
336
344
  |:CommandTFlush|Instructs the plug-in to flush its path cache, causing
337
345
  the directory to be rescanned for new or deleted paths
@@ -351,8 +359,8 @@ By default Command-T comes with only two mappings:
351
359
  However, Command-T won't overwrite a pre-existing mapping so if you prefer
352
360
  to define different mappings use lines like these in your ~/.vimrc:
353
361
 
354
- nmap <silent> <Leader>t :CommandT<CR>
355
- nmap <silent> <Leader>b :CommandTBuffer<CR>
362
+ nnoremap <silent> <Leader>t :CommandT<CR>
363
+ nnoremap <silent> <Leader>b :CommandTBuffer<CR>
356
364
 
357
365
  Replacing "<Leader>t" or "<Leader>b" with your mapping of choice.
358
366
 
@@ -399,6 +407,16 @@ Following is a list of all available options:
399
407
  current directory. Any directories at levels beyond this depth will be
400
408
  skipped.
401
409
 
410
+ *g:CommandTMaxCachedDirectories*
411
+ |g:CommandTMaxCachedDirectories| number (default 1)
412
+
413
+ The maximum number of directories whose contents should be cached when
414
+ recursively scanning. With the default value of 1, each time you change
415
+ directories the cache will be emptied and Command-T will have to
416
+ rescan. Higher values will make Command-T hold more directories in the
417
+ cache, bringing performance at the cost of memory usage. If set to 0,
418
+ there is no limit on the number of cached directories.
419
+
402
420
  *g:CommandTMaxHeight*
403
421
  |g:CommandTMaxHeight| number (default: 0)
404
422
 
@@ -565,8 +583,10 @@ Command-T is written and maintained by Wincent Colaiuta <win@wincent.com>.
565
583
  Other contributors that have submitted patches include (in alphabetical
566
584
  order):
567
585
 
586
+ Anthony Panozzo
568
587
  Daniel Hahler
569
588
  Lucas de Vries
589
+ Marian Schubert
570
590
  Matthew Todd
571
591
  Mike Lundy
572
592
  Scott Bronson
@@ -647,9 +667,15 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
647
667
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
648
668
  POSSIBILITY OF SUCH DAMAGE.
649
669
 
650
-
651
670
  HISTORY *command-t-history*
652
671
 
672
+ 1.3 (27 November 2011)
673
+
674
+ - added the option to maintain multiple caches when changing among
675
+ directories; see the accompanying |g:CommandTMaxCachedDirectories| setting
676
+ - added the ability to navigate using the Vim jumplist (patch from Marian
677
+ Schubert)
678
+
653
679
  1.2.1 (30 April 2011)
654
680
 
655
681
  - Remove duplicate copy of the documentation that was causing "Duplicate tag"
data/Rakefile CHANGED
@@ -134,7 +134,9 @@ desc 'Compile extension'
134
134
  task :make do
135
135
  Dir.chdir 'ruby/command-t' do
136
136
  ruby 'extconf.rb'
137
- system 'make clean && make'
137
+ system 'make clean'
138
+ bail_on_failure
139
+ system 'make'
138
140
  bail_on_failure
139
141
  end
140
142
  end
@@ -212,8 +214,3 @@ desc 'Push gem to Gemcutter ("gem push")'
212
214
  task :push => :gem do
213
215
  sh "gem push command-t-#{rubygems_version}.gem"
214
216
  end
215
-
216
- desc 'Install the command-t ruby gem'
217
- task :install => :gem do
218
- sh "gem install command-t-#{rubygems_version}.gem"
219
- end
@@ -332,6 +332,14 @@ COMMANDS *command-t-commands*
332
332
  except that the selection is limited to files that
333
333
  you already have open in buffers.
334
334
 
335
+ *:CommandTJumps*
336
+ |:CommandTJump| Brings up the Command-T jumplist window.
337
+ This works exactly like the standard file window,
338
+ except that the selection is limited to files that
339
+ you already have in the jumplist. Note that jumps
340
+ can persist across Vim sessions (see Vim's |jumplist|
341
+ documentation for more info).
342
+
335
343
  *:CommandTFlush*
336
344
  |:CommandTFlush|Instructs the plug-in to flush its path cache, causing
337
345
  the directory to be rescanned for new or deleted paths
@@ -351,8 +359,8 @@ By default Command-T comes with only two mappings:
351
359
  However, Command-T won't overwrite a pre-existing mapping so if you prefer
352
360
  to define different mappings use lines like these in your ~/.vimrc:
353
361
 
354
- nmap <silent> <Leader>t :CommandT<CR>
355
- nmap <silent> <Leader>b :CommandTBuffer<CR>
362
+ nnoremap <silent> <Leader>t :CommandT<CR>
363
+ nnoremap <silent> <Leader>b :CommandTBuffer<CR>
356
364
 
357
365
  Replacing "<Leader>t" or "<Leader>b" with your mapping of choice.
358
366
 
@@ -399,6 +407,16 @@ Following is a list of all available options:
399
407
  current directory. Any directories at levels beyond this depth will be
400
408
  skipped.
401
409
 
410
+ *g:CommandTMaxCachedDirectories*
411
+ |g:CommandTMaxCachedDirectories| number (default 1)
412
+
413
+ The maximum number of directories whose contents should be cached when
414
+ recursively scanning. With the default value of 1, each time you change
415
+ directories the cache will be emptied and Command-T will have to
416
+ rescan. Higher values will make Command-T hold more directories in the
417
+ cache, bringing performance at the cost of memory usage. If set to 0,
418
+ there is no limit on the number of cached directories.
419
+
402
420
  *g:CommandTMaxHeight*
403
421
  |g:CommandTMaxHeight| number (default: 0)
404
422
 
@@ -565,8 +583,10 @@ Command-T is written and maintained by Wincent Colaiuta <win@wincent.com>.
565
583
  Other contributors that have submitted patches include (in alphabetical
566
584
  order):
567
585
 
586
+ Anthony Panozzo
568
587
  Daniel Hahler
569
588
  Lucas de Vries
589
+ Marian Schubert
570
590
  Matthew Todd
571
591
  Mike Lundy
572
592
  Scott Bronson
@@ -647,9 +667,15 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
647
667
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
648
668
  POSSIBILITY OF SUCH DAMAGE.
649
669
 
650
-
651
670
  HISTORY *command-t-history*
652
671
 
672
+ 1.3 (27 November 2011)
673
+
674
+ - added the option to maintain multiple caches when changing among
675
+ directories; see the accompanying |g:CommandTMaxCachedDirectories| setting
676
+ - added the ability to navigate using the Vim jumplist (patch from Marian
677
+ Schubert)
678
+
653
679
  1.2.1 (30 April 2011)
654
680
 
655
681
  - Remove duplicate copy of the documentation that was causing "Duplicate tag"
@@ -28,15 +28,16 @@ endif
28
28
  let g:command_t_loaded = 1
29
29
 
30
30
  command CommandTBuffer call <SID>CommandTShowBufferFinder()
31
+ command CommandTJump call <SID>CommandTShowJumpFinder()
31
32
  command -nargs=? -complete=dir CommandT call <SID>CommandTShowFileFinder(<q-args>)
32
33
  command CommandTFlush call <SID>CommandTFlush()
33
34
 
34
35
  if !hasmapto(':CommandT<CR>')
35
- silent! nmap <unique> <silent> <Leader>t :CommandT<CR>
36
+ silent! nnoremap <unique> <silent> <Leader>t :CommandT<CR>
36
37
  endif
37
38
 
38
39
  if !hasmapto(':CommandTBuffer<CR>')
39
- silent! nmap <unique> <silent> <Leader>b :CommandTBuffer<CR>
40
+ silent! nnoremap <unique> <silent> <Leader>b :CommandTBuffer<CR>
40
41
  endif
41
42
 
42
43
  function s:CommandTRubyWarning()
@@ -62,6 +63,14 @@ function s:CommandTShowFileFinder(arg)
62
63
  endif
63
64
  endfunction
64
65
 
66
+ function s:CommandTShowJumpFinder()
67
+ if has('ruby')
68
+ ruby $command_t.show_jump_finder
69
+ else
70
+ call s:CommandTRubyWarning()
71
+ endif
72
+ endfunction
73
+
65
74
  function s:CommandTFlush()
66
75
  if has('ruby')
67
76
  ruby $command_t.flush
@@ -4,67 +4,84 @@ SHELL = /bin/sh
4
4
  #### Start of system configuration section. ####
5
5
 
6
6
  srcdir = .
7
- topdir = /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0
8
- hdrdir = $(topdir)
9
- VPATH = $(srcdir):$(topdir):$(hdrdir)
7
+ topdir = /Users/greg/.multiruby/install/1.9.2-p180/include/ruby-1.9.1
8
+ hdrdir = /Users/greg/.multiruby/install/1.9.2-p180/include/ruby-1.9.1
9
+ arch_hdrdir = /Users/greg/.multiruby/install/1.9.2-p180/include/ruby-1.9.1/$(arch)
10
+ VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
11
+ prefix = $(DESTDIR)/Users/greg/.multiruby/install/1.9.2-p180
12
+ rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
10
13
  exec_prefix = $(prefix)
11
- prefix = $(DESTDIR)/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr
12
- sharedstatedir = $(prefix)/com
13
- mandir = $(DESTDIR)/usr/share/man
14
- psdir = $(docdir)
15
- oldincludedir = $(DESTDIR)/usr/include
14
+ vendorhdrdir = $(rubyhdrdir)/vendor_ruby
15
+ sitehdrdir = $(rubyhdrdir)/site_ruby
16
+ rubyhdrdir = $(includedir)/$(RUBY_BASE_NAME)-$(ruby_version)
17
+ vendordir = $(rubylibprefix)/vendor_ruby
18
+ sitedir = $(rubylibprefix)/site_ruby
19
+ ridir = $(datarootdir)/$(RI_BASE_NAME)
20
+ mandir = $(datarootdir)/man
16
21
  localedir = $(datarootdir)/locale
17
- bindir = $(exec_prefix)/bin
18
- libexecdir = $(exec_prefix)/libexec
19
- sitedir = $(DESTDIR)/Library/Ruby/Site
22
+ libdir = $(exec_prefix)/lib
23
+ psdir = $(docdir)
24
+ pdfdir = $(docdir)
25
+ dvidir = $(docdir)
20
26
  htmldir = $(docdir)
21
- vendorarchdir = $(vendorlibdir)/$(sitearch)
27
+ infodir = $(datarootdir)/info
28
+ docdir = $(datarootdir)/doc/$(PACKAGE)
29
+ oldincludedir = $(DESTDIR)/usr/include
22
30
  includedir = $(prefix)/include
23
- infodir = $(DESTDIR)/usr/share/info
24
- vendorlibdir = $(vendordir)/$(ruby_version)
31
+ localstatedir = $(prefix)/var
32
+ sharedstatedir = $(prefix)/com
25
33
  sysconfdir = $(prefix)/etc
26
- libdir = $(exec_prefix)/lib
27
- sbindir = $(exec_prefix)/sbin
28
- rubylibdir = $(libdir)/ruby/$(ruby_version)
29
- docdir = $(datarootdir)/doc/$(PACKAGE)
30
- dvidir = $(docdir)
31
- vendordir = $(libdir)/ruby/vendor_ruby
34
+ datadir = $(datarootdir)
32
35
  datarootdir = $(prefix)/share
33
- pdfdir = $(docdir)
36
+ libexecdir = $(exec_prefix)/libexec
37
+ sbindir = $(exec_prefix)/sbin
38
+ bindir = $(exec_prefix)/bin
39
+ rubylibdir = $(rubylibprefix)/$(ruby_version)
34
40
  archdir = $(rubylibdir)/$(arch)
35
- sitearchdir = $(sitelibdir)/$(sitearch)
36
- datadir = $(datarootdir)
37
- localstatedir = $(prefix)/var
38
41
  sitelibdir = $(sitedir)/$(ruby_version)
42
+ sitearchdir = $(sitelibdir)/$(sitearch)
43
+ vendorlibdir = $(vendordir)/$(ruby_version)
44
+ vendorarchdir = $(vendorlibdir)/$(sitearch)
39
45
 
40
46
  CC = gcc
47
+ CXX = g++
41
48
  LIBRUBY = $(LIBRUBY_SO)
42
49
  LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
43
50
  LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
44
- LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)
51
+ LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
52
+ OUTFLAG = -o
53
+ COUTFLAG = -o
45
54
 
46
55
  RUBY_EXTCONF_H =
47
- CFLAGS = -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common $(cflags)
48
- INCFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)
56
+ cflags = $(optflags) $(debugflags) $(warnflags)
57
+ optflags = -O3
58
+ debugflags = -ggdb
59
+ warnflags = -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long
60
+ CFLAGS = -fno-common $(cflags) -fno-common -pipe
61
+ INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
49
62
  DEFS =
50
- CPPFLAGS = -DHAVE_RUBY_H -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $(DEFS) $(cppflags)
51
- CXXFLAGS = $(CFLAGS)
52
- ldflags = -L. -arch i386 -arch x86_64
53
- dldflags =
54
- archflag =
55
- DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
56
- LDSHARED = cc -arch i386 -arch x86_64 -pipe -bundle -undefined dynamic_lookup
63
+ CPPFLAGS = -DHAVE_RUBY_H -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $(DEFS) $(cppflags)
64
+ CXXFLAGS = $(CFLAGS) $(cxxflags)
65
+ ldflags = -L. -L/usr/local/lib
66
+ dldflags = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace
67
+ ARCH_FLAG =
68
+ DLDFLAGS = $(ldflags) $(dldflags)
69
+ LDSHARED = $(CC) -dynamic -bundle
70
+ LDSHAREDXX = $(CXX) -dynamic -bundle
57
71
  AR = ar
58
72
  EXEEXT =
59
73
 
74
+ RUBY_BASE_NAME = ruby
60
75
  RUBY_INSTALL_NAME = ruby
61
- RUBY_SO_NAME = ruby
62
- arch = universal-darwin10.0
63
- sitearch = universal-darwin10.0
64
- ruby_version = 1.8
65
- ruby = /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
76
+ RUBY_SO_NAME = ruby.1.9.1
77
+ arch = x86_64-darwin10.6.0
78
+ sitearch = $(arch)
79
+ ruby_version = 1.9.1
80
+ ruby = /Users/greg/.multiruby/install/1.9.2-p180/bin/ruby
66
81
  RUBY = $(ruby)
67
82
  RM = rm -f
83
+ RM_RF = $(RUBY) -run -e rm -- -rf
84
+ RMDIRS = $(RUBY) -run -e rmdir -- -p
68
85
  MAKEDIRS = mkdir -p
69
86
  INSTALL = /usr/bin/install -c
70
87
  INSTALL_PROG = $(INSTALL) -m 0755
@@ -81,12 +98,13 @@ DEFFILE =
81
98
 
82
99
  CLEANFILES = mkmf.log
83
100
  DISTCLEANFILES =
101
+ DISTCLEANDIRS =
84
102
 
85
103
  extout =
86
104
  extout_prefix =
87
105
  target_prefix =
88
106
  LOCAL_LIBS =
89
- LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl
107
+ LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl -lobjc
90
108
  SRCS = ext.c match.c matcher.c
91
109
  OBJS = ext.o match.o matcher.o
92
110
  TARGET = ext
@@ -98,28 +116,40 @@ BINDIR = $(bindir)
98
116
  RUBYCOMMONDIR = $(sitedir)$(target_prefix)
99
117
  RUBYLIBDIR = $(sitelibdir)$(target_prefix)
100
118
  RUBYARCHDIR = $(sitearchdir)$(target_prefix)
119
+ HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
120
+ ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
101
121
 
102
122
  TARGET_SO = $(DLLIB)
103
- CLEANLIBS = $(TARGET).bundle $(TARGET).il? $(TARGET).tds $(TARGET).map
104
- CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
105
-
106
- all: $(DLLIB)
107
- static: $(STATIC_LIB)
108
-
109
- clean:
123
+ CLEANLIBS = $(TARGET).bundle
124
+ CLEANOBJS = *.o *.bak
125
+
126
+ all: $(DLLIB)
127
+ static: $(STATIC_LIB)
128
+ .PHONY: all install static install-so install-rb
129
+ .PHONY: clean clean-so clean-rb
130
+
131
+ clean-rb-default::
132
+ clean-rb::
133
+ clean-so::
134
+ clean: clean-so clean-rb-default clean-rb
110
135
  @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
111
136
 
112
- distclean: clean
137
+ distclean-rb-default::
138
+ distclean-rb::
139
+ distclean-so::
140
+ distclean: clean distclean-so distclean-rb-default distclean-rb
113
141
  @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
114
142
  @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
143
+ @-$(RMDIRS) $(DISTCLEANDIRS)
115
144
 
116
- realclean: distclean
145
+ realclean: distclean
117
146
  install: install-so install-rb
118
147
 
119
148
  install-so: $(RUBYARCHDIR)
120
149
  install-so: $(RUBYARCHDIR)/$(DLLIB)
121
150
  $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
122
- $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
151
+ @-$(MAKEDIRS) $(@D)
152
+ $(INSTALL_PROG) $(DLLIB) $(@D)
123
153
  install-rb: pre-install-rb install-rb-default
124
154
  install-rb-default: pre-install-rb-default
125
155
  pre-install-rb: Makefile
@@ -134,22 +164,22 @@ site-install-rb: install-rb
134
164
  .SUFFIXES: .c .m .cc .cxx .cpp .C .o
135
165
 
136
166
  .cc.o:
137
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
167
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
138
168
 
139
169
  .cxx.o:
140
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
170
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
141
171
 
142
172
  .cpp.o:
143
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
173
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
144
174
 
145
175
  .C.o:
146
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
176
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
147
177
 
148
178
  .c.o:
149
- $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
179
+ $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
150
180
 
151
181
  $(DLLIB): $(OBJS) Makefile
152
- @-$(RM) $@
182
+ @-$(RM) $(@)
153
183
  $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
154
184
 
155
185
 
@@ -22,6 +22,7 @@
22
22
  # POSSIBILITY OF SUCH DAMAGE.
23
23
 
24
24
  require 'command-t/finder/buffer_finder'
25
+ require 'command-t/finder/jump_finder'
25
26
  require 'command-t/finder/file_finder'
26
27
  require 'command-t/match_window'
27
28
  require 'command-t/prompt'
@@ -33,22 +34,25 @@ module CommandT
33
34
 
34
35
  def initialize
35
36
  @prompt = Prompt.new
36
- @buffer_finder = CommandT::BufferFinder.new
37
- set_up_file_finder
38
- set_up_max_height
39
37
  end
40
38
 
41
39
  def show_buffer_finder
42
40
  @path = VIM::pwd
43
- @active_finder = @buffer_finder
41
+ @active_finder = buffer_finder
42
+ show
43
+ end
44
+
45
+ def show_jump_finder
46
+ @path = VIM::pwd
47
+ @active_finder = jump_finder
44
48
  show
45
49
  end
46
50
 
47
51
  def show_file_finder
48
52
  # optional parameter will be desired starting directory, or ""
49
53
  @path = File.expand_path(::VIM::evaluate('a:arg'), VIM::pwd)
50
- @file_finder.path = @path
51
- @active_finder = @file_finder
54
+ @active_finder = file_finder
55
+ file_finder.path = @path
52
56
  show
53
57
  rescue Errno::ENOENT
54
58
  # probably a problem with the optional parameter
@@ -69,8 +73,8 @@ module CommandT
69
73
  end
70
74
 
71
75
  def flush
72
- set_up_max_height
73
- set_up_file_finder
76
+ @max_height = nil
77
+ @file_finder = nil
74
78
  end
75
79
 
76
80
  def handle_key
@@ -165,17 +169,8 @@ module CommandT
165
169
  clear # clears prompt and lists matches
166
170
  end
167
171
 
168
- def set_up_max_height
169
- @max_height = get_number('g:CommandTMaxHeight') || 0
170
- end
171
-
172
- def set_up_file_finder
173
- @file_finder = CommandT::FileFinder.new nil,
174
- :max_files => get_number('g:CommandTMaxFiles'),
175
- :max_depth => get_number('g:CommandTMaxDepth'),
176
- :always_show_dot_files => get_bool('g:CommandTAlwaysShowDotFiles'),
177
- :never_show_dot_files => get_bool('g:CommandTNeverShowDotFiles'),
178
- :scan_dot_directories => get_bool('g:CommandTScanDotDirectories')
172
+ def max_height
173
+ @max_height ||= get_number('g:CommandTMaxHeight') || 0
179
174
  end
180
175
 
181
176
  def exists? name
@@ -305,7 +300,7 @@ module CommandT
305
300
  def match_limit
306
301
  limit = VIM::Screen.lines - 5
307
302
  limit = 1 if limit < 0
308
- limit = [limit, @max_height].min if @max_height > 0
303
+ limit = [limit, max_height].min if max_height > 0
309
304
  limit
310
305
  end
311
306
 
@@ -313,5 +308,23 @@ module CommandT
313
308
  matches = @active_finder.sorted_matches_for @prompt.abbrev, :limit => match_limit
314
309
  @match_window.matches = matches
315
310
  end
311
+
312
+ def buffer_finder
313
+ @buffer_finder ||= CommandT::BufferFinder.new
314
+ end
315
+
316
+ def file_finder
317
+ @file_finder ||= CommandT::FileFinder.new nil,
318
+ :max_depth => get_number('g:CommandTMaxDepth'),
319
+ :max_files => get_number('g:CommandTMaxFiles'),
320
+ :max_caches => get_number('g:CommandTMaxCachedDirectories'),
321
+ :always_show_dot_files => get_bool('g:CommandTAlwaysShowDotFiles'),
322
+ :never_show_dot_files => get_bool('g:CommandTNeverShowDotFiles'),
323
+ :scan_dot_directories => get_bool('g:CommandTScanDotDirectories')
324
+ end
325
+
326
+ def jump_finder
327
+ @jump_finder ||= CommandT::JumpFinder.new
328
+ end
316
329
  end # class Controller
317
330
  end # module commandT
@@ -0,0 +1,35 @@
1
+ # Copyright 2011 Wincent Colaiuta. All rights reserved.
2
+ #
3
+ # Redistribution and use in source and binary forms, with or without
4
+ # modification, are permitted provided that the following conditions are met:
5
+ #
6
+ # 1. Redistributions of source code must retain the above copyright notice,
7
+ # this list of conditions and the following disclaimer.
8
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
9
+ # this list of conditions and the following disclaimer in the documentation
10
+ # and/or other materials provided with the distribution.
11
+ #
12
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
13
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
16
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22
+ # POSSIBILITY OF SUCH DAMAGE.
23
+
24
+ require 'command-t/ext' # CommandT::Matcher
25
+ require 'command-t/scanner/jump_scanner'
26
+ require 'command-t/finder'
27
+
28
+ module CommandT
29
+ class JumpFinder < Finder
30
+ def initialize
31
+ @scanner = JumpScanner.new
32
+ @matcher = Matcher.new @scanner, :always_show_dot_files => true
33
+ end
34
+ end # class JumpFinder
35
+ end # module CommandT
@@ -38,8 +38,9 @@ module CommandT
38
38
  # save existing window dimensions so we can restore them later
39
39
  @windows = []
40
40
  (0..(::VIM::Window.count - 1)).each do |i|
41
- window = OpenStruct.new :index => i, :height => ::VIM::Window[i].height
42
- @windows << window
41
+ @windows << OpenStruct.new(:index => i,
42
+ :height => ::VIM::Window[i].height,
43
+ :width => ::VIM::Window[i].width)
43
44
  end
44
45
 
45
46
  # global settings (must manually save and restore)
@@ -249,16 +250,25 @@ module CommandT
249
250
  end
250
251
 
251
252
  def restore_window_dimensions
252
- # sort from tallest to shortest
253
- @windows.sort! { |a, b| b.height <=> a.height }
253
+ # sort from tallest to shortest, tie-breaking on window width
254
+ @windows.sort! do |a, b|
255
+ order = b.height <=> a.height
256
+ if order.zero?
257
+ b.width <=> a.width
258
+ else
259
+ order
260
+ end
261
+ end
254
262
 
255
263
  # starting with the tallest ensures that there are no constraints
256
264
  # preventing windows on the side of vertical splits from regaining
257
265
  # their original full size
258
266
  @windows.each do |w|
259
267
  # beware: window may be nil
260
- window = ::VIM::Window[w.index]
261
- window.height = w.height if window
268
+ if window = ::VIM::Window[w.index]
269
+ window.height = w.height
270
+ window.width = w.width
271
+ end
262
272
  end
263
273
  end
264
274
 
@@ -339,20 +349,13 @@ module CommandT
339
349
  end
340
350
 
341
351
  def get_cursor_highlight
342
- # as :highlight returns nothing and only prints,
343
- # must redirect its output to a variable
344
- ::VIM::command 'silent redir => g:command_t_cursor_highlight'
345
-
346
- # force 0 verbosity to ensure origin information isn't printed as well
347
- ::VIM::command 'silent! 0verbose highlight Cursor'
348
- ::VIM::command 'silent redir END'
349
-
350
352
  # there are 3 possible formats to check for, each needing to be
351
353
  # transformed in a certain way in order to reapply the highlight:
352
354
  # Cursor xxx guifg=bg guibg=fg -> :hi! Cursor guifg=bg guibg=fg
353
355
  # Cursor xxx links to SomethingElse -> :hi! link Cursor SomethingElse
354
356
  # Cursor xxx cleared -> :hi! clear Cursor
355
- highlight = ::VIM::evaluate 'g:command_t_cursor_highlight'
357
+ highlight = VIM::capture 'silent! 0verbose highlight Cursor'
358
+
356
359
  if highlight =~ /^Cursor\s+xxx\s+links to (\w+)/
357
360
  "link Cursor #{$~[1]}"
358
361
  elsif highlight =~ /^Cursor\s+xxx\s+cleared/
@@ -28,40 +28,47 @@ module CommandT
28
28
  # Reads the current directory recursively for the paths to all regular files.
29
29
  class FileScanner < Scanner
30
30
  class FileLimitExceeded < ::RuntimeError; end
31
+ attr_accessor :path
31
32
 
32
33
  def initialize path = Dir.pwd, options = {}
34
+ @paths = {}
35
+ @paths_keys = []
33
36
  @path = path
34
37
  @max_depth = options[:max_depth] || 15
35
38
  @max_files = options[:max_files] || 10_000
39
+ @max_caches = options[:max_caches] || 1
36
40
  @scan_dot_directories = options[:scan_dot_directories] || false
37
41
  end
38
42
 
39
43
  def paths
40
- return @paths unless @paths.nil?
44
+ return @paths[@path] if @paths.has_key?(@path)
41
45
  begin
42
- @paths = []
43
- @depth = 0
44
- @files = 0
45
- @prefix_len = @path.chomp('/').length
46
- add_paths_for_directory @path, @paths
46
+ ensure_cache_under_limit
47
+ @paths[@path] = []
48
+ @depth = 0
49
+ @files = 0
50
+ @prefix_len = @path.chomp('/').length
51
+ add_paths_for_directory @path, @paths[@path]
47
52
  rescue FileLimitExceeded
48
53
  end
49
- @paths
54
+ @paths[@path]
50
55
  end
51
56
 
52
57
  def flush
53
- @paths = nil
58
+ @paths = {}
54
59
  end
55
60
 
56
- def path= str
57
- if @path != str
58
- @path = str
59
- flush
61
+ private
62
+
63
+ def ensure_cache_under_limit
64
+ # Ruby 1.8 doesn't have an ordered hash, so use a separate stack to
65
+ # track and expire the oldest entry in the cache
66
+ if @max_caches > 0 && @paths_keys.length >= @max_caches
67
+ @paths.delete @paths_keys.shift
60
68
  end
69
+ @paths_keys << @path
61
70
  end
62
71
 
63
- private
64
-
65
72
  def path_excluded? path
66
73
  # first strip common prefix (@path) from path to match VIM's behavior
67
74
  path = path[(@prefix_len + 1)..-1]
@@ -0,0 +1,53 @@
1
+ # Copyright 2011 Wincent Colaiuta. All rights reserved.
2
+ #
3
+ # Redistribution and use in source and binary forms, with or without
4
+ # modification, are permitted provided that the following conditions are met:
5
+ #
6
+ # 1. Redistributions of source code must retain the above copyright notice,
7
+ # this list of conditions and the following disclaimer.
8
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
9
+ # this list of conditions and the following disclaimer in the documentation
10
+ # and/or other materials provided with the distribution.
11
+ #
12
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
13
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
16
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22
+ # POSSIBILITY OF SUCH DAMAGE.
23
+
24
+ require 'command-t/vim'
25
+ require 'command-t/vim/path_utilities'
26
+ require 'command-t/scanner'
27
+
28
+ module CommandT
29
+ # Returns a list of files in the jumplist.
30
+ class JumpScanner < Scanner
31
+ include VIM::PathUtilities
32
+
33
+ def paths
34
+ jumps_with_filename = jumps.select do |line|
35
+ line_contains_filename?(line)
36
+ end
37
+ filenames = jumps_with_filename[1..-2].map do |line|
38
+ relative_path_under_working_directory line.split[3]
39
+ end
40
+ filenames.sort.uniq
41
+ end
42
+
43
+ private
44
+
45
+ def line_contains_filename? line
46
+ line.split.count > 3
47
+ end
48
+
49
+ def jumps
50
+ VIM::capture 'silent jumps'
51
+ end
52
+ end # class JumpScanner
53
+ end # module CommandT
@@ -27,12 +27,8 @@ module CommandT
27
27
  'Please see INSTALLATION and TROUBLE-SHOOTING in the help',
28
28
  'For more information type: :help command-t']
29
29
 
30
- def show_file_finder
31
- warn *@@load_error
32
- end
33
-
34
- def flush
35
- warn *@@load_error
30
+ [:flush, :show_buffer_finder, :show_file_finder].each do |method|
31
+ define_method(method.to_sym) { warn *@@load_error }
36
32
  end
37
33
 
38
34
  private
@@ -1,4 +1,4 @@
1
- # Copyright 2010 Wincent Colaiuta. All rights reserved.
1
+ # Copyright 2010-2011 Wincent Colaiuta. All rights reserved.
2
2
  #
3
3
  # Redistribution and use in source and binary forms, with or without
4
4
  # modification, are permitted provided that the following conditions are met:
@@ -34,6 +34,14 @@ module CommandT
34
34
  ::VIM::evaluate 'getcwd()'
35
35
  end
36
36
 
37
+ # Execute cmd, capturing the output into a variable and returning it.
38
+ def self.capture cmd
39
+ ::VIM::command 'silent redir => g:command_t_captured_output'
40
+ ::VIM::command cmd
41
+ ::VIM::command 'silent redir END'
42
+ ::VIM::evaluate 'g:command_t_captured_output'
43
+ end
44
+
37
45
  # Escape a string for safe inclusion in a Vim single-quoted string
38
46
  # (single quotes escaped by doubling, everything else is literal)
39
47
  def self.escape_for_single_quotes str
metadata CHANGED
@@ -1,13 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: command-t
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
5
- prerelease:
4
+ prerelease: false
6
5
  segments:
7
6
  - 1
8
- - 2
9
- - 1
10
- version: 1.2.1
7
+ - 3
8
+ version: "1.3"
11
9
  platform: ruby
12
10
  authors:
13
11
  - Wincent Colaiuta
@@ -34,12 +32,12 @@ files:
34
32
  - Rakefile
35
33
  - ruby/command-t/controller.rb
36
34
  - ruby/command-t/depend
37
- - ruby/command-t/ext.bundle
38
35
  - ruby/command-t/ext.c
39
36
  - ruby/command-t/ext.h
40
37
  - ruby/command-t/extconf.rb
41
38
  - ruby/command-t/finder/buffer_finder.rb
42
39
  - ruby/command-t/finder/file_finder.rb
40
+ - ruby/command-t/finder/jump_finder.rb
43
41
  - ruby/command-t/finder.rb
44
42
  - ruby/command-t/Makefile
45
43
  - ruby/command-t/match.c
@@ -51,6 +49,7 @@ files:
51
49
  - ruby/command-t/ruby_compat.h
52
50
  - ruby/command-t/scanner/buffer_scanner.rb
53
51
  - ruby/command-t/scanner/file_scanner.rb
52
+ - ruby/command-t/scanner/jump_scanner.rb
54
53
  - ruby/command-t/scanner.rb
55
54
  - ruby/command-t/settings.rb
56
55
  - ruby/command-t/stub.rb
@@ -70,27 +69,23 @@ rdoc_options: []
70
69
  require_paths:
71
70
  - ruby
72
71
  required_ruby_version: !ruby/object:Gem::Requirement
73
- none: false
74
72
  requirements:
75
73
  - - ">="
76
74
  - !ruby/object:Gem::Version
77
- hash: 3
78
75
  segments:
79
76
  - 0
80
77
  version: "0"
81
78
  required_rubygems_version: !ruby/object:Gem::Requirement
82
- none: false
83
79
  requirements:
84
80
  - - ">="
85
81
  - !ruby/object:Gem::Version
86
- hash: 3
87
82
  segments:
88
83
  - 0
89
84
  version: "0"
90
85
  requirements: []
91
86
 
92
87
  rubyforge_project:
93
- rubygems_version: 1.6.2
88
+ rubygems_version: 1.3.6
94
89
  signing_key:
95
90
  specification_version: 3
96
91
  summary: The Command-T plug-in for VIM.
Binary file