mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-15 19:45:46 +08:00
fix(flygrep): support detect filetype defined in vim script
This commit is contained in:
parent
db52071cb4
commit
98de528e19
@ -300,6 +300,19 @@ local function preview_timer(_)
|
|||||||
local ft = vim.filetype.match({ filename = filename })
|
local ft = vim.filetype.match({ filename = filename })
|
||||||
if ft then
|
if ft then
|
||||||
vim.api.nvim_buf_set_option(preview_bufnr, 'syntax', ft)
|
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
|
end
|
||||||
vim.api.nvim_win_set_cursor(preview_win_id, { liner, colum })
|
vim.api.nvim_win_set_cursor(preview_win_id, { liner, colum })
|
||||||
mpt._build_prompt()
|
mpt._build_prompt()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user