Skip to content

Commit a8686aa

Browse files
author
Oliver Caldwell
committed
Fix updating virtual text while not moving the cursor
1 parent f05787a commit a8686aa

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

dev/clojure/src/dev/sandbox.cljc

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
"Hello, World!
1313
This is a function."
1414
[a b]
15-
#dbg (+ a b))
15+
(+ a b))
1616

1717
(add 1 2)
1818

19+
(rand-int 10)
20+
1921
#{:a :b :c}
2022
#?(:clj :hi-clojure :cljs :hi-cljs)
2123
#(+ 1 %)

fnl/conjure/inline.fnl

+8-7
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,20 @@
1010
(s:gsub "%s+" " ")
1111
""))
1212

13+
(defn clear [opts]
14+
"Clear all (Conjure related) virtual text for opts.buf, defaults to 0 which
15+
is the current buffer."
16+
(pcall
17+
(fn []
18+
(nvim.buf_clear_namespace (a.get opts :buf 0) ns-id 0 -1))))
19+
1320
(defn display [opts]
1421
"Display virtual text for opts.buf on opts.line containing opts.text."
1522
(local hl-group (config.get-in [:eval :inline :highlight]))
1623
(pcall
1724
(fn []
25+
(clear)
1826
(nvim.buf_set_virtual_text
1927
(a.get opts :buf 0) ns-id opts.line
2028
[[(sanitise-text opts.text) hl-group]]
2129
{}))))
22-
23-
(defn clear [opts]
24-
"Clear all (Conjure related) virtual text for opts.buf, defaults to 0 which
25-
is the current buffer."
26-
(pcall
27-
(fn []
28-
(nvim.buf_clear_namespace (a.get opts :buf 0) ns-id 0 -1))))

lua/conjure/inline.lua

+8-7
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,20 @@ local function sanitise_text(s)
2525
end
2626
end
2727
_2amodule_2a["sanitise-text"] = sanitise_text
28-
local function display(opts)
29-
local hl_group = config["get-in"]({"eval", "inline", "highlight"})
28+
local function clear(opts)
3029
local function _2_()
31-
return nvim.buf_set_virtual_text(a.get(opts, "buf", 0), ns_id, opts.line, {{sanitise_text(opts.text), hl_group}}, {})
30+
return nvim.buf_clear_namespace(a.get(opts, "buf", 0), ns_id, 0, -1)
3231
end
3332
return pcall(_2_)
3433
end
35-
_2amodule_2a["display"] = display
36-
local function clear(opts)
34+
_2amodule_2a["clear"] = clear
35+
local function display(opts)
36+
local hl_group = config["get-in"]({"eval", "inline", "highlight"})
3737
local function _3_()
38-
return nvim.buf_clear_namespace(a.get(opts, "buf", 0), ns_id, 0, -1)
38+
clear()
39+
return nvim.buf_set_virtual_text(a.get(opts, "buf", 0), ns_id, opts.line, {{sanitise_text(opts.text), hl_group}}, {})
3940
end
4041
return pcall(_3_)
4142
end
42-
_2amodule_2a["clear"] = clear
43+
_2amodule_2a["display"] = display
4344
return _2amodule_2a

0 commit comments

Comments
 (0)