diff options
| author | Robert Jackson <rjackson@linkedin.com> | 2021-11-03 11:56:23 -0400 |
|---|---|---|
| committer | Santos Gallegos <stsewd@protonmail.com> | 2021-11-11 21:11:15 -0500 |
| commit | da5920f2bf5cd453c19258adba1df35a6793af84 (patch) | |
| tree | efbbf3a9d4fbe5178ee771ff22d153c6f49de015 | |
| parent | Add `html.handlebars` as a valid type for the glimmer parser. (diff) | |
| download | nvim-treesitter-da5920f2bf5cd453c19258adba1df35a6793af84.tar nvim-treesitter-da5920f2bf5cd453c19258adba1df35a6793af84.tar.gz nvim-treesitter-da5920f2bf5cd453c19258adba1df35a6793af84.tar.bz2 nvim-treesitter-da5920f2bf5cd453c19258adba1df35a6793af84.tar.lz nvim-treesitter-da5920f2bf5cd453c19258adba1df35a6793af84.tar.xz nvim-treesitter-da5920f2bf5cd453c19258adba1df35a6793af84.tar.zst nvim-treesitter-da5920f2bf5cd453c19258adba1df35a6793af84.zip | |
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.
| -rw-r--r-- | lua/nvim-treesitter/parsers.lua | 9 |
1 files changed, 7 insertions, 2 deletions
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() |
