nvim 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbd0024450444336d8516c543f5bf6b9ac1f0a6a08a8e342f03a413e20794bcd
4
- data.tar.gz: 5ecd7b84dccc752f82aaf303ad146e5b7462478bc8a58eb25f70fb9393b30e6f
3
+ metadata.gz: ec0d28da100b26fcaca45acb51d863eb7683978b06dab4345f265d8c75d5b28a
4
+ data.tar.gz: c086178c5dcfd31520dfc13142a2827ae5b36edd5340f3037baf1246c6e3af03
5
5
  SHA512:
6
- metadata.gz: 5dfce6dc61d6c2910f8e1a273324682524246f92c9b7f9d62c8a6c9b915852b7d359b02435039105d6bcf811719a3f9e6a8579f8851f87e0c49e7f8b0182d389
7
- data.tar.gz: 1b58e82f140457815c0ff571aff1a209f591ff3f301269140685f0a5098d3efc315c318797fb22ea10d77c2ab34536f0c220a4ee6cc62c03a5da46a1150992c7
6
+ metadata.gz: a1d1de3dd0b50f63ba7f62335e6d6e0d1f061c9771e59848ca1d231049f4e668212a3f2fdc4b7b26ec4be0d78041b3142b0d8d4ba14bbd4ab06d8325f7c841f7
7
+ data.tar.gz: 17d86d71201706daeb1fca9691bdfea2ac4b064bdeafc2deeef0f394559acc405072f04699cb01363984d14d5238f794d14218be2c6be15240df0502d10ddacc
data/INFO.yaml CHANGED
@@ -3,7 +3,7 @@
3
3
  #
4
4
 
5
5
  nvim:
6
- version: 1.6.0
6
+ version: 1.7.0
7
7
  license: BSD-2-Clause+
8
8
  authors:
9
9
  - Bertram Scharpf
data/README.md CHANGED
@@ -224,7 +224,7 @@ Further, the variables `$range` and `$lines` will be set.
224
224
  2 bar
225
225
  3 baz
226
226
  ~
227
- :%ruby puts $range.inspect, $lines.inspect
227
+ :%ruby puts $range, $lines
228
228
  ```
229
229
 
230
230
  The legacy variables `$curbuf` and `$curwin` are supported.
@@ -411,21 +411,26 @@ main:1:004> \q!!
411
411
  Put text into an X selection or a TMux register.
412
412
 
413
413
  ```vim
414
- let g:ruby_require = "neovim/tools/copy"
414
+ rubyfile <neovim/tools/copy>
415
415
  '<,'>ruby xsel $lines
416
416
  '<,'>ruby xsel! $lines
417
417
  '<,'>ruby tmuxbuf $lines
418
418
  ```
419
419
 
420
- Make a hex dump.
420
+ Maybe you like to install the
421
+ [Nxxd](https://github.com/BertramScharpf/ruby-nxxd) gem.
421
422
 
422
423
  ```vim
