Clean up space pad for reference listview

pull/15/head
ray-x 3 years ago
parent 09667c32a9
commit 4ad8fa3e95

@ -200,7 +200,7 @@ function M.new_list_view(opts)
end
local l = idx(data, pos) -- bug it not work with fzy filter
log(data)
trace(data)
trace("on move", pos, l)
trace("on move", pos, l.text or l, l.uri, l.filename)
-- todo fix

@ -27,15 +27,15 @@ local function get_pads(win_width, text, postfix)
local space
local i = math.floor((sz + 10) / 10)
i = i * 10 - #text
if i + #text + #postfix + 2 < win_width then
-- push to left twice
log(i, #text, #postfix, postfix, text, win_width)
if i + #text + #postfix < win_width then
local rem = win_width - i - #text - #postfix
rem = (rem - 2) / 10
rem = math.floor(rem / 10)
if rem > 0 then
i = i + rem * 10
rem = (i + #text) % 10
-- rem = (i + #text) % 10
-- i = i - rem
log(i)
end
end
@ -67,7 +67,7 @@ function M.prepare_for_render(items, opts)
local call_by_presented = false
local width = 100
opts.width = opts.width or width
local win_width = opts.width - 2 -- buf
local win_width = opts.width -- buf
for i = 1, #items do
if items[i].call_by and #items[i].call_by > 0 then
@ -76,23 +76,25 @@ function M.prepare_for_render(items, opts)
end
for i = 1, #items do
local space = ''
local trim = false
local space
local trim
local lspapi_display = lspapi
items[i].symbol_name = items[i].symbol_name or "" -- some LSP API does not have range for this
local fn = display_items[last_summary_idx].filename
local dfn = items[i].display_filename
if last_summary_idx == 1 then
lspapi_display = items[i].symbol_name .. ' ' .. lspapi_display
trace(items[1], lspapi_display)
trace(items[1], lspapi_display, display_items[last_summary_idx])
end
-- trace(items[i], items[i].filename, last_summary_idx, display_items[last_summary_idx].filename)
-- TODO refact display_filename generate part
local fn = display_items[last_summary_idx].filename
if items[i].filename == fn then
space, trim = get_pads(opts.width, icon .. ' ' .. fn, lspapi_display .. ' 12')
if trim and opts.width > 50 and #fn > opts.width - 20 then
local fn1 = string.sub(fn, 1, opts.width - 50)
local fn2 = string.sub(fn, #fn - 10, #fn)
space, trim = get_pads(opts.width, icon .. ' ' .. dfn, lspapi_display .. ' 12')
if trim and opts.width > 50 and #dfn > opts.width - 20 then
local fn1 = string.sub(dfn, 1, opts.width - 50)
local fn2 = string.sub(dfn, #dfn - 10, #dfn)
display_items[last_summary_idx].display_filename = fn1 .. "" .. fn2
space = ' '
-- log("trim", fn1, fn2)

@ -323,7 +323,7 @@ local function get_all_nodes(bufnr, filter, summary)
end
end
log(item.node_text, item.kind, item.type)
trace(item.node_text, item.kind, item.type)
if scope ~= nil then
-- it is strange..
if not is_func and summary then
@ -336,7 +336,10 @@ local function get_all_nodes(bufnr, filter, summary)
table.insert(all_nodes, item)
end
log(item.type, tsdata:type(), item.node_text, item.kind, item.node_text, item.node_scope)
if item.node_scope then
log(item.type, tsdata:type(), item.node_text, item.kind, item.node_text, "range",
item.node_scope.start.line, item.node_scope['end'].line)
end
goto continue
end

Loading…
Cancel
Save