File tree Expand file tree Collapse file tree 6 files changed +12
-28
lines changed
integrations/codecompanion Expand file tree Collapse file tree 6 files changed +12
-28
lines changed Original file line number Diff line number Diff line change 11--- @type VectorCode.CacheBackend
22local M = {}
3+
4+ local utils = require (" vectorcode.utils" )
35local vc_config = require (" vectorcode.config" )
46local notify_opts = vc_config .notify_opts
57local jobrunner = require (" vectorcode.jobrunner.cmd" )
@@ -54,7 +56,7 @@ local function async_runner(query_message, buf_nr)
5456 local project_root = cache .options .project_root
5557 if project_root ~= nil then
5658 assert (
57- vim . uv . fs_stat ( vim . fs . normalize ( project_root )). type == " directory " ,
59+ utils . is_directory ( project_root ),
5860 (" %s is not a valid directory!" ):format (project_root )
5961 )
6062 vim .list_extend (args , { " --project_root" , project_root })
Original file line number Diff line number Diff line change @@ -149,10 +149,7 @@ M.vectorise = vc_config.check_cli_wrap(
149149M .update = vc_config .check_cli_wrap (function (project_root )
150150 logger .info (" vectorcode.update: " , project_root )
151151 local args = { " update" }
152- if
153- type (project_root ) == " string"
154- and vim .uv .fs_stat (vim .fs .normalize (project_root )).type == " directory"
155- then
152+ if project_root ~= nil and utils .is_directory (project_root ) then
156153 vim .list_extend (args , { " --project_root" , project_root })
157154 end
158155 logger .debug (" vectorcode.update cmd args: " , args )
Original file line number Diff line number Diff line change @@ -33,8 +33,7 @@ return function(opts)
3333 or vim .fs .root (0 , { " .vectorcode" , " .git" })
3434 if action .project_root ~= nil then
3535 action .project_root = vim .fs .normalize (action .project_root )
36- local stat = vim .uv .fs_stat (action .project_root )
37- if stat and stat .type == " directory" then
36+ if utils .is_directory (action .project_root ) then
3837 vim .list_extend (args , { " --project_root" , action .project_root })
3938 end
4039 end
Original file line number Diff line number Diff line change 22
33local cc_common = require (" vectorcode.integrations.codecompanion.common" )
44local vc_config = require (" vectorcode.config" )
5+ local utils = require (" vectorcode.utils" )
56
67local default_opts = {
78 use_lsp = vc_config .get_user_config ().async_backend == " lsp" ,
@@ -59,8 +60,7 @@ The value should be one of the following:
5960 local args = { " files" , " rm" , " --pipe" }
6061 if action .project_root then
6162 local project_root = vim .fs .abspath (vim .fs .normalize (action .project_root ))
62- local stat = vim .uv .fs_stat (project_root )
63- if stat and stat .type == " directory" then
63+ if utils .is_directory (project_root ) then
6464 vim .list_extend (args , { " --project_root" , project_root })
6565 else
6666 return { status = " error" , data = " Invalid path " .. project_root }
@@ -76,12 +76,7 @@ The value should be one of the following:
7676 :filter (
7777 --- @param item string
7878 function (item )
79- local stat = vim .uv .fs_stat (item )
80- if stat and stat .type == " file" then
81- return true
82- else
83- return false
84- end
79+ return utils .is_file (item )
8580 end
8681 )
8782 :totable ()
Original file line number Diff line number Diff line change @@ -417,10 +417,7 @@ return check_cli_wrap(function(opts)
417417 end
418418 if action .project_root ~= nil then
419419 action .project_root = vim .fs .normalize (action .project_root )
420- if
421- vim .uv .fs_stat (action .project_root ) ~= nil
422- and vim .uv .fs_stat (action .project_root ).type == " directory"
423- then
420+ if utils .is_directory (action .project_root ) then
424421 action .project_root = vim .fs .abspath (vim .fs .normalize (action .project_root ))
425422 vim .list_extend (args , { " --project_root" , action .project_root })
426423 else
@@ -446,8 +443,7 @@ return check_cli_wrap(function(opts)
446443 elseif ref .bufnr then
447444 local fname = vim .api .nvim_buf_get_name (ref .bufnr )
448445 if fname ~= nil then
449- local stat = vim .uv .fs_stat (fname )
450- if stat and stat .type == " file" then
446+ if utils .is_file (fname ) then
451447 table.insert (existing_files , fname )
452448 end
453449 end
Original file line number Diff line number Diff line change @@ -78,20 +78,15 @@ The value should be one of the following:
7878 local args = { " vectorise" , " --pipe" }
7979 if action .project_root then
8080 local project_root = vim .fs .abspath (vim .fs .normalize (action .project_root ))
81- local stat = vim .uv .fs_stat (project_root )
82- if stat and stat .type == " directory" then
81+ if utils .is_directory (project_root ) then
8382 vim .list_extend (args , { " --project_root" , project_root })
8483 else
8584 return { status = " error" , data = " Invalid path " .. project_root }
8685 end
8786 end
8887 if
8988 vim .iter (action .paths ):any (function (p )
90- local stat = vim .uv .fs_stat (vim .fs .normalize (p ))
91- if stat and stat .type == " directory" then
92- return true
93- end
94- return false
89+ return utils .is_directory (p )
9590 end )
9691 then
9792 return {
You can’t perform that action at this time.
0 commit comments