diff options
| author | Kyren223 <ulmliad223@gmail.com> | 2024-08-05 16:26:54 +0300 |
|---|---|---|
| committer | Kyren223 <ulmliad223@gmail.com> | 2024-08-05 16:26:54 +0300 |
| commit | 6abe2a79f71401003134d967327d4ee526ed12ae (patch) | |
| tree | 6e6f824d7c622e706bd59a13d8dfe6fbe0c4b7a5 /.config/nvim/lua/overseer/template/custom/make_c_file.lua | |
| parent | d296700cb3a8fa7909e38b8bfcb15ddf1b811e25 (diff) | |
feat(nvim): setup overseer for C with cmake
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.lua | 33 |
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, + }, +} |
