REFACTOR: Annotations for autocompletion, reworked how projects are made
and handled, wrote the c file replacing the copied python code.
This commit is contained in:
+81
-21
@@ -21,10 +21,30 @@ main()
|
||||
File: __init__.py
|
||||
Target: src/{project_name}/__init__.py
|
||||
===================================================================== --]]
|
||||
__init__ = vim.trim([=[
|
||||
# %s init
|
||||
|
||||
__all__: list[str] = []
|
||||
format = vim.trim([=[
|
||||
---
|
||||
BasedOnStyle: Google
|
||||
Standard: Latest
|
||||
UseTab: Always
|
||||
TabWidth: 8
|
||||
IndentWidth: 8
|
||||
BreakBeforeBraces: Allman
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
SeparateDefinitionBlocks: Always
|
||||
Cpp11BracedListStyle: false
|
||||
BreakAfterReturnType: TopLevel
|
||||
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
|
||||
IndentGotoLabels: InnerIndent
|
||||
DerivePointerAlignment: false
|
||||
PointerAlignment: Left
|
||||
IndentPPDirectives: AfterHash
|
||||
SortIncludes: CaseSensitive
|
||||
IncludeBlocks: Preserve
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
@@ -32,21 +52,28 @@ __all__: list[str] = []
|
||||
File: pyproject.toml
|
||||
Target: pyproject.toml
|
||||
===================================================================== --]]
|
||||
pyproject = vim.trim([=[
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
CmakeLists = vim.trim([=[
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(__PROJECT_NAME__ LANGUAGES C)
|
||||
set(CMAKE_C_STANDARD 23)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
[project]
|
||||
name = "%s"
|
||||
version = "0.1.0"
|
||||
description = "Project %s"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
dependencies = []
|
||||
add_library(__PROJECT_NAME__ STATIC
|
||||
# Add your other types here as you implement them:
|
||||
# src/example1.c
|
||||
# src/example2.c
|
||||
)
|
||||
|
||||
[project.scripts]
|
||||
%s = "%s.main:main"
|
||||
target_include_directories(__PROJECT_NAME__
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
add_executable(__PROJECT_NAME___bin src/main.c)
|
||||
set_target_properties(__PROJECT_NAME___bin PROPERTIES OUTPUT_NAME "__PROJECT_NAME__")
|
||||
|
||||
target_link_libraries(__PROJECT_NAME___bin PRIVATE __PROJECT_NAME__)
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
@@ -54,9 +81,42 @@ dependencies = []
|
||||
File: {name}.py
|
||||
Target: src/{project_name}/{name}.py
|
||||
===================================================================== --]]
|
||||
module = vim.trim([=[
|
||||
"""
|
||||
Module: %s
|
||||
"""
|
||||
header = vim.trim([=[
|
||||
#ifndef __PROJECT_NAME___H
|
||||
#define __PROJECT_NAME___H
|
||||
|
||||
// Code
|
||||
|
||||
#endif /* __PROJECT_NAME___H */
|
||||
]=]) .. "\n",
|
||||
|
||||
source = vim.trim([=[
|
||||
]=]) .. "\n",
|
||||
|
||||
linter = vim.trim([=[
|
||||
Checks: >
|
||||
-*,
|
||||
clang-analyzer-*,
|
||||
bugprone-*,
|
||||
-bugprone-easily-swappable-parameters,
|
||||
-bugprone-reserved-identifier,
|
||||
performance-*,
|
||||
security-*
|
||||
|
||||
readability-redundant-declaration
|
||||
readability-misleading-indentation
|
||||
readability-implicit-bool-conversion
|
||||
misc-misplaced-const,
|
||||
misc-include-cleaner
|
||||
|
||||
-bugprone-narrowing-conversions,
|
||||
-readability-identifier-length
|
||||
CheckOptions:
|
||||
readability-identifier-naming.VariableCase: lower_case
|
||||
readability-identifier-naming.FunctionCase: lower_case
|
||||
readability-identifier-naming.StructCase: lower_case
|
||||
readability-identifier-naming.EnumCase: CamelCase
|
||||
readability-identifier-naming.EnumConstantCase: UPPER_CASE
|
||||
readability-identifier-naming.MacroDefinitionCase: UPPER_CASE
|
||||
]=]) .. "\n",
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
local M = {}
|
||||
|
||||
---@param path string Filetype of template
|
||||
---@param kind_path string Filetype of template
|
||||
---@param kind string Template in language table
|
||||
---@param name string A string to replace temp values in template
|
||||
---@return string
|
||||
---@return string Content Formatted string
|
||||
function M.fetch(kind_path, kind, name)
|
||||
kind_path, kind, name = kind_path or "", kind or "", name or ""
|
||||
if kind_path == "" or kind == "" or name == "" then
|
||||
kind, name = kind or "", name or ""
|
||||
if (kind == "" or nil) or (name == "" or nil) then
|
||||
return ""
|
||||
end
|
||||
local ok, mod = pcall(require, kind_path)
|
||||
if ok and type(mod) == "table" then
|
||||
return (string.gsub(mod[kind], "%%s", name))
|
||||
return (string.gsub(mod[kind], "__PROJECT_NAME__", name))
|
||||
end
|
||||
return ""
|
||||
end
|
||||
|
||||
@@ -6,7 +6,7 @@ return {
|
||||
===================================================================== --]]
|
||||
main = vim.trim([=[
|
||||
def main() -> None:
|
||||
print("Hello from %s!")
|
||||
print("Hello from __PROJECT_NAME__!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@@ -19,7 +19,7 @@ if __name__ == "__main__":
|
||||
Target: src/{project_name}/__init__.py
|
||||
===================================================================== --]]
|
||||
__init__ = vim.trim([=[
|
||||
# %s init
|
||||
# __PROJECT_NAME__ init
|
||||
|
||||
__all__: list[str] = []
|
||||
]=]) .. "\n",
|
||||
@@ -35,15 +35,15 @@ requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "%s"
|
||||
name = "__PROJECT_NAME__"
|
||||
version = "0.1.0"
|
||||
description = "Project %s"
|
||||
description = "Project __PROJECT_NAME__"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
dependencies = []
|
||||
|
||||
[project.scripts]
|
||||
%s = "%s.main:main"
|
||||
__PROJECT_NAME__ = "__PROJECT_NAME__.main:main"
|
||||
]=]) .. "\n",
|
||||
|
||||
--[[ =====================================================================
|
||||
@@ -53,7 +53,7 @@ dependencies = []
|
||||
===================================================================== --]]
|
||||
module = vim.trim([=[
|
||||
"""
|
||||
Module: %s
|
||||
Module: __PROJECT_NAME__
|
||||
"""
|
||||
]=]) .. "\n",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user