Skip to content

Commit c956454

Browse files
authored
Small fixes & merge leftover cleanups (#76)
* Make indirection layer smaller * Cleanup previously re-introduced duplicated fn * Force redraw for virtualtext
1 parent a873b36 commit c956454

File tree

5 files changed

+8
-40
lines changed

5 files changed

+8
-40
lines changed

lua/acid/core.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ local utils = require("acid.utils")
88
local log = require("acid.log")
99

1010
local core = {
11-
indirection = setmetatable({}, utils.LRU(10))
11+
indirection = setmetatable({}, utils.LRU(5))
1212
}
1313

1414
--- Forward messages to the nrepl and registers the handler.

lua/acid/features.lua

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -59,40 +59,6 @@ features.eval_print = function(code, ns)
5959
))
6060
end
6161

62-
--- Evaluate the current form or the given motion.
63-
-- The result will replace the current form
64-
-- @tparam[opt] string mode motion mode
65-
-- @tparam[opt] string ns Namespace to be used when evaluating the code.
66-
-- Defaults to current file's ns.
67-
features.eval_inplace = function(mode, ns)
68-
local payload = {}
69-
local coord, form
70-
if mode == nil then
71-
form, coord = forms.form_under_cursor()
72-
payload.code = table.concat(form, "\n")
73-
elseif mode == "symbol" then
74-
payload.code, coord = forms.symbol_under_cursor()
75-
elseif mode == "top" then
76-
form, coord = forms.form_under_cursor(true)
77-
payload.code = table.concat(form, "\n")
78-
else
79-
lines, coord = forms.form_from_motion(mode)
80-
payload.code = table.concat(lines, "\n")
81-
end
82-
ns = ns or vim.api.nvim_call_function("AcidGetNs", {})
83-
if ns ~= nil or ns ~= "" then
84-
payload.ns = ns
85-
end
86-
acid.run(ops.eval(payload):with_handler(middlewares
87-
.refactor(utils.merge(coord, {accessor = function(dt)
88-
if dt.value ~= nil then
89-
return dt.value
90-
else
91-
return dt.out
92-
end
93-
end}))))
94-
end
95-
9662
--- Evaluate the current form or the given motion.
9763
-- The result will be shown on a virtualtext next to the current form
9864
-- and also stored on the clipboard.
@@ -132,6 +98,10 @@ features.eval_expr = function(mode, replace, ns)
13298
end}))
13399
else
134100
midlws = middlewares
101+
.print{}
102+
.clipboard{}
103+
.virtualtext(coord)
104+
end
135105

136106
.print{}
137107
.clipboard{}

lua/acid/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ end
5454
--- Setup admin nrepl session
5555
-- This nrepl session should be used by plugins to deal with clojure code
5656
-- without injecting things in the user nrepl session
57-
-- or for things that clojure could deal with better while not having a
57+
-- or for things that clojure could deal with better while not having a
5858
-- nrepl session to use.
5959
acid.admin_session_start = function()
6060
if admin_session_path == nil then

lua/acid/middlewares/virtualtext.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ virtualtext.toggle = function()
2525
end
2626

2727
vim.api.nvim_buf_set_virtual_text(cb, virtualtext.ns, ln, possible_vts[current_ix], {})
28+
vim.api.nvim__buf_redraw_range(cb, ln, ln)
2829
virtualtext.cache_index[key] = current_ix
2930

3031
end
@@ -66,6 +67,7 @@ virtualtext.middleware = function(config)
6667

6768
-- TODO split_lines
6869
vim.api.nvim_buf_set_virtual_text(cb, virtualtext.ns, ln, vt, {})
70+
vim.api.nvim__buf_redraw_range(cb, ln, ln)
6971

7072
end
7173
return middleware(data)

plugin/acid.vim

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ function! AcidEvalInplace(mode)
6767
exec 'lua require("acid.features").eval_expr("'.a:mode.'", true)'
6868
endfunction
6969

70-
function! AcidEvalInplace(mode)
71-
exec 'lua require("acid.features").eval_inplace("'.a:mode.'")'
72-
endfunction
73-
7470
function! AcidSendEval(handler)
7571
let ns = AcidGetNs()
7672
if ns == ""

0 commit comments

Comments
 (0)