423
- ruby <<EOT
424
- require "neovim/foreign/xxd"
425
- bn = $curbuf.get_name
426
- $vim.command :enew!
427
- File.open bn do |b| Xxd::Dump.new.run b do |l| $vim.put [l], "l", false, true end end
428
- EOT
424
+ rubyfile <nxxd>
425
+ ruby r = (0...0x80).to_a.map { |c| c.chr }.join
426
+ ruby puts Nxxd::Dump.new.run r
427
+ ```
428
+
429
+ Or even:
430
+
431
+ ```vim
432
+ rubyfile <nxxd>
433
+ HexDump /etc/localtime
429
434
  ```
430
435
 
431
436
 
@@ -433,4 +438,5 @@ EOT
433
438
 
434
439
  * (C) 2024,2025 Bertram Scharpf <software@bertram-scharpf.de>
435
440
  * License: [BSD-2-Clause+](./LICENSE)
441
+ * Repository: [ruby-nvim](https://github.com/BertramScharpf/ruby-nvim)
436
442
 
data/lib/neovim/client.rb CHANGED
@@ -114,5 +114,64 @@ module Neovim
114
114
 
115
115
  end
116
116
 
117
+ class Lines
118
+
119
+ include Enumerable
120
+
121
+ def initialize client, range
122
+ case client
123
+ when Buffer then @client, @buffer = client.client, client.index
124
+ else @client, @buffer = client, 0
125
+ end
126
+ @i, @last = range.begin, range.end
127
+ end
128
+
129
+ def to_s
130
+ (@client.buf_get_lines @buffer, @i-1, @last, true).join $/
131
+ end
132
+
133
+ def method_missing sym, *args, **kwargs, &block
134
+ to_a.send sym, *args, **kwargs, &block
135
+ end
136
+
137
+ def each
138
+ while @i <= @last do
139
+ @inc = 1
140
+ l, = @client.buf_get_lines @buffer, @i-1, @i, true
141
+ yield l
142
+ @i += @inc
143
+ end
144
+ ensure
145
+ @i = nil
146
+ end
147
+ alias each_line each
148
+
149
+ def each_with_no
150
+ each do |l|
151
+ yield l, @i
152
+ end
153
+ end
154
+
155
+ def map!
156
+ each do |l|
157
+ h = l.hash
158
+ m = yield l, @i
159
+ r =
160
+ case m
161
+ when String then m.lines unless m.hash == h
162
+ when Enumerable then m.map { |l| l.to_s }
163
+ when nil, false then []
164
+ end
165
+ if r then
166
+ r.each { |l| l.chomp! }
167
+ @client.buf_set_lines @buffer, @i-1, @i, true, r
168
+ @inc = r.length
169
+ @last += @inc-1
170
+ end
171
+ end
172
+ end
173
+
174
+ end
175
+
117
176
  end
118
177
 
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.6.0",
3
+ version: "1.7.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: "b2ddce4"
10
+ commit: "4e96338"
data/lib/neovim/remote.rb CHANGED
@@ -191,7 +191,7 @@ module Neovim
191
191
  if @responses.key? message.request_id then
192
192
  @responses[ message.request_id] = message
193
193
  else
194
- log :warning, "Dropped response", message.request_id
194
+ log :warning, "Dropped response", rid: message.request_id
195
195
  end
196
196
  when Message::Request, Message::Notification then
197
197
  h = find_handler message.method_name
@@ -100,18 +100,13 @@ module Neovim
100
100
 
101
101
  def set_globals client, range
102
102
  set_global_client client do
103
- lines = get_lines client, range
104
- $range, $lines = range, lines
105
- yield lines
103
+ $range, $lines = range, (Lines.new client, range)
104
+ yield $lines
106
105
  end
107
106
  ensure
108
107
  $range, $lines = nil, nil
109
108
  end
110
109
 
111
- def get_lines client, range
112
- client.buf_get_lines 0, range.begin-1, range.end, true
113
- end
114
-
115
110
  def plugin_provider &block
116
111
  run_dsl DslProvider, &block
117
112
  end
@@ -123,11 +118,13 @@ module Neovim
123
118
  dsl.setup do |client|
124
119
  r = client.get_var "ruby_require" rescue nil
125
120
  case r
126
- when Array then r = r.notempty?
127
- when nil then nil
128
- else r = [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]
129
126
  end
130
- if r then
127
+ if r.notempty? then
131
128
  WriteOut.redirect client do # Protect the RPC interface against erroneous output.
132
129
  r.each do |l|
133
130
  require l
@@ -164,11 +161,10 @@ module Neovim
164
161
  code.rstrip!
165
162
  if code =~ /\A\|?(-)?\z/ then # | is a workaround because Neovim doesn't allow empty code (the ultimate Quine).
166
163
  no_out = $1
167
- set_global_client client do
164
+ set_globals client, fst..lst do |lines|
168
165
  client.command "#{lst}"
169
- code = (get_lines client, fst..lst).join $/
170
166
  WriteBuf.redirect client do
171
- r = script_binding.eval code, "ruby_run"
167
+ r = script_binding.eval lines.to_s, "ruby_run"
172
168
  unless no_out or r.nil? then
173
169
  script_binding.local_variable_set :_, r
174
170
  puts "#=> #{r.inspect}"
@@ -219,20 +215,10 @@ module Neovim
219
215
  # This is called by the +:rubydo+ command.
220
216
  dsl.rpc :ruby_do_range do |client,fst,lst,code|
221
217
  set_globals client, fst..lst do |lines|
222
- i = fst
223
- lines.each do |l|
224
- h = l.hash
218
+ lines.map! do |l,i|
225
219
  (script_binding.eval 'proc do |l,i| $_, $. = l, i end').call l, i
226
220
  script_binding.eval code, "ruby_do_range"
227
- m = script_binding.eval '$_'
228
- if m.hash != h then
229
- m = m.lines
230
- m.each { |x| x.chomp! }
231
- client.buf_set_lines 0, i-1, i, true, m
232
- i += m.length
233
- else
234
- i += 1
235
- end
221
+ script_binding.eval '$_'
236
222
  end
237
223
  end
238
224
  nil
@@ -63,9 +63,9 @@ module Kernel
63
63
 
64
64
  def cmd_write cmd, data
65
65
  case data
66
- when Array then data = data.join $/
67
- when String then nil
68
- else data = data.to_s
66
+ when Enumerable then data = data.join $/
67
+ when String then nil
68
+ else data = data.to_s
69
69
  end
70
70
  IO.popen cmd, "w" do |t| t.write data end
71
71
  end
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.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bertram Scharpf
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-26 00:00:00.000000000 Z
10
+ date: 2025-02-05 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  email: software@bertram-scharpf.de
13
13
  executables:
@@ -48,7 +48,6 @@ files:
48
48
  - lib/neovim/foreign/mplight/bufferio.rb
49
49
  - lib/neovim/foreign/supplement.rb
50
50
  - lib/neovim/foreign/supplement/socket.rb
51
- - lib/neovim/foreign/xxd.rb
52
51
  - lib/neovim/handler.rb
53
52
  - lib/neovim/host.rb
54
53
  - lib/neovim/info.rb
@@ -80,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
79
  - !ruby/object:Gem::Version
81
80
  version: '0'
82
81
  requirements: []
83
- rubygems_version: 3.6.2
82
+ rubygems_version: 3.6.3
84
83
  specification_version: 4
85
84
  summary: Yet another Ruby client for Neovim
86
85
  test_files: []
@@ -1,195 +0,0 @@
1
- #
2
- # neovim/foreign/xxd.rb -- Xxd reimplementation
3
- #
4
-
5
- # The purpose of this is simply to reduce dependencies.
6
-
7
- begin
8
- require "xxd"
9
- rescue LoadError
10
-
11
- # ----------------------------------------------------------------
12
- #
13
- # xxd.rb -- A Reimplementation of Xxd in plain Ruby
14
- #
15
-
16
- module Xxd
17
-
18
- module ReadChunks
19
-
20
- private
21
-
22
- def read_chunks input
23
- case input
24
- when String then
25
- i = 0
26
- while i < input.bytesize do
27
- b = input.byteslice i, @line_size
28
- yield b
29
- i += @line_size
30
- end
31
- else
32
- loop do
33
- b = input.read @line_size
34
- break unless b
35
- yield b
36
- break if b.length < @line_size
37
- end
38
- end
39
- end
40
-
41
- end
42
-
43
- class Dump
44
-
45
- include ReadChunks
46
-
47
- LINE_SIZE = 16
48
- ADDR_FMT = "%%0%dx:"
49
-
50
- def initialize full: nil, upper: false, line_size: nil, addr_len: nil, input: nil
51
- @full = full
52
- @input = input
53
- @line_size = line_size||LINE_SIZE
54
- @addr_fmt = ADDR_FMT % (addr_len||8)
55
- @nib_fmt = "%02x"
56
- if upper then
57
- @addr_fmt.upcase!
58
- @nib_fmt.upcase!
59
- end
60
- end
61
-
62
- def run input
63
- addr = 0
64
- prev, repeat = nil, false
65
- yield "# #@input" if @input
66
- read_chunks input do |b|
67
- if b == prev and not @full then
68
- unless repeat then
69
- yield "*"
70
- repeat = true
71
- end
72
- else
73
- r = @addr_fmt % addr
74
- r << " "
75
- h = b.unpack "C*"
76
- sp = false
77
- @line_size.times {
78
- x = h.shift
79
- r << (x ? @nib_fmt % x : " ")
80
- r << " " if sp
81
- sp = !sp
82
- }
83
- r << " " << (b.gsub /[^ -~]/, ".")
84
- yield r
85
- prev, repeat = b, false
86
- end
87
- addr += b.size
88
- end
89
- yield @addr_fmt % addr
90
- end
91
-
92
- class <<self
93
-
94
- def reverse input
95
- r = nil
96
- pos = 0
97
- repeat = false
98
- input.each_line { |l|
99
- case l
100
- when /^\s*#/ then
101
- when /^\*/ then repeat = true
102
- else
103
- if (l.slice! /^(\h+):\s*/) then
104
- addr = $1.to_i 0x10
105
- if repeat then
106
- while pos + r.length < addr do
107
- yield r
108
- pos += r.length
109
- end
110
- if pos < addr then
111
- yield r[ 0, addr - pos]
112
- pos = addr
113
- end
114
- repeat = false
115
- else
116
- if pos < addr then
117
- r = ([0].pack "C*") * (addr - pos)
118
- yield r
119
- pos = addr
120
- elsif pos > addr then
121
- yield nil, addr
122
- pos = addr
123
- end
124
- end
125
- end
126
- row = []
127
- while (nib = l.slice! /^\h\h ?/) do
128
- row.push nib.to_i 0x10
129
- end
130
- if row.any? then
131
- r = row.pack "C*"
132
- yield r
133
- pos += r.length
134
- end
135
- end
136
- }
137
- end
138
-
139
- end
140
-
141
- end
142
-
143
- class DumpNums
144
-
145
- include ReadChunks
146
-
147
- LINE_SIZE = 12
148
-
149
- def initialize upper: false, line_size: nil, capitals: nil, input: nil
150
- @line_size = line_size||LINE_SIZE
151
- @nib_fmt = "%#04x"
152
- @nib_fmt.upcase! if upper
153
- if input then
154
- @varname = input.dup
155
- @varname.insert 0, "__" if @varname =~ /\A\d/
156
- @varname.gsub! /[^a-zA-Z0-9]/, "_"
157
- @varname.upcase! if capitals
158
- end
159
- end
160
-
161
- def run input, &block
162
- if @varname then
163
- yield "unsigned char #@varname[] = {"
164
- yield "};"
165
- len = run_plain input, &block
166
- yield "unsigned int #@varname\_len = %d;" % len
167
- else
168
- run_plain input, &block
169
- end
170
- end
171
-
172
- private
173
-
174
- def run_plain input
175
- prev, len = nil, 0
176
- read_chunks input do |b|
177
- if prev then
178
- prev << ","
179
- yield prev
180
- end
181
- prev = " " + ((b.unpack "C*").map { |x| @nib_fmt % x }.join ", ")
182
- len += b.bytesize
183
- end
184
- yield prev if prev
185
- len
186
- end
187
-
188
- end
189
-
190
- end
191
-
192
- # ----------------------------------------------------------------
193
-
194
- end
195
-