@@ -5,7 +5,7 @@ local luv = vim.uv or vim.loop
55
66local M = {}
77
8- local function is_port_in_use (host , port , callback )
8+ function M . is_port_in_use (host , port , callback )
99 local check = luv .new_tcp ()
1010
1111 if not check then
@@ -26,19 +26,19 @@ local function is_port_in_use(host, port, callback)
2626 end )
2727end
2828
29- local function wait_for_unbind (host , port , attempt , max_attempts , callback )
29+ function M . wait_for_unbind (host , port , attempt , max_attempts , callback )
3030 if attempt > max_attempts then
3131 utils .notify_err (" Existing server did not unbind in time" )
3232 return
3333 end
3434
35- is_port_in_use (host , port , function (in_use )
35+ M . is_port_in_use (host , port , function (in_use )
3636 if not in_use then
3737 callback ()
3838 else
3939 local delay = math.min (1000 * 2 ^ (attempt - 1 ), 10000 )
4040 vim .defer_fn (function ()
41- wait_for_unbind (host , port , attempt + 1 , max_attempts , callback )
41+ M . wait_for_unbind (host , port , attempt + 1 , max_attempts , callback )
4242 end , delay )
4343 end
4444 end )
@@ -126,7 +126,7 @@ function M.start()
126126end
127127
128128function M .init ()
129- is_port_in_use (" 127.0.0.1" , opts .core .port , function (in_use )
129+ M . is_port_in_use (" 127.0.0.1" , opts .core .port , function (in_use )
130130 if in_use then
131131 -- utils.notify_info("Stopping existing server before initializing")
132132 local stop_signal = luv .new_tcp ()
@@ -139,7 +139,7 @@ function M.init()
139139 if not err then
140140 stop_signal :write (" shutdown" , function ()
141141 stop_signal :close ()
142- wait_for_unbind (" 127.0.0.1" , opts .core .port , 1 , 5 , M .start )
142+ M . wait_for_unbind (" 127.0.0.1" , opts .core .port , 1 , 5 , M .start )
143143 end )
144144 else
145145 M .start ()
0 commit comments