From 98de528e193f6eb763bc64e026e47bc464029b67 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Tue, 20 Jun 2023 18:56:07 +0800 Subject: [PATCH] fix(flygrep): support detect filetype defined in vim script --- lua/spacevim/plugin/flygrep.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lua/spacevim/plugin/flygrep.lua b/lua/spacevim/plugin/flygrep.lua index c1fb110eb..acfc5432d 100644 --- a/lua/spacevim/plugin/flygrep.lua +++ b/lua/spacevim/plugin/flygrep.lua @@ -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()