Skip to content

Commit 8c7a872

Browse files
committed
fix: Only map TSLang → ft on NeoVim 0.9+
1 parent 60ed92c commit 8c7a872

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lua/debugprint/utils.lua

+8-3
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,14 @@ M.get_effective_filetypes = function()
117117
})
118118
:lang()
119119

120-
local filetypes = vim.treesitter.language.get_filetypes(treesitter_lang)
121-
assert(vim.tbl_count(filetypes) > 0)
122-
return filetypes
120+
if vim.fn.has("nvim-0.9.0") == 1 then
121+
local filetypes = vim.treesitter.language.get_filetypes(treesitter_lang)
122+
assert(vim.tbl_count(filetypes) > 0)
123+
return filetypes
124+
else
125+
-- nvim < 0.9 doesn't have get_filetypes; so just return the lang as if it were a filetype. This will work for many languages (e.g. lua), although not for others (e.g. tsx).
126+
return { treesitter_lang }
127+
end
123128
else
124129
return { vim.api.nvim_get_option_value("filetype", { scope = "local" }) }
125130
end

0 commit comments

Comments
 (0)