Skip to content

Commit acb7587

Browse files
committed
fix: handle strange filetypes
closes #18
1 parent 556f0f2 commit acb7587

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

lua/freeze/init.lua

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@ local function open_by_os(args)
107107
return vim.fn.system(cmd)
108108
end
109109

110+
-- Normalise the filetype
111+
---@param ft string
112+
---@return string
113+
local function normalise_ft(ft)
114+
-- TODO: add proper nested language support
115+
-- https://github.com/charmbracelet/freeze/pull/79
116+
if ft == "typescriptreact" then
117+
return "typescript"
118+
elseif ft == "markdown.mdx" then
119+
return "markdown"
120+
end
121+
122+
return ft
123+
end
124+
110125
-- Open the generated image
111126
---@param args FreezeOptions
112127
M.open = function(args)
@@ -208,7 +223,8 @@ M.start = function(args, options)
208223
elseif options.language then
209224
table.insert(cmd, options.language)
210225
else
211-
table.insert(cmd, vim.bo.filetype)
226+
local ft = normalise_ft(vim.bo.filetype)
227+
table.insert(cmd, ft)
212228
end
213229

214230
-- Run the command and get the output

0 commit comments

Comments
 (0)