nvim 1.0.0 → 1.1.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 +2 -2
- data/README.md +28 -0
- data/bin/neovim-ruby-host +24 -21
- data/lib/neovim/connection.rb +2 -2
- data/lib/neovim/foreign/supplement.rb +9 -0
- data/lib/neovim/foreign/xxd.rb +195 -0
- data/lib/neovim/handler.rb +33 -20
- data/lib/neovim/host.rb +27 -47
- data/lib/neovim/info.rb +3 -3
- data/lib/neovim/logging.rb +16 -7
- data/lib/neovim/output.rb +142 -0
- data/lib/neovim/remote.rb +241 -18
- data/lib/neovim/remote_object.rb +7 -7
- data/lib/neovim/ruby_provider.rb +25 -110
- data/lib/neovim/tools/copy.rb +78 -0
- data/lib/neovim/vimscript_provider.rb +1 -1
- data/lib/neovim.rb +14 -4
- metadata +7 -6
- data/lib/neovim/messager.rb +0 -185
- data/lib/neovim/session.rb +0 -60
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86b10be9d49da003c89060559febe3e475e543660e957e6c3dffc15522fbbdd5
|
4
|
+
data.tar.gz: 5d4ea6f5bf523a0a8918eb5a6defbbdf58bfd001fde2ba77d75c4ccd2a75858b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 976dbd80726c5626ff8aacefe48f3b9a3f30b432eb915ab82dca589604bc23260f8073184bf007a168acf7576d1923c8ede6fc3d59f64f7751ec54e4d4a37867
|
7
|
+
data.tar.gz: 8f1f04a090a323ffed4011a7a8c22953a3d294034d5e319f5825307c9c45528766a6ac1268483ba540e773d3b6763048580032aa6f4dfc191d89d7e8355fb648
|
data/INFO.yaml
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
|
5
5
|
nvim:
|
6
|
-
version: 1.
|
6
|
+
version: 1.1.0
|
7
7
|
license: BSD-2-Clause+
|
8
8
|
authors:
|
9
9
|
- Bertram Scharpf
|
@@ -14,5 +14,5 @@ nvim:
|
|
14
14
|
A simple Ruby client for Neovim.
|
15
15
|
Clean code, minimal dependecies, no frills, no wokeness.
|
16
16
|
|
17
|
-
homepage:
|
17
|
+
homepage: https://github.com/BertramScharpf/ruby-nvim
|
18
18
|
|
data/README.md
CHANGED
@@ -69,6 +69,9 @@ 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 before
|
73
|
+
the first Ruby code will be run.
|
74
|
+
|
72
75
|
Additionally you can directly execute the buffers contents:
|
73
76
|
|
74
77
|
```vim
|
@@ -129,6 +132,8 @@ This results in:
|
|
129
132
|
:
|
130
133
|
```
|
131
134
|
|
135
|
+
The anonymous variable `_` hold this last result.
|
136
|
+
|
132
137
|
Output will be added to the buffer, too.
|
133
138
|
|
134
139
|
```
|
@@ -257,6 +262,29 @@ main:1:004> \q!!
|
|
257
262
|
```
|
258
263
|
|
259
264
|
|
265
|
+
#### Miscellaneous Tools
|
266
|
+
|
267
|
+
Put text into an X selection or a TMux register.
|
268
|
+
|
269
|
+
```vim
|
270
|
+
let g:ruby_require = "neovim/tools/copy"
|
271
|
+
'<,'>ruby xsel $lines
|
272
|
+
'<,'>ruby xsel! $ines
|
273
|
+
'<,'>ruby tmuxbuf $lines
|
274
|
+
```
|
275
|
+
|
276
|
+
Make a hex dump.
|
277
|
+
|
278
|
+
```vim
|
279
|
+
ruby <<EOT
|
280
|
+
require "neovim/foreign/xxd"
|
281
|
+
bn = $curbuf.get_name
|
282
|
+
$vim.command :new
|
283
|
+
File.open bn do |b| Xxd::Dump.new.run b do |l| $vim.put [l], "l", false, true end end
|
284
|
+
EOT
|
285
|
+
```
|
286
|
+
|
287
|
+
|
260
288
|
## Copyright
|
261
289
|
|
262
290
|
* (C) 2024 Bertram Scharpf <software@bertram-scharpf.de>
|
data/bin/neovim-ruby-host
CHANGED
@@ -9,6 +9,11 @@ require "neovim/host"
|
|
9
9
|
|
10
10
|
module Neovim
|
11
11
|
|
12
|
+
if $*.delete "--version" then
|
13
|
+
puts [ INFO.name, INFO.version].join " "
|
14
|
+
exit
|
15
|
+
end
|
16
|
+
|
12
17
|
class <<self
|
13
18
|
|
14
19
|
def plugin &block
|
@@ -18,33 +23,31 @@ module Neovim
|
|
18
23
|
|
19
24
|
private
|
20
25
|
|
21
|
-
def run_dsl dsl
|
22
|
-
@
|
23
|
-
dsl.open @path,
|
24
|
-
yield dsl
|
25
|
-
end
|
26
|
+
def run_dsl dsl, &block
|
27
|
+
@plugins or raise "Can't add plugins outside of a running session."
|
28
|
+
@plugins[ @path] = dsl.open @path, &block
|
26
29
|
end
|
27
30
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
@
|
40
|
-
Kernel.load @path, true
|
31
|
+
public
|
32
|
+
|
33
|
+
def load_plugins
|
34
|
+
begin
|
35
|
+
@plugins = {}
|
36
|
+
$*.each do |p|
|
37
|
+
@path = p
|
38
|
+
Kernel.load @path, true
|
39
|
+
ensure
|
40
|
+
@path = nil
|
41
|
+
end
|
42
|
+
@plugins
|
41
43
|
ensure
|
42
|
-
@
|
44
|
+
@plugins = nil
|
43
45
|
end
|
44
|
-
ensure
|
45
|
-
@host = nil
|
46
46
|
end
|
47
|
+
|
47
48
|
end
|
49
|
+
|
50
|
+
r = Host.run load_plugins
|
48
51
|
exit r.to_i
|
49
52
|
|
50
53
|
end
|
data/lib/neovim/connection.rb
CHANGED
@@ -33,8 +33,8 @@ module Neovim
|
|
33
33
|
end
|
34
34
|
|
35
35
|
|
36
|
-
def start comm
|
37
|
-
comm.notify :nvim_set_client_info, client_name,
|
36
|
+
def start comm
|
37
|
+
comm.notify :nvim_set_client_info, comm.client_name, INFO.version_h, comm.client_type, comm.client_methods||{}, INFO.attributes
|
38
38
|
channel_id, api_info = *(comm.request :nvim_get_api_info)
|
39
39
|
@client = Client.new comm, channel_id
|
40
40
|
prefixes = {}
|
@@ -14,6 +14,15 @@ rescue LoadError
|
|
14
14
|
class FalseClass ; def to_bool ; false ; end ; end
|
15
15
|
class Object ; def to_bool ; true ; end ; end
|
16
16
|
class <<Struct ; alias [] new ; end
|
17
|
+
class Module
|
18
|
+
def plain_name
|
19
|
+
sep = "::"
|
20
|
+
n = name.dup
|
21
|
+
i = n.rindex sep
|
22
|
+
n.slice! 0, i+sep.length if i
|
23
|
+
n
|
24
|
+
end
|
25
|
+
end
|
17
26
|
class String
|
18
27
|
def axe n
|
19
28
|
if n < length then
|
@@ -0,0 +1,195 @@
|
|
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
|
+
|
data/lib/neovim/handler.rb
CHANGED
@@ -29,9 +29,8 @@ module Neovim
|
|
29
29
|
def sync ; @spec[ :sync] ; end
|
30
30
|
alias sync? sync
|
31
31
|
|
32
|
-
def
|
33
|
-
|
34
|
-
end
|
32
|
+
def needs_client? ; true ; end
|
33
|
+
def execute *args ; @block.call *args ; end
|
35
34
|
|
36
35
|
private
|
37
36
|
|
@@ -49,18 +48,30 @@ module Neovim
|
|
49
48
|
|
50
49
|
end
|
51
50
|
|
51
|
+
class HandlerPlain < Handler
|
52
|
+
|
53
|
+
def initialize *args, **kwargs
|
54
|
+
super *args, **kwargs do |client,*a|
|
55
|
+
yield *a
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def needs_client? ; false ; end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
52
63
|
class DslBase
|
53
64
|
|
54
65
|
class Plugins
|
55
66
|
|
56
67
|
attr_reader :type
|
57
68
|
|
58
|
-
def initialize type,
|
59
|
-
@type, @
|
69
|
+
def initialize type, setups, handlers
|
70
|
+
@type, @setups, @handlers = type, setups, handlers
|
60
71
|
end
|
61
72
|
|
62
73
|
def setup client
|
63
|
-
@
|
74
|
+
@setups.each { |b| b.call client }
|
64
75
|
end
|
65
76
|
|
66
77
|
def get_handler name
|
@@ -81,46 +92,48 @@ module Neovim
|
|
81
92
|
|
82
93
|
class <<self
|
83
94
|
private :new
|
84
|
-
def open
|
85
|
-
i = new
|
95
|
+
def open *args
|
96
|
+
i = new *args
|
86
97
|
yield i
|
87
|
-
i.
|
98
|
+
i.mkplugin
|
88
99
|
end
|
89
100
|
end
|
90
101
|
|
91
|
-
def initialize
|
92
|
-
@
|
102
|
+
def initialize
|
103
|
+
@setups = []
|
93
104
|
@handlers = {}
|
94
105
|
end
|
95
106
|
|
96
|
-
def
|
97
|
-
|
107
|
+
def mkplugin
|
108
|
+
Plugins.new self.class::TYPE, @setups, @handlers
|
98
109
|
end
|
99
110
|
|
100
111
|
private
|
101
112
|
|
113
|
+
HANDLER = Handler
|
114
|
+
|
102
115
|
def add_handler qualified_name, name, type = nil, sync = nil, **opts, &block
|
103
116
|
name = name.to_s
|
104
117
|
qualified_name ||= name
|
105
|
-
h =
|
118
|
+
h = self.class::HANDLER.new name, type, sync, **opts, &block
|
106
119
|
log :info, "Adding Handler", qualified_name: qualified_name, handler: h.spec
|
107
120
|
@handlers[ qualified_name] = h
|
108
121
|
end
|
109
122
|
|
110
123
|
def add_setup_block &block
|
111
|
-
@
|
124
|
+
@setups.push block
|
112
125
|
end
|
113
126
|
|
114
127
|
end
|
115
128
|
|
116
129
|
class DslPlain < DslBase
|
117
130
|
|
118
|
-
TYPE =
|
131
|
+
TYPE = nil
|
119
132
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
133
|
+
HANDLER = HandlerPlain
|
134
|
+
|
135
|
+
def plain name, **opts, &block
|
136
|
+
add_handler nil, name, **opts, &block
|
124
137
|
end
|
125
138
|
|
126
139
|
end
|
data/lib/neovim/host.rb
CHANGED
@@ -3,29 +3,48 @@
|
|
3
3
|
#
|
4
4
|
|
5
5
|
require "neovim/remote"
|
6
|
+
require "neovim/handler"
|
6
7
|
|
7
8
|
|
8
9
|
module Neovim
|
9
10
|
|
10
|
-
class
|
11
|
+
class Provider < Remote
|
11
12
|
|
12
13
|
class <<self
|
13
14
|
|
14
|
-
def start
|
15
|
-
super ConnectionStdio do |h|
|
15
|
+
def start plugins
|
16
|
+
super plugins, ConnectionStdio do |h|
|
16
17
|
yield h
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
21
|
+
def run plugins
|
22
|
+
$stdin.tty? and raise "This program expects to be called by Neovim. It can't run interactively."
|
23
|
+
start plugins do |h|
|
24
|
+
h.run
|
25
|
+
nil
|
26
|
+
rescue Remote::Disconnected
|
27
|
+
log :fatal, "Disconnected"
|
28
|
+
nil
|
29
|
+
rescue SignalException
|
30
|
+
n = $!.signm
|
31
|
+
log :fatal, "Signal was caught: #{n}"
|
32
|
+
(n =~ /\A(?:SIG)?TERM\z/) ? 0 : 1
|
33
|
+
rescue Exception
|
34
|
+
log_exception :fatal
|
35
|
+
2
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
20
39
|
end
|
21
40
|
|
22
|
-
|
41
|
+
end
|
23
42
|
|
24
|
-
|
43
|
+
class Host < Provider
|
25
44
|
|
26
|
-
def initialize conn
|
27
|
-
super
|
28
|
-
DslPlain.open
|
45
|
+
def initialize plugins, conn
|
46
|
+
super plugins, conn
|
47
|
+
@plugins[ :base] = DslPlain.open do |dsl|
|
29
48
|
dsl.plain "poll" do
|
30
49
|
start
|
31
50
|
@plugins.each_value { |p| p.setup @conn.client }
|
@@ -42,45 +61,6 @@ module Neovim
|
|
42
61
|
end
|
43
62
|
end
|
44
63
|
|
45
|
-
def client_name
|
46
|
-
types = @plugins.map { |_,p| p.type if p.type != BASE }
|
47
|
-
types.uniq!
|
48
|
-
types.compact!
|
49
|
-
name = types.join "-"
|
50
|
-
log :info, "Client Name", name: name
|
51
|
-
"ruby-#{name}-host"
|
52
|
-
end
|
53
|
-
|
54
|
-
def client_methods
|
55
|
-
r = {}
|
56
|
-
@plugins[ BASE].options { |name,opts| r[ name] = opts }
|
57
|
-
r
|
58
|
-
end
|
59
|
-
|
60
|
-
|
61
|
-
class <<self
|
62
|
-
|
63
|
-
def run
|
64
|
-
$stdin.tty? and raise "This program expects to be called by Neovim. It can't run interactively."
|
65
|
-
Host.start do |h|
|
66
|
-
yield h
|
67
|
-
h.run
|
68
|
-
nil
|
69
|
-
rescue Messager::Disconnected
|
70
|
-
log :fatal, "Disconnected"
|
71
|
-
nil
|
72
|
-
rescue SignalException
|
73
|
-
n = $!.signm
|
74
|
-
log :fatal, "Signal was caught: #{n}"
|
75
|
-
(n =~ /\A(?:SIG)?TERM\z/) ? 0 : 1
|
76
|
-
rescue Exception
|
77
|
-
log_exception :fatal
|
78
|
-
2
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
64
|
end
|
85
65
|
|
86
66
|
end
|
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.1.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
|
-
homepage: "
|
10
|
-
commit: "
|
9
|
+
homepage: "https://github.com/BertramScharpf/ruby-nvim",
|
10
|
+
commit: "45c1473"
|
data/lib/neovim/logging.rb
CHANGED
@@ -5,6 +5,15 @@
|
|
5
5
|
require "neovim/foreign/supplement"
|
6
6
|
|
7
7
|
|
8
|
+
class Object
|
9
|
+
def class_name
|
10
|
+
obj = self
|
11
|
+
while not obj.is_a? Module do obj = obj.class end
|
12
|
+
obj.plain_name
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
|
8
17
|
module Neovim
|
9
18
|
|
10
19
|
module Logging
|
@@ -111,7 +120,7 @@ module Neovim
|
|
111
120
|
|
112
121
|
class Text < Stream
|
113
122
|
NAME = "file"
|
114
|
-
def initialize file, color: nil, short: nil
|
123
|
+
def initialize file, color: nil, short: nil, maxlen: 256
|
115
124
|
super
|
116
125
|
@color =
|
117
126
|
case color
|
@@ -120,7 +129,7 @@ module Neovim
|
|
120
129
|
when Integer then true
|
121
130
|
else @file.tty?
|
122
131
|
end
|
123
|
-
@short = short
|
132
|
+
@short, @maxlen = short, maxlen
|
124
133
|
end
|
125
134
|
COLORS = %w(33 32 34;1 4 31;1 35;1 36)
|
126
135
|
def put **fields
|
@@ -131,8 +140,8 @@ module Neovim
|
|
131
140
|
(fields.delete :caller).to_s[ %r([^/]+:\d+)],
|
132
141
|
(fields.delete :level),
|
133
142
|
(fields.delete :message).inspect,
|
134
|
-
(
|
135
|
-
((fields.map { |k,v| "#{k}:#{v}" }.join " ").axe
|
143
|
+
(fields.delete :sender).class_name,
|
144
|
+
((fields.map { |k,v| "#{k}:#{v}" }.join " ").axe @maxlen),
|
136
145
|
]
|
137
146
|
if @color then
|
138
147
|
l = l.zip COLORS
|
@@ -216,16 +225,16 @@ module Neovim
|
|
216
225
|
|
217
226
|
def log level, message, **kwargs
|
218
227
|
Logging.put level, message,
|
219
|
-
|
228
|
+
sender: self, caller: (caller 1, 1).first,
|
220
229
|
**kwargs
|
221
230
|
end
|
222
231
|
|
223
232
|
def log_exception level
|
224
233
|
Logging.put level, "Exception: #$!",
|
225
|
-
|
234
|
+
sender: self, caller: (caller 1, 1).first,
|
226
235
|
exception: $!.class
|
227
236
|
$@.each { |b|
|
228
|
-
Logging.put :debug3, "Backtrace", line: b
|
237
|
+
Logging.put :debug3, "Backtrace", sender: self, line: b
|
229
238
|
}
|
230
239
|
nil
|
231
240
|
end
|