Skip to content

Commit 99a8993

Browse files
committed
Force eval treesitter
+ Actually display the errors
1 parent a4ed825 commit 99a8993

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

lua/telescope/builtin/__files.lua

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,14 +423,20 @@ files.treesitter = function(opts)
423423
end
424424

425425
local parsers = require "nvim-treesitter.parsers"
426-
if not parsers.has_parser(parsers.get_buf_lang(opts.bufnr)) then
426+
local lang = parsers.get_buf_lang(opts.bufnr)
427+
if not parsers.has_parser(lang) then
427428
utils.notify("builtin.treesitter", {
428429
msg = "No parser for the current buffer",
429430
level = "ERROR",
430431
})
431432
return
432433
end
433434

435+
-- force evaluation, don't wait for it to lazily load
436+
local parser = vim.treesitter.get_parser(opts.bufnr, lang)
437+
---@diagnostic disable-next-line: need-check-nil
438+
parser:parse()
439+
434440
local ts_locals = require "nvim-treesitter.locals"
435441
local results = {}
436442
for _, definition in ipairs(ts_locals.get_definitions(opts.bufnr)) do
@@ -441,16 +447,23 @@ files.treesitter = function(opts)
441447
end
442448
end
443449

444-
results = utils.filter_symbols(results, opts)
445450
if vim.tbl_isempty(results) then
446-
-- error message already printed in `utils.filter_symbols`
451+
utils.notify("builtin.treesitter", {
452+
msg = "Parser provided no results",
453+
level = "ERROR",
454+
})
447455
return
448456
end
449457

458+
results = utils.filter_symbols(results, opts)
459+
450460
if vim.tbl_isempty(results) then
461+
utils.notify("builtin.treesitter", {
462+
msg = "Parser gave results, but we filtered them all away",
463+
level = "ERROR",
464+
})
451465
return
452466
end
453-
454467
pickers
455468
.new(opts, {
456469
prompt_title = "Treesitter Symbols",

0 commit comments

Comments
 (0)