Skip to content

Commit

Permalink
Add variables for the different options. See README.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamis committed Oct 13, 2008
1 parent 8641b06 commit 5b47120
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README
Expand Up @@ -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
-----------------------
Expand Down
35 changes: 33 additions & 2 deletions fuzzyfinder_textmate.vim
Expand Up @@ -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)

Expand All @@ -76,15 +96,26 @@ 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]]
menu = "[%5d]" % [match[:score] * 10000]
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
Expand Down

0 comments on commit 5b47120

Please sign in to comment.