nvim 1.15 → 1.17

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d400abbf959061772a9955dbe4fbc14ce0618b5a4d0383f7a508d593c4e3402
4
- data.tar.gz: a147f00213db4e1fc9ea90aff76cb8d8c0e810c3cb893a7825b0c0c279a40719
3
+ metadata.gz: 06b12df6d8856b91180d67ebb8be66160f424c3e71845c09504da6a4078ce308
4
+ data.tar.gz: ce4ae49114a9cd755b15259d5f4c2887ebdb6366b32a7a111bc35d74af9f756c
5
5
  SHA512:
6
- metadata.gz: 50505d6d75eb31ff042ba1494b803382d693ce5703416917f2bb390e005fae2eb96ac704c4a2a1356496054ab2f27663a81c3b0313ebba974874accc08bddb33
7
- data.tar.gz: d6ea941226c7bf1d3f2ce19e4a694349902039ca7f8804996fd02ea20f34e3b3c8b2aa40e4021066a13469c81b1d212f13cf62897b2709d96d34fb959df0d88f
6
+ metadata.gz: 67d166365ac13745e323a379c7490dc2a11a718610413d0989904afe9df8e22ac282d193b52b8b0f5ff92d864b8757b2c57f9ace301532f059c38574c68f6dc2
7
+ data.tar.gz: 49ab2db7e0d4159765b4c1c85346e0fdd0fdcf9637a5a2709ffb3c184102366e319d09dc1eafa7008857d3a7aff98818cef83ce08a388223f3b59de10b2edb63
data/INFO.yaml CHANGED
@@ -3,7 +3,7 @@
3
3
  #
4
4
 
5
5
  nvim:
6
- version: "1.15"
6
+ version: "1.17"
7
7
  license: LicenseRef-BSD-2-Clause-and-DECENT_LANGUAGE
8
8
  authors:
9
9
  - Bertram Scharpf
data/README.md CHANGED
@@ -206,6 +206,28 @@ Yet, I suggest not to use `fork` and `exec`, except when
206
206
  you're absolutely sure what you're doing.
207
207
 
208
208
 
209
+ #### Output to a specific buffer
210
+
211
+ You may specify an output buffer by its number.
212
+
213
+ ```
214
+ 1 a = 0
215
+ 2 begin
216
+ 3 puts a
217
+ 4 a = (a * 61 + 637) % 1000
218
+ 5 end while a.nonzero?
219
+ ~
220
+ ~
221
+ :%ruby @3
222
+ ```
223
+
224
+ Use `:execute` if you determine the buffer number by a function.
225
+
226
+ ```
227
+ :exe "%ruby @".bufnr("#")
228
+ ```
229
+
230
+
209
231
  #### Exception handling
210
232
 
211
233
  If you prefer, you may return an error as a value, too.
@@ -225,8 +247,9 @@ Then:
225
247
  1 $rescue = true
226
248
  2 z = 0
227
249
  3 q = 1 / z
228
- 4 #=> #<ZeroDivisionError: divided by 0>
229
- 5 puts "=begin", _.backtrace, "=end"
250
+ 4 #!= ZeroDivisionError
251
+ 5 #! divided by 0
252
+ 6 puts "=begin", _.backtrace, "=end"
230
253
  ~
231
254
  ~
232
255
  :5ruby |
@@ -237,8 +260,8 @@ If `$result` is `false`, `$rescue` will be ignored.
237
260
  Even non-standard errors wil be caught.
238
261
 
239
262
  ```
240
- 1 def f ; f ; end
241
- 2 f
263
+ 1 def fn ; fn ; end
264
+ 2 fn
242
265
  ~
243
266
  ~
244
267
  :1,2ruby |
@@ -252,6 +275,7 @@ Even non-standard errors wil be caught.
252
275
  ~
253
276
  :3ruby |
254
277
  ```
278
+
255
279
  Then say 'kill 49042' somewhere else.
256
280
 
257
281
 
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.15",
3
+ version: "1.17",
4
4
  license: "LicenseRef-BSD-2-Clause-and-DECENT_LANGUAGE",
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: "8c2c256"
10
+ commit: "6f143de"
data/lib/neovim/output.rb CHANGED
@@ -45,9 +45,10 @@ module Neovim
45
45
  i.finish
46
46
  end
47
47
  end
48
- def initialize client, *rest
48
+ def initialize client, *rest, **kwargs
49
49
  @client = client
50
50
  end
51
+ def tty? ; false ; end
51
52
  def << arg
52
53
  write arg.to_s
53
54
  self
@@ -90,7 +91,7 @@ module Neovim
90
91
  end
91
92
  end
92
93
  end
93
- def initialize *args
94
+ def initialize *args, **kwargs
94
95
  super
95
96
  @str = ""
96
97
  end
@@ -137,19 +138,34 @@ module Neovim
137
138
  end
138
139
 
139
140
  class WriteBuf < WriteStd
140
- def initialize *args, follow: nil
141
+ def initialize *args, buffer: nil, follow: true
141
142
  super
142
143
  @lines = []
144
+ @buffer = buffer
145
+ if Integer === @buffer then
146
+ @buffer = Buffer.new @buffer, @client
147
+ end
143
148
  @follow = follow.to_bool
144
149
  end
145
150
  def finish
146
151
  super
147
- @client.put @lines, "l", @follow, @follow
152
+ if @buffer then
153
+ r = buffer_is_empty? ? 0..1 : (@follow ? -1..-1 : 0..0)
154
+ @buffer.set_lines r.begin, r.end, true, @lines
155
+ else
156
+ @client.put @lines, "l", @follow, @follow
157
+ end
148
158
  end
149
159
  private
150
160
  def write_line l
151
161
  @lines.push l
152
162
  end
163
+ def buffer_is_empty?
164
+ if @buffer.line_count <= 1 then
165
+ e, = @buffer.get_lines 0, 1, true
166
+ e.empty?
167
+ end
168
+ end
153
169
  end
154
170
 
155
171
  end
@@ -23,14 +23,14 @@ module Vim
23
23
  class <<Buffer
24
24
  def current ; $vim.get_current_buf ; end
25
25
  def count ; $vim.list_bufs.size ; end
26
- def [] i ; $vim.list_bufs[ i] ; end
26
+ def [] i ; $vim.list_bufs.find { |b| b.index == i } ; end
27
27
  end
28
28
 
29
29
  Window = ::Neovim::Window
30
30
  class <<Window
31
31
  def current ; $vim.get_current_win ; end
32
32
  def count ; $vim.get_current_tabpage.list_wins.size ; end
33
- def [] i ; $vim.get_current_tabpage.list_wins[ i] ; end
33
+ def [] i ; $vim.get_current_tabpage.list_wins.find { |w| w.index == i } ; end
34
34
  self
35
35
  end
36
36
 
@@ -167,6 +167,12 @@ module Neovim
167
167
  script_binding.local_variable_set :_, $!
168
168
  end
169
169
  end
170
+ elsif code =~ /\A@(\d+)\z/ then
171
+ set_globals client, fst..lst do |lines|
172
+ WriteBuf.redirect client, buffer: $1.to_i, follow: true do
173
+ script_binding.eval lines.to_s, "ruby_run"
174
+ end
175
+ end
170
176
  elsif code == "+" then
171
177
  client.command "#{lst}"
172
178
  set_globals client, fst..lst do |lines|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nvim
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.15'
4
+ version: '1.17'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bertram Scharpf