fix(treesitter): enforce lowercase language names (#28546)

* fix(treesitter): enforce lowercase language names

Problem: On case-insensitive file systems (e.g., macOS), `has_parser`
will return `true` for uppercase aliases, which will then try to inject
the uppercase language unsuccessfully.

Solution: Enforce and assume parser names to be lowercase when
resolving language names.
This commit is contained in:
Christian Clason
2024-04-28 16:27:47 +02:00
committed by GitHub
parent 4625394a76
commit 26b5405d18
4 changed files with 8 additions and 12 deletions

View File

@@ -484,7 +484,7 @@ describe('treesitter highlighting (C)', function()
exec_lua [[
vim.treesitter.language.register("c", "foo")
local parser = vim.treesitter.get_parser(0, "c", {
injections = {c = '(preproc_def (preproc_arg) @injection.content (#set! injection.language "fOO")) (preproc_function_def value: (preproc_arg) @injection.content (#set! injection.language "fOO"))'}
injections = {c = '(preproc_def (preproc_arg) @injection.content (#set! injection.language "foo")) (preproc_function_def value: (preproc_arg) @injection.content (#set! injection.language "foo"))'}
})
local highlighter = vim.treesitter.highlighter
test_hl = highlighter.new(parser, {queries = {c = hl_query}})