fix: fallback to filetype for get_lang for treesitter highlighting (#2867)

This commit is contained in:
Sebastian Lyng Johansen
2024-01-18 11:43:26 +01:00
committed by GitHub
parent 43cabe5327
commit b4befa1c2f
2 changed files with 2 additions and 2 deletions

View File

@@ -482,7 +482,7 @@ files.current_buffer_fuzzy_find = function(opts)
end
opts.results_ts_highlight = vim.F.if_nil(opts.results_ts_highlight, true)
local lang = vim.treesitter.language.get_lang(filetype)
local lang = vim.treesitter.language.get_lang(filetype) or filetype
if opts.results_ts_highlight and lang and utils.has_ts_parser(lang) then
local parser = vim.treesitter.get_parser(opts.bufnr, lang)
local query = vim.treesitter.query.get(lang, "highlights")

View File

@@ -167,7 +167,7 @@ end
-- Attach ts highlighter
utils.ts_highlighter = function(bufnr, ft)
if has_filetype(ft) then
local lang = vim.treesitter.language.get_lang(ft)
local lang = vim.treesitter.language.get_lang(ft) or ft
if lang and ts_utils.has_ts_parser(lang) then
return vim.treesitter.start(bufnr, lang)
end