39 lines
817 B
Lua
39 lines
817 B
Lua
local M = {}
|
|
|
|
function M.get_cmake_project_file()
|
|
return vim.fn.findfile('CMakeLists.txt', '.;')
|
|
end
|
|
|
|
function M.in_cmake_project()
|
|
return M.get_cmake_project_file() ~= ''
|
|
end
|
|
|
|
function M.get_cargo_project_file()
|
|
return vim.fn.findfile('Cargo.toml', '.;')
|
|
end
|
|
|
|
function M.in_cargo_project()
|
|
return M.get_cargo_project_file() ~= ''
|
|
end
|
|
|
|
function M.in_git_project()
|
|
return vim.fn.finddir('.git', '.;') ~= ''
|
|
end
|
|
|
|
-- TODO: is there some better way to do this?
|
|
-- TODO: also add `in_golang_project()` function to detect based on presence of go.mod file?
|
|
function M.is_golang_filetype()
|
|
return M.contains({ 'go', 'gomod', 'gosum', 'gotmpl' }, vim.bo.filetype)
|
|
end
|
|
|
|
function M.contains(tbl, v)
|
|
for i, value in ipairs(tbl) do
|
|
if value == v then
|
|
return true
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
|
|
return M
|