nvim 1.5.0 → 1.5.1

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: b7da86bd1593e902be08b9336b57ec728ff26c9bf27e8988db31abc6aca9e0c6
4
- data.tar.gz: def46654276768006e2091feb5f7d40ebf8fd2f2eaad10e4e5104d748d992b56
3
+ metadata.gz: b2f33b262cf70f6226c1af40d6b6173c56f5d808e7e4ba6629caa342f3131944
4
+ data.tar.gz: b78833e0442c2ba8e6a74786576bb4dcfecf5ecebf005bd45dd1c9b4a49732f5
5
5
  SHA512:
6
- metadata.gz: 806dff346c4a8e988fad37e14ab91391dafffccd4ba426002a9c5a3ea26ce6cebd43ad505b6de512bb0099b91dcabca5fe31f5d7ffdc41aa93c26fefebb0c663
7
- data.tar.gz: eec34f3b3c5be8327ee62fbd7ae9838151d7ed0361b34c5fbbf4632dc692aa2433129119f7c1a0cc146491c433d5d1791c5be9b74172829d6108e49703f389c3
6
+ metadata.gz: 49a0ba665e6d93a4f629b1b0375c29237d90cbb2510bb99d4ff3e4533f7e5cab68c76ee841cc7b25a5117411f5fb5e2ab24d3763f9cf4fa9617b9bef4d693cab
7
+ data.tar.gz: 1dafb13f71a994566f383577de178766fa6e0dc05a36075dc2af53c77cf3c5a0c8b21ac8dc08835fcbe89824441b857a193cfa8a503537f8ad642775276b8f6b
data/INFO.yaml CHANGED
@@ -3,7 +3,7 @@
3
3
  #
4
4
 
5
5
  nvim:
6
- version: 1.5.0
6
+ version: 1.5.1
7
7
  license: BSD-2-Clause+
8
8
  authors:
9
9
  - Bertram Scharpf
@@ -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
@@ -112,6 +112,7 @@ module Neovim
112
112
 
113
113
  def command arg ; call_api :command, arg ; end
114
114
 
115
+ # Be aware that #eval was a private instance method from module Kernel.
115
116
  def evaluate expr ; call_api :eval, expr ; end
116
117
 
117
118
  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
- log :fatal, "Signal was caught: #{n}"
58
- (n =~ /\A(?:SIG)?TERM\z/) ? 0 : 1
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.5.0",
3
+ version: "1.5.1",
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: "bc7977a"
10
+ commit: "3508371"
@@ -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 :info, "Starting", args: $*
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 :info, "Leaving"
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 :info, "Client Name", name: name
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 :info, "Deferred handler for", name: message.method_name
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 :info, "Found handler", name: name
269
+ log :debug1, "Found handler", name: name
270
270
  return h
271
271
  end
272
272
  end
data/lib/neovim.rb CHANGED
@@ -19,7 +19,7 @@ module Neovim
19
19
  class <<self
20
20
 
21
21
  def start_remote &block
22
- Job.run remote: (DslRemote.open &block), &block
22
+ Job.run remote: (DslRemote.open &block)
23
23
  end
24
24
 
25
25
  end
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.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bertram Scharpf
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-12-31 00:00:00.000000000 Z
10
+ date: 2025-01-14 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.5.23
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: []