Skip to content

Commit 2e29d5f

Browse files
committed
fix(previewer): allow diff/git cmd syntax
1 parent 33321eb commit 2e29d5f

1 file changed

Lines changed: 19 additions & 16 deletions

File tree

lua/fzf-lua/previewer/builtin.lua

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,11 @@ function Previewer.buffer_or_file:do_syntax(entry)
11841184
if not ft then return end
11851185
did_filetype_detect = true
11861186
end
1187+
if ft == "diff" or ft == "git" then
1188+
api.nvim_buf_call(bufnr, function()
1189+
api.nvim_exec_autocmds("FileType", { pattern = ft, modeline = false })
1190+
end)
1191+
end
11871192

11881193
-- Use buf local var as setting ft might have unintended consequences
11891194
-- used in `update_render_markdown`, `attach_snacks_image`
@@ -1366,25 +1371,23 @@ function Previewer.buffer_or_file:preview_buf_post(entry, min_winopts)
13661371
-- set cursor highlights for line|col or tag
13671372
self:set_cursor_hl(entry)
13681373

1369-
if not utils.is_term_buffer(self.preview_bufnr) then
1370-
local syntax = function()
1371-
if self.syntax then
1372-
self:do_syntax(entry)
1373-
self:update_render_markdown()
1374-
self:update_ts_context()
1375-
self:attach_snacks_image_inline()
1376-
end
1377-
-- for attach_snacks_image_{inline,buf}
1378-
-- https://github.com/folke/snacks.nvim/pull/1615
1379-
if self.preview_bufnr and vim.b[self.preview_bufnr].snacks_image_attached then
1380-
utils.wo[self.win.preview_winid][0].winblend = 0
1381-
end
1374+
local syntax = function()
1375+
if self.syntax then
1376+
self:do_syntax(entry)
1377+
self:update_render_markdown()
1378+
self:update_ts_context()
1379+
self:attach_snacks_image_inline()
1380+
end
1381+
-- for attach_snacks_image_{inline,buf}
1382+
-- https://github.com/folke/snacks.nvim/pull/1615
1383+
if self.preview_bufnr and vim.b[self.preview_bufnr].snacks_image_attached then
1384+
utils.wo[self.win.preview_winid][0].winblend = 0
13821385
end
1383-
1384-
-- syntax highlighting
1385-
self:debounce("syntax", self.syntax_delay, syntax)
13861386
end
13871387

1388+
-- syntax highlighting
1389+
self:debounce("syntax", self.syntax_delay, syntax)
1390+
13881391
self:update_title(entry)
13891392

13901393
if entry.no_scrollbar then

0 commit comments

Comments
 (0)