neo2vim 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/neo2vim.rb +21 -5
  2. metadata +1 -1
@@ -17,8 +17,13 @@ class Neo2Vim
17
17
 
18
18
 
19
19
  def neovim_annotation line
20
- if line =~ /^\s*@neovim\.(\w+)\('(\w+)'.*/
21
- {type: $1, name: $2}
20
+ # Supported pattern: @neovim.{type}({name}, attr1 = value1, attr2 = value2, ...)
21
+ if line =~ /^\s*@neovim\.(\w+)\(((?:'\w+')|(?:"\w+"))(.+)/
22
+ basic = {type: $1, name: $2[1..-2]}
23
+ args = $3.scan(/\s*,\s*(\w+)\s*=\s*((?:'[^']*')|(?:"[^"]*"))/).map {|name, value|
24
+ [name.to_sym, value[1..-2]]
25
+ }.to_h
26
+ basic.merge(args)
22
27
  else
23
28
  nil
24
29
  end
@@ -56,7 +61,7 @@ class Neo2Vim
56
61
  contents.autoload_py.write line
57
62
  case @state
58
63
  when :plugin_class_definiton
59
- @plugin_class_name = line.chomp.gsub(/^[^ ]* /, "").gsub(/\(.*/, "")
64
+ @plugin_class_name = line.chomp.gsub(/^class\s+(\w+).*$/, '\1')
60
65
  @plugin_id = to_snake(@plugin_class_name)
61
66
  @state = :normal
62
67
  when :plugin_method_definition
@@ -102,14 +107,25 @@ augroup #{@plugin_id}
102
107
  EOS
103
108
  @stores["autocmd"].each do |k, v|
104
109
  contents.plugin.puts <<-EOS
105
- autocmd #{v[:annotation][:name]} * call #{@plugin_id}\##{k}(expand('<afile>'))
110
+ autocmd #{v[:annotation][:name]} #{v[:annotation][:pattern] || '*'} call #{@plugin_id}\##{k}(#{v[:annotation][:eval] || "expand('<afile>')"})
106
111
  EOS
107
112
  end
108
113
  contents.plugin.puts "augroup END"
109
114
  contents.plugin.puts
110
115
 
111
116
  @stores["command"].each do |k, v|
112
- contents.plugin.puts "command! -nargs=0 #{v[:annotation][:name]} call #{@plugin_id}\##{k}([])"
117
+ range =
118
+ case v[:annotation][:range]
119
+ when ''
120
+ "-range"
121
+ when nil
122
+ ""
123
+ else
124
+ "-range=#{v[:annotation][:range]}"
125
+ end
126
+ nargs = "-nargs=#{v[:annotation][:nargs] || '0'}"
127
+ # TODO: range argument is dummy
128
+ contents.plugin.puts "command! #{nargs} #{range} #{v[:annotation][:name]} call #{@plugin_id}\##{k}([<f-args>], '')"
113
129
  end
114
130
  contents.plugin.puts
115
131
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo2vim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: