1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-13 02:05:40 +08:00

fix(flygrep): support detect filetype defined in vim script

This commit is contained in:
wsdjeg 2023-06-20 18:56:07 +08:00
parent db52071cb4
commit 98de528e19

View File

@ -300,6 +300,19 @@ local function preview_timer(_)
local ft = vim.filetype.match({ filename = filename })
if ft then
vim.api.nvim_buf_set_option(preview_bufnr, 'syntax', ft)
else
local ftdetect_autocmd = vim.api.nvim_get_autocmds({
group = 'filetypedetect',
event = 'BufRead',
pattern = '*.' .. vim.fn.fnamemodify(filename, ':e')
})
-- logger.info(vim.inspect(ftdetect_autocmd))
if ftdetect_autocmd[1] then
if ftdetect_autocmd[1].command then
ft = ftdetect_autocmd[1].command:gsub('set filetype=', '')
vim.api.nvim_buf_set_option(preview_bufnr, 'syntax', ft)
end
end
end
vim.api.nvim_win_set_cursor(preview_win_id, { liner, colum })
mpt._build_prompt()