nvim 1.7.0 → 1.9.0
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.
- checksums.yaml +4 -4
- data/INFO.yaml +1 -1
- data/README.md +50 -9
- data/examples/passwords +2 -2
- data/lib/neovim/client.rb +8 -2
- data/lib/neovim/connection.rb +7 -0
- data/lib/neovim/foreign/supplement.rb +5 -1
- data/lib/neovim/info.rb +2 -2
- data/lib/neovim/output.rb +32 -45
- data/lib/neovim/ruby_provider.rb +15 -21
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 769e2a668a793cc62f7683c1e6a40bb0ab703a65c1538a82afe6ef08326d023b
         | 
| 4 | 
            +
              data.tar.gz: aa69006de05ddf6eba0635b6ce35478b8ef074fa3fcd73be300b2d78089436a4
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b3ddad1a7f7719f17e17c1767d3bdf394b5703c24fc700840c2b0e39c332c9290225fc94d5b4abc5d391d979e64a796b11b82bca1c44ef77c0ab4ad7cfbae401
         | 
| 7 | 
            +
              data.tar.gz: 934aff104babc3f80f3265d6f26881cb02b85ad3d8b8cbe53fe3a716e12dc3d5d7c157e1d68a819fc7011fb05f5999562fb08b0bee6bf5cc22c7dbd4268093df
         | 
    
        data/INFO.yaml
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -69,14 +69,8 @@ echo Sum(13,7) | |
| 69 69 | 
             
            The `:ruby...` commands and the `rubyeval()` function behave as descibed
         | 
| 70 70 | 
             
            in `:h ruby`.
         | 
| 71 71 |  | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 75 | 
            -
            Additionally you can directly execute the buffers contents:
         | 
| 76 | 
            -
             | 
| 77 | 
            -
            ```vim
         | 
| 78 | 
            -
            set number
         | 
| 79 | 
            -
            ```
         | 
| 72 | 
            +
            Additionally you can directly execute the buffers contents (here, I did
         | 
| 73 | 
            +
            `:set number`):
         | 
| 80 74 |  | 
| 81 75 | 
             
            ```
         | 
| 82 76 | 
             
             1 class C
         | 
| @@ -203,10 +197,57 @@ the RPC communication. | |
| 203 197 | 
             
            :%ruby |
         | 
| 204 198 | 
             
            ```
         | 
| 205 199 |  | 
| 206 | 
            -
            Yet,  | 
| 200 | 
            +
            Yet, I suggest not to use `fork` and `exec`, except when
         | 
| 207 201 | 
             
            you're absolutely sure what you're doing.
         | 
| 208 202 |  | 
| 209 203 |  | 
| 204 | 
            +
            #### Exception handling
         | 
| 205 | 
            +
             | 
| 206 | 
            +
            If you prefer, you may return an error as a value, too.
         | 
| 207 | 
            +
             | 
| 208 | 
            +
            ```
         | 
| 209 | 
            +
             1 $rescue = true
         | 
| 210 | 
            +
             2 z = 0
         | 
| 211 | 
            +
             3 q = 1 / z
         | 
| 212 | 
            +
            ~
         | 
| 213 | 
            +
            ~
         | 
| 214 | 
            +
            :set ft=ruby|1,3ruby |
         | 
| 215 | 
            +
            ```
         | 
| 216 | 
            +
             | 
| 217 | 
            +
            Then:
         | 
| 218 | 
            +
             | 
| 219 | 
            +
            ```
         | 
| 220 | 
            +
             1 $rescue = true
         | 
| 221 | 
            +
             2 z = 0
         | 
| 222 | 
            +
             3 q = 1 / z
         | 
| 223 | 
            +
             4 #=> #<ZeroDivisionError: divided by 0>
         | 
| 224 | 
            +
             5 puts "=begin", _.backtrace, "=end"
         | 
| 225 | 
            +
            ~
         | 
| 226 | 
            +
            ~
         | 
| 227 | 
            +
            :5ruby |
         | 
| 228 | 
            +
            ```
         | 
| 229 | 
            +
             | 
| 230 | 
            +
            Even non-standard errors wil be caught.
         | 
| 231 | 
            +
             | 
| 232 | 
            +
            ```
         | 
| 233 | 
            +
             1 def f ; f ; end
         | 
| 234 | 
            +
             2 f
         | 
| 235 | 
            +
            ~
         | 
| 236 | 
            +
            ~
         | 
| 237 | 
            +
            :1,2ruby |
         | 
| 238 | 
            +
            ```
         | 
| 239 | 
            +
             | 
