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
|
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,
},
}
|