Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add two options for winbar: show_nodes, and max_nodes #1386

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lua/lspsaga/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ local default_config = {
folder_level = 1,
color_mode = true,
dely = 300,
show_nodes = true,
max_nodes = nil,
},
outline = {
win_position = 'right',
Expand Down
9 changes: 7 additions & 2 deletions lua/lspsaga/symbol/winbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -149,8 +153,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)
Expand Down
Loading