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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
local commandline = require("cmake.commandline")
local actions = require("cmake.actions")
local M = {}
local cmd = vim.api.nvim_create_user_command
local prefix = "CMake"
local commands = {
["Generate"] = {
command = actions.generate,
parse = true,
default_opts = { fresh = false },
cmd_opts = {
desc = "Generate with last configuration",
nargs = "*",
complete = commandline.cmake_generate_complete,
},
},
["GenerateExplain"] = {
command = actions.generate_explain,
parse = true,
default_opts = { fresh = false },
cmd_opts = {
desc = "Explain current generate command",
nargs = "*",
complete = commandline.cmake_generate_complete,
},
},
["GenerateSelect"] = {
command = actions.generate_select,
cmd_opts = { desc = "Select generate configuration" },
},
["Build"] = {
command = actions.build,
parse = true,
cmd_opts = {
desc = "Build with last configuration",
nargs = "*",
complete = commandline.cmake_build_complete,
},
},
["BuildExplain"] = {
command = actions.build_explain,
parse = true,
cmd_opts = {
desc = "Explain current build command",
nargs = "*",
complete = commandline.cmake_build_complete,
},
},
["BuildSelect"] = {
command = actions.build_select,
cmd_opts = { desc = "Select build configuration" },
},
-- ["Install"] = {},
["Run"] = {
command = actions.run_target,
cmd_opts = { desc = "Run current executable target", nargs = "*" },
},
["RunSelect"] = {
command = actions.run_target_select,
cmd_opts = { desc = "Select executable target" },
},
["Toggle"] = {
command = actions.toggle,
cmd_opts = { desc = "Toggle cmake terminal" },
},
["EditVariants"] = {
command = actions.edit_variants,
cmd_opts = { desc = "Edit variants" },
},
}
M.register_commands = function()
for k, v in pairs(commands) do
cmd(prefix .. k, function(opts)
local action_opts = v.default_opts or {}
if v.parse then
action_opts = vim.tbl_deep_extend("keep", commandline.parse(opts.args) or {}, action_opts)
end
v.command(action_opts)
end, v.cmd_opts)
end
end
return M
|