Skip to content

Commit 0436fe0

Browse files
committed
refactor: replace vim.loop with vim.uv and simplify file checks
Replace deprecated vim.loop with vim.uv throughout the codebase. Remove custom file_exists utility function in favor of direct vim.uv.fs_stat calls for file existence checks. This change improves code consistency and leverages built-in Neovim API functions rather than custom implementations.
1 parent decc13d commit 0436fe0

File tree

5 files changed

+6
-14
lines changed

5 files changed

+6
-14
lines changed

lua/CopilotChat/config/prompts.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Keep your answers short and impersonal.
1414
The user works in an IDE called Neovim which has a concept for editors with open files, integrated unit test support, an output pane that shows the output of running the code as well as an integrated terminal.
1515
The user is working on a %s machine. Please respond with system specific commands if applicable.
1616
]],
17-
vim.loop.os_uname().sysname
17+
vim.uv.os_uname().sysname
1818
)
1919

2020
local COPILOT_INSTRUCTIONS = [[

lua/CopilotChat/config/providers.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
local async = require('plenary.async')
21
local utils = require('CopilotChat.utils')
32

43
---@class CopilotChat.Provider.model
@@ -58,18 +57,18 @@ local cached_github_token = nil
5857

5958
local function config_path()
6059
local config = vim.fs.normalize('$XDG_CONFIG_HOME')
61-
if config and utils.file_exists(config) then
60+
if config and vim.uv.fs_stat(config) then
6261
return config
6362
end
6463
if vim.fn.has('win32') > 0 then
6564
config = vim.fs.normalize('$LOCALAPPDATA')
66-
if not config or not utils.file_exists(config) then
65+
if not config or not vim.uv.fs_stat(config) then
6766
config = vim.fs.normalize('$HOME/AppData/Local')
6867
end
6968
else
7069
config = vim.fs.normalize('$HOME/.config')
7170
end
72-
if config and utils.file_exists(config) then
71+
if config and vim.uv.fs_stat(config) then
7372
return config
7473
end
7574
end

lua/CopilotChat/tiktoken.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ local function load_tiktoken_data(tokenizer)
2121
vim.fn.mkdir(tostring(cache_dir), 'p')
2222
local cache_path = cache_dir .. '/' .. tiktoken_url:match('.+/(.+)')
2323

24-
if utils.file_exists(cache_path) then
24+
if vim.uv.fs_stat(cache_path) then
2525
return cache_path
2626
end
2727

lua/CopilotChat/ui/spinner.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function Spinner:start()
3838
return
3939
end
4040

41-
self.timer = vim.loop.new_timer()
41+
self.timer = vim.uv.new_timer()
4242
self.timer:start(
4343
0,
4444
100,

lua/CopilotChat/utils.lua

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -425,13 +425,6 @@ M.scan_dir = async.wrap(function(path, opts, callback)
425425
)
426426
end, 3)
427427

428-
--- Check if a file exists
429-
---@param path string The file path
430-
M.file_exists = function(path)
431-
local err, stat = async.uv.fs_stat(path)
432-
return err == nil and stat ~= nil
433-
end
434-
435428
--- Get last modified time of a file
436429
---@param path string The file path
437430
---@return number?

0 commit comments

Comments
 (0)