diff --git a/lua/Polydev/templates.lua b/lua/Polydev/templates.lua index f078454..35d64e7 100644 --- a/lua/Polydev/templates.lua +++ b/lua/Polydev/templates.lua @@ -94,24 +94,30 @@ setup( #include int main() { - printf("%s", "Hello World"); - return 0; + printf("%s", "Hello World"); + return 0; } ]]) utils.write_file({ full_project_root, "CMakeLists.txt" }, string.format([[ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(%s) -include_directories(include) -set(SOURCES src/main.c) -add_executable(%s ${SOURCES}) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_C_STANDARD 23) set(CMAKE_C_STANDARD_REQUIRED ON) +include_directories(include) -# find_package(SDL3 CONFIG REQUIRED) # An example of how to import libraries from vcpkg -# target_link_libraries(Game PRIVATE SDL3::SDL3) -]], project_name, project_name)) - local gitignore = { "build/" } +set(SOURCES + src/main.c +) + +add_executable(%s ${SOURCES}) + +# find_package(Curses REQUIRED) +# include_directories(${CURSES_INCLUDE_DIR}) +# target_link_libraries(%s ${CURSES_LIBRARIES}) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +]], project_name, project_name, project_name)) + local gitignore = { "build/", ".cache/" } utils.init_git(full_project_root, gitignore) vim.fn.system(string.format("cd %s/build && cmake -S .. -B . && cmake --build . && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. && ln -sf compile_commands.json ../compile_commands.json", full_project_root)) vim.cmd("edit " .. full_project_root .. "/src/main.c") @@ -127,25 +133,31 @@ set(CMAKE_C_STANDARD_REQUIRED ON) #include int main() { - std::cout << "Hello World" << std::endl; - return 0; + std::cout << "Hello World" << std::endl; + return 0; } ]]) utils.write_file({ full_project_root, "CMakeLists.txt" }, string.format([[ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(%s) -include_directories(include) -set(SOURCES src/main.cpp) -add_executable(%s ${SOURCES}) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_C_STANDARD 23) set(CMAKE_C_STANDARD_REQUIRED ON) +include_directories(include) -# find_package(SDL3 CONFIG REQUIRED) # An example of how to import libraries from vcpkg -# target_link_libraries(Game PRIVATE SDL3::SDL3) -]], project_name, project_name)) +set(SOURCES + src/main.cpp +) - local gitignore = { "build/" } +add_executable(%s ${SOURCES}) + +# find_package(Curses REQUIRED) +# include_directories(${CURSES_INCLUDE_DIR}) +# target_link_libraries(%s ${CURSES_LIBRARIES}) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +]], project_name, project_name, project_name)) + + local gitignore = { "build/", ".cache/" } utils.init_git(full_project_root, gitignore) vim.fn.system(string.format("cd %s/build && cmake -S .. -B . && cmake --build . && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. && ln -sf compile_commands.json ../compile_commands.json", full_project_root)) vim.cmd("edit " .. full_project_root .. "/src/main.cpp") diff --git a/lua/Polydev/utils.lua b/lua/Polydev/utils.lua index f17168e..763642c 100644 --- a/lua/Polydev/utils.lua +++ b/lua/Polydev/utils.lua @@ -1,15 +1,14 @@ - +local M = {} M.opts = {} function M.setup(opts) M.opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("terminal"), opts or {}) end -function exists(path) +function M.exists(path) return (io.open(path,"r") ~= nil) end - ---@return string function M.get_project_root() local plugin_dir = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":h:h:h")