fix: changed formatting and defaults for c/c++

This commit is contained in:
DarthMooMancer
2025-09-01 00:36:35 -04:00
parent 0cc4374865
commit bc825895ac
2 changed files with 36 additions and 25 deletions
+30 -18
View File
@@ -99,19 +99,25 @@ int main() {
} }
]]) ]])
utils.write_file({ full_project_root, "CMakeLists.txt" }, string.format([[ utils.write_file({ full_project_root, "CMakeLists.txt" }, string.format([[
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.16)
project(%s) 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 23)
set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD_REQUIRED ON)
include_directories(include)
# find_package(SDL3 CONFIG REQUIRED) # An example of how to import libraries from vcpkg set(SOURCES
# target_link_libraries(Game PRIVATE SDL3::SDL3) src/main.c
]], project_name, project_name)) )
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) 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.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") vim.cmd("edit " .. full_project_root .. "/src/main.c")
@@ -132,20 +138,26 @@ int main() {
} }
]]) ]])
utils.write_file({ full_project_root, "CMakeLists.txt" }, string.format([[ utils.write_file({ full_project_root, "CMakeLists.txt" }, string.format([[
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.16)
project(%s) 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 23)
set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD_REQUIRED ON)
include_directories(include)
# find_package(SDL3 CONFIG REQUIRED) # An example of how to import libraries from vcpkg set(SOURCES
# target_link_libraries(Game PRIVATE SDL3::SDL3) src/main.cpp
]], project_name, project_name)) )
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) 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.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") vim.cmd("edit " .. full_project_root .. "/src/main.cpp")
+2 -3
View File
@@ -1,15 +1,14 @@
local M = {}
M.opts = {} M.opts = {}
function M.setup(opts) function M.setup(opts)
M.opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("terminal"), opts or {}) M.opts = vim.tbl_deep_extend("force", {}, require("Polydev.configs").get("terminal"), opts or {})
end end
function exists(path) function M.exists(path)
return (io.open(path,"r") ~= nil) return (io.open(path,"r") ~= nil)
end end
---@return string ---@return string
function M.get_project_root() function M.get_project_root()
local plugin_dir = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":h:h:h") local plugin_dir = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":h:h:h")