-
Notifications
You must be signed in to change notification settings - Fork 67
/
update_intellisense.lua
44 lines (40 loc) · 1.16 KB
/
update_intellisense.lua
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
-- imports
import("core.project.config")
import("core.project.project")
import("clang.compile_commands", {rootdir = path.join(os.programdir(), "plugins", "project")})
-- config target
function _config_target(target)
local oldenvs = os.addenvs(target:pkgenvs())
for _, rule in ipairs(target:orderules()) do
local on_config = rule:script("config")
if on_config then
on_config(target)
end
end
local on_config = target:script("config")
if on_config then
on_config(target)
end
if oldenvs then
os.setenvs(oldenvs)
end
end
-- config targets
function _config_targets()
for _, target in ipairs(project.ordertargets()) do
if target:is_enabled() then
_config_target(target)
end
end
end
-- main entry
function main()
-- generate compile_commands.json
-- @note we can only load configuration because we watched onFileChanged(xmake.conf)
os.setenv("XMAKE_IN_PROJECT_GENERATOR", "true")
os.setenv("XMAKE_GENERATOR_COMPDB_LSP", "clangd")
config.load()
_config_targets()
compile_commands.make(".vscode")
os.setenv("XMAKE_IN_PROJECT_GENERATOR", nil)
end