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
|
--- Personal lua config files for NeoVim.
-- Last Changed: 2023-02-08
-- Author: Federico Igne <git@federicoigne.com>
-- License: This file is placed in the public domain.
local cp = require 'dyamon.util.checkpoint'
local cmake = require 'tasks.module.cmake'
local cmd = vim.cmd
local map = require 'dyamon.util.map'
vim.b.ctags_command="ctags -R --c++-kinds=+p --fields=+iaS --extra=+qf --exclude=build ."
vim.b['surround_'..string.byte('h')] = "#ifndef \1#define: \r.*\r\\U&\\E_H\1\n#define \1\r.*\r\\U&\\E_H\1\n\n\r\n\n#endif //\1\r.*\r\\U&\\E_H\1"
--- Tasks
map.b.nore.n(0, '<leader>cb', '<cmd>Task start cmake build<cr>')
map.b.nore.n(0, '<leader>cc', '<cmd>Task start cmake configure<cr>')
map.b.nore.n(0, '<leader>cg', '<cmd>Task start cmake debug<cr>')
map.b.nore.n(0, '<leader>cdu', '<cmd>Task start docker up<cr>')
map.b.nore.n(0, '<leader>cdd', '<cmd>Task start docker down<cr>')
map.b.nore.n(0, '<leader>cr', '<cmd>Task start cmake run<cr>')
map.b.nore.n(0, '<leader>ct', '<cmd>Task set_module_param cmake target<cr>')
function compose(first, second, idx)
if (type(first) == "table") then
-- NOTE we need a copy, first is passed by reference!
local res = {}
for _,t in ipairs(first) do
table.insert(res,t)
end
local idx = idx or #res
local task = res[idx]
res[idx] = function(module_config, _)
return second(task(module_config))
end
return res
else
return function(module_config, _)
return second(first(module_config))
end
end
end
local function add_conan_options(t)
-- NOTE slow operation since it reads JSON from file
local build_type = require'tasks.project_config'.new().cmake.build_type
local args = {
"-D", "CONAN_OPTIONS=--build missing --settings build_type=" .. build_type ,
table.unpack(t.args)
}
t.args = args
return t
end
local function close_qf(t)
local old_after_success = t.after_success
function t.after_success()
old_after_success()
cmd.cclose()
end
return t
end
local function lsp_restart(t)
local old_after_success = t.after_success
function t.after_success()
old_after_success()
cmd.LspRestart()
end
return t
end
local function invoke_gdb(t)
local function after_success()
cmd.cclose()
cmd.only()
cmd.packadd("termdebug")
cmd.Termdebug(t.cmd)
end
return {
cmd = "true",
after_success = after_success
}
end
cmake.tasks.configure = compose(compose(compose(cmake.tasks.configure, add_conan_options), close_qf), lsp_restart)
cmake.tasks.build = compose(cmake.tasks.build, close_qf)
cmake.tasks.debug = compose(cmake.tasks.run, invoke_gdb)
|