nvim 1.5.0 → 1.6.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/LICENSE +1 -1
- data/README.md +48 -2
- data/examples/passwords +78 -0
- data/lib/neovim/client.rb +1 -3
- data/lib/neovim/host.rb +8 -2
- data/lib/neovim/info.rb +2 -2
- data/lib/neovim/logging.rb +2 -2
- data/lib/neovim/remote.rb +5 -5
- data/lib/neovim/remote_object.rb +3 -0
- data/lib/neovim/ruby_provider.rb +10 -4
- data/lib/neovim.rb +1 -1
- metadata +5 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbd0024450444336d8516c543f5bf6b9ac1f0a6a08a8e342f03a413e20794bcd
|
4
|
+
data.tar.gz: 5ecd7b84dccc752f82aaf303ad146e5b7462478bc8a58eb25f70fb9393b30e6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5dfce6dc61d6c2910f8e1a273324682524246f92c9b7f9d62c8a6c9b915852b7d359b02435039105d6bcf811719a3f9e6a8579f8851f87e0c49e7f8b0182d389
|
7
|
+
data.tar.gz: 1b58e82f140457815c0ff571aff1a209f591ff3f301269140685f0a5098d3efc315c318797fb22ea10d77c2ab34536f0c220a4ee6cc62c03a5da46a1150992c7
|
data/INFO.yaml
CHANGED
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# BSD-2-clause license, extended by language use conditions
|
2
2
|
|
3
|
-
Copyright (C) 2024, Bertram Scharpf <software@bertram-scharpf.de>.
|
3
|
+
Copyright (C) 2024-2025, Bertram Scharpf <software@bertram-scharpf.de>.
|
4
4
|
All rights reserved.
|
5
5
|
|
6
6
|
Redistribution and use in source and binary forms, with or without
|
data/README.md
CHANGED
@@ -207,6 +207,52 @@ Yet, you should avoid to use `fork` and `exec`, except when
|
|
207
207
|
you're absolutely sure what you're doing.
|
208
208
|
|
209
209
|
|
210
|
+
#### Global variables
|
211
|
+
|
212
|
+
The global variable `$vim` will be set to the client.
|
213
|
+
|
214
|
+
```
|
215
|
+
~
|
216
|
+
~
|
217
|
+
:ruby $vim.command "split"
|
218
|
+
```
|
219
|
+
|
220
|
+
Further, the variables `$range` and `$lines` will be set.
|
221
|
+
|
222
|
+
```
|
223
|
+
1 foo
|
224
|
+
2 bar
|
225
|
+
3 baz
|
226
|
+
~
|
227
|
+
:%ruby puts $range.inspect, $lines.inspect
|
228
|
+
```
|
229
|
+
|
230
|
+
The legacy variables `$curbuf` and `$curwin` are supported.
|
231
|
+
|
232
|
+
```
|
233
|
+
~
|
234
|
+
~
|
235
|
+
:ruby puts $curbuf.get_name, $curwin.get_height
|
236
|
+
```
|
237
|
+
|
238
|
+
|
239
|
+
### Requiring Ruby files
|
240
|
+
|
241
|
+
In addition to the `:rubyfile` command as documented, that command can also be
|
242
|
+
used to just require a Ruby file. Set the name into angle brackets, and the
|
243
|
+
file will be searched in `$:`. Sorry, file name completion will not work.
|
244
|
+
|
245
|
+
```
|
246
|
+
~
|
247
|
+
~
|
248
|
+
:rubyfile <yaml>
|
249
|
+
```
|
250
|
+
|
251
|
+
In this case, the global variables `$range` and `$lines` will not be set. Yet,
|
252
|
+
`$vim` still will be available. See the
|
253
|
+
[Nxxd](https://github.com/BertramScharpf/ruby-nxxd) gem for a nice example.
|
254
|
+
|
255
|
+
|
210
256
|
### List all API functions
|
211
257
|
|
212
258
|
To show a list of the API functions call something like this:
|
@@ -377,7 +423,7 @@ Make a hex dump.
|
|
377
423
|
ruby <<EOT
|
378
424
|
require "neovim/foreign/xxd"
|
379
425
|
bn = $curbuf.get_name
|
380
|
-
$vim.command :
|
426
|
+
$vim.command :enew!
|
381
427
|
File.open bn do |b| Xxd::Dump.new.run b do |l| $vim.put [l], "l", false, true end end
|
382
428
|
EOT
|
383
429
|
```
|
@@ -385,6 +431,6 @@ EOT
|
|
385
431
|
|
386
432
|
## Copyright
|
387
433
|
|
388
|
-
* (C) 2024 Bertram Scharpf <software@bertram-scharpf.de>
|
434
|
+
* (C) 2024,2025 Bertram Scharpf <software@bertram-scharpf.de>
|
389
435
|
* License: [BSD-2-Clause+](./LICENSE)
|
390
436
|
|
data/examples/passwords
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#
|
4
|
+
# examples/passwords -- Manage a file containing your passwords
|
5
|
+
#
|
6
|
+
|
7
|
+
# (C) 2025 Bertram Scharpf <software@bertram-scharpf.de>
|
8
|
+
|
9
|
+
require "neovim/host"
|
10
|
+
|
11
|
+
|
12
|
+
class Passwords
|
13
|
+
|
14
|
+
PW_FILE = File.expand_path "~/.config/mypasswords.asc"
|
15
|
+
RECIPIENT = "jdoe@example.com"
|
16
|
+
|
17
|
+
def initialize debug: false
|
18
|
+
@debug = debug
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
contents = get_contents.split $/
|
23
|
+
Neovim::Remote.run_sub do |pw_dsl|
|
24
|
+
pw_dsl.setup do |client|
|
25
|
+
client.set_option shadafile: "NONE"
|
26
|
+
client.set_option filetype: "dosini"
|
27
|
+
client.put contents, "l", true, false
|
28
|
+
client.command "1"
|
29
|
+
client.get_current_line.empty? and client.del_current_line
|
30
|
+
{
|
31
|
+
"Save" => "rb_save",
|
32
|
+
"Totp" => "rb_totp",
|
33
|
+
}.each { |cmd,fn|
|
34
|
+
client.command "command -buffer -nargs=0 %s call rpcrequest(%d,'%s')" % [ cmd, client.channel_id, fn]
|
35
|
+
}
|
36
|
+
end
|
37
|
+
pw_dsl.register_handler "rb_save" do |client|
|
38
|
+
File.rename PW_FILE, "#{PW_FILE}.bak" rescue nil
|
39
|
+
IO.popen %W(gpg -a -r #{RECIPIENT} --encrypt -o #{PW_FILE}), "w" do |gpg|
|
40
|
+
gpg.puts client.get_current_buf[1..]
|
41
|
+
end
|
42
|
+
File.chmod 0600, PW_FILE
|
43
|
+
end
|
44
|
+
pw_dsl.register_handler "rb_totp" do |client|
|
45
|
+
require "potp"
|
46
|
+
require "neovim/tools/copy"
|
47
|
+
p = client.call_function "expand", [ "<cword>"]
|
48
|
+
key = (POTP::TOTP.new p).now if p.notempty? and p.length % 4 == 0
|
49
|
+
client.echo [ [ key]], true, {}
|
50
|
+
xsel key
|
51
|
+
rescue
|
52
|
+
client.err_writeln "No OTP under cursor?"
|
53
|
+
rescue ScriptError
|
54
|
+
client.err_writeln $!.message
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def get_contents
|
60
|
+
r = IO.popen %W(gpg -d #{PW_FILE}), "r" do |gpg| gpg.read end
|
61
|
+
r.notempty? or <<~EOT
|
62
|
+
# Move the cursor to the OTP keyword and give the command `:Totp`.
|
63
|
+
# The TOTP key will be displayed and further copied to the clipboard.
|
64
|
+
|
65
|
+
[account "dummy"]
|
66
|
+
name = John Doe
|
67
|
+
password = very$ecret
|
68
|
+
optauth = GYS5L3N3E4AAYNMN562LW76TMWHQBJ4A
|
69
|
+
|
70
|
+
# As soon as you have set the `RECIPIENT` constant in the executable,
|
71
|
+
# you may save this file calling the command `:Save`.
|
72
|
+
EOT
|
73
|
+
end
|
74
|
+
|
75
|
+
new.run
|
76
|
+
|
77
|
+
end
|
78
|
+
|
data/lib/neovim/client.rb
CHANGED
@@ -16,9 +16,6 @@ module Neovim
|
|
16
16
|
attr_accessor :strict
|
17
17
|
end
|
18
18
|
|
19
|
-
class UnknownApiFunction < RuntimeError ; end
|
20
|
-
class UnknownApiObjectFunction < RuntimeError ; end
|
21
|
-
|
22
19
|
|
23
20
|
attr_reader :channel_id
|
24
21
|
|
@@ -112,6 +109,7 @@ module Neovim
|
|
112
109
|
|
113
110
|
def command arg ; call_api :command, arg ; end
|
114
111
|
|
112
|
+
# Be aware that #eval was a private instance method from module Kernel.
|
115
113
|
def evaluate expr ; call_api :eval, expr ; end
|
116
114
|
|
117
115
|
end
|
data/lib/neovim/host.rb
CHANGED
@@ -47,6 +47,7 @@ module Neovim
|
|
47
47
|
def run plugins
|
48
48
|
$stdin.tty? and raise "This program expects to be called by Neovim. It can't run interactively."
|
49
49
|
start plugins do |h|
|
50
|
+
log :info, "Starting event loop."
|
50
51
|
h.run
|
51
52
|
nil
|
52
53
|
rescue Remote::Disconnected
|
@@ -54,8 +55,13 @@ module Neovim
|
|
54
55
|
nil
|
55
56
|
rescue SignalException
|
56
57
|
n = $!.signm.notempty? || $!.class.to_s
|
57
|
-
|
58
|
-
|
58
|
+
if n =~ /\A(?:SIG)?TERM\z/ then
|
59
|
+
log :info, "Exiting after terminate signal."
|
60
|
+
nil
|
61
|
+
else
|
62
|
+
log :fatal, "Signal was caught: #{n}"
|
63
|
+
1
|
64
|
+
end
|
59
65
|
rescue Exception
|
60
66
|
log_exception :fatal
|
61
67
|
2
|
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.6.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: "b2ddce4"
|
data/lib/neovim/logging.rb
CHANGED
@@ -234,8 +234,8 @@ module Neovim
|
|
234
234
|
**kwargs
|
235
235
|
end
|
236
236
|
|
237
|
-
def log_exception level
|
238
|
-
Logging.put level, "Exception: #$!",
|
237
|
+
def log_exception level = nil
|
238
|
+
Logging.put level||:error, "Exception: #$!",
|
239
239
|
sender: self, caller: (caller 1, 1).first,
|
240
240
|
exception: $!.class
|
241
241
|
$@.each { |b|
|
data/lib/neovim/remote.rb
CHANGED
@@ -122,13 +122,13 @@ module Neovim
|
|
122
122
|
|
123
123
|
def start plugins, *args, **kwargs
|
124
124
|
open_logfile do
|
125
|
-
log :
|
125
|
+
log :debug1, "Starting", args: $*
|
126
126
|
open_conn *args, **kwargs do |conn|
|
127
127
|
i = new plugins, conn
|
128
128
|
yield i
|
129
129
|
end
|
130
130
|
ensure
|
131
|
-
log :
|
131
|
+
log :debug1, "Leaving"
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
@@ -154,7 +154,7 @@ module Neovim
|
|
154
154
|
l.map! { |p| p.type }
|
155
155
|
l.uniq!
|
156
156
|
name = l.join "-"
|
157
|
-
log :
|
157
|
+
log :debug1, "Client Name", name: name
|
158
158
|
"ruby-#{name}-host"
|
159
159
|
else
|
160
160
|
"ruby-client"
|
@@ -210,7 +210,7 @@ module Neovim
|
|
210
210
|
if @conn.client or not h.needs_client? then
|
211
211
|
p.call
|
212
212
|
else
|
213
|
-
log :
|
213
|
+
log :debug1, "Deferred handler for", name: message.method_name
|
214
214
|
@deferred ||= []
|
215
215
|
@deferred.push p
|
216
216
|
end
|
@@ -266,7 +266,7 @@ module Neovim
|
|
266
266
|
@plugins.each_value do |plugin|
|
267
267
|
h = plugin.get_handler name
|
268
268
|
if h then
|
269
|
-
log :
|
269
|
+
log :debug1, "Found handler", name: name
|
270
270
|
return h
|
271
271
|
end
|
272
272
|
end
|
data/lib/neovim/remote_object.rb
CHANGED
data/lib/neovim/ruby_provider.rb
CHANGED
@@ -203,11 +203,17 @@ module Neovim
|
|
203
203
|
|
204
204
|
# This is called by the +:rubyfile+ command.
|
205
205
|
dsl.rpc :ruby_execute_file do |client,path,fst,lst|
|
206
|
-
|
207
|
-
|
208
|
-
|
206
|
+
if path =~ /<(.*)>\z/ then
|
207
|
+
set_global_client client do
|
208
|
+
require $1
|
209
|
+
end
|
210
|
+
else
|
211
|
+
set_globals client, fst..lst do ||
|
212
|
+
r = File.read path
|
213
|
+
script_binding.eval r, "ruby_file #{path}"
|
214
|
+
end
|
215
|
+
nil
|
209
216
|
end
|
210
|
-
nil
|
211
217
|
end
|
212
218
|
|
213
219
|
# This is called by the +:rubydo+ command.
|
data/lib/neovim.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nvim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bertram Scharpf
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-26 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
|
-
description:
|
14
12
|
email: software@bertram-scharpf.de
|
15
13
|
executables:
|
16
14
|
- neovim-ruby-host
|
@@ -28,6 +26,7 @@ extra_rdoc_files:
|
|
28
26
|
- examples/demo_remote_inside_block.rb
|
29
27
|
- examples/demo_sub
|
30
28
|
- examples/dump_api
|
29
|
+
- examples/passwords
|
31
30
|
files:
|
32
31
|
- INFO.yaml
|
33
32
|
- LICENSE
|
@@ -41,6 +40,7 @@ files:
|
|
41
40
|
- examples/demo_remote_inside_block.rb
|
42
41
|
- examples/demo_sub
|
43
42
|
- examples/dump_api
|
43
|
+
- examples/passwords
|
44
44
|
- lib/neovim.rb
|
45
45
|
- lib/neovim/client.rb
|
46
46
|
- lib/neovim/connection.rb
|
@@ -66,7 +66,6 @@ homepage: https://github.com/BertramScharpf/ruby-nvim
|
|
66
66
|
licenses:
|
67
67
|
- BSD-2-Clause+
|
68
68
|
metadata: {}
|
69
|
-
post_install_message:
|
70
69
|
rdoc_options: []
|
71
70
|
require_paths:
|
72
71
|
- lib
|
@@ -81,8 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
80
|
- !ruby/object:Gem::Version
|
82
81
|
version: '0'
|
83
82
|
requirements: []
|
84
|
-
rubygems_version: 3.
|
85
|
-
signing_key:
|
83
|
+
rubygems_version: 3.6.2
|
86
84
|
specification_version: 4
|
87
85
|
summary: Yet another Ruby client for Neovim
|
88
86
|
test_files: []
|