- Set up project structure and Source of Truth (GEMINI.md). - Implement DNA source files (src/*.yaml) with semantic color definitions. - Build clinical light (Aeon) and high-contrast dark (Neon) specifications. - Create Jinja2-based build system (build.py) using uv for reproducibility. - Implement Neovim theme template mirroring the philosophy.
65 lines
2.6 KiB
Python
65 lines
2.6 KiB
Python
import yaml
|
|
import os
|
|
from jinja2 import Environment, FileSystemLoader
|
|
|
|
# Configuration
|
|
SRC_DIR = 'src'
|
|
TEMPLATES_DIR = 'templates'
|
|
DIST_DIR = 'dist'
|
|
SCHEMES = ['neon.yaml', 'aeon.yaml']
|
|
|
|
def load_scheme(filename):
|
|
with open(os.path.join(SRC_DIR, filename), 'r') as f:
|
|
return yaml.safe_load(f)
|
|
|
|
def render_template(template_path, context):
|
|
env = Environment(loader=FileSystemLoader(TEMPLATES_DIR))
|
|
template = env.get_template(template_path)
|
|
return template.render(context)
|
|
|
|
def build():
|
|
# Ensure dist directory exists
|
|
if not os.path.exists(DIST_DIR):
|
|
os.makedirs(DIST_DIR)
|
|
|
|
for scheme_file in SCHEMES:
|
|
scheme_data = load_scheme(scheme_file)
|
|
scheme_name_slug = scheme_data['scheme'].lower().replace(' ', '-')
|
|
print(f"Building {scheme_data['scheme']}...")
|
|
|
|
# Find all templates
|
|
for root, dirs, files in os.walk(TEMPLATES_DIR):
|
|
for file in files:
|
|
if file.endswith('.j2'):
|
|
# Calculate relative path to mirror structure in dist
|
|
rel_path = os.path.relpath(root, TEMPLATES_DIR)
|
|
template_rel_path = os.path.join(rel_path, file)
|
|
|
|
# Prepare output path
|
|
output_filename = file.replace('.j2', '')
|
|
# If the template is generic (apex.lua), rename it to the scheme name (apex-neon.lua)
|
|
if 'apex' in output_filename:
|
|
output_filename = output_filename.replace('apex', scheme_name_slug)
|
|
|
|
output_dir = os.path.join(DIST_DIR, scheme_name_slug, rel_path)
|
|
if not os.path.exists(output_dir):
|
|
os.makedirs(output_dir)
|
|
|
|
output_path = os.path.join(output_dir, output_filename)
|
|
|
|
# Render and write
|
|
# We pass template_rel_path because jinja loader is rooted at TEMPLATES_DIR
|
|
# But os.walk returns paths relative to CWD usually, but we constructed it.
|
|
# Actually Environment loader is correct. We just need the path relative to templates dir.
|
|
template_name_for_jinja = template_rel_path
|
|
|
|
rendered_content = render_template(template_name_for_jinja, scheme_data)
|
|
|
|
with open(output_path, 'w') as f:
|
|
f.write(rendered_content)
|
|
|
|
print(f" -> {output_path}")
|
|
|
|
if __name__ == '__main__':
|
|
build()
|