Skip to content

Commit 6169a7b

Browse files
authored
Merge pull request #11 from tomgeorge/vim-loop
Prefer vim.uv to vim.loop
2 parents 1a5be09 + e8de598 commit 6169a7b

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

lua/eca/path_finder.lua

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
local uv = vim.uv or vim.loop
12
local Utils = require("eca.utils")
23
local Config = require("eca.config")
34

@@ -37,9 +38,9 @@ end
3738
---@param arch? string
3839
---@return string
3940
function M:_get_artifact_name(platform, arch)
40-
platform = platform or vim.loop.os_uname().sysname:lower()
41-
arch = arch or vim.loop.os_uname().machine
42-
41+
platform = platform or uv.os_uname().sysname:lower()
42+
arch = arch or uv.os_uname().machine
43+
4344
-- Normalize platform names
4445
if platform:match("darwin") then
4546
platform = "darwin"
@@ -65,14 +66,14 @@ end
6566
function M:_get_extension_server_path(platform, arch)
6667
local artifact_name = self:_get_artifact_name(platform, arch)
6768
local name
68-
69+
6970
if artifact_name:match("%.jar$") then
7071
name = "eca.jar"
7172
else
72-
platform = platform or vim.loop.os_uname().sysname:lower()
73+
platform = platform or uv.os_uname().sysname:lower()
7374
name = platform:match("windows") and "eca.exe" or "eca"
7475
end
75-
76+
7677
return self._cache_dir .. "/" .. name
7778
end
7879

lua/eca/utils.lua

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
local uv = vim.uv or vim.loop
2+
13
local M = {}
24

35
local CONSTANTS = {
@@ -92,14 +94,14 @@ end
9294
---@param path string
9395
---@return boolean
9496
function M.file_exists(path)
95-
local stat = vim.loop.fs_stat(path)
97+
local stat = uv.fs_stat(path)
9698
return stat and stat.type == "file"
9799
end
98100

99101
---@param dir string
100102
---@return boolean
101103
function M.dir_exists(dir)
102-
local stat = vim.loop.fs_stat(dir)
104+
local stat = uv.fs_stat(dir)
103105
return stat and stat.type == "directory"
104106
end
105107

@@ -132,12 +134,12 @@ function M.read_file(path)
132134
if not M.file_exists(path) then
133135
return nil
134136
end
135-
137+
136138
local file = io.open(path, "r")
137139
if not file then
138140
return nil
139141
end
140-
142+
141143
local content = file:read("*a")
142144
file:close()
143145
return content
@@ -151,7 +153,7 @@ function M.write_file(path, content)
151153
if not file then
152154
return false
153155
end
154-
156+
155157
file:write(content)
156158
file:close()
157159
return true

0 commit comments

Comments
 (0)