diff --git a/lua/navigator.lua b/lua/navigator.lua index 0caafa9..1708cc4 100755 --- a/lua/navigator.lua +++ b/lua/navigator.lua @@ -33,6 +33,7 @@ _NgConfigValues = { treesitter_analysis = true, -- treesitter variable context treesitter_analysis_max_num = 100, -- how many items to run treesitter analysis treesitter_analysis_condense = true, -- short format of function + treesitter_analysis_depth = 3, -- max depth transparency = 50, -- 0 ~ 100 blur the main window, 100: fully transparent, 0: opaque, set to nil to disable it lsp_signature_help = true, -- if you would like to hook ray-x/lsp_signature plugin in navigator -- setup here. if it is nil, navigator will not init signature help diff --git a/lua/navigator/treesitter.lua b/lua/navigator/treesitter.lua index 7342e34..ea59634 100644 --- a/lua/navigator/treesitter.lua +++ b/lua/navigator/treesitter.lua @@ -188,13 +188,11 @@ function M.ref_context(opts) table.insert(lines, 1, line) end expr = expr:parent() + if #line > _NgConfigValues.treesitter_analysis_depth then + break + end end - table.remove(lines, #lines) - - if #lines < 1 then - return "" - end local text = table.concat(lines, separator) local text_len = #text if text_len > indicator_size then