| 240 | 
            +
            ```
         | 
| 241 | 
            +
             1 $$
         | 
| 242 | 
            +
             2 #=> 49042
         | 
| 243 | 
            +
             3 sleep 1000
         | 
| 244 | 
            +
            ~
         | 
| 245 | 
            +
            ~
         | 
| 246 | 
            +
            :3ruby |
         | 
| 247 | 
            +
            ```
         | 
| 248 | 
            +
            Then say 'kill 49042' somewhere else.
         | 
| 249 | 
            +
             | 
| 250 | 
            +
             | 
| 210 251 | 
             
            #### Global variables
         | 
| 211 252 |  | 
| 212 253 | 
             
            The global variable `$vim` will be set to the client.
         | 
    
        data/examples/passwords
    CHANGED
    
    | @@ -49,9 +49,9 @@ class Passwords | |
| 49 49 | 
             
                    client.echo [ [ key]], true, {}
         | 
| 50 50 | 
             
                    xsel key
         | 
| 51 51 | 
             
                  rescue
         | 
| 52 | 
            -
                    client. | 
| 52 | 
            +
                    client.message_err "No OTP under cursor?"
         | 
| 53 53 | 
             
                  rescue ScriptError
         | 
| 54 | 
            -
                    client. | 
| 54 | 
            +
                    client.message_err $!.message
         | 
| 55 55 | 
             
                  end
         | 
| 56 56 | 
             
                end
         | 
| 57 57 | 
             
              end
         | 
    
        data/lib/neovim/client.rb
    CHANGED
    
    | @@ -12,6 +12,9 @@ module Neovim | |
| 12 12 | 
             
              class Client
         | 
| 13 13 |  | 
| 14 14 | 
             
                @strict = true
         | 
| 15 | 
            +
                ENV[ "NVIM_RUBY_STRICT"]&.tap { |s|
         | 
| 16 | 
            +
                  @strict = s =~ /[1-9]|true|yes|on|enable/i
         | 
| 17 | 
            +
                }
         | 
| 15 18 | 
             
                class <<self
         | 
| 16 19 | 
             
                  attr_accessor :strict
         | 
| 17 20 | 
             
                end
         | 
| @@ -99,8 +102,11 @@ module Neovim | |
| 99 102 |  | 
| 100 103 |  | 
| 101 104 | 
             
                def message str
         | 
| 102 | 
            -
                  call_api : | 
| 103 | 
            -
             | 
| 105 | 
            +
                  call_api :echo, [ [ str]], true, {}
         | 
| 106 | 
            +
                end
         | 
| 107 | 
            +
             | 
| 108 | 
            +
                def message_err msg
         | 
| 109 | 
            +
                  call_api :echo, [ [ msg]], true, err: true
         | 
| 104 110 | 
             
                end
         | 
| 105 111 |  | 
| 106 112 |  | 
    
        data/lib/neovim/connection.rb
    CHANGED
    
    | @@ -47,6 +47,12 @@ module Neovim | |
| 47 47 | 
             
                  api_info[ "error_types"].each { |type,info|
         | 
| 48 48 | 
             
                    register_error type, info[ "id"]
         | 
| 49 49 | 
             
                  }
         | 
| 50 | 
            +
                  if api_info["version"]["api_level"] < 13 then
         | 
| 51 | 
            +
                    log :warn, "Using nvim_err_writeln() which is deprecated in since Neovim 0.11.0"
         | 
| 52 | 
            +
                    @client.define_singleton_method :message_err do |msg|
         | 
| 53 | 
            +
                      call_api :err_writeln, msg
         | 
| 54 | 
            +
                    end
         | 
| 55 | 
            +
                  end
         | 
| 50 56 | 
             
                  nil
         | 
| 51 57 | 
             
                end
         | 
| 52 58 |  | 
| @@ -133,6 +139,7 @@ module Neovim | |
| 133 139 |  | 
| 134 140 | 
             
                  def stdpath what
         | 
| 135 141 | 
             
                    cmd = [ path, "--headless", ]
         | 
| 142 | 
            +
                    cmd.push "-u", "NONE"
         | 
| 136 143 | 
             
                    cmd.push "-c", "echo stdpath(#{what.to_s.inspect})"
         | 
| 137 144 | 
             
                    cmd.push "-c", "q"
         | 
| 138 145 | 
             
                    (pipe_stderr cmd)&.tap { |x| x.chomp! }
         | 
| @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            #
         | 
| 2 | 
            -
            #  neovim/foreign/supplement.rb  --   | 
| 2 | 
            +
            #  neovim/foreign/supplement.rb  --  Additional useful Ruby functions
         | 
