Development Documentation

Welcome to the development documentation for typstwriter.nvim. This section contains technical information for contributors and advanced users.

Architecture Overview

typstwriter.nvim is designed as a metadata-driven Typst writing system with a modular architecture:

Development Resources

Core Architecture

Command System

Module Structure

1
2
3
4
5
6
7
8
lua/typstwriter/
├── init.lua          # Main entry point, plugin setup, command creation
├── config.lua        # Configuration management with defaults and validation
├── templates.lua     # Template discovery, validation, and document creation
├── compiler.lua      # Typst compilation, PDF opening, status checking
├── metadata.lua      # Native Typst metadata parsing using `typst query`
├── utils.lua         # Utility functions (filename generation, system checks)
└── linking.lua       # Future: Document linking system

Development Workflow

Setup Development Environment

1
2
3
4
5
6
7
8
9
10
11
12
# Clone the repository
git clone https://github.com/gl1tchc0d3r/typstwriter.nvim.git
cd typstwriter.nvim

# Install development dependencies
make install-deps

# Run tests
make test

# Check code quality
make check

Development Commands

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Testing
make test              # Run passing integration tests (7 tests)
make test-all          # Run all tests (includes unit tests)
make test-coverage     # Generate coverage report
make test-watch        # Watch mode for development

# Code Quality
make format            # Format code with StyLua
make lint              # Lint with luacheck
make format-check      # Check formatting without changes
make check             # Run all quality checks

# CI/CD
make ci                # Full CI pipeline locally

# Shortcuts
make f                 # format
make l                 # lint  
make c                 # check
make t                 # test
make tc                # test-coverage

Testing Strategy

typstwriter.nvim uses a pragmatic two-tier testing approach:

Production Tests (spec/integration_spec.lua)

Development Tests (spec/*_spec.lua)

Key Design Patterns

Metadata-First Approach

All templates use #metadata((...)) blocks parsed via typst query:

#metadata((
  type: "note",
  title: "My Document",
  date: "2024-01-15",
  tags: ("example",),
))

Configuration System

Template Discovery Process

  1. Scan template_dir for .typ files
  2. Query each file using typst query for metadata
  3. Validate required fields (type, title)
  4. Build template registry with fallback handling

Future Architecture (PKS Evolution)

The plugin is designed to evolve into a Personal Knowledge System:

Phase 1: Enhanced Linking

Phase 3: Visual Relationship Mapping

Phase 4: Local AI Integration

Contributing

Code Style

Testing Requirements

Branch Protection

Getting Help


typstwriter.nvim - Built with quality, designed for the future of knowledge management.