Class: Vimdb::Options

Inherits:
Item
  • Object
show all
Defined in:
lib/vimdb/options.rb

Instance Method Summary collapse

Methods inherited from Item

all, #default_field, inherited, instance, item_name, #key, #search, #tempfile

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/vimdb/options.rb', line 10

def create
  file = tempfile(:options_help) do |file|
    vim 'silent help option-list', 'exe "normal 2_y}"', 'new',
      'exe "normal p"', "silent! w! #{file}"
  end

  opts = File.read(file).scan(/^'(\S+)'\s*('\S*')?\s*(.*$)/).map do |line|
    { name: line[0], alias: line[1] ? line[1][1..-2] : '', desc: line[2] }
  end
  opts
end

#fieldsObject



2
3
4
# File 'lib/vimdb/options.rb', line 2

def fields
  [:name, :alias, :desc]
end

#infoObject



6
7
8
# File 'lib/vimdb/options.rb', line 6

def info
  "Created using :help option-list"
end