@@ -215,17 +215,16 @@ end
215215
216216--- Run the command in the environment variable
217217--- @param var string
218+ --- @param timeout number
218219--- @return string | nil
219- local function run_cmd (var )
220+ local function run_cmd (var , timeout )
220221 log :trace (" [Adapters] Detected cmd in environment variable" )
221222
222- local timeout_ms = 5000 -- 5 second timeout
223-
224223 local cmd = var :sub (5 )
225224
226225 local shell_cmd = require (" codecompanion.utils.os" ).build_shell_command (cmd )
227226
228- local obj = vim .system (shell_cmd , { text = true , timeout = timeout_ms })
227+ local obj = vim .system (shell_cmd , { text = true , timeout = timeout })
229228 if not obj then
230229 return log :error (" [Adapters] Could not execute cmd: %s" , cmd )
231230 end
302301
303302--- Get the variables from the env key of the adapter
304303--- @param adapter table
304+ --- @param args ? { timeout : number }
305305--- @return table
306- function M .get_env_vars (adapter )
306+ function M .get_env_vars (adapter , args )
307307 local env_vars = adapter .env or {}
308308
309309 if not env_vars then
@@ -314,7 +314,8 @@ function M.get_env_vars(adapter)
314314
315315 for k , v in pairs (env_vars ) do
316316 if type (v ) == " string" and is_cmd (v ) then
317- adapter .env_replaced [k ] = run_cmd (v )
317+ local timeout = (args and args .timeout ) or 5000
318+ adapter .env_replaced [k ] = run_cmd (v , timeout )
318319 elseif type (v ) == " string" and is_env_var (v ) then
319320 adapter .env_replaced [k ] = get_env_var (v )
320321 elseif type (v ) == " function" then
0 commit comments