Skip to content

Commit

Permalink
fix: Only map TSLang → ft on NeoVim 0.9+
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewferrier committed Apr 3, 2024
1 parent 60ed92c commit 8c7a872
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lua/debugprint/utils.lua
Expand Up @@ -117,9 +117,14 @@ M.get_effective_filetypes = function()
})
:lang()

local filetypes = vim.treesitter.language.get_filetypes(treesitter_lang)
assert(vim.tbl_count(filetypes) > 0)
return filetypes
if vim.fn.has("nvim-0.9.0") == 1 then
local filetypes = vim.treesitter.language.get_filetypes(treesitter_lang)
assert(vim.tbl_count(filetypes) > 0)
return filetypes
else
-- 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).
return { treesitter_lang }
end
else
return { vim.api.nvim_get_option_value("filetype", { scope = "local" }) }
end
Expand Down

0 comments on commit 8c7a872

Please sign in to comment.