summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/overseer/template/custom/make_c_file.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/overseer/template/custom/make_c_file.lua')
-rw-r--r--.config/nvim/lua/overseer/template/custom/make_c_file.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/.config/nvim/lua/overseer/template/custom/make_c_file.lua b/.config/nvim/lua/overseer/template/custom/make_c_file.lua
new file mode 100644
index 0000000..75f89d0
--- /dev/null
+++ b/.config/nvim/lua/overseer/template/custom/make_c_file.lua
@@ -0,0 +1,33 @@
+local overseer = require('overseer')
+return {
+ name = 'Make Current C file',
+ builder = function(_)
+ local path = vim.fn.expand('%:p')
+ local dir, file = path:gmatch('(.*)[/\\](.*)')()
+ file = string.sub(file, 1, -3) -- remove .c extension
+
+ return {
+ cmd = { 'make' },
+ args = { file },
+ cwd = dir,
+ }
+ end,
+ tags = { overseer.TAG.BUILD },
+ priority = 50,
+ condition = {
+ filetype = { 'c' },
+ callback = function()
+ -- Disable if already using make/cmake
+ local filename = vim.fn.expand('%:p')
+ local root_dir = require('lspconfig/util').root_pattern(
+ 'Makefile',
+ 'build/Makefile',
+ 'CMakePresets.json',
+ 'CTestConfig.cmake',
+ 'build',
+ 'cmake'
+ )(filename)
+ return root_dir == nil
+ end,
+ },
+}