From 927c464b70731249fc6c5c314b633cec03491985 Mon Sep 17 00:00:00 2001 From: ray-x Date: Mon, 29 Aug 2022 18:20:27 +1000 Subject: [PATCH] optimize for go and ts_contex --- lua/navigator/render.lua | 5 +++-- lua/navigator/treesitter.lua | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lua/navigator/render.lua b/lua/navigator/render.lua index 8c96d16..37f810d 100644 --- a/lua/navigator/render.lua +++ b/lua/navigator/render.lua @@ -170,10 +170,11 @@ function M.prepare_for_render(items, opts) -- let check if there are unmatched "/' end if #space + #item.text + #ts_report >= win_width then - if #item.text + #ts_report > win_width then - trace('exceeding', #item.text, #ts_report, win_width) + if #item.text + #ts_report >= win_width then space = ' ' local len = math.max(win_width - #item.text - 4, 16) + + trace('exceeding', #item.text, #ts_report, win_width, len) ts_report = ts_report:sub(1, len) else local remain = win_width - #item.text - #ts_report diff --git a/lua/navigator/treesitter.lua b/lua/navigator/treesitter.lua index bff5561..3de1c86 100644 --- a/lua/navigator/treesitter.lua +++ b/lua/navigator/treesitter.lua @@ -148,7 +148,10 @@ local transform_line = function(line) line = line:gsub("function", "") line = line:gsub("func%w*%s+", "") if _NgConfigValues.treesitter_analysis_condense then - line = line:gsub("%([%a,%s]+%)", "()") + line = line:gsub("%([%a%.,%s%[%]%*]+%)", "()") + -- this is for multi return + line = line:gsub("%([%a%.,%s%[%]%*]+%)", "()") + line = line:gsub("%(%)%s*%(%)", "()") end return line end @@ -158,9 +161,6 @@ function M.ref_context(opts) return end local options = opts or {} - -- if type(opts) == "number" then - -- options = { indicator_size = opts } - -- end local bufnr = options.bufnr or 0 local pos = options.pos