@@ -423,14 +423,20 @@ files.treesitter = function(opts)
423
423
end
424
424
425
425
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
427
428
utils .notify (" builtin.treesitter" , {
428
429
msg = " No parser for the current buffer" ,
429
430
level = " ERROR" ,
430
431
})
431
432
return
432
433
end
433
434
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
+
434
440
local ts_locals = require " nvim-treesitter.locals"
435
441
local results = {}
436
442
for _ , definition in ipairs (ts_locals .get_definitions (opts .bufnr )) do
@@ -441,16 +447,23 @@ files.treesitter = function(opts)
441
447
end
442
448
end
443
449
444
- results = utils .filter_symbols (results , opts )
445
450
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
+ })
447
455
return
448
456
end
449
457
458
+ results = utils .filter_symbols (results , opts )
459
+
450
460
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
+ })
451
465
return
452
466
end
453
-
454
467
pickers
455
468
.new (opts , {
456
469
prompt_title = " Treesitter Symbols" ,
0 commit comments