From ffe90fac32122f401429b14d383137bd92a685d0 Mon Sep 17 00:00:00 2001 From: James Trew <66286082+jamestrew@users.noreply.github.com> Date: Thu, 28 Sep 2023 21:42:03 -0400 Subject: [PATCH] feat(current_buffer_fuzzy_find): `results_ts_highlight` option (#2722) * feat(current_buffer_fuzzy_find): `results_ts_highlight` option adds new option to the `current_buffer_fuzzy_find` picker `results_ts_highlight` to enable/disable treesitter highlight for result entries (default: true) closes #2720 * [docgen] Update doc/telescope.txt skip-checks: true --------- Co-authored-by: Github Actions --- doc/telescope.txt | 13 ++++++++++--- lua/telescope/builtin/__files.lua | 3 ++- lua/telescope/builtin/init.lua | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/doc/telescope.txt b/doc/telescope.txt index a1872a0..24b1c1f 100644 --- a/doc/telescope.txt +++ b/doc/telescope.txt @@ -936,9 +936,11 @@ builtin.current_buffer_fuzzy_find({opts}) *telescope.builtin.current_buffer_fuzz {opts} (table) options to pass to the picker Options: ~ - {skip_empty_lines} (boolean) if true we don't display empty lines - (default: false) - {file_encoding} (string) file encoding for the previewer + {skip_empty_lines} (boolean) if true we don't display empty lines + (default: false) + {results_ts_highlight} (boolean) highlight result entries with + treesitter (default: true) + {file_encoding} (string) file encoding for the previewer builtin.tags({opts}) *telescope.builtin.tags()* @@ -3020,6 +3022,11 @@ actions.git_switch_branch({prompt_bufnr}) *telescope.actions.git_switch_branch() {prompt_bufnr} (number) The prompt bufnr +actions.git_rename_branch() *telescope.actions.git_rename_branch()* + Action to rename selected git branch + + + actions.git_track_branch({prompt_bufnr}) *telescope.actions.git_track_branch()* Tell git to track the currently selected remote branch in Telescope diff --git a/lua/telescope/builtin/__files.lua b/lua/telescope/builtin/__files.lua index 66c8583..fc91fee 100644 --- a/lua/telescope/builtin/__files.lua +++ b/lua/telescope/builtin/__files.lua @@ -480,8 +480,9 @@ files.current_buffer_fuzzy_find = function(opts) }) end + opts.results_ts_highlight = vim.F.if_nil(opts.results_ts_highlight, true) local lang = vim.treesitter.language.get_lang(filetype) - if lang and utils.has_ts_parser(lang) then + if opts.results_ts_highlight and lang and utils.has_ts_parser(lang) then local parser = vim.treesitter.get_parser(opts.bufnr, lang) local query = vim.treesitter.query.get(lang, "highlights") local root = parser:parse()[1]:root() diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua index 4e5d72e..4bff017 100644 --- a/lua/telescope/builtin/init.lua +++ b/lua/telescope/builtin/init.lua @@ -103,6 +103,7 @@ builtin.treesitter = require_on_exported_call("telescope.builtin.__files").trees --- Live fuzzy search inside of the currently open buffer ---@param opts table: options to pass to the picker ---@field skip_empty_lines boolean: if true we don't display empty lines (default: false) +---@field results_ts_highlight boolean: highlight result entries with treesitter (default: true) ---@field file_encoding string: file encoding for the previewer builtin.current_buffer_fuzzy_find = require_on_exported_call("telescope.builtin.__files").current_buffer_fuzzy_find