Skip to content

Commit c114e42

Browse files
authored
fix(slash_command): typescript ft not recognised (#723)
1 parent f8b9dce commit c114e42

File tree

1 file changed

+12
-0
lines changed
  • lua/codecompanion/strategies/chat/slash_commands

1 file changed

+12
-0
lines changed

lua/codecompanion/strategies/chat/slash_commands/symbols.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,18 @@ function SlashCommand:output(selected, opts)
162162
opts = opts or {}
163163

164164
local ft = vim.filetype.match({ filename = selected.path })
165+
-- weird TypeScript bug for vim.filetype.match
166+
-- see: https://github.com/neovim/neovim/issues/27265
167+
if not ft then
168+
local base_name = vim.fs.basename(selected.path)
169+
local split_name = vim.split(base_name, "%.")
170+
if #split_name > 1 then
171+
local ext = split_name[#split_name]
172+
if ext == "ts" then
173+
ft = "typescript"
174+
end
175+
end
176+
end
165177
local content = path.new(selected.path):read()
166178

167179
local query = vim.treesitter.query.get(ft, "symbols")

0 commit comments

Comments
 (0)