Ensure ft_to_lang supports multipart filetypes.

This allows a given parser to directly implement a multipart filetype
(like `glimmer` parser does for `html.handlebars`).

If an exact match for the current filetype is found in the lookup table,
it will be used; otherwise we look for just the first segment.
This commit is contained in:
Robert Jackson 2021-11-03 11:56:23 -04:00 committed by Santos Gallegos
parent 89b3b77033
commit da5920f2bf

View file

@ -767,9 +767,14 @@ local M = {
} }
function M.ft_to_lang(ft) function M.ft_to_lang(ft)
local result = ft_to_parsername[ft]
if result then
return result
else
ft = vim.split(ft, ".", true)[1] ft = vim.split(ft, ".", true)[1]
return ft_to_parsername[ft] or ft return ft_to_parsername[ft] or ft
end end
end
function M.available_parsers() function M.available_parsers()
if vim.fn.executable "tree-sitter" == 1 and vim.fn.executable "node" == 1 then if vim.fn.executable "tree-sitter" == 1 and vim.fn.executable "node" == 1 then