command-t 1.11 → 1.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.txt +53 -12
- data/Rakefile +2 -2
- data/doc/command-t.txt +53 -12
- data/ruby/command-t/controller.rb +34 -56
- data/ruby/command-t/ext.bundle +0 -0
- data/ruby/command-t/extconf.rb +1 -0
- data/ruby/command-t/finder.rb +4 -4
- data/ruby/command-t/finder/mru_buffer_finder.rb +8 -8
- data/ruby/command-t/finder/tag_finder.rb +2 -2
- data/ruby/command-t/match.c +8 -19
- data/ruby/command-t/match_window.rb +15 -15
- data/ruby/command-t/mru.rb +5 -0
- data/ruby/command-t/prompt.rb +18 -18
- data/ruby/command-t/scanner/buffer_scanner.rb +0 -1
- data/ruby/command-t/scanner/file_scanner.rb +30 -16
- data/ruby/command-t/scanner/file_scanner/find_file_scanner.rb +29 -36
- data/ruby/command-t/scanner/file_scanner/git_file_scanner.rb +18 -25
- data/ruby/command-t/scanner/file_scanner/ruby_file_scanner.rb +12 -17
- data/ruby/command-t/scanner/file_scanner/watchman_file_scanner.rb +29 -35
- data/ruby/command-t/scanner/jump_scanner.rb +1 -2
- data/ruby/command-t/scanner/tag_scanner.rb +1 -2
- data/ruby/command-t/settings.rb +5 -15
- data/ruby/command-t/stub.rb +3 -2
- data/ruby/command-t/vim.rb +53 -29
- data/ruby/command-t/vim/path_utilities.rb +1 -1
- data/ruby/command-t/vim/screen.rb +4 -2
- data/ruby/command-t/vim/window.rb +11 -9
- metadata +2 -2
@@ -7,34 +7,27 @@ module CommandT
|
|
7
7
|
class FileScanner
|
8
8
|
# Uses git ls-files to scan for files
|
9
9
|
class GitFileScanner < FindFileScanner
|
10
|
-
def paths
|
11
|
-
@
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
def paths!
|
11
|
+
Dir.chdir(@path) do
|
12
|
+
stdin, stdout, stderr = Open3.popen3(*[
|
13
|
+
'git',
|
14
|
+
'ls-files',
|
15
|
+
'--exclude-standard',
|
16
|
+
@path
|
17
|
+
])
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
])
|
19
|
+
all_files = stdout.readlines.
|
20
|
+
map { |path| path.chomp }.
|
21
|
+
reject { |path| path_excluded?(path, 0) }.
|
22
|
+
take(@max_files).
|
23
|
+
to_a
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
reject { |path| path_excluded?(path, 0) }.
|
26
|
-
take(@max_files).
|
27
|
-
to_a
|
28
|
-
|
29
|
-
# will fall back to find if not a git repository or there's an error
|
30
|
-
stderr.gets ? super : all_files
|
31
|
-
end
|
32
|
-
rescue Errno::ENOENT => e
|
33
|
-
# git executable not present and executable
|
34
|
-
super
|
35
|
-
ensure
|
36
|
-
set_wild_ignore(@base_wild_ignore)
|
25
|
+
# will fall back to find if not a git repository or there's an error
|
26
|
+
stderr.gets ? super : all_files
|
37
27
|
end
|
28
|
+
rescue Errno::ENOENT => e
|
29
|
+
# git executable not present and executable
|
30
|
+
super
|
38
31
|
end
|
39
32
|
end # class GitFileScanner
|
40
33
|
end # class FileScanner
|
@@ -1,37 +1,32 @@
|
|
1
1
|
# Copyright 2010-2014 Greg Hurrell. All rights reserved.
|
2
2
|
# Licensed under the terms of the BSD 2-clause license.
|
3
3
|
|
4
|
-
require 'command-t/vim'
|
5
4
|
require 'command-t/scanner/file_scanner'
|
6
5
|
|
7
6
|
module CommandT
|
8
7
|
class FileScanner
|
9
8
|
# Pure Ruby implementation of a file scanner.
|
10
9
|
class RubyFileScanner < FileScanner
|
11
|
-
def paths
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
ensure
|
20
|
-
set_wild_ignore(@base_wild_ignore)
|
21
|
-
end
|
22
|
-
@paths[@path]
|
10
|
+
def paths!
|
11
|
+
accumulator = []
|
12
|
+
@depth = 0
|
13
|
+
@files = 0
|
14
|
+
add_paths_for_directory(@path, accumulator)
|
15
|
+
accumulator
|
16
|
+
rescue FileLimitExceeded
|
17
|
+
accumulator
|
23
18
|
end
|
24
19
|
|
25
20
|
private
|
26
21
|
|
27
|
-
def looped_symlink?
|
22
|
+
def looped_symlink?(path)
|
28
23
|
if File.symlink?(path)
|
29
24
|
target = File.expand_path(File.readlink(path), File.dirname(path))
|
30
25
|
target.include?(@path) || @path.include?(target)
|
31
26
|
end
|
32
27
|
end
|
33
28
|
|
34
|
-
def add_paths_for_directory
|
29
|
+
def add_paths_for_directory(dir, accumulator)
|
35
30
|
Dir.foreach(dir) do |entry|
|
36
31
|
next if ['.', '..'].include?(entry)
|
37
32
|
path = File.join(dir, entry)
|
@@ -39,13 +34,13 @@ module CommandT
|
|
39
34
|
if File.file?(path)
|
40
35
|
@files += 1
|
41
36
|
raise FileLimitExceeded if @files > @max_files
|
42
|
-
accumulator << path[@prefix_len
|
37
|
+
accumulator << path[@prefix_len..-1]
|
43
38
|
elsif File.directory?(path)
|
44
39
|
next if @depth >= @max_depth
|
45
40
|
next if (entry.match(/\A\./) && !@scan_dot_directories)
|
46
41
|
next if looped_symlink?(path)
|
47
42
|
@depth += 1
|
48
|
-
add_paths_for_directory
|
43
|
+
add_paths_for_directory(path, accumulator)
|
49
44
|
@depth -= 1
|
50
45
|
end
|
51
46
|
end
|
@@ -3,7 +3,6 @@
|
|
3
3
|
|
4
4
|
require 'pathname'
|
5
5
|
require 'socket'
|
6
|
-
require 'command-t/vim'
|
7
6
|
require 'command-t/vim/path_utilities'
|
8
7
|
require 'command-t/scanner/file_scanner'
|
9
8
|
require 'command-t/scanner/file_scanner/find_file_scanner'
|
@@ -20,43 +19,38 @@ module CommandT
|
|
20
19
|
# requested path.
|
21
20
|
class WatchmanUnavailable < RuntimeError; end
|
22
21
|
|
23
|
-
def paths
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
# root_restrict_files setting may prevent Watchman from working
|
39
|
-
raise WatchmanUnavailable if result.has_key?('error')
|
40
|
-
end
|
41
|
-
|
42
|
-
query = ['query', root, {
|
43
|
-
'expression' => ['type', 'f'],
|
44
|
-
'fields' => ['name'],
|
45
|
-
}]
|
46
|
-
paths = Watchman::Utils.query(query, socket)
|
47
|
-
|
48
|
-
# could return error if watch is removed
|
49
|
-
raise WatchmanUnavailable if paths.has_key?('error')
|
50
|
-
|
51
|
-
@paths[@path] = paths['files']
|
22
|
+
def paths!
|
23
|
+
sockname = Watchman::Utils.load(
|
24
|
+
%x{watchman --output-encoding=bser get-sockname}
|
25
|
+
)['sockname']
|
26
|
+
raise WatchmanUnavailable unless $?.exitstatus.zero?
|
27
|
+
|
28
|
+
UNIXSocket.open(sockname) do |socket|
|
29
|
+
root = Pathname.new(@path).realpath.to_s
|
30
|
+
roots = Watchman::Utils.query(['watch-list'], socket)['roots']
|
31
|
+
if !roots.include?(root)
|
32
|
+
# this path isn't being watched yet; try to set up watch
|
33
|
+
result = Watchman::Utils.query(['watch', root], socket)
|
34
|
+
|
35
|
+
# root_restrict_files setting may prevent Watchman from working
|
36
|
+
raise WatchmanUnavailable if result.has_key?('error')
|
52
37
|
end
|
53
|
-
end
|
54
38
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
39
|
+
query = ['query', root, {
|
40
|
+
'expression' => ['type', 'f'],
|
41
|
+
'fields' => ['name'],
|
42
|
+
}]
|
43
|
+
paths = Watchman::Utils.query(query, socket)
|
44
|
+
|
45
|
+
# could return error if watch is removed
|
46
|
+
raise WatchmanUnavailable if paths.has_key?('error')
|
47
|
+
|
48
|
+
paths['files']
|
49
|
+
end
|
59
50
|
end
|
51
|
+
rescue Errno::ENOENT, WatchmanUnavailable
|
52
|
+
# watchman executable not present, or unable to fulfil request
|
53
|
+
super
|
60
54
|
end # class WatchmanFileScanner
|
61
55
|
end # class FileScanner
|
62
56
|
end # module CommandT
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# Copyright 2011-2014 Greg Hurrell. All rights reserved.
|
2
2
|
# Licensed under the terms of the BSD 2-clause license.
|
3
3
|
|
4
|
-
require 'command-t/vim'
|
5
4
|
require 'command-t/vim/path_utilities'
|
6
5
|
require 'command-t/scanner'
|
7
6
|
|
@@ -23,7 +22,7 @@ module CommandT
|
|
23
22
|
|
24
23
|
private
|
25
24
|
|
26
|
-
def line_contains_filename?
|
25
|
+
def line_contains_filename?(line)
|
27
26
|
line.split.count > 3
|
28
27
|
end
|
29
28
|
|
@@ -1,14 +1,13 @@
|
|
1
1
|
# Copyright 2011-2014 Greg Hurrell. All rights reserved.
|
2
2
|
# Licensed under the terms of the BSD 2-clause license.
|
3
3
|
|
4
|
-
require 'command-t/vim'
|
5
4
|
require 'command-t/scanner'
|
6
5
|
|
7
6
|
module CommandT
|
8
7
|
class TagScanner < Scanner
|
9
8
|
attr_reader :include_filenames
|
10
9
|
|
11
|
-
def initialize
|
10
|
+
def initialize(options = {})
|
12
11
|
@include_filenames = options[:include_filenames] || false
|
13
12
|
@cached_tags = nil
|
14
13
|
end
|
data/ruby/command-t/settings.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Copyright 2010-2014 Greg Hurrell. All rights reserved.
|
2
2
|
# Licensed under the terms of the BSD 2-clause license.
|
3
3
|
|
4
|
+
require 'command-t/vim'
|
5
|
+
|
4
6
|
module CommandT
|
5
7
|
# Convenience class for saving and restoring global settings.
|
6
8
|
class Settings
|
@@ -52,13 +54,13 @@ module CommandT
|
|
52
54
|
|
53
55
|
case value
|
54
56
|
when TrueClass, FalseClass
|
55
|
-
@settings.push([setting, get_bool(setting)]) if global?(setting)
|
57
|
+
@settings.push([setting, VIM::get_bool("&#{setting}")]) if global?(setting)
|
56
58
|
set_bool setting, value
|
57
59
|
when Numeric
|
58
|
-
@settings.push([setting, get_number(setting)]) if global?(setting)
|
60
|
+
@settings.push([setting, VIM::get_number("&#{setting}")]) if global?(setting)
|
59
61
|
set_number setting, value
|
60
62
|
when String
|
61
|
-
@settings.push([setting, get_string(setting)]) if global?(setting)
|
63
|
+
@settings.push([setting, VIM::get_string("&#{setting}")]) if global?(setting)
|
62
64
|
set_string setting, value
|
63
65
|
end
|
64
66
|
end
|
@@ -82,18 +84,6 @@ module CommandT
|
|
82
84
|
GLOBAL_SETTINGS.include?(setting)
|
83
85
|
end
|
84
86
|
|
85
|
-
def get_bool(setting)
|
86
|
-
::VIM::evaluate("&#{setting}").to_i == 1
|
87
|
-
end
|
88
|
-
|
89
|
-
def get_number(setting)
|
90
|
-
::VIM::evaluate("&#{setting}").to_i
|
91
|
-
end
|
92
|
-
|
93
|
-
def get_string(name)
|
94
|
-
::VIM::evaluate("&#{name}").to_s
|
95
|
-
end
|
96
|
-
|
97
87
|
def set_bool(setting, value)
|
98
88
|
command = global?(setting) ? 'set' : 'setlocal'
|
99
89
|
setting = value ? setting : "no#{setting}"
|
data/ruby/command-t/stub.rb
CHANGED
@@ -3,9 +3,10 @@
|
|
3
3
|
|
4
4
|
module CommandT
|
5
5
|
class Stub
|
6
|
+
@@patch_level = defined?(RUBY_PATCHLEVEL) ? RUBY_PATCHLEVEL : '[unknown]'
|
6
7
|
@@load_error = ['command-t.vim could not load the C extension',
|
7
8
|
'Please see INSTALLATION and TROUBLE-SHOOTING in the help',
|
8
|
-
"Vim Ruby version: #{RUBY_VERSION}-p#{
|
9
|
+
"Vim Ruby version: #{RUBY_VERSION}-p#{@@patch_level}",
|
9
10
|
'For more information type: :help command-t']
|
10
11
|
|
11
12
|
[
|
@@ -21,7 +22,7 @@ module CommandT
|
|
21
22
|
|
22
23
|
private
|
23
24
|
|
24
|
-
def warn
|
25
|
+
def warn(*msg)
|
25
26
|
::VIM::command 'echohl WarningMsg'
|
26
27
|
msg.each { |m| ::VIM::command "echo '#{m}'" }
|
27
28
|
::VIM::command 'echohl none'
|
data/ruby/command-t/vim.rb
CHANGED
@@ -6,42 +6,66 @@ require 'command-t/vim/window'
|
|
6
6
|
|
7
7
|
module CommandT
|
8
8
|
module VIM
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
class << self
|
10
|
+
# Check for the existence of a feature such as "conceal" or "syntax".
|
11
|
+
def has?(feature)
|
12
|
+
::VIM::evaluate(%{has("#{feature}")}).to_i != 0
|
13
|
+
end
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
15
|
+
# Check for the presence of a setting such as:
|
16
|
+
#
|
17
|
+
# - g:CommandTSmartCase (plug-in setting)
|
18
|
+
# - &wildignore (Vim setting)
|
19
|
+
# - +cursorcolumn (Vim setting, that works)
|
20
|
+
#
|
21
|
+
def exists?(str)
|
22
|
+
::VIM::evaluate(%{exists("#{str}")}).to_i != 0
|
23
|
+
end
|
16
24
|
|
17
|
-
|
18
|
-
|
19
|
-
|
25
|
+
def get_number(name)
|
26
|
+
exists?(name) ? ::VIM::evaluate("#{name}").to_i : nil
|
27
|
+
end
|
20
28
|
|
21
|
-
|
22
|
-
|
23
|
-
|
29
|
+
def get_bool(name)
|
30
|
+
exists?(name) ? ::VIM::evaluate("#{name}").to_i != 0 : nil
|
31
|
+
end
|
24
32
|
|
25
|
-
|
26
|
-
|
27
|
-
|
33
|
+
def get_string(name)
|
34
|
+
exists?(name) ? ::VIM::evaluate("#{name}").to_s : nil
|
35
|
+
end
|
28
36
|
|
29
|
-
|
30
|
-
|
31
|
-
|
37
|
+
# expect a string or a list of strings
|
38
|
+
def get_list_or_string(name)
|
39
|
+
return nil unless exists?(name)
|
40
|
+
list_or_string = ::VIM::evaluate("#{name}")
|
41
|
+
if list_or_string.kind_of?(Array)
|
42
|
+
list_or_string.map { |item| item.to_s }
|
43
|
+
else
|
44
|
+
list_or_string.to_s
|
45
|
+
end
|
46
|
+
end
|
32
47
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
48
|
+
def pwd
|
49
|
+
::VIM::evaluate 'getcwd()'
|
50
|
+
end
|
51
|
+
|
52
|
+
def current_file_dir
|
53
|
+
::VIM::evaluate 'expand("%:p:h")'
|
54
|
+
end
|
55
|
+
|
56
|
+
# Execute cmd, capturing the output into a variable and returning it.
|
57
|
+
def capture(cmd)
|
58
|
+
::VIM::command 'silent redir => g:command_t_captured_output'
|
59
|
+
::VIM::command cmd
|
60
|
+
::VIM::command 'silent redir END'
|
61
|
+
::VIM::evaluate 'g:command_t_captured_output'
|
62
|
+
end
|
40
63
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
64
|
+
# Escape a string for safe inclusion in a Vim single-quoted string
|
65
|
+
# (single quotes escaped by doubling, everything else is literal)
|
66
|
+
def escape_for_single_quotes(str)
|
67
|
+
str.gsub "'", "''"
|
68
|
+
end
|
45
69
|
end
|
46
70
|
end # module VIM
|
47
71
|
end # module CommandT
|
@@ -9,7 +9,7 @@ module CommandT
|
|
9
9
|
|
10
10
|
private
|
11
11
|
|
12
|
-
def relative_path_under_working_directory
|
12
|
+
def relative_path_under_working_directory(path)
|
13
13
|
# any path under the working directory will be specified as a relative
|
14
14
|
# path to improve the readability of the buffer list etc
|
15
15
|
pwd = File.expand_path(VIM::pwd) + '/'
|
@@ -3,16 +3,18 @@
|
|
3
3
|
|
4
4
|
module CommandT
|
5
5
|
module VIM
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
module Window
|
7
|
+
class << self
|
8
|
+
def select(window)
|
9
|
+
return true if $curwin == window
|
10
|
+
initial = $curwin
|
11
|
+
while true do
|
12
|
+
::VIM::command 'wincmd w' # cycle through windows
|
13
|
+
return true if $curwin == window # have selected desired window
|
14
|
+
return false if $curwin == initial # have already looped through all
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
16
|
-
end #
|
18
|
+
end # module Window
|
17
19
|
end # module VIM
|
18
20
|
end # module CommandT
|