diff --git a/lua/Polydev/languages.lua b/lua/Polydev/languages.lua index 719e37c..ceea957 100644 --- a/lua/Polydev/languages.lua +++ b/lua/Polydev/languages.lua @@ -66,11 +66,11 @@ M.languages = { if not success then local term_buf = utils.terminal({ cmd }) - vim.api.nvim_set_option_value("modifiable", true, { win = term_buf }) + vim.api.nvim_set_option_value("modifiable", true, { buf = term_buf }) vim.api.nvim_buf_set_lines(term_buf, 0, -1, false, vim.list_extend({ "Error during compilation:" }, vim.split(output, "\n", { trimempty = true })) ) - vim.api.nvim_set_option_value("modifiable", false, { win = term_buf }) + vim.api.nvim_set_option_value("modifiable", false, { buf = term_buf }) end if success then local run_cmd = "cd '" .. build_dir .. "' && ./" .. utils.get_project_name() diff --git a/lua/Polydev/templates.lua b/lua/Polydev/templates.lua index a959aec..7a9bf2d 100644 --- a/lua/Polydev/templates.lua +++ b/lua/Polydev/templates.lua @@ -87,6 +87,27 @@ setup( run = function(project_name, project_root) local full_project_root = vim.fn.expand(project_root) .. "/" .. project_name for _, path in ipairs({ "/src", "/build", "/include" }) do vim.fn.mkdir(full_project_root .. path, "p") end + utils.write_file({ full_project_root, ".clang-format" }, [[ +--- +BasedOnStyle: Google +Standard: Latest +UseTab: Always +TabWidth: 8 +IndentWidth: 8 +BreakBeforeBraces: Allman +SpaceBeforeCpp11BracedList: true +SeparateDefinitionBlocks: Always +Cpp11BracedListStyle: false +BreakAfterReturnType: TopLevel +AlignTrailingComments: + Kind: Always +ReflowComments: Always +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: AllIfsAndElse +AllowShortLoopsOnASingleLine: true +IndentAccessModifiers: false # Indent access specifiers by one level +AccessModifierOffset: -4 # Optional: adjust offset relative to the class indentation level +]]) utils.write_file({ full_project_root, "src/main.c" }, [[ #include @@ -101,7 +122,7 @@ set(CMAKE_C_STANDARD 23) set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) include_directories(include) -project(%s) +project(%s LANGUAGES C) set(SOURCES src/main.c @@ -121,6 +142,28 @@ add_executable(%s ${SOURCES}) for _, path in ipairs({ "/src", "/build", "/include" }) do vim.fn.mkdir(full_project_root .. path, "p") end + utils.write_file({ full_project_root, ".clang-format" }, [[ +--- +BasedOnStyle: Google +Standard: Latest +UseTab: Always +TabWidth: 8 +IndentWidth: 8 +BreakBeforeBraces: Allman +SpaceBeforeCpp11BracedList: true +SeparateDefinitionBlocks: Always +Cpp11BracedListStyle: false +BreakAfterReturnType: TopLevel +AlignTrailingComments: + Kind: Always +ReflowComments: Always +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: AllIfsAndElse +AllowShortLoopsOnASingleLine: true +IndentAccessModifiers: false # Indent access specifiers by one level +AccessModifierOffset: -4 # Optional: adjust offset relative to the class indentation level +]]) + utils.write_file({ full_project_root, "src/main.cpp" }, [[ #include @@ -135,7 +178,7 @@ set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -project(%s) +project(%s LANGUAGES CXX) set(SOURCES @@ -143,8 +186,7 @@ set(SOURCES ) add_executable(%s ${SOURCES}) -target_include_directories(%s PRIVATE include) -]], project_name, project_name, project_name, project_name)) +]], project_name, project_name)) local gitignore = { "build/", ".cache/" } utils.init_git(full_project_root, gitignore)