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

bug: Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:107: no parser for 'fstab' language, see :help treesitter-parsers #101

Closed
1 task done
xfzv opened this issue Jul 27, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@xfzv
Copy link

xfzv commented Jul 27, 2024

Neovim version (nvim -v)

NVIM v0.11.0-dev-504+gaa853f362-dirty
Build type: Release
LuaJIT 2.1.1716656478

Operating system

Linux

Terminal emulator / GUI

kitty 0.35.2

Describe the bug

I have a markdown file with a code block containing # vim: ft=fstab (which is a valid file type). This triggers the following error when opening said markdown file with markdown.nvim enabled:

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:107: no parser for 'fstab' language, see :help treesitter-parsers
stack traceback:
	[C]: in function 'error'
	/usr/share/nvim/runtime/lua/vim/treesitter/language.lua:107: in function 'add'
	/usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:111: in function 'new'
	/usr/share/nvim/runtime/lua/vim/treesitter.lua:41: in function '_create_parser'
	/usr/share/nvim/runtime/lua/vim/treesitter.lua:108: in function 'get_parser'
	...share/nvim/lazy/markdown.nvim/lua/render-markdown/ui.lua:119: in function 'parse_buffer'
	...share/nvim/lazy/markdown.nvim/lua/render-markdown/ui.lua:74: in function 'render'
	...share/nvim/lazy/markdown.nvim/lua/render-markdown/ui.lua:39: in function <...share/nvim/lazy/markdown.nvim/lua/render-markdown/ui.lua:33>

To reproduce:

  1. Add # vim: ft=fstab (also occurs with # vim: ft=zzz for example) in a code block of a new markdown file
  2. Open the markdown file with markdown.nvim enabled
  3. The error is triggered

Expected behavior

No error.

Healthcheck output

==============================================================================
render-markdown: require("render-markdown.health").check()

markdown.nvim [neovim version] ~
- OK Version >= 0.10

markdown.nvim [configuration] ~
- OK valid

markdown.nvim [nvim-treesitter] ~
- OK installed
- OK markdown: parser installed
- OK markdown: highlight enabled
- OK markdown_inline: parser installed
- OK markdown_inline: highlight enabled
- WARNING latex: parser not installed
  - ADVICE:
    - Disable LaTeX support to avoid this warning by setting { latex = { enabled = false } }

markdown.nvim [executables] ~
- WARNING latex2text: not installed
  - ADVICE:
    - Disable LaTeX support to avoid this warning by setting { latex = { enabled = false } }

markdown.nvim [conflicts] ~
- OK headlines: not installed
- OK obsidian: not installed

Plugin configuration

return {
  "MeanderingProgrammer/markdown.nvim",
  ft = "markdown",
  opts = {},
}

Confirmations

  • I have provided markdown text for any screenshots used in my description & understand that my issue will be closed if I have not

Additional information

No response

@xfzv xfzv added the bug Something isn't working label Jul 27, 2024
MeanderingProgrammer added a commit that referenced this issue Jul 27, 2024
# Details

Issue: #101

While we still won't be able to parse the file in these error cases it will
at least prevent error messages from being propagated up to the user.
@MeanderingProgrammer
Copy link
Owner

MeanderingProgrammer commented Jul 27, 2024

Since the filetype gets overridden to fstab and there is no parser defined by treesitter for this filetype I wouldn't expect it to work. This type of setup creates 2 FileType events, the first one for markdown causes this plugin to attempt to parse the file. However when we later attempt to get the parser, treesitter only picks up the fstab filetype and fails.

I have pushed a fix to avoid errors in these cases: ddb4547.

So at least it won't break but it also won't do any rendering, effectively becomes a no-op. If you want this plugin to render fstab as it would markdown you'll need to add the following somewhere in your config:

vim.treesitter.language.register('markdown', 'fstab')

Which tells treesitter to parse fstab files as if they were markdown. Similar for all other filetypes you want to treat as markdown. This will change the highlighting behavior for all of these filetypes.

@xfzv
Copy link
Author

xfzv commented Jul 27, 2024

Thank you for the detailed explanation!

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

No branches or pull requests

2 participants