Improve code: [code]
- User
Improve code:
codelocal function clone_github(repo) local dir = vim.fn.stdpath("data") .. "/site/pack/p/start/" .. repo:match("[^/]*$") if not vim.loop.fs_stat(dir) then vim.notify("Cloning") vim.fn.jobstart({ "git", "clone", "--depth=1", "https://github.com/" .. repo, dir }) end end Assistant
Here's an improved version of the code:
lualocal function clone_github(repo) local dir = vim.fn.stdpath("data") .. "/site/pack/p/start/" .. vim.fn.fnamemodify(repo, ":t") if vim.fn.isdirectory(dir) == 0 then vim.notify("Cloning " .. repo, vim.log.levels.INFO) local job_id = vim.fn.jobstart({ "git", "clone", "--depth=1", "--filter=blob:none", "https://github.com/" .. repo, dir }, { on_exit = function(_, exit_code) if exit_code == 0 then vim.notify("Successfully cloned " .. repo, vim.log.levels.INFO) else vim.notify("Failed to clone " .. repo, vim.log.levels.ERROR) end end }) if job_id <= 0 then vim.notify("Failed to start git clone job", vim.log.levels.ERROR) end end end
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.