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 <actions@github>
This commit is contained in:
James Trew
2023-09-28 21:42:03 -04:00
committed by GitHub
parent 84d53dfdbe
commit ffe90fac32
3 changed files with 13 additions and 4 deletions

View File

@@ -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()