Skip to content

Commit

Permalink
Fix updating virtual text while not moving the cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Caldwell committed Aug 31, 2022
1 parent f05787a commit a8686aa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
4 changes: 3 additions & 1 deletion dev/clojure/src/dev/sandbox.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
"Hello, World!
This is a function."
[a b]
#dbg (+ a b))
(+ a b))

(add 1 2)

(rand-int 10)

#{:a :b :c}
#?(:clj :hi-clojure :cljs :hi-cljs)
#(+ 1 %)
Expand Down
15 changes: 8 additions & 7 deletions fnl/conjure/inline.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@
(s:gsub "%s+" " ")
""))

(defn clear [opts]
"Clear all (Conjure related) virtual text for opts.buf, defaults to 0 which
is the current buffer."
(pcall
(fn []
(nvim.buf_clear_namespace (a.get opts :buf 0) ns-id 0 -1))))

(defn display [opts]
"Display virtual text for opts.buf on opts.line containing opts.text."
(local hl-group (config.get-in [:eval :inline :highlight]))
(pcall
(fn []
(clear)
(nvim.buf_set_virtual_text
(a.get opts :buf 0) ns-id opts.line
[[(sanitise-text opts.text) hl-group]]
{}))))

(defn clear [opts]
"Clear all (Conjure related) virtual text for opts.buf, defaults to 0 which
is the current buffer."
(pcall
(fn []
(nvim.buf_clear_namespace (a.get opts :buf 0) ns-id 0 -1))))
15 changes: 8 additions & 7 deletions lua/conjure/inline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ local function sanitise_text(s)
end
end
_2amodule_2a["sanitise-text"] = sanitise_text
local function display(opts)
local hl_group = config["get-in"]({"eval", "inline", "highlight"})
local function clear(opts)
local function _2_()
return nvim.buf_set_virtual_text(a.get(opts, "buf", 0), ns_id, opts.line, {{sanitise_text(opts.text), hl_group}}, {})
return nvim.buf_clear_namespace(a.get(opts, "buf", 0), ns_id, 0, -1)
end
return pcall(_2_)
end
_2amodule_2a["display"] = display
local function clear(opts)
_2amodule_2a["clear"] = clear
local function display(opts)
local hl_group = config["get-in"]({"eval", "inline", "highlight"})
local function _3_()
return nvim.buf_clear_namespace(a.get(opts, "buf", 0), ns_id, 0, -1)
clear()
return nvim.buf_set_virtual_text(a.get(opts, "buf", 0), ns_id, opts.line, {{sanitise_text(opts.text), hl_group}}, {})
end
return pcall(_3_)
end
_2amodule_2a["clear"] = clear
_2amodule_2a["display"] = display
return _2amodule_2a

0 comments on commit a8686aa

Please sign in to comment.