From 05f4d6f0a9ec1aa35816c34c52b6f8578511b434 Mon Sep 17 00:00:00 2001 From: Max Jendruk Date: Thu, 23 May 2024 03:50:14 +0200 Subject: [PATCH] feat(builtin.treesitter): add `symbol_width` opt (#3105) * Add options to customize length of symbols and line numbers for gen_from_treesitter * Revert adding symbol_type_width option * Add docs and type hint --- doc/telescope.txt | 2 ++ lua/telescope/builtin/init.lua | 1 + lua/telescope/make_entry.lua | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/telescope.txt b/doc/telescope.txt index 8217b9b..f63162d 100644 --- a/doc/telescope.txt +++ b/doc/telescope.txt @@ -970,6 +970,8 @@ builtin.treesitter() *telescope.builtin.treesitter()* {bufnr} (number) specify the buffer number where treesitter should run. (default: current buffer) + {symbol_width} (number) defines the width of the symbol + section (default: 25) {symbols} (string|table) filter results by symbol kind(s) {ignore_symbols} (string|table) list of symbols to ignore {symbol_highlights} (table) string -> string. Matches symbol diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua index 355a79f..d46ff30 100644 --- a/lua/telescope/builtin/init.lua +++ b/lua/telescope/builtin/init.lua @@ -94,6 +94,7 @@ builtin.fd = builtin.find_files --- - ``: show autocompletion menu to prefilter your query by kind of ts node you want to see (i.e. `:var:`) ---@field show_line boolean: if true, shows the row:column that the result is found at (default: true) ---@field bufnr number: specify the buffer number where treesitter should run. (default: current buffer) +---@field symbol_width number: defines the width of the symbol section (default: 25) ---@field symbols string|table: filter results by symbol kind(s) ---@field ignore_symbols string|table: list of symbols to ignore ---@field symbol_highlights table: string -> string. Matches symbol with hl_group diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index 033524c..cf0a1a4 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -657,7 +657,7 @@ function make_entry.gen_from_treesitter(opts) local bufnr = opts.bufnr or vim.api.nvim_get_current_buf() local display_items = { - { width = 25 }, + { width = opts.symbol_width or 25 }, { width = 10 }, { remaining = true }, }