@@ -53,7 +53,6 @@ function M.start(filepath, port)
5353 M .close ()
5454
5555 M .serverObj = server .Server :new (config .config .dynamic_root and vim .fs .dirname (filepath ) or nil )
56- vim .wait (50 , function ()
5756 local function onTextChanged (client )
5857 local bufname = vim .api .nvim_buf_get_name (0 )
5958 if not utils .supported_filetype (bufname ) or utils .supported_filetype (bufname ) == " html" then
@@ -67,27 +66,24 @@ function M.start(filepath, port)
6766 server .websocket .send_json (client , message )
6867 end
6968
70- M .serverObj :start (config .config .address , port , {
71- on_events = utils .supported_filetype (filepath ) == " html"
72- and {
73- --- @param client uv_tcp_t
74- --- @param data { filename : string , event : FsEvent }
75- LivePreviewDirChanged = function (client , data )
76- if not vim .regex ([[ \.\(html\|css\|js\)$]] ):match_str (data .filename ) then
77- return
78- end
79-
80- server .websocket .send_json (client , { type = " reload" })
81- end ,
82- }
83- or {
84- TextChanged = vim .schedule_wrap (onTextChanged ),
85- TextChangedI = vim .schedule_wrap (onTextChanged ),
86- },
87- })
88-
89- return true
90- end , 98 )
69+ M .serverObj :start (config .config .address , port , {
70+ on_events = utils .supported_filetype (filepath ) == " html"
71+ and {
72+ --- @param client uv_tcp_t
73+ --- @param data { filename : string , event : FsEvent }
74+ LivePreviewDirChanged = function (client , data )
75+ if not vim .regex ([[ \.\(html\|css\|js\)$]] ):match_str (data .filename ) then
76+ return
77+ end
78+
79+ server .websocket .send_json (client , { type = " reload" })
80+ end ,
81+ }
82+ or {
83+ TextChanged = vim .schedule_wrap (onTextChanged ),
84+ TextChangedI = vim .schedule_wrap (onTextChanged ),
85+ },
86+ })
9187
9288 return true
9389end
0 commit comments