fix(utils): get non-nil filetype

This commit is contained in:
Hanchin Hsieh 2025-02-13 16:55:10 +08:00
parent 16bcbc0229
commit 1a4f2575d6

View File

@ -895,7 +895,7 @@ function M.get_filetype(filepath)
-- https://github.com/neovim/neovim/issues/27265
local buf = vim.api.nvim_create_buf(false, true)
local filetype = vim.filetype.match({ filename = filepath, buf = buf })
local filetype = vim.filetype.match({ filename = filepath, buf = buf }) or ""
vim.api.nvim_buf_delete(buf, { force = true })
return filetype