From 542294f3d4fb186af68856daa1e61caae9c480f3 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 21 Jan 2024 20:05:08 +0100 Subject: [PATCH 1/2] Add the ability to toggle nodes on/off if you only want to show the filepath. --- lua/lspsaga/init.lua | 2 ++ lua/lspsaga/symbol/winbar.lua | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/lspsaga/init.lua b/lua/lspsaga/init.lua index 93c4b78d1..d935479fe 100644 --- a/lua/lspsaga/init.lua +++ b/lua/lspsaga/init.lua @@ -124,6 +124,8 @@ local default_config = { folder_level = 1, color_mode = true, dely = 300, + show_nodes = true, + max_nodes = nil, }, outline = { win_position = 'right', diff --git a/lua/lspsaga/symbol/winbar.lua b/lua/lspsaga/symbol/winbar.lua index 2714d4a9d..0ad4b5ad4 100644 --- a/lua/lspsaga/symbol/winbar.lua +++ b/lua/lspsaga/symbol/winbar.lua @@ -149,8 +149,9 @@ local function render_symbol_winbar(buf, symbols) local winbar_str = config.show_file and path_in_bar(buf) or '' local winbar_elements = {} - - find_in_node(buf, symbols, current_line - 1, winbar_elements) + if config.show_nodes then + find_in_node(buf, symbols, current_line - 1, winbar_elements) + end local lens, over_idx = 0, 0 local max_width = math.floor(api.nvim_win_get_width(cur_win) * 0.9) From ba5f81d40a656c4efb8711fa52baed7a16edd847 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 21 Jan 2024 20:20:17 +0100 Subject: [PATCH 2/2] Add the ability to set a max limit on the number of nodes that gets added to the winbar. --- lua/lspsaga/symbol/winbar.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/lspsaga/symbol/winbar.lua b/lua/lspsaga/symbol/winbar.lua index 0ad4b5ad4..919648071 100644 --- a/lua/lspsaga/symbol/winbar.lua +++ b/lua/lspsaga/symbol/winbar.lua @@ -118,6 +118,10 @@ end --@private local function find_in_node(buf, tbl, line, elements) + if config.max_nodes and #elements >= config.max_nodes then + return + end + local mid = binary_search(tbl, line) if not mid then return