CDL Language Server¶
Language Server Protocol (LSP) Implementation for the Crystal Description Language (CDL).
Interactive companion
See live examples in the CDL Playground, browse 96+ rendered presets in the Crystal Gallery, or take a practice quiz on related material.
Overview¶
The CDL Language Server provides IDE features for editing CDL files:
- Diagnostics: Real-time error detection and warnings
- Completion: Context-aware autocomplete for systems, point groups, forms, and modifications
- Hover: Documentation on hover for CDL elements
- Go to Definition: Navigate to symbol definitions
- Formatting: Automatic CDL formatting
- Code Actions: Quick fixes for common errors
- Document Symbols: Outline view of CDL documents
- Signature Help: Parameter hints for modifications
Installation¶
Dependencies¶
gemmology-cdl-parser>=1.0.0- CDL parsing librarypygls>=1.0.0- Python language server frameworklsprotocol>=2023.0.0- LSP type definitions
Optional Dependencies¶
For live crystal preview:
Quick Start¶
From Command Line¶
# Standard I/O mode (default)
cdl-lsp
# TCP mode
cdl-lsp --tcp --host 127.0.0.1 --port 2087
# With logging
cdl-lsp --log-file /tmp/cdl-lsp.log --log-level DEBUG
From Python¶
from cdl_lsp import create_server
server = create_server()
server.start_io() # or server.start_tcp(host, port)
CDL Syntax Overview¶
The Crystal Description Language describes crystal morphologies:
# Basic forms
cubic[m3m]:{111} # Octahedron
cubic[m3m]:{100} # Cube
# Combined forms
cubic[m3m]:{111}@1.0 + {100}@1.3 # Truncated octahedron
# Named forms
cubic[m3m]:octahedron # Same as {111}
# Modifications
cubic[m3m]:{111}|elongate(c:1.5) # Elongated
cubic[m3m]:{111}|twin(spinel) # Twinned
# Different crystal systems
hexagonal[6/mmm]:{10-10}@1.0 + {0001}@0.5 # Hexagonal prism
trigonal[-3m]:{10-11} # Rhombohedron
Editor Integration¶
VS Code¶
Install the CDL extension from the VS Code marketplace, or configure manually in settings.json:
Neovim (nvim-lspconfig)¶
Sublime Text (LSP)¶
Add to LSP settings:
Related Packages¶
- cdl-parser - CDL parser library
- crystal-geometry - 3D geometry engine
- crystal-renderer - SVG/3D rendering
License¶
MIT License - see LICENSE for details.