Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lua/vectorcode/cacher/default.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---@type VectorCode.CacheBackend
local M = {}

local utils = require("vectorcode.utils")
local vc_config = require("vectorcode.config")
local notify_opts = vc_config.notify_opts
local jobrunner = require("vectorcode.jobrunner.cmd")
Expand Down Expand Up @@ -54,7 +56,7 @@ local function async_runner(query_message, buf_nr)
local project_root = cache.options.project_root
if project_root ~= nil then
assert(
vim.uv.fs_stat(vim.fs.normalize(project_root)).type == "directory",
utils.is_directory(project_root),
("%s is not a valid directory!"):format(project_root)
)
vim.list_extend(args, { "--project_root", project_root })
Expand Down
5 changes: 1 addition & 4 deletions lua/vectorcode/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,7 @@ M.vectorise = vc_config.check_cli_wrap(
M.update = vc_config.check_cli_wrap(function(project_root)
logger.info("vectorcode.update: ", project_root)
local args = { "update" }
if
type(project_root) == "string"
and vim.uv.fs_stat(vim.fs.normalize(project_root)).type == "directory"
then
if project_root ~= nil and utils.is_directory(project_root) then
vim.list_extend(args, { "--project_root", project_root })
end
logger.debug("vectorcode.update cmd args: ", args)
Expand Down
3 changes: 1 addition & 2 deletions lua/vectorcode/integrations/codecompanion/files_ls_tool.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ return function(opts)
or vim.fs.root(0, { ".vectorcode", ".git" })
if action.project_root ~= nil then
action.project_root = vim.fs.normalize(action.project_root)
local stat = vim.uv.fs_stat(action.project_root)
if stat and stat.type == "directory" then
if utils.is_directory(action.project_root) then
vim.list_extend(args, { "--project_root", action.project_root })
end
end
Expand Down
11 changes: 3 additions & 8 deletions lua/vectorcode/integrations/codecompanion/files_rm_tool.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

local cc_common = require("vectorcode.integrations.codecompanion.common")
local vc_config = require("vectorcode.config")
local utils = require("vectorcode.utils")

local default_opts = {
use_lsp = vc_config.get_user_config().async_backend == "lsp",
Expand Down Expand Up @@ -59,8 +60,7 @@ The value should be one of the following:
local args = { "files", "rm", "--pipe" }
if action.project_root then
local project_root = vim.fs.abspath(vim.fs.normalize(action.project_root))
local stat = vim.uv.fs_stat(project_root)
if stat and stat.type == "directory" then
if utils.is_directory(project_root) then
vim.list_extend(args, { "--project_root", project_root })
else
return { status = "error", data = "Invalid path " .. project_root }
Expand All @@ -76,12 +76,7 @@ The value should be one of the following:
:filter(
---@param item string
function(item)
local stat = vim.uv.fs_stat(item)
if stat and stat.type == "file" then
return true
else
return false
end
return utils.is_file(item)
end
)
:totable()
Expand Down
8 changes: 2 additions & 6 deletions lua/vectorcode/integrations/codecompanion/query_tool.lua
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,7 @@ return check_cli_wrap(function(opts)
end
if action.project_root ~= nil then
action.project_root = vim.fs.normalize(action.project_root)
if
vim.uv.fs_stat(action.project_root) ~= nil
and vim.uv.fs_stat(action.project_root).type == "directory"
then
if utils.is_directory(action.project_root) then
action.project_root = vim.fs.abspath(vim.fs.normalize(action.project_root))
vim.list_extend(args, { "--project_root", action.project_root })
else
Expand All @@ -446,8 +443,7 @@ return check_cli_wrap(function(opts)
elseif ref.bufnr then
local fname = vim.api.nvim_buf_get_name(ref.bufnr)
if fname ~= nil then
local stat = vim.uv.fs_stat(fname)
if stat and stat.type == "file" then
if utils.is_file(fname) then
table.insert(existing_files, fname)
end
end
Expand Down
9 changes: 2 additions & 7 deletions lua/vectorcode/integrations/codecompanion/vectorise_tool.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,15 @@ The value should be one of the following:
local args = { "vectorise", "--pipe" }
if action.project_root then
local project_root = vim.fs.abspath(vim.fs.normalize(action.project_root))
local stat = vim.uv.fs_stat(project_root)
if stat and stat.type == "directory" then
if utils.is_directory(project_root) then
vim.list_extend(args, { "--project_root", project_root })
else
return { status = "error", data = "Invalid path " .. project_root }
end
end
if
vim.iter(action.paths):any(function(p)
local stat = vim.uv.fs_stat(vim.fs.normalize(p))
if stat and stat.type == "directory" then
return true
end
return false
return utils.is_directory(p)
end)
then
return {
Expand Down
Loading