tomkersten-vixploder 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +105 -0
- data/PostInstall.txt +21 -0
- data/README.rdoc +131 -0
- data/Rakefile +21 -0
- data/bin/256colors2.pl +63 -0
- data/bin/colortest +365 -0
- data/bin/vixplode +10 -0
- data/lib/dotfiles/aliases +30 -0
- data/lib/dotfiles/gvimrc +20 -0
- data/lib/dotfiles/vim/.VimballRecord +2 -0
- data/lib/dotfiles/vim/after/ftplugin/actionscript_snippets.vim +9 -0
- data/lib/dotfiles/vim/after/ftplugin/aspvbs_snippets.vim +17 -0
- data/lib/dotfiles/vim/after/ftplugin/c_snippets.vim +58 -0
- data/lib/dotfiles/vim/after/ftplugin/css_snippets.vim +30 -0
- data/lib/dotfiles/vim/after/ftplugin/django_model_snippets.vim +61 -0
- data/lib/dotfiles/vim/after/ftplugin/django_template_snippets.vim +32 -0
- data/lib/dotfiles/vim/after/ftplugin/f-script_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/haskell_snippets.vim +9 -0
- data/lib/dotfiles/vim/after/ftplugin/html_snippets.vim +57 -0
- data/lib/dotfiles/vim/after/ftplugin/java_snippets.vim +52 -0
- data/lib/dotfiles/vim/after/ftplugin/javascript_snippets.vim +10 -0
- data/lib/dotfiles/vim/after/ftplugin/latex_snippets.vim +13 -0
- data/lib/dotfiles/vim/after/ftplugin/logo_snippets.vim +9 -0
- data/lib/dotfiles/vim/after/ftplugin/markdown_snippets.vim +10 -0
- data/lib/dotfiles/vim/after/ftplugin/movable_type_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/objc_snippets.vim +53 -0
- data/lib/dotfiles/vim/after/ftplugin/ocaml_snippets.vim +26 -0
- data/lib/dotfiles/vim/after/ftplugin/perl_snippets.vim +23 -0
- data/lib/dotfiles/vim/after/ftplugin/php_snippets.vim +30 -0
- data/lib/dotfiles/vim/after/ftplugin/phpdoc_snippets.vim +19 -0
- data/lib/dotfiles/vim/after/ftplugin/propel_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/python_snippets.vim +202 -0
- data/lib/dotfiles/vim/after/ftplugin/rails_snippets.vim +54 -0
- data/lib/dotfiles/vim/after/ftplugin/ruby_snippets.vim +32 -0
- data/lib/dotfiles/vim/after/ftplugin/sh_snippets.vim +12 -0
- data/lib/dotfiles/vim/after/ftplugin/slate_snippets.vim +19 -0
- data/lib/dotfiles/vim/after/ftplugin/smarty_snippets.vim +35 -0
- data/lib/dotfiles/vim/after/ftplugin/symfony_snippets.vim +21 -0
- data/lib/dotfiles/vim/after/ftplugin/tcl_snippets.vim +14 -0
- data/lib/dotfiles/vim/after/ftplugin/template_toolkit_snippets.vim +13 -0
- data/lib/dotfiles/vim/after/ftplugin/tex_snippets.vim +13 -0
- data/lib/dotfiles/vim/after/ftplugin/xhtml_snippets.vim +48 -0
- data/lib/dotfiles/vim/autoload/fakeclip.vim +253 -0
- data/lib/dotfiles/vim/autoload/rails.vim +4377 -0
- data/lib/dotfiles/vim/autoload/rubycomplete.vim +802 -0
- data/lib/dotfiles/vim/colors/inkpot.vim +212 -0
- data/lib/dotfiles/vim/colors/ir_black.vim +212 -0
- data/lib/dotfiles/vim/colors/ir_black_mod.vim +213 -0
- data/lib/dotfiles/vim/colors/railscasts.vim +100 -0
- data/lib/dotfiles/vim/colors/rubyblue.vim +74 -0
- data/lib/dotfiles/vim/colors/twilight.vim +75 -0
- data/lib/dotfiles/vim/colors/twilight2.vim +74 -0
- data/lib/dotfiles/vim/colors/wombat256.vim +302 -0
- data/lib/dotfiles/vim/compiler/eruby.vim +41 -0
- data/lib/dotfiles/vim/compiler/ruby.vim +68 -0
- data/lib/dotfiles/vim/compiler/rubyunit.vim +35 -0
- data/lib/dotfiles/vim/doc/NERD_tree.txt +1235 -0
- data/lib/dotfiles/vim/doc/fakeclip.txt +190 -0
- data/lib/dotfiles/vim/doc/matchit.txt +406 -0
- data/lib/dotfiles/vim/doc/project.txt +710 -0
- data/lib/dotfiles/vim/doc/rails.txt +1123 -0
- data/lib/dotfiles/vim/doc/snippets_emu.txt +354 -0
- data/lib/dotfiles/vim/doc/surround.txt +218 -0
- data/lib/dotfiles/vim/doc/tags +433 -0
- data/lib/dotfiles/vim/filetype.vim +13 -0
- data/lib/dotfiles/vim/ftdetect/gist.vim +3 -0
- data/lib/dotfiles/vim/ftdetect/ruby.vim +14 -0
- data/lib/dotfiles/vim/ftplugin/eruby.vim +101 -0
- data/lib/dotfiles/vim/ftplugin/ruby.vim +230 -0
- data/lib/dotfiles/vim/indent/eruby.vim +73 -0
- data/lib/dotfiles/vim/indent/ruby.vim +373 -0
- data/lib/dotfiles/vim/plugin/NERD_tree.vim +3536 -0
- data/lib/dotfiles/vim/plugin/comments.vim +321 -0
- data/lib/dotfiles/vim/plugin/fakeclip.vim +174 -0
- data/lib/dotfiles/vim/plugin/fuzzyfinder.vim +1676 -0
- data/lib/dotfiles/vim/plugin/fuzzyfinder_textmate.vim +150 -0
- data/lib/dotfiles/vim/plugin/gist.vim +241 -0
- data/lib/dotfiles/vim/plugin/gitdiff.vim +141 -0
- data/lib/dotfiles/vim/plugin/matchit.vim +812 -0
- data/lib/dotfiles/vim/plugin/mru.vim +787 -0
- data/lib/dotfiles/vim/plugin/rails.vim +310 -0
- data/lib/dotfiles/vim/plugin/rspec.vim +12 -0
- data/lib/dotfiles/vim/plugin/snippets.vim +17 -0
- data/lib/dotfiles/vim/plugin/snippetsEmu.vim +973 -0
- data/lib/dotfiles/vim/plugin/supertab.vim +531 -0
- data/lib/dotfiles/vim/plugin/surround.vim +632 -0
- data/lib/dotfiles/vim/ref_vimrc +80 -0
- data/lib/dotfiles/vim/ruby/fuzzy_file_finder.rb +353 -0
- data/lib/dotfiles/vim/syntax/eruby.vim +85 -0
- data/lib/dotfiles/vim/syntax/haml.vim +113 -0
- data/lib/dotfiles/vim/syntax/mkd.vim +86 -0
- data/lib/dotfiles/vim/syntax/ruby.vim +324 -0
- data/lib/dotfiles/vim/syntax/sass.vim +93 -0
- data/lib/dotfiles/vimrc +269 -0
- data/lib/vixplode/cli.rb +73 -0
- data/lib/vixploder.rb +6 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/vixplode_cli_spec.rb +15 -0
- data/spec/vixploder_spec.rb +7 -0
- data/tasks/rspec.rake +21 -0
- metadata +202 -8
@@ -0,0 +1,80 @@
|
|
1
|
+
filetype plugin indent on " Automatically detect file types.
|
2
|
+
set nocompatible " We don't want vi compatibility.
|
3
|
+
|
4
|
+
" Add recently accessed projects menu (project plugin)
|
5
|
+
set viminfo^=!
|
6
|
+
|
7
|
+
" Minibuffer Explorer Settings
|
8
|
+
let g:miniBufExplMapWindowNavVim = 1
|
9
|
+
let g:miniBufExplMapWindowNavArrows = 1
|
10
|
+
let g:miniBufExplMapCTabSwitchBufs = 1
|
11
|
+
let g:miniBufExplModSelTarget = 1
|
12
|
+
|
13
|
+
" Change which file opens after executing :Rails command
|
14
|
+
let g:rails_default_file='config/database.yml'
|
15
|
+
|
16
|
+
syntax enable
|
17
|
+
|
18
|
+
set cf " Enable error files & error jumping.
|
19
|
+
set clipboard+=unnamed " Yanks go on clipboard instead.
|
20
|
+
set history=256 " Number of things to remember in history.
|
21
|
+
set autowrite " Writes on make/shell commands
|
22
|
+
set ruler " Ruler on
|
23
|
+
set nu " Line numbers on
|
24
|
+
set nowrap " Line wrapping off
|
25
|
+
set timeoutlen=250 " Time to wait after ESC (default causes an annoying delay)
|
26
|
+
|
27
|
+
" Color scheme
|
28
|
+
set background=dark
|
29
|
+
colorscheme ir_black_mod " This is a much better color scheme, Scotty :)
|
30
|
+
"colorscheme twilight
|
31
|
+
|
32
|
+
" Formatting (some of these are for coding in C and C++)
|
33
|
+
set ts=2 " Tabs are 4 spaces
|
34
|
+
set bs=2 " Backspace over everything in insert mode
|
35
|
+
set shiftwidth=2 " Tabs under smart indent
|
36
|
+
set nocp incsearch
|
37
|
+
set nocp hlsearch
|
38
|
+
set cinoptions=:0,p0,t0
|
39
|
+
set cinwords=if,else,while,do,for,switch,case
|
40
|
+
set formatoptions=tcqr
|
41
|
+
set cindent
|
42
|
+
set autoindent
|
43
|
+
set smarttab
|
44
|
+
"set lines=50
|
45
|
+
"set columns=120
|
46
|
+
set backspace=2
|
47
|
+
|
48
|
+
" Visual
|
49
|
+
set showmatch " Show matching brackets.
|
50
|
+
set mat=5 " Bracket blinking.
|
51
|
+
set novisualbell " No blinking .
|
52
|
+
set noerrorbells " No noise.
|
53
|
+
set laststatus=2 " Always show status line.
|
54
|
+
|
55
|
+
" gvim specific
|
56
|
+
set mousehide " Hide mouse after chars typed
|
57
|
+
set mouse=a " Mouse in all modes
|
58
|
+
|
59
|
+
"set showtabline=2
|
60
|
+
set tabpagemax=15
|
61
|
+
" set guifont=DejaVu\ Sans\ Mono\ 10
|
62
|
+
set cursorline
|
63
|
+
|
64
|
+
runtime! macros/matchit.vim
|
65
|
+
|
66
|
+
augroup myfiletypes
|
67
|
+
autocmd!
|
68
|
+
autocmd FileType ruby,eruby,yaml set ai sw=2 sts=2 et
|
69
|
+
augroup END
|
70
|
+
|
71
|
+
nnoremap <silent> <C-n> :tabnext<CR>
|
72
|
+
nnoremap <silent> <C-p> :tabprevious<CR>
|
73
|
+
nnoremap <silent> <C-t> :tabnew<CR>
|
74
|
+
nnoremap <silent> <C-w> :tabclose<CR>
|
75
|
+
noremap <C-j> :bprev<CR>
|
76
|
+
noremap <C-k> :bnext<CR>
|
77
|
+
|
78
|
+
let g:buftabs_only_basename=1
|
79
|
+
set laststatus=2
|
80
|
+
let g:buftabs_in_statusline=1
|
@@ -0,0 +1,353 @@
|
|
1
|
+
#--
|
2
|
+
# ==================================================================
|
3
|
+
# Author: Jamis Buck (jamis@jamisbuck.org)
|
4
|
+
# Date: 2008-10-09
|
5
|
+
#
|
6
|
+
# This file is in the public domain. Usage, modification, and
|
7
|
+
# redistribution of this file are unrestricted.
|
8
|
+
# ==================================================================
|
9
|
+
#++
|
10
|
+
|
11
|
+
# The "fuzzy" file finder provides a way for searching a directory
|
12
|
+
# tree with only a partial name. This is similar to the "cmd-T"
|
13
|
+
# feature in TextMate (http://macromates.com).
|
14
|
+
#
|
15
|
+
# Usage:
|
16
|
+
#
|
17
|
+
# finder = FuzzyFileFinder.new
|
18
|
+
# finder.search("app/blogcon") do |match|
|
19
|
+
# puts match[:highlighted_path]
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# In the above example, all files matching "app/blogcon" will be
|
23
|
+
# yielded to the block. The given pattern is reduced to a regular
|
24
|
+
# expression internally, so that any file that contains those
|
25
|
+
# characters in that order (even if there are other characters
|
26
|
+
# in between) will match.
|
27
|
+
#
|
28
|
+
# In other words, "app/blogcon" would match any of the following
|
29
|
+
# (parenthesized strings indicate how the match was made):
|
30
|
+
#
|
31
|
+
# * (app)/controllers/(blog)_(con)troller.rb
|
32
|
+
# * lib/c(ap)_(p)ool/(bl)ue_(o)r_(g)reen_(co)loratio(n)
|
33
|
+
# * test/(app)/(blog)_(con)troller_test.rb
|
34
|
+
#
|
35
|
+
# And so forth.
|
36
|
+
class FuzzyFileFinder
|
37
|
+
module Version
|
38
|
+
MAJOR = 1
|
39
|
+
MINOR = 0
|
40
|
+
TINY = 4
|
41
|
+
STRING = [MAJOR, MINOR, TINY].join(".")
|
42
|
+
end
|
43
|
+
|
44
|
+
# This is the exception that is raised if you try to scan a
|
45
|
+
# directory tree with too many entries. By default, a ceiling of
|
46
|
+
# 10,000 entries is enforced, but you can change that number via
|
47
|
+
# the +ceiling+ parameter to FuzzyFileFinder.new.
|
48
|
+
class TooManyEntries < RuntimeError; end
|
49
|
+
|
50
|
+
# Used internally to represent a run of characters within a
|
51
|
+
# match. This is used to build the highlighted version of
|
52
|
+
# a file name.
|
53
|
+
class CharacterRun < Struct.new(:string, :inside) #:nodoc:
|
54
|
+
def to_s
|
55
|
+
if inside
|
56
|
+
"(#{string})"
|
57
|
+
else
|
58
|
+
string
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Used internally to represent a file within the directory tree.
|
64
|
+
class FileSystemEntry #:nodoc:
|
65
|
+
attr_reader :parent
|
66
|
+
attr_reader :name
|
67
|
+
|
68
|
+
def initialize(parent, name)
|
69
|
+
@parent = parent
|
70
|
+
@name = name
|
71
|
+
end
|
72
|
+
|
73
|
+
def path
|
74
|
+
File.join(parent.name, name)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Used internally to represent a subdirectory within the directory
|
79
|
+
# tree.
|
80
|
+
class Directory #:nodoc:
|
81
|
+
attr_reader :name
|
82
|
+
|
83
|
+
def initialize(name, is_root=false)
|
84
|
+
@name = name
|
85
|
+
@is_root = is_root
|
86
|
+
end
|
87
|
+
|
88
|
+
def root?
|
89
|
+
is_root
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# The roots directory trees to search.
|
94
|
+
attr_reader :roots
|
95
|
+
|
96
|
+
# The list of files beneath all +roots+
|
97
|
+
attr_reader :files
|
98
|
+
|
99
|
+
# The maximum number of files beneath all +roots+
|
100
|
+
attr_reader :ceiling
|
101
|
+
|
102
|
+
# The prefix shared by all +roots+.
|
103
|
+
attr_reader :shared_prefix
|
104
|
+
|
105
|
+
# The list of glob patterns to ignore.
|
106
|
+
attr_reader :ignores
|
107
|
+
|
108
|
+
# Initializes a new FuzzyFileFinder. This will scan the
|
109
|
+
# given +directories+, using +ceiling+ as the maximum number
|
110
|
+
# of entries to scan. If there are more than +ceiling+ entries
|
111
|
+
# a TooManyEntries exception will be raised.
|
112
|
+
def initialize(directories=['.'], ceiling=10_000, ignores=nil)
|
113
|
+
directories = Array(directories)
|
114
|
+
directories << "." if directories.empty?
|
115
|
+
|
116
|
+
# expand any paths with ~
|
117
|
+
root_dirnames = directories.map { |d| File.expand_path(d) }.select { |d| File.directory?(d) }.uniq
|
118
|
+
|
119
|
+
@roots = root_dirnames.map { |d| Directory.new(d, true) }
|
120
|
+
@shared_prefix = determine_shared_prefix
|
121
|
+
@shared_prefix_re = Regexp.new("^#{Regexp.escape(shared_prefix)}" + (shared_prefix.empty? ? "" : "/"))
|
122
|
+
|
123
|
+
@files = []
|
124
|
+
@ceiling = ceiling
|
125
|
+
|
126
|
+
@ignores = Array(ignores)
|
127
|
+
|
128
|
+
rescan!
|
129
|
+
end
|
130
|
+
|
131
|
+
# Rescans the subtree. If the directory contents every change,
|
132
|
+
# you'll need to call this to force the finder to be aware of
|
133
|
+
# the changes.
|
134
|
+
def rescan!
|
135
|
+
@files.clear
|
136
|
+
roots.each { |root| follow_tree(root) }
|
137
|
+
end
|
138
|
+
|
139
|
+
# Takes the given +pattern+ (which must be a string) and searches
|
140
|
+
# all files beneath +root+, yielding each match.
|
141
|
+
#
|
142
|
+
# +pattern+ is interpreted thus:
|
143
|
+
#
|
144
|
+
# * "foo" : look for any file with the characters 'f', 'o', and 'o'
|
145
|
+
# in its basename (discounting directory names). The characters
|
146
|
+
# must be in that order.
|
147
|
+
# * "foo/bar" : look for any file with the characters 'b', 'a',
|
148
|
+
# and 'r' in its basename (discounting directory names). Also,
|
149
|
+
# any successful match must also have at least one directory
|
150
|
+
# element matching the characters 'f', 'o', and 'o' (in that
|
151
|
+
# order.
|
152
|
+
# * "foo/bar/baz" : same as "foo/bar", but matching two
|
153
|
+
# directory elements in addition to a file name of "baz".
|
154
|
+
#
|
155
|
+
# Each yielded match will be a hash containing the following keys:
|
156
|
+
#
|
157
|
+
# * :path refers to the full path to the file
|
158
|
+
# * :directory refers to the directory of the file
|
159
|
+
# * :name refers to the name of the file (without directory)
|
160
|
+
# * :highlighted_directory refers to the directory of the file with
|
161
|
+
# matches highlighted in parentheses.
|
162
|
+
# * :highlighted_name refers to the name of the file with matches
|
163
|
+
# highlighted in parentheses
|
164
|
+
# * :highlighted_path refers to the full path of the file with
|
165
|
+
# matches highlighted in parentheses
|
166
|
+
# * :abbr refers to an abbreviated form of :highlighted_path, where
|
167
|
+
# path segments without matches are compressed to just their first
|
168
|
+
# character.
|
169
|
+
# * :score refers to a value between 0 and 1 indicating how closely
|
170
|
+
# the file matches the given pattern. A score of 1 means the
|
171
|
+
# pattern matches the file exactly.
|
172
|
+
def search(pattern, &block)
|
173
|
+
pattern.strip!
|
174
|
+
path_parts = pattern.split("/")
|
175
|
+
path_parts.push "" if pattern[-1,1] == "/"
|
176
|
+
|
177
|
+
file_name_part = path_parts.pop || ""
|
178
|
+
|
179
|
+
if path_parts.any?
|
180
|
+
path_regex_raw = "^(.*?)" + path_parts.map { |part| make_pattern(part) }.join("(.*?/.*?)") + "(.*?)$"
|
181
|
+
path_regex = Regexp.new(path_regex_raw, Regexp::IGNORECASE)
|
182
|
+
end
|
183
|
+
|
184
|
+
file_regex_raw = "^(.*?)" << make_pattern(file_name_part) << "(.*)$"
|
185
|
+
file_regex = Regexp.new(file_regex_raw, Regexp::IGNORECASE)
|
186
|
+
|
187
|
+
path_matches = {}
|
188
|
+
files.each do |file|
|
189
|
+
path_match = match_path(file.parent, path_matches, path_regex, path_parts.length)
|
190
|
+
next if path_match[:missed]
|
191
|
+
|
192
|
+
match_file(file, file_regex, path_match, &block)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
# Takes the given +pattern+ (which must be a string, formatted as
|
197
|
+
# described in #search), and returns up to +max+ matches in an
|
198
|
+
# Array. If +max+ is nil, all matches will be returned.
|
199
|
+
def find(pattern, max=nil)
|
200
|
+
results = []
|
201
|
+
search(pattern) do |match|
|
202
|
+
results << match
|
203
|
+
break if max && results.length >= max
|
204
|
+
end
|
205
|
+
return results
|
206
|
+
end
|
207
|
+
|
208
|
+
# Displays the finder object in a sane, non-explosive manner.
|
209
|
+
def inspect #:nodoc:
|
210
|
+
"#<%s:0x%x roots=%s, files=%d>" % [self.class.name, object_id, roots.map { |r| r.name.inspect }.join(", "), files.length]
|
211
|
+
end
|
212
|
+
|
213
|
+
private
|
214
|
+
|
215
|
+
# Recursively scans +directory+ and all files and subdirectories
|
216
|
+
# beneath it, depth-first.
|
217
|
+
def follow_tree(directory)
|
218
|
+
Dir.entries(directory.name).each do |entry|
|
219
|
+
next if entry[0,1] == "."
|
220
|
+
raise TooManyEntries if files.length > ceiling
|
221
|
+
|
222
|
+
full = File.join(directory.name, entry)
|
223
|
+
|
224
|
+
if File.directory?(full)
|
225
|
+
follow_tree(Directory.new(full))
|
226
|
+
elsif !ignore?(full.sub(@shared_prefix_re, ""))
|
227
|
+
files.push(FileSystemEntry.new(directory, entry))
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
# Returns +true+ if the given name matches any of the ignore
|
233
|
+
# patterns.
|
234
|
+
def ignore?(name)
|
235
|
+
ignores.any? { |pattern| File.fnmatch(pattern, name) }
|
236
|
+
end
|
237
|
+
|
238
|
+
# Takes the given pattern string "foo" and converts it to a new
|
239
|
+
# string "(f)([^/]*?)(o)([^/]*?)(o)" that can be used to create
|
240
|
+
# a regular expression.
|
241
|
+
def make_pattern(pattern)
|
242
|
+
pattern = pattern.split(//)
|
243
|
+
pattern << "" if pattern.empty?
|
244
|
+
|
245
|
+
pattern.inject("") do |regex, character|
|
246
|
+
regex << "([^/]*?)" if regex.length > 0
|
247
|
+
regex << "(" << Regexp.escape(character) << ")"
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
# Given a MatchData object +match+ and a number of "inside"
|
252
|
+
# segments to support, compute both the match score and the
|
253
|
+
# highlighted match string. The "inside segments" refers to how
|
254
|
+
# many patterns were matched in this one match. For a file name,
|
255
|
+
# this will always be one. For directories, it will be one for
|
256
|
+
# each directory segment in the original pattern.
|
257
|
+
def build_match_result(match, inside_segments)
|
258
|
+
runs = []
|
259
|
+
inside_chars = total_chars = 0
|
260
|
+
match.captures.each_with_index do |capture, index|
|
261
|
+
if capture.length > 0
|
262
|
+
# odd-numbered captures are matches inside the pattern.
|
263
|
+
# even-numbered captures are matches between the pattern's elements.
|
264
|
+
inside = index % 2 != 0
|
265
|
+
|
266
|
+
total_chars += capture.gsub(%r(/), "").length # ignore '/' delimiters
|
267
|
+
inside_chars += capture.length if inside
|
268
|
+
|
269
|
+
if runs.last && runs.last.inside == inside
|
270
|
+
runs.last.string << capture
|
271
|
+
else
|
272
|
+
runs << CharacterRun.new(capture, inside)
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
# Determine the score of this match.
|
278
|
+
# 1. fewer "inside runs" (runs corresponding to the original pattern)
|
279
|
+
# is better.
|
280
|
+
# 2. better coverage of the actual path name is better
|
281
|
+
|
282
|
+
inside_runs = runs.select { |r| r.inside }
|
283
|
+
run_ratio = inside_runs.length.zero? ? 1 : inside_segments / inside_runs.length.to_f
|
284
|
+
|
285
|
+
char_ratio = total_chars.zero? ? 1 : inside_chars.to_f / total_chars
|
286
|
+
|
287
|
+
score = run_ratio * char_ratio
|
288
|
+
|
289
|
+
return { :score => score, :result => runs.join }
|
290
|
+
end
|
291
|
+
|
292
|
+
# Match the given path against the regex, caching the result in +path_matches+.
|
293
|
+
# If +path+ is already cached in the path_matches cache, just return the cached
|
294
|
+
# value.
|
295
|
+
def match_path(path, path_matches, path_regex, path_segments)
|
296
|
+
return path_matches[path] if path_matches.key?(path)
|
297
|
+
|
298
|
+
name_with_slash = path.name + "/" # add a trailing slash for matching the prefix
|
299
|
+
matchable_name = name_with_slash.sub(@shared_prefix_re, "")
|
300
|
+
matchable_name.chop! # kill the trailing slash
|
301
|
+
|
302
|
+
if path_regex
|
303
|
+
match = matchable_name.match(path_regex)
|
304
|
+
|
305
|
+
path_matches[path] =
|
306
|
+
match && build_match_result(match, path_segments) ||
|
307
|
+
{ :score => 1, :result => matchable_name, :missed => true }
|
308
|
+
else
|
309
|
+
path_matches[path] = { :score => 1, :result => matchable_name }
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
# Match +file+ against +file_regex+. If it matches, yield the match
|
314
|
+
# metadata to the block.
|
315
|
+
def match_file(file, file_regex, path_match, &block)
|
316
|
+
if file_match = file.name.match(file_regex)
|
317
|
+
match_result = build_match_result(file_match, 1)
|
318
|
+
full_match_result = path_match[:result].empty? ? match_result[:result] : File.join(path_match[:result], match_result[:result])
|
319
|
+
shortened_path = path_match[:result].gsub(/[^\/]+/) { |m| m.index("(") ? m : m[0,1] }
|
320
|
+
abbr = shortened_path.empty? ? match_result[:result] : File.join(shortened_path, match_result[:result])
|
321
|
+
|
322
|
+
result = { :path => file.path,
|
323
|
+
:abbr => abbr,
|
324
|
+
:directory => file.parent.name,
|
325
|
+
:name => file.name,
|
326
|
+
:highlighted_directory => path_match[:result],
|
327
|
+
:highlighted_name => match_result[:result],
|
328
|
+
:highlighted_path => full_match_result,
|
329
|
+
:score => path_match[:score] * match_result[:score] }
|
330
|
+
yield result
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
def determine_shared_prefix
|
335
|
+
# the common case: if there is only a single root, then the entire
|
336
|
+
# name of the root is the shared prefix.
|
337
|
+
return roots.first.name if roots.length == 1
|
338
|
+
|
339
|
+
split_roots = roots.map { |root| root.name.split(%r{/}) }
|
340
|
+
segments = split_roots.map { |root| root.length }.max
|
341
|
+
master = split_roots.pop
|
342
|
+
|
343
|
+
segments.times do |segment|
|
344
|
+
if !split_roots.all? { |root| root[segment] == master[segment] }
|
345
|
+
return master[0,segment].join("/")
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
# shouldn't ever get here, since we uniq the root list before
|
350
|
+
# calling this method, but if we do, somehow...
|
351
|
+
return roots.first.name
|
352
|
+
end
|
353
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
" Vim syntax file
|
2
|
+
" Language: eRuby
|
3
|
+
" Maintainer: Tim Pope <vimNOSPAM@tpope.info>
|
4
|
+
" Info: $Id: eruby.vim,v 1.18 2007/05/06 23:56:12 tpope Exp $
|
5
|
+
" URL: http://vim-ruby.rubyforge.org
|
6
|
+
" Anon CVS: See above site
|
7
|
+
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
8
|
+
|
9
|
+
if exists("b:current_syntax")
|
10
|
+
finish
|
11
|
+
endif
|
12
|
+
|
13
|
+
if !exists("main_syntax")
|
14
|
+
let main_syntax = 'eruby'
|
15
|
+
endif
|
16
|
+
|
17
|
+
if !exists("g:eruby_default_subtype")
|
18
|
+
let g:eruby_default_subtype = "html"
|
19
|
+
endif
|
20
|
+
|
21
|
+
if !exists("b:eruby_subtype") && main_syntax == 'eruby'
|
22
|
+
let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$")
|
23
|
+
let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+')
|
24
|
+
if b:eruby_subtype == ''
|
25
|
+
let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\)\+$','',''),'\.\zs\w\+$')
|
26
|
+
endif
|
27
|
+
if b:eruby_subtype == 'rhtml'
|
28
|
+
let b:eruby_subtype = 'html'
|
29
|
+
elseif b:eruby_subtype == 'rb'
|
30
|
+
let b:eruby_subtype = 'ruby'
|
31
|
+
elseif b:eruby_subtype == 'yml'
|
32
|
+
let b:eruby_subtype = 'yaml'
|
33
|
+
elseif b:eruby_subtype == 'js'
|
34
|
+
let b:eruby_subtype = 'javascript'
|
35
|
+
elseif b:eruby_subtype == 'txt'
|
36
|
+
" Conventional; not a real file type
|
37
|
+
let b:eruby_subtype = 'text'
|
38
|
+
elseif b:eruby_subtype == ''
|
39
|
+
let b:eruby_subtype = g:eruby_default_subtype
|
40
|
+
endif
|
41
|
+
endif
|
42
|
+
|
43
|
+
if !exists("b:eruby_nest_level")
|
44
|
+
let b:eruby_nest_level = strlen(substitute(substitute(substitute(expand("%:t"),'@','','g'),'\c\.\%(erb\|rhtml\)\>','@','g'),'[^@]','','g'))
|
45
|
+
endif
|
46
|
+
if !b:eruby_nest_level
|
47
|
+
let b:eruby_nest_level = 1
|
48
|
+
endif
|
49
|
+
|
50
|
+
if exists("b:eruby_subtype") && b:eruby_subtype != ''
|
51
|
+
exe "runtime! syntax/".b:eruby_subtype.".vim"
|
52
|
+
unlet! b:current_syntax
|
53
|
+
endif
|
54
|
+
syn include @rubyTop syntax/ruby.vim
|
55
|
+
|
56
|
+
syn cluster erubyRegions contains=erubyOneLiner,erubyBlock,erubyExpression,erubyComment
|
57
|
+
|
58
|
+
exe 'syn region erubyOneLiner matchgroup=erubyDelimiter start="^%\{1,'.b:eruby_nest_level.'\}%\@!" end="$" contains=@rubyTop containedin=ALLBUT,@erbRegions keepend oneline'
|
59
|
+
exe 'syn region erubyBlock matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}%\@!-\=" end="-\=%>" contains=@rubyTop containedin=ALLBUT,@erbRegions'
|
60
|
+
exe 'syn region erubyExpression matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}=" end="-\=%>" contains=@rubyTop containedin=ALLBUT,@erbRegions'
|
61
|
+
exe 'syn region erubyComment matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}#" end="-\=%>" contains=rubyTodo,@Spell containedin=ALLBUT,@erbRegions keepend'
|
62
|
+
|
63
|
+
" Define the default highlighting.
|
64
|
+
" For version 5.7 and earlier: only when not done already
|
65
|
+
" For version 5.8 and later: only when an item doesn't have highlighting yet
|
66
|
+
if version >= 508 || !exists("did_eruby_syntax_inits")
|
67
|
+
if version < 508
|
68
|
+
let did_ruby_syntax_inits = 1
|
69
|
+
command -nargs=+ HiLink hi link <args>
|
70
|
+
else
|
71
|
+
command -nargs=+ HiLink hi def link <args>
|
72
|
+
endif
|
73
|
+
|
74
|
+
HiLink erubyDelimiter Delimiter
|
75
|
+
HiLink erubyComment Comment
|
76
|
+
|
77
|
+
delcommand HiLink
|
78
|
+
endif
|
79
|
+
let b:current_syntax = 'eruby'
|
80
|
+
|
81
|
+
if main_syntax == 'eruby'
|
82
|
+
unlet main_syntax
|
83
|
+
endif
|
84
|
+
|
85
|
+
" vim: nowrap sw=2 sts=2 ts=8 ff=unix:
|