Update UI for code lens

neovim_0_5
ray-x 3 years ago
parent 58ac955777
commit a200c1db2b

@ -97,15 +97,17 @@ function M.run_action()
end
local width = 40
local data = {"  Auto Fix <C-o> Apply <C-e> Exit"}
local data = {"  CodeLens Action <C-o> Apply <C-e> Exit"}
local idx = 1
for i, lens in pairs(lenses) do
if lens.range.start.line == (line - 1) then
local title = lens.command.title:gsub("\r\n", "\\r\\n")
title = title:gsub("\n", "\\n")
title = string.format("[%d] %s", i, title)
title = string.format("[%d] %s", idx, title)
table.insert(data, title)
lenses[i].display_title = title
width = math.max(width, #lens.command.title)
idx = idx + 1
end
end
local apply = require('navigator.lspwrapper').apply_action
@ -122,24 +124,24 @@ function M.run_action()
end
apply(action_chosen)
end
gui.new_list_view {
items = data,
width = width + 4,
loc = "top_center",
relative = "cursor",
rawdata = true,
data = data,
on_confirm = function(pos)
log(pos)
apply_action(pos)
end,
on_move = function(pos)
log(pos)
return pos
end
}
if #data > 0 then
gui.new_list_view {
items = data,
width = width + 4,
loc = "top_center",
relative = "cursor",
rawdata = true,
data = data,
on_confirm = function(pos)
log(pos)
apply_action(pos)
end,
on_move = function(pos)
log(pos)
return pos
end
}
end
end
return M

@ -319,10 +319,7 @@ end
function M.apply_action(action_chosen)
assert(action_chosen ~= nil, "action must not be nil")
if action_chosen == nil then
log("no match for ", action, lenses)
return
end
local bufnr = api.nvim_get_current_buf()
local switch = string.format("silent b %d", bufnr)
if action_chosen.edit or type(action_chosen.command) == "table" then
if action_chosen.edit then

Loading…
Cancel
Save