diff --git a/README b/README index 8be6e8f..0164487 100644 --- a/README +++ b/README @@ -13,6 +13,12 @@ Usage is almost identical to the Fuzzyfinder script, so you should check out the Once in TextMate mode, completion is done against the entire directory tree at once, using partial matches. Results are sorted by "score", which is a measure of how closely the file matches the text you entered. +There are several different variables that you may set in your .vimrc file that can be used to tweak the finder's behavior: + +* g:fuzzy_roots - this defaults to the current directory, but may be set to an array of paths that you want the finder to search. +* g:fuzzy_ceiling - this defaults to 10,000, and is the maximum number of files that the finder will scan before it raises an error. To use the finder on larger trees, set this variable to a value larger than the number of files you expect to scan. +* g:fuzzy_ignore - this is a semi-colon delimited list of file glob patterns to ignore. +* g:fuzzy_match_limit - this is the maximum number of items that will be matched, and defaults to 200. If the finder feels sluggish to you, you can reduce this to something smaller (100, or 50). Installation ----------------------- diff --git a/fuzzyfinder_textmate.vim b/fuzzyfinder_textmate.vim index 3a1cfa5..3d9da3b 100644 --- a/fuzzyfinder_textmate.vim +++ b/fuzzyfinder_textmate.vim @@ -54,7 +54,27 @@ RUBY let g:fuzzy_ceiling = 10000 endif - ruby def finder; @finder ||= FuzzyFileFinder.new(VIM.evaluate("g:fuzzy_roots").split("\n"), VIM.evaluate("g:fuzzy_ceiling").to_i); end + " Configuration option: g:fuzzy_ignore + " A semi-colon delimited list of file glob patterns to ignore + if !exists('g:fuzzy_ignore') + let g:fuzzy_ignore = "" + endif + + " Configuration option: g:fuzzy_matching_limit + " The maximum number of matches to return at a time. Defaults to 200, via the + " g:FuzzyFinderMode.TextMate.matching_limit variable, but using a global variable + " makes it easier to set this value. + +ruby << RUBY + def finder + @finder ||= begin + roots = VIM.evaluate("g:fuzzy_roots").split("\n") + ceiling = VIM.evaluate("g:fuzzy_ceiling").to_i + ignore = VIM.evaluate("g:fuzzy_ignore").split(/;/) + FuzzyFileFinder.new(roots, ceiling, ignore) + end + end +RUBY let g:FuzzyFinderMode.TextMate = copy(g:FuzzyFinderMode.Base) @@ -76,8 +96,18 @@ RUBY call s:HighlightPrompt(self.prompt, self.prompt_highlight) let result = [] + + if exists('g:fuzzy_matching_limit') + let l:limit = g:fuzzy_matching_limit + else + let l:limit = self.matching_limit + endif + ruby << RUBY - matches = finder.find(VIM.evaluate('self.remove_prompt(a:base)'), VIM.evaluate('self.matching_limit').to_i + 1) + text = VIM.evaluate('self.remove_prompt(a:base)') + limit = VIM.evaluate('l:limit').to_i + + matches = finder.find(text, limit) matches.sort_by { |a| [-a[:score], a[:path]] }.each_with_index do |match, index| word = match[:path] abbr = "%2d: %s" % [index+1, match[:abbr]] @@ -85,6 +115,7 @@ RUBY VIM.evaluate("add(result, { 'word' : #{word.inspect}, 'abbr' : #{abbr.inspect}, 'menu' : #{menu.inspect} })") end RUBY + if empty(result) || len(result) >= self.matching_limit call s:HighlightError() endif