--- Personal lua config files for NeoVim. -- Last Changed: 2023-02-08 -- Author: Federico Igne -- 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, 'cb', 'Task start cmake build') map.b.nore.n(0, 'cc', 'Task start cmake configure') map.b.nore.n(0, 'cg', 'Task start cmake debug') map.b.nore.n(0, 'cdu', 'Task start docker up') map.b.nore.n(0, 'cdd', 'Task start docker down') map.b.nore.n(0, 'cr', 'Task start cmake run') map.b.nore.n(0, 'ct', 'Task set_module_param cmake target') 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)