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.
- data/lib/neo2vim.rb +21 -5
 - metadata +1 -1
 
    
        data/lib/neo2vim.rb
    CHANGED
    
    | 
         @@ -17,8 +17,13 @@ class Neo2Vim 
     | 
|
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
                def neovim_annotation line
         
     | 
| 
       20 
     | 
    
         
            -
                     
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 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(/^ 
     | 
| 
      
 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 
     | 
    
         
            -
                         
     | 
| 
      
 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 
     | 
    
         |