| 3 3 | 
             
            #
         | 
| 4 4 |  | 
| 5 5 | 
             
            # The purpose of this is simply to reduce dependencies.
         | 
| @@ -10,6 +10,9 @@ rescue LoadError | |
| 10 10 | 
             
              class NilClass ; def notempty? ;                      end ; end
         | 
| 11 11 | 
             
              class String   ; def notempty? ; self unless empty? ; end ; end
         | 
| 12 12 | 
             
              class Array    ; def notempty? ; self unless empty? ; end ; end
         | 
| 13 | 
            +
              class Array    ; def first= val ; self[ 0] = val ; end ; end
         | 
| 14 | 
            +
              class Array    ; def last=  val ; self[-1] = val ;
         | 
| 15 | 
            +
                                rescue IndexError ; a.push val ; end ; end
         | 
| 13 16 | 
             
              class NilClass   ; def to_bool ; false ; end ; end
         | 
| 14 17 | 
             
              class FalseClass ; def to_bool ; false ; end ; end
         | 
| 15 18 | 
             
              class Object     ; def to_bool ; true  ; end ; end
         | 
| @@ -43,5 +46,6 @@ rescue LoadError | |
| 43 46 | 
             
                alias starts_with starts_with?
         | 
| 44 47 | 
             
                alias ends_with   ends_with?
         | 
| 45 48 | 
             
              end
         | 
| 49 | 
            +
              class Dir ; def entries! ; entries - %w(. ..) ; end ; end
         | 
| 46 50 | 
             
            end
         | 
| 47 51 |  | 
    
        data/lib/neovim/info.rb
    CHANGED
    
    | @@ -1,10 +1,10 @@ | |
| 1 1 | 
             
            require "neovim/meta.rb"
         | 
| 2 2 | 
             
            Neovim::INFO = Neovim::Meta.new "nvim",
         | 
| 3 | 
            -
              version: "1. | 
| 3 | 
            +
              version: "1.9.0",
         | 
| 4 4 | 
             
              license: "BSD-2-Clause+",
         | 
| 5 5 | 
             
              authors: ["Bertram Scharpf"],
         | 
| 6 6 | 
             
              email: "software@bertram-scharpf.de",
         | 
| 7 7 | 
             
              summary: "Yet another Ruby client for Neovim",
         | 
| 8 8 | 
             
              description: "A simple Ruby client for Neovim.\nClean code, minimal dependecies, no frills, no wokeness.",
         | 
| 9 9 | 
             
              homepage: "https://github.com/BertramScharpf/ruby-nvim",
         | 
| 10 | 
            -
              commit: " | 
| 10 | 
            +
              commit: "a24b682"
         | 
    
        data/lib/neovim/output.rb
    CHANGED
    
    | @@ -69,7 +69,7 @@ module Neovim | |
| 69 69 | 
             
                      else
         | 
| 70 70 | 
             
                        a = a.to_s
         | 
| 71 71 | 
             
                        write a
         | 
| 72 | 
            -
                         | 
| 72 | 
            +
                        a.end_with? $/ or write $/
         | 
| 73 73 | 
             
                      end
         | 
| 74 74 | 
             
                    }
         | 
| 75 75 | 
             
                  end
         | 
| @@ -90,27 +90,36 @@ module Neovim | |
| 90 90 | 
             
                    end
         | 
| 91 91 | 
             
                  end
         | 
| 92 92 | 
             
                end
         | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 93 | 
            +
                def initialize *args
         | 
| 94 | 
            +
                  super
         | 
| 95 | 
            +
                  @str = ""
         | 
| 96 | 
            +
                end
         | 
| 96 97 | 
             
                def write *args
         | 
