diff --git a/lua/orgmode/config/init.lua b/lua/orgmode/config/init.lua index 2cc7fb55e..ca1123b64 100644 --- a/lua/orgmode/config/init.lua +++ b/lua/orgmode/config/init.lua @@ -423,7 +423,7 @@ function Config:setup_ts_predicates() if not text or vim.trim(text) == '' then return end - metadata['injection.language'] = utils.detect_filetype(text) + metadata['injection.language'] = utils.detect_filetype(text, true) end, { force = true }) vim.treesitter.query.add_predicate('org-is-headline-level?', function(match, _, _, predicate) diff --git a/lua/orgmode/utils/init.lua b/lua/orgmode/utils/init.lua index 2caba3824..dd24aa467 100644 --- a/lua/orgmode/utils/init.lua +++ b/lua/orgmode/utils/init.lua @@ -568,8 +568,9 @@ function utils.find(entries, check_fn) end ---@param name string +---@param skip_ftmatch? boolean ---@return string -function utils.detect_filetype(name) +function utils.detect_filetype(name, skip_ftmatch) local map = { ['emacs-lisp'] = 'lisp', js = 'javascript', @@ -580,10 +581,12 @@ function utils.detect_filetype(name) sh = 'bash', uxn = 'uxntal', } - local filename = '__org__detect_filetype__.' .. (map[name] or name) - local ft = vim.filetype.match({ filename = filename }) - if ft then - return ft + if not skip_ftmatch then + local filename = '__org__detect_filetype__.' .. (map[name] or name) + local ft = vim.filetype.match({ filename = filename }) + if ft then + return ft + end end if map[name] then return map[name]