Changes and fixes to c++ project creation

This commit is contained in:
DarthMooMancer
2025-04-25 09:04:59 -04:00
parent 546d204f9d
commit e2ebe918bd
3 changed files with 27 additions and 33 deletions
+10 -10
View File
@@ -21,6 +21,16 @@ function M.setup(opts)
end
end
function M.get_project_root()
local dir = vim.fn.expand("%:p:h")
while dir ~= "/" do
if vim.fn.isdirectory(dir .. "/src") == 1 or vim.fn.filereadable(dir .. "/CMakeLists.txt") == 1 then
return dir
end
dir = vim.fn.fnamemodify(dir, ":h")
end
end
function M.create_new_header_file()
vim.ui.input({ prompt = "Enter header file name: " }, function(header_name)
if not header_name then return print("Header file creation canceled.") end
@@ -42,16 +52,6 @@ void example_function();
end)
end
function M.get_project_root()
local dir = vim.fn.expand("%:p:h")
while dir ~= "/" do
if vim.fn.isdirectory(dir .. "/src") == 1 or vim.fn.filereadable(dir .. "/CMakeLists.txt") == 1 then
return dir
end
dir = vim.fn.fnamemodify(dir, ":h")
end
end
function M.run()
local root = M.get_project_root()
if not root then return print("Error: Project root not found.") end