When previewing a file, which does not have a treesitter parser, on nvim v0.11 an error is thrown. This change always uses pcall to try to add the treesitter parser for the detected filetype. Hence, the success and a message is returned and the previewer can gracefully just display the file's contents without highlighting.
==============================================================================
telescope: require("telescope.health").check()
Checking for required plugins ~
- OK plenary installed.
- OK nvim-treesitter installed.
Checking external dependencies ~
- OK rg: found ripgrep 14.1.0 (rev e50df40a19)
- WARNING fd: not found. Install [sharkdp/fd](https://github.com/sharkdp/fd) for extended capabilities
===== Installed extensions ===== ~
Telescope Extension: `dap` ~
- No healthcheck provided
Telescope Extension: `refactoring` ~
- No healthcheck provided
Steps to reproduce
echo ' .file "test.cpp"' > test.s
nvim -nu init.lua
:lua require"telescope.builtin".find_files()
Type test.s
search for an existing file with a filetype for which no treesitter parser exists, in this case test.s which requires the asm parser
Expected behavior
The preview window shows the contents without any highlighting.
Actual behavior
Error executing vim.schedule lua callback: ...eovim/share/nvim/runtime/lua/vim/treesitter/language.lua:107: no parser for 'asm' language, see :help treesitter-parsers
stack traceback:
[C]: in function 'error'
...eovim/share/nvim/runtime/lua/vim/treesitter/language.lua:107: in function 'has_ts_parser'
...lugins/telescope.nvim/lua/telescope/previewers/utils.lua:173: in function 'ts_highlighter'
...lugins/telescope.nvim/lua/telescope/previewers/utils.lua:154: in function 'highlighter'
...scope.nvim/lua/telescope/previewers/buffer_previewer.lua:233: in function 'fn'
vim/_editor.lua:351: in function <vim/_editor.lua:350>
Minimal config
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs { "config", "data", "state", "cache" } do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then
vim.fn.system {
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
lazypath,
}
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
{
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
config = function()
-- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
require("telescope").setup {}
end,
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
Description
When previewing a file, which does not have a treesitter parser, on nvim v0.11 an error is thrown. This change always uses pcall to try to add the treesitter parser for the detected filetype. Hence, the success and a message is returned and the previewer can gracefully just display the file's contents without highlighting.
Neovim version
Operating system and version
Windows 11 Enterprise
Telescope version / branch / rev
main
checkhealth telescope
Steps to reproduce
echo ' .file "test.cpp"' > test.s
nvim -nu init.lua
:lua require"telescope.builtin".find_files()
test.s
test.s
which requires theasm
parserExpected behavior
The preview window shows the contents without any highlighting.
Actual behavior
Minimal config