Skip to content

Commit

Permalink
fix: typescript file type matching
Browse files Browse the repository at this point in the history
recognize typescript file type based on extension
  • Loading branch information
dzonatan authored and deathbeam committed Feb 7, 2025
1 parent 834ba1b commit 7a95d6e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lua/CopilotChat/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,20 @@ end
---@return string|nil
function M.filetype(filename)
local ft = vim.filetype.match({ filename = filename })

-- weird TypeScript bug for vim.filetype.match
-- see: https://github.com/neovim/neovim/issues/27265
if not ft then
local base_name = vim.fs.basename(filename)
local split_name = vim.split(base_name, '%.')
if #split_name > 1 then
local ext = split_name[#split_name]
if ext == 'ts' then
ft = 'typescript'
end
end
end

if ft == '' then
return nil
end
Expand Down

0 comments on commit 7a95d6e

Please sign in to comment.