summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/overseer/template/custom/cmake_run.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/overseer/template/custom/cmake_run.lua')
-rw-r--r--.config/nvim/lua/overseer/template/custom/cmake_run.lua45
1 files changed, 45 insertions, 0 deletions
diff --git a/.config/nvim/lua/overseer/template/custom/cmake_run.lua b/.config/nvim/lua/overseer/template/custom/cmake_run.lua
new file mode 100644
index 0000000..cdb4d5c
--- /dev/null
+++ b/.config/nvim/lua/overseer/template/custom/cmake_run.lua
@@ -0,0 +1,45 @@
+local overseer = require('overseer')
+local root_pattern = require('lspconfig/util').root_pattern('CMakePresets.json', 'CTestConfig.cmake', 'build', 'cmake')
+return {
+ name = 'Run Cmake Project',
+ params = {
+ args = {
+ optional = true,
+ type = 'string',
+ },
+ },
+ builder = function(params)
+ local filename = vim.fn.expand('%:p')
+ local root_dir = root_pattern(filename)
+ local exe = vim.g.overseer_cmake_main_exe
+
+ -- Make sure params.args is a string
+ if not params.args or type(params.args) ~= 'string' then
+ params.args = ''
+ end
+
+ return {
+ name = 'Run ' .. exe,
+ cmd = './' .. 'Kalc ' .. params.args,
+ cwd = root_dir .. '/build',
+ }
+ end,
+ tags = { overseer.TAG.RUN },
+ priority = 41,
+ condition = {
+ callback = function()
+ local filename = vim.fn.expand('%:p')
+ local root_dir = root_pattern(filename)
+ if not root_dir then
+ return false, 'Unable to detect root directory of cmake project'
+ end
+
+ if not vim.g.overseer_cmake_main_exe then
+ return false,
+ 'Global "overseer_cmake_main_exe" must be defined. use `vim.g.overseer_cmake_main_exe = "Value"` to define it'
+ end
+
+ return true
+ end,
+ },
+}