Skip to content

Commit 47e6e1d

Browse files
authored
fix(slash_commands): can load from a module path (#2370)
1 parent ca87f13 commit 47e6e1d

File tree

1 file changed

+9
-2
lines changed
  • lua/codecompanion/strategies/chat/slash_commands

1 file changed

+9
-2
lines changed

lua/codecompanion/strategies/chat/slash_commands/init.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,22 @@ local function resolve(callback)
1212
return slash_command
1313
end
1414

15-
-- Try loading the tool from the user's config
15+
-- Try loading the tool from the user's config using a module path
16+
ok, slash_command = pcall(require, callback)
17+
if ok then
18+
log:debug("Calling slash command using a module path: %s", callback)
19+
return slash_command
20+
end
21+
22+
-- Try loading the tool from the user's config using a file path
1623
local err
1724
slash_command, err = loadfile(callback)
1825
if err then
1926
return log:error("Could not load the slash command: %s", callback)
2027
end
2128

2229
if slash_command then
23-
log:debug("Calling slash command: %s", callback)
30+
log:debug("Calling slash command from a file path: %s", callback)
2431
return slash_command()
2532
end
2633
end

0 commit comments

Comments
 (0)