Skip to content

Commit 9fd068f

Browse files
authored
fix(files): use also plenary filetype on top of vim.filetype.match (#1250)
I thought its fine to go back to vim.filetype.match but its as unreliable as ever. Closes #1249 Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
1 parent 40a88e1 commit 9fd068f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lua/CopilotChat/utils.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,17 @@ end
214214
---@param filename string The file name
215215
---@return string|nil
216216
function M.filetype(filename)
217-
return vim.filetype.match({ filename = filename })
217+
local filetype = require('plenary.filetype')
218+
219+
local ft = filetype.detect(filename, {
220+
fs_access = false,
221+
})
222+
223+
if ft == '' or not ft then
224+
return vim.filetype.match({ filename = filename })
225+
end
226+
227+
return ft
218228
end
219229

220230
--- Get the mimetype from filetype

0 commit comments

Comments
 (0)