fix(treesitter): disallow empty filetypes

Fixes #22473
This commit is contained in:
Lewis Russell
2023-03-03 09:44:02 +00:00
committed by GitHub
parent 89cccea167
commit 6d4f481821
4 changed files with 31 additions and 3 deletions

View File

@@ -60,6 +60,16 @@ function M.add(lang, opts)
filetype = { filetype, { 'string', 'table' }, true },
})
if filetype == '' then
error(string.format("'%s' is not a valid filetype", filetype))
elseif type(filetype) == 'table' then
for _, f in ipairs(filetype) do
if f == '' then
error(string.format("'%s' is not a valid filetype", filetype))
end
end
end
M.register(lang, filetype or lang)
if vim._ts_has_language(lang) then