blob: 8e01a57486b0e6d9313a32d7c9629f8714c44346 (
plain)
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
67
68
|
local globals = require("cmake-explorer.globals")
local config = require("cmake-explorer.config")
local runner = require("cmake-explorer.runner")
local Project = require("cmake-explorer.project")
local Build = require("cmake-explorer.build")
local M = {}
local projects = {}
local current_project = nil
local function set_current_project(path)
if path then
for _, v in ipairs(projects) do
-- print(v.path:absolute() .. " ? " .. path)
if v.path:absolute() == path then
current_project = v
return
end
end
end
if #projects ~= 0 then
current_project = projects[1]
else
print("set_current_project. no projects available")
end
end
function M.list_build_dirs()
if current_project then
vim.print(current_project:list_build_dirs_names())
end
end
function M.configure(opts)
print("configure. #projects " .. #projects)
if current_project then
runner.start(current_project:configure(opts))
end
end
M.setup = function(cfg)
cfg = cfg or {}
globals.setup()
config.setup(cfg)
projects = { Project:new(vim.loop.cwd()) }
set_current_project()
local cmd = vim.api.nvim_create_user_command
cmd("CMakeConfigure", function(opts)
if #opts.fargs ~= 0 then
M.configure({ build_type = opts.fargs[1] })
else
M.configure()
end
end, { -- opts
nargs = "*",
bang = true,
desc = "CMake configure",
})
cmd("CMakeListBuildDirs", M.list_build_dirs, { nargs = 0 })
end
return M
|