From 3fab7abf6f653eb92eee74c19ce5e655536ced87 Mon Sep 17 00:00:00 2001 From: Nat Williams Date: Thu, 2 Feb 2023 13:16:44 -0600 Subject: add statusline option to dedupe or not --- lua/nvim-treesitter/statusline.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lua') diff --git a/lua/nvim-treesitter/statusline.lua b/lua/nvim-treesitter/statusline.lua index cd75fcb00..fde7def2b 100644 --- a/lua/nvim-treesitter/statusline.lua +++ b/lua/nvim-treesitter/statusline.lua @@ -21,6 +21,10 @@ function M.statusline(opts) local type_patterns = options.type_patterns or { "class", "function", "method" } local transform_fn = options.transform_fn or transform_line local separator = options.separator or " -> " + local dedupe = options.dedupe + if dedupe == nil then + dedupe = true + end local current_node = ts_utils.get_node_at_cursor() if not current_node then @@ -32,8 +36,10 @@ function M.statusline(opts) while expr do local line = ts_utils._get_line_for_node(expr, type_patterns, transform_fn, bufnr) - if line ~= "" and not vim.tbl_contains(lines, line) then - table.insert(lines, 1, line) + if line ~= "" then + if not dedupe or not vim.tbl_contains(lines, line) then + table.insert(lines, 1, line) + end end expr = expr:parent() end -- cgit v1.2.3-70-g09d2