Skip to content

Commit

Permalink
fix(slash_command): typescript ft not recognised (#723)
Browse files Browse the repository at this point in the history
  • Loading branch information
GitMurf authored Jan 27, 2025
1 parent f8b9dce commit c114e42
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lua/codecompanion/strategies/chat/slash_commands/symbols.lua
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ function SlashCommand:output(selected, opts)
opts = opts or {}

local ft = vim.filetype.match({ filename = selected.path })
-- 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(selected.path)
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
local content = path.new(selected.path):read()

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

0 comments on commit c114e42

Please sign in to comment.