Class: CommandT::Finder

Inherits:
Object
  • Object
show all
Includes:
PathUtilities
Defined in:
lib/command-t/finder.rb,
lib/command-t/finder/tag_finder.rb,
lib/command-t/finder/file_finder.rb,
lib/command-t/finder/help_finder.rb,
lib/command-t/finder/jump_finder.rb,
lib/command-t/finder/line_finder.rb,
lib/command-t/finder/buffer_finder.rb,
lib/command-t/finder/command_finder.rb,
lib/command-t/finder/history_finder.rb,
lib/command-t/finder/mru_buffer_finder.rb

Overview

Encapsulates a Scanner instance (which builds up a list of available files in a directory) and a Matcher instance (which selects from that list based on a search string).

Specialized subclasses use different kinds of scanners adapted for different kinds of search (files, buffers).

Defined Under Namespace

Classes: BufferFinder, CommandFinder, FileFinder, HelpFinder, HistoryFinder, JumpFinder, LineFinder, MRUBufferFinder, TagFinder

Instance Method Summary collapse

Constructor Details

#initialize(path = Dir.pwd, options = {}) ⇒ Finder

Returns a new instance of Finder.

Raises:

  • (RuntimeError)


26
27
28
# File 'lib/command-t/finder.rb', line 26

def initialize(path = Dir.pwd, options = {})
  raise RuntimeError, 'Subclass responsibility'
end

Instance Method Details

#nameObject

Returns a human-readable name describing the finder, for display in the statusline attached to the MatchWindow buffer.

Raises:

  • (RuntimeError)


32
33
34
# File 'lib/command-t/finder.rb', line 32

def name
  raise RuntimeError, 'Subclass responsibility'
end

#open_selection(command, selection, options = {}) ⇒ Object



42
43
44
# File 'lib/command-t/finder.rb', line 42

def open_selection(command, selection, options = {})
  ::VIM::command "silent #{command} #{selection}"
end

#path=(path) ⇒ Object



46
47
48
# File 'lib/command-t/finder.rb', line 46

def path=(path)
  @scanner.path = path
end

#sorted_matches_for(str, options = {}) ⇒ Object

Options:

:limit (integer): limit the number of returned matches


38
39
40
# File 'lib/command-t/finder.rb', line 38

def sorted_matches_for(str, options = {})
  @matcher.sorted_matches_for str, options
end