Skip to content

Commit 7ee1f13

Browse files
fix(injections)!: Do not use vim.filetype.match for injections
Potentially fixes issue: #792
1 parent de02a0c commit 7ee1f13

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lua/orgmode/config/init.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ function Config:setup_ts_predicates()
423423
if not text or vim.trim(text) == '' then
424424
return
425425
end
426-
metadata['injection.language'] = utils.detect_filetype(text)
426+
metadata['injection.language'] = utils.detect_filetype(text, true)
427427
end, { force = true })
428428

429429
vim.treesitter.query.add_predicate('org-is-headline-level?', function(match, _, _, predicate)

lua/orgmode/utils/init.lua

+8-5
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,9 @@ function utils.find(entries, check_fn)
568568
end
569569

570570
---@param name string
571+
---@param skip_ftmatch? boolean
571572
---@return string
572-
function utils.detect_filetype(name)
573+
function utils.detect_filetype(name, skip_ftmatch)
573574
local map = {
574575
['emacs-lisp'] = 'lisp',
575576
js = 'javascript',
@@ -580,10 +581,12 @@ function utils.detect_filetype(name)
580581
sh = 'bash',
581582
uxn = 'uxntal',
582583
}
583-
local filename = '__org__detect_filetype__.' .. (map[name] or name)
584-
local ft = vim.filetype.match({ filename = filename })
585-
if ft then
586-
return ft
584+
if not skip_ftmatch then
585+
local filename = '__org__detect_filetype__.' .. (map[name] or name)
586+
local ft = vim.filetype.match({ filename = filename })
587+
if ft then
588+
return ft
589+
end
587590
end
588591
if map[name] then
589592
return map[name]

0 commit comments

Comments
 (0)