| 97 | 
            -
                  args.each { |a|
         | 
| 98 | 
            -
             | 
| 99 | 
            -
                     | 
| 100 | 
            -
                     | 
| 101 | 
            -
                     | 
| 102 | 
            -
             | 
| 98 | 
            +
                  args.each { |a| @str << a.to_s }
         | 
| 99 | 
            +
                  loop do
         | 
| 100 | 
            +
                    l, r = @str.split $/, 2
         | 
| 101 | 
            +
                    r or break
         | 
| 102 | 
            +
                    write_line l
         | 
| 103 | 
            +
                    @str = r
         | 
| 104 | 
            +
                  end
         | 
| 103 105 | 
             
                  nil
         | 
| 104 106 | 
             
                end
         | 
| 105 107 | 
             
                def finish
         | 
| 106 | 
            -
                  if @ | 
| 107 | 
            -
                    @ | 
| 108 | 
            -
                    @ | 
| 108 | 
            +
                  if @str.notempty? then
         | 
| 109 | 
            +
                    write_line @str
         | 
| 110 | 
            +
                    @str = nil
         | 
| 109 111 | 
             
                  end
         | 
| 110 112 | 
             
                end
         | 
| 111 113 | 
             
              end
         | 
| 112 114 |  | 
| 113 | 
            -
              class  | 
| 115 | 
            +
              class WriteOut < WriteStd
         | 
| 116 | 
            +
                private
         | 
| 117 | 
            +
                def write_line l
         | 
| 118 | 
            +
                  @client.message l
         | 
| 119 | 
            +
                end
         | 
| 120 | 
            +
              end
         | 
| 121 | 
            +
             | 
| 122 | 
            +
              class WriteErr < WriteStd
         | 
| 114 123 | 
             
                class <<self
         | 
| 115 124 | 
             
                  def redirect *args, **kwargs
         | 
| 116 125 | 
             
                    open *args, **kwargs do |i|
         | 
| @@ -121,52 +130,30 @@ module Neovim | |
| 121 130 | 
             
                    end
         | 
| 122 131 | 
             
                  end
         | 
| 123 132 | 
             
                end
         | 
| 124 | 
            -
                 | 
| 125 | 
            -
             | 
| 126 | 
            -
             | 
| 127 | 
            -
                    @rest << a.to_s
         | 
| 128 | 
            -
                    while @rest =~ /#$// do
         | 
| 129 | 
            -
                      @client.err_writeln $`
         | 
| 130 | 
            -
                      @rest = $'
         | 
| 131 | 
            -
                    end
         | 
| 132 | 
            -
                  }
         | 
| 133 | 
            -
                  nil
         | 
| 134 | 
            -
                end
         | 
| 135 | 
            -
                def finish
         | 
| 136 | 
            -
                  if @rest.notempty? then
         | 
| 137 | 
            -
                    @client.err_writeln @rest
         | 
| 138 | 
            -
                    @rest = nil
         | 
| 139 | 
            -
                  end
         | 
| 133 | 
            +
                private
         | 
| 134 | 
            +
                def write_line l
         | 
| 135 | 
            +
                  @client.message_err l
         | 
| 140 136 | 
             
                end
         | 
| 141 137 | 
             
              end
         | 
| 142 138 |  | 
| 143 139 | 
             
              class WriteBuf < WriteStd
         | 
| 144 140 | 
             
                def initialize *args, whole: nil, top: nil
         | 
| 145 141 | 
             
                  super
         | 
| 146 | 
            -
                  @lines | 
| 142 | 
            +
                  @lines = []
         | 
| 147 143 | 
             
                  @whole, @top = whole, top
         | 
| 148 144 | 
             
                end
         | 
| 149 | 
            -
                def write *args
         | 
| 150 | 
            -
                  args.each { |a| @last << a.to_s }
         | 
| 151 | 
            -
                  loop do
         | 
| 152 | 
            -
                    n, r = @last.split $/, 2
         | 
| 153 | 
            -
                    r or break
         | 
| 154 | 
            -
                    @lines.push n
         | 
| 155 | 
            -
                    @last = r
         | 
| 156 | 
            -
                  end
         | 
| 157 | 
            -
                  nil
         | 
| 158 | 
            -
                end
         | 
| 159 145 | 
             
                def finish
         | 
| 160 | 
            -
                   | 
| 161 | 
            -
                    @lines.push @last
         | 
| 162 | 
            -
                    @last = nil
         | 
| 163 | 
            -
                  end
         | 
| 146 | 
            +
                  super
         | 
| 164 147 | 
             
                  if @whole then
         | 
| 165 148 | 
             
                    @client.buf_set_lines 0, 0, -1, true, @lines
         | 
| 166 149 | 
             
                  else
         | 
| 167 150 | 
             
                    @client.put @lines, "l", true, !@top
         | 
| 168 151 | 
             
                  end
         | 
| 169 152 | 
             
                end
         | 
| 153 | 
            +
                private
         | 
| 154 | 
            +
                def write_line l
         | 
| 155 | 
            +
                  @lines.push l
         | 
| 156 | 
            +
                end
         | 
| 170 157 | 
             
              end
         | 
| 171 158 |  | 
| 172 159 | 
             
            end
         | 
    
        data/lib/neovim/ruby_provider.rb
    CHANGED
    
    | @@ -81,9 +81,14 @@ module Neovim | |
| 81 81 | 
             
                        yield client, *args
         | 
| 82 82 | 
             
                      end
         | 
| 83 83 | 
             
                    end
         | 
| 84 | 
            -
                  rescue  | 
| 85 | 
            -
                     | 
| 86 | 
            -
                     | 
| 84 | 
            +
                  rescue Exception
         | 
| 85 | 
            +
                    msg = $!.to_s
         | 
| 86 | 
            +
                    if msg =~ /\A.*?:(\d+):\s*/ then
         | 
| 87 | 
            +
                      line, msg = $1, $'
         | 
| 88 | 
            +
                    else
         | 
| 89 | 
            +
                      line = $@.first[ /:(\d+):in\b/, 1]
         | 
| 90 | 
            +
                    end
         | 
| 91 | 
            +
                    client.message_err "Ruby #{$!.class}:#{line}: #{msg}"
         | 
| 87 92 | 
             
                  end
         | 
| 88 93 | 
             
                end
         | 
| 89 94 |  | 
| @@ -116,23 +121,6 @@ module Neovim | |
| 116 121 | 
             
              plugin_provider do |dsl|
         | 
| 117 122 |  | 
| 118 123 | 
             
                dsl.setup do |client|
         | 
| 119 | 
            -
                  r = client.get_var "ruby_require" rescue nil
         | 
| 120 | 
            -
                  case r
         | 
| 121 | 
            -
                  when String then r = r.split
         | 
| 122 | 
            -
                  when Array  then
         | 
| 123 | 
            -
                  when Hash   then r = r.keys
         | 
| 124 | 
            -
                  when nil    then nil
         | 
| 125 | 
            -
                  else             r = [r.to_s]
         | 
| 126 | 
            -
                  end
         | 
| 127 | 
            -
                  if r.notempty? then
         | 
| 128 | 
            -
                    WriteOut.redirect client do  # Protect the RPC interface against erroneous output.
         | 
| 129 | 
            -
                      r.each do |l|
         | 
| 130 | 
            -
                        require l
         | 
| 131 | 
            -
                      rescue LoadError
         | 
| 132 | 
            -
                        client.out_write "Warning: #$!"
         | 
| 133 | 
            -
                      end
         | 
| 134 | 
            -
                    end
         | 
| 135 | 
            -
                  end
         | 
| 136 124 | 
             
                  $curbuf = client.get_current_buf
         | 
| 137 125 | 
             
                  $curwin = client.get_current_win
         | 
| 138 126 | 
             
                end
         | 
| @@ -164,7 +152,13 @@ module Neovim | |
| 164 152 | 
             
                    set_globals client, fst..lst do |lines|
         | 
| 165 153 | 
             
                      client.command "#{lst}"
         | 
| 166 154 | 
             
                      WriteBuf.redirect client do
         | 
| 167 | 
            -
                        r =  | 
| 155 | 
            +
                        r = begin
         | 
| 156 | 
            +
                          script_binding.eval lines.to_s, "ruby_run"
         | 
| 157 | 
            +
                        rescue Exception
         | 
| 158 | 
            +
                          $@.pop until $@.empty? or $@.last.ends_with? ":in `empty_binding'"
         | 
| 159 | 
            +
                          raise unless $rescue
         | 
| 160 | 
            +
                          $!
         | 
| 161 | 
            +
                        end
         | 
| 168 162 | 
             
                        unless no_out or r.nil? then
         | 
| 169 163 | 
             
                          script_binding.local_variable_set :_, r
         | 
| 170 164 | 
             
                          puts "#=> #{r.inspect}"
         | 
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: nvim
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.9.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Bertram Scharpf
         | 
| 8 8 | 
             
            bindir: bin
         | 
| 9 9 | 
             
            cert_chain: []
         | 
| 10 | 
            -
            date: 2025- | 
| 10 | 
            +
            date: 2025-03-31 00:00:00.000000000 Z
         | 
| 11 11 | 
             
            dependencies: []
         | 
| 12 12 | 
             
            email: software@bertram-scharpf.de
         | 
| 13 13 | 
             
            executables:
         | 
| @@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 79 79 | 
             
                - !ruby/object:Gem::Version
         | 
| 80 80 | 
             
                  version: '0'
         | 
| 81 81 | 
             
            requirements: []
         | 
| 82 | 
            -
            rubygems_version: 3.6. | 
| 82 | 
            +
            rubygems_version: 3.6.6
         | 
| 83 83 | 
             
            specification_version: 4
         | 
| 84 84 | 
             
            summary: Yet another Ruby client for Neovim
         | 
| 85 85 | 
             
            test_files: []
         |