File tree Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Original file line number Diff line number Diff line change
1
+ local uv = vim .uv or vim .loop
1
2
local Utils = require (" eca.utils" )
2
3
local Config = require (" eca.config" )
3
4
37
38
--- @param arch ? string
38
39
--- @return string
39
40
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
+
43
44
-- Normalize platform names
44
45
if platform :match (" darwin" ) then
45
46
platform = " darwin"
65
66
function M :_get_extension_server_path (platform , arch )
66
67
local artifact_name = self :_get_artifact_name (platform , arch )
67
68
local name
68
-
69
+
69
70
if artifact_name :match (" %.jar$" ) then
70
71
name = " eca.jar"
71
72
else
72
- platform = platform or vim . loop .os_uname ().sysname :lower ()
73
+ platform = platform or uv .os_uname ().sysname :lower ()
73
74
name = platform :match (" windows" ) and " eca.exe" or " eca"
74
75
end
75
-
76
+
76
77
return self ._cache_dir .. " /" .. name
77
78
end
78
79
Original file line number Diff line number Diff line change
1
+ local uv = vim .uv or vim .loop
2
+
1
3
local M = {}
2
4
3
5
local CONSTANTS = {
92
94
--- @param path string
93
95
--- @return boolean
94
96
function M .file_exists (path )
95
- local stat = vim . loop .fs_stat (path )
97
+ local stat = uv .fs_stat (path )
96
98
return stat and stat .type == " file"
97
99
end
98
100
99
101
--- @param dir string
100
102
--- @return boolean
101
103
function M .dir_exists (dir )
102
- local stat = vim . loop .fs_stat (dir )
104
+ local stat = uv .fs_stat (dir )
103
105
return stat and stat .type == " directory"
104
106
end
105
107
@@ -132,12 +134,12 @@ function M.read_file(path)
132
134
if not M .file_exists (path ) then
133
135
return nil
134
136
end
135
-
137
+
136
138
local file = io.open (path , " r" )
137
139
if not file then
138
140
return nil
139
141
end
140
-
142
+
141
143
local content = file :read (" *a" )
142
144
file :close ()
143
145
return content
@@ -151,7 +153,7 @@ function M.write_file(path, content)
151
153
if not file then
152
154
return false
153
155
end
154
-
156
+
155
157
file :write (content )
156
158
file :close ()
157
159
return true
You can’t perform that action at this time.
0 commit comments