Skip to content

Error (freezes nvim) when opening file with code block name in different case (e.g. "Python", "JSON", "R"): no such language: R #727

Closed
@milanglacier

Description

@milanglacier

Describe the bug

This is a macOS only bug, I cannot reproduce it in linux.

When opening a markdown file that contains code block with same name with the treesitter parser but have different case (e.g. python vs Python, r vs R, Json vs json), you will get the following error:

stack traceback:
        [C]: in function '_ts_parse_query'
        ...m/0.10.0/share/nvim/runtime/lua/vim/treesitter/query.lua:252: in function 'fn'
        ...ovim/0.10.0/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'fn'
        ...ovim/0.10.0/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'get'
        ...0/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:128: in function 'new'
        ...0/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:511: in function 'add_child'
        ...0/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:395: in function '_add_injections'
        ...0/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:447: in function 'parse'
        ....0/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:397: in function <....0/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:392>
Error in decoration provider treesitter/highlighter.win:
Error executing lua: ...m/0.10.0/share/nvim/runtime/lua/vim/treesitter/query.lua:252: no such language: R

This error is actually the same error as in nvim-treesitter: nvim-treesitter/nvim-treesitter#6642

Steps to reproduce

  1. open the following example org mode file, say : hello.org

  2. Open it in neovim, get billions of errors so that you can't do anything with neovim.

https://pastebin.com/sSLFxXBZ

Expected behavior

  1. nvim should open this file normally.

Emacs functionality

No response

Minimal init.lua

local plugins = {
	orgmode = "https://github.com/nvim-orgmode/orgmode",
	ts = "https://github.com/nvim-treesitter/nvim-treesitter",
}

for name, url in pairs(plugins) do
	local install_path = "/tmp/nvim/site/" .. name
	if vim.fn.isdirectory(install_path) == 0 then
		vim.fn.system({ "git", "clone", "--depth=1", url, install_path })
	end
	vim.o.runtimepath = install_path .. "," .. vim.o.runtimepath
end

require("nvim-treesitter.configs").setup({
	-- One of "all", "maintained" (parsers with maintainers), or a list of languages
	ensure_installed = {
		"r",
	},
	sync_install = true,
	highlight = {
		enable = true,
	},
})
require("orgmode").setup()


Screenshots and recordings

Screenshot 2024-05-16 at 21 30 08

OS / Distro

macos 13.4

Neovim version/commit

0.10

Additional context

R and r are both considered as "Canonical" name for R language, so you would expect to see different authors use R and r interchangably from different sources. While treesitter uses r as its name, the orgmode should handles language name R robustly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions