nvim 1.8.0 → 1.10.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 +17 -12
- data/examples/passwords +2 -2
- data/lib/neovim/client.rb +5 -2
- data/lib/neovim/connection.rb +5 -3
- data/lib/neovim/info.rb +2 -2
- data/lib/neovim/output.rb +32 -45
- data/lib/neovim/ruby_provider.rb +4 -22
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc85eeab49096ed77dd13e5180ab09be73eefbfe902c1b072df4a4a1e43a3ab4
|
4
|
+
data.tar.gz: dfe8c784d1fa82258905ab6391a6ff5a96452fabf2c48a04d252080e9a7d91e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09a1efb791771fe4ff4e07d18dfc1c7c6692d052227177fdcc53b1f2b3c708426c8b726e5378b010d466f8c925b53cab234bdc0750162263e39dfb8e0ab2efd8'
|
7
|
+
data.tar.gz: 4528ee24eedd1cedd741c9e195372a63e70131ba0a6adbed692fcf21c6cc6ce52bbccf88151a096070b706667aec5ec0dc58f8350400bfda6399eec5b5682e84
|
data/INFO.yaml
CHANGED
data/README.md
CHANGED
@@ -69,9 +69,6 @@ echo Sum(13,7)
|
|
69
69
|
The `:ruby...` commands and the `rubyeval()` function behave as descibed
|
70
70
|
in `:h ruby`.
|
71
71
|
|
72
|
-
Files mentioned in the global variable `g:ruby_require` will be loaded
|
73
|
-
before the first Ruby code will be run.
|
74
|
-
|
75
72
|
Additionally you can directly execute the buffers contents (here, I did
|
76
73
|
`:set number`):
|
77
74
|
|
@@ -129,18 +126,24 @@ This results in:
|
|
129
126
|
:
|
130
127
|
```
|
131
128
|
|
132
|
-
To inhibit the output of the last value,
|
133
|
-
|
129
|
+
To inhibit the output of the last value, set the
|
130
|
+
`$result` variable to `false`.
|
131
|
+
|
132
|
+
| $result | Output |
|
133
|
+
| ------------- |---------------------------|
|
134
|
+
| `nil` | every result except `nil` |
|
135
|
+
| `false` | nothing |
|
136
|
+
| `true` | every result, even `nil` |
|
134
137
|
|
135
138
|
```
|
136
|
-
|
139
|
+
1 $result = true
|
140
|
+
2 puts "hi"
|
141
|
+
3 #=> nil
|
137
142
|
~
|
138
143
|
~
|
139
|
-
|
144
|
+
:1,2ruby |
|
140
145
|
```
|
141
146
|
|
142
|
-
In this case, you may even omit the pipe (`|`) character.
|
143
|
-
|
144
147
|
|
145
148
|
#### Last return value
|
146
149
|
|
@@ -230,6 +233,8 @@ Then:
|
|
230
233
|
:5ruby |
|
231
234
|
```
|
232
235
|
|
236
|
+
If `$result` is `false`, `$rescue` will be ignored.
|
237
|
+
|
233
238
|
Even non-standard errors wil be caught.
|
234
239
|
|
235
240
|
```
|
@@ -309,9 +314,9 @@ pp $vim.obj_classes.map { |c| [ c.type, ($vim.obj_functions c).sort] }.to_h
|
|
309
314
|
:%ruby |-
|
310
315
|
```
|
311
316
|
|
312
|
-
Deprecated functions
|
313
|
-
|
314
|
-
`get_api_info`.
|
317
|
+
Deprecated functions will be hidden unless you set the environment variable
|
318
|
+
`NVIM_RUBY_STRICT=off`. Old functions not starting with `nvim_` will be hidden.
|
319
|
+
The full list of API functions can be obtained by a call to `get_api_info`.
|
315
320
|
|
316
321
|
```
|
317
322
|
pp $vim.get_api_info
|
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
@@ -102,8 +102,11 @@ module Neovim
|
|
102
102
|
|
103
103
|
|
104
104
|
def message str
|
105
|
-
call_api :
|
106
|
-
|
105
|
+
call_api :echo, [ [ str]], true, {}
|
106
|
+
end
|
107
|
+
|
108
|
+
def message_err msg
|
109
|
+
call_api :echo, [ [ msg]], true, err: true
|
107
110
|
end
|
108
111
|
|
109
112
|
|
data/lib/neovim/connection.rb
CHANGED
@@ -47,9 +47,10 @@ 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"]
|
51
|
-
|
52
|
-
|
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
|
53
54
|
end
|
54
55
|
end
|
55
56
|
nil
|
@@ -138,6 +139,7 @@ module Neovim
|
|
138
139
|
|
139
140
|
def stdpath what
|
140
141
|
cmd = [ path, "--headless", ]
|
142
|
+
cmd.push "-u", "NONE"
|
141
143
|
cmd.push "-c", "echo stdpath(#{what.to_s.inspect})"
|
142
144
|
cmd.push "-c", "q"
|
143
145
|
(pipe_stderr cmd)&.tap { |x| x.chomp! }
|
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.10.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: "40737d0"
|
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
@@ -88,7 +88,7 @@ module Neovim
|
|
88
88
|
else
|
89
89
|
line = $@.first[ /:(\d+):in\b/, 1]
|
90
90
|
end
|
91
|
-
client.
|
91
|
+
client.message_err "Ruby #{$!.class}:#{line}: #{msg}"
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -121,23 +121,6 @@ module Neovim
|
|
121
121
|
plugin_provider do |dsl|
|
122
122
|
|
123
123
|
dsl.setup do |client|
|
124
|
-
r = client.get_var "ruby_require" rescue nil
|
125
|
-
case r
|
126
|
-
when String then r = r.split
|
127
|
-
when Array then
|
128
|
-
when Hash then r = r.keys
|
129
|
-
when nil then nil
|
130
|
-
else r = [r.to_s]
|
131
|
-
end
|
132
|
-
if r.notempty? then
|
133
|
-
WriteOut.redirect client do # Protect the RPC interface against erroneous output.
|
134
|
-
r.each do |l|
|
135
|
-
require l
|
136
|
-
rescue LoadError
|
137
|
-
client.out_write "Warning: #$!"
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
124
|
$curbuf = client.get_current_buf
|
142
125
|
$curwin = client.get_current_win
|
143
126
|
end
|
@@ -164,8 +147,7 @@ module Neovim
|
|
164
147
|
# This is called by the +:ruby+ command.
|
165
148
|
dsl.rpc :ruby_execute do |client,code,fst,lst|
|
166
149
|
code.rstrip!
|
167
|
-
if code
|
168
|
-
no_out = $1
|
150
|
+
if code == "|" then # | is a workaround because Neovim doesn't allow empty code (the ultimate Quine).
|
169
151
|
set_globals client, fst..lst do |lines|
|
170
152
|
client.command "#{lst}"
|
171
153
|
WriteBuf.redirect client do
|
@@ -173,10 +155,10 @@ module Neovim
|
|
173
155
|
script_binding.eval lines.to_s, "ruby_run"
|
174
156
|
rescue Exception
|
175
157
|
$@.pop until $@.empty? or $@.last.ends_with? ":in `empty_binding'"
|
176
|
-
raise unless $rescue
|
158
|
+
raise unless $rescue and $result != false
|
177
159
|
$!
|
178
160
|
end
|
179
|
-
unless
|
161
|
+
unless $result == false or (not $result and r.nil?) then
|
180
162
|
script_binding.local_variable_set :_, r
|
181
163
|
puts "#=> #{r.inspect}"
|
182
164
|
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.
|
4
|
+
version: 1.10.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-04-08 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
email: software@bertram-scharpf.de
|
13
13
|
executables:
|