truncate filepath

neovim_0_5
ray-x 3 years ago
parent 7e8c3376f4
commit b61e280400

@ -71,12 +71,17 @@ local function goto_adjent_reference(opt)
vim.api.nvim_win_set_cursor(0, {next.start.line + 1, next.start.character})
return next
end
-- autocmd ColorScheme *
-- \ hi default LspReferenceRead cterm=bold gui=Bold ctermbg=yellow guifg=yellow guibg=purple4 |
-- \ hi default LspReferenceText cterm=bold gui=Bold ctermbg=red guifg=SlateBlue guibg=MidnightBlue |
-- \ hi default LspReferenceWrite cterm=bold gui=Bold,Italic ctermbg=red guifg=DarkSlateBlue guibg=MistyRose
local function documentHighlight()
api.nvim_exec([[
hi default LspReferenceRead cterm=bold gui=Bold ctermbg=yellow guifg=yellow guibg=purple4
hi default LspReferenceText cterm=bold gui=Bold ctermbg=red guibg=gray27
hi default LspReferenceWrite cterm=bold gui=Bold,Italic ctermbg=red guifg=DarkSlateBlue guibg=MistyRose
autocmd ColorScheme * |
hi default LspReferenceRead cterm=bold gui=Bold ctermbg=yellow guifg=yellow guibg=purple4 |
hi default LspReferenceText cterm=bold gui=Bold ctermbg=red guifg=SlateBlue guibg=MidnightBlue |
hi default LspReferenceWrite cterm=bold gui=Bold,Italic ctermbg=red guifg=DarkSlateBlue guibg=MistyRose
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()

@ -52,8 +52,8 @@ function M.prepare_for_render(items, opts)
icon = devicons.get_icon(fn, ext) or icon
end
local call_by_presented = false
opts.width = opts.width or 100
local width = 100
opts.width = opts.width or width
local win_width = opts.width - 2 -- buf
for i = 1, #items do
@ -73,17 +73,16 @@ function M.prepare_for_render(items, opts)
end
-- trace(items[i], items[i].filename, last_summary_idx, display_items[last_summary_idx].filename)
if items[i].filename == display_items[last_summary_idx].filename then
space, trim = get_pads(opts.width,
icon .. ' ' .. display_items[last_summary_idx].display_filename,
lspapi_display .. ' 12')
if trim then
display_items[last_summary_idx].display_filename = string.sub(
display_items[last_summary_idx]
.display_filename, 1,
opts.width - 20)
display_items[last_summary_idx].display_filename =
display_items[last_summary_idx].display_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)
display_items[last_summary_idx].display_filename = fn1 .. "" .. fn2
space = ' '
-- log("trim", fn1, fn2)
end
display_items[last_summary_idx].text = string.format("%s %s%s%s %i", icon,
display_items[last_summary_idx]
@ -97,8 +96,12 @@ function M.prepare_for_render(items, opts)
space, trim = get_pads(opts.width, icon .. ' ' .. item.display_filename,
lspapi_display .. ' 12')
if trim then
item.text = string.sub(item.text, 1, opts.width - 20) .. ""
if trim and opts.width > 52 and item.display_filename > opts.width - 20 then
item.display_filename = string.sub(item.display_filename, 1, opts.width - 52) .. ""
.. string.sub(item.display_filename,
#item.display_filename - 10,
#item.display_filename)
space = ' '
end
item.text = string.format("%s %s%s%s 1", icon, item.display_filename, space, lspapi_display)

@ -79,7 +79,7 @@ function M.find_definition(range, bufnr)
local definition = locals.find_definition(node_at_point, bufnr)
if definition ~= node_at_point then
log("def found:", definition:range())
log("def found:", definition:range(), definition:type())
local r, c = definition:range()
return {start = {line = r, character = c}}
else
@ -163,8 +163,8 @@ local function get_scope(type, source)
end
if type == "var" and next ~= nil then
if next:type() == "function" or next:type() == "arrow_function" or next:type() ==
"function_definition" then
if next:type() == "function" or next:type() == "arrow_function" or next:type()
== "function_definition" then
trace(current:type(), current:range())
return next, true
elseif parent:type() == 'function_declaration' then
@ -281,8 +281,8 @@ local function get_all_nodes(bufnr, filter, summary)
for i = 1, n do
local index = n + 1 - i
local parent_def = parents[index]
if ts_utils.is_parent(parent_def.node, def.node) or
(containers[parent_def.type] and ts_utils.is_parent(parent_def.node:parent(), def.node)) then
if ts_utils.is_parent(parent_def.node, def.node)
or (containers[parent_def.type] and ts_utils.is_parent(parent_def.node:parent(), def.node)) then
break
else
parents[index] = nil
@ -316,8 +316,8 @@ local function get_all_nodes(bufnr, filter, summary)
if is_func then
-- hack for lua and maybe other language aswell
local parent = tsdata:parent()
if parent ~= nil and parent:type() == 'function_name' or parent:type() ==
'function_name_field' then
if parent ~= nil and parent:type() == 'function_name' or parent:type()
== 'function_name_field' then
item.node_text = ts_utils.get_node_text(parent, bufnr)[1]
log(parent:type(), item.node_text)
end

Loading…
Cancel
Save