forked from LuaLS/lua-language-server
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebugger.lua
More file actions
Latest commit
66 lines (57 loc) · 1.77 KB
/
Copy pathdebugger.lua
File metadata and controls
66 lines (57 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
ifnotDEVELOPthen
return
end
localfs=require'bee.filesystem'
localluaDebugs= {}
localhome=os.getenv'USERPROFILE' oros.getenv'HOME'
ifnothomethen
log.error('Cannot find home directory')
return
end
for_, vscodePathinipairs { '.vscode', '.vscode-insiders', '.vscode-server-insiders' } do
localextensionPath=fs.path(home) /vscodePath/'extensions'
log.debug('Search extensions at:', extensionPath:string())
iffs.exists(extensionPath) then
forpathinfs.pairs(extensionPath) do
iffs.is_directory(path) then
localname=path:filename():string()
ifname:find('actboy168.lua-debug-', 1, true) then
luaDebugs[#luaDebugs+1] =path:string()
end
end
end
end
end
if#luaDebugs==0then
log.debug('Cant find "actboy168.lua-debug"')
return
end
localfunctiongetVer(filename)
locala, b, c=filename:match('actboy168%.lua%-debug%-(%d+)%.(%d+)%.(%d+)')
ifnotathen
return0
end
returna*1000000+b*1000+c
end
table.sort(luaDebugs, function (a, b)
returngetVer(a) >getVer(b)
end)
localdebugPath=luaDebugs[1]
localcpath="/runtime/win64/lua54/?.dll;/runtime/win64/lua54/?.so"
localpath="/script/?.lua"
localfunctiontryDebugger()
localentry=assert(package.searchpath('debugger', debugPath..path))
localroot=debugPath
localaddr= ("127.0.0.1:%d"):format(DBGPORT)
localdbg=loadfile(entry)(root)
dbg:start {
address=addr,
}
log.debug('Debugger startup, listen port:', DBGPORT)
log.debug('Debugger args:', addr, root, path, cpath)
ifDBGWAITthen
dbg:event('wait')
end
returndbg
end
xpcall(tryDebugger, log.debug)