Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Previewer errors out when there is no treesitter parser for the detected filetype #3314

Closed
ChristianHeinigk opened this issue Oct 2, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@ChristianHeinigk
Copy link

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

NVIM v0.11.0-dev-616+gfd65422b9
Build type: RelWithDebInfo
LuaJIT 2.1.1723675123

Operating system and version

Windows 11 Enterprise

Telescope version / branch / rev

main

checkhealth telescope

==============================================================================
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

  1. echo ' .file "test.cpp"' > test.s
  2. nvim -nu init.lua
  3. :lua require"telescope.builtin".find_files()
  4. Type test.s
  5. 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",
})
@jamestrew
Copy link
Contributor

As mentioned in your PR, this should already be resolved by #3308

@ChristianHeinigk
Copy link
Author

Thanks for the reply! I can confirm, it has been resolved already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants