From da5920f2bf5cd453c19258adba1df35a6793af84 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Wed, 3 Nov 2021 11:56:23 -0400 Subject: 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. --- lua/nvim-treesitter/parsers.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lua') diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 3025c1d4f..71ca152e0 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -767,8 +767,13 @@ local M = { } function M.ft_to_lang(ft) - ft = vim.split(ft, ".", true)[1] - return ft_to_parsername[ft] or ft + local result = ft_to_parsername[ft] + if result then + return result + else + ft = vim.split(ft, ".", true)[1] + return ft_to_parsername[ft] or ft + end end function M.available_parsers() -- cgit v1.2.3-70-g09d2