Language Server Protocol implementation for Crystal Description Language
Project description
CDL Language Server
A Language Server Protocol (LSP) implementation for the Crystal Description Language (CDL).
Part of the Gemmology Project.
Features
- 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
pip install cdl-lsp
Dependencies
The package requires:
cdl-parser>=1.0.0- CDL parsing librarypygls>=1.0.0- Python language server frameworklsprotocol>=2023.0.0- LSP type definitions
Usage
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)
Editor Integration
VS Code
Install the CDL extension from the VS Code marketplace, or configure manually:
{
"cdl.server.path": "cdl-lsp"
}
Neovim (nvim-lspconfig)
require('lspconfig').cdl_lsp.setup{
cmd = {'cdl-lsp'},
filetypes = {'cdl'},
}
Sublime Text (LSP)
Add to LSP settings:
{
"clients": {
"cdl": {
"command": ["cdl-lsp"],
"selector": "source.cdl"
}
}
}
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
API Reference
Constants
from cdl_lsp.constants import (
CRYSTAL_SYSTEMS, # Set of crystal system names
POINT_GROUPS, # Dict mapping system to point groups
ALL_POINT_GROUPS, # Set of all 32 point groups
TWIN_LAWS, # Set of twin law names
NAMED_FORMS, # Dict mapping form names to Miller indices
MODIFICATIONS, # Set of modification names
)
Server
The LSP server handles all features internally. Use the server module to start the language server:
from cdl_lsp import create_server, SERVER_NAME, SERVER_VERSION
server = create_server()
print(f"Running {SERVER_NAME} v{SERVER_VERSION}")
server.start_io() # or server.start_tcp(host, port)
Development
Setup
git clone https://github.com/gemmology-dev/cdl-lsp
cd cdl-lsp
pip install -e ".[dev]"
Testing
pytest tests/ -v
Linting
ruff check src/
mypy src/
License
MIT License - see LICENSE for details.
Links
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gemmology_cdl_lsp-1.0.1.tar.gz.
File metadata
- Download URL: gemmology_cdl_lsp-1.0.1.tar.gz
- Upload date:
- Size: 46.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e22534534b81e48133b9c8756967dae2740b88dfbebeacf501112e171a02224c
|
|
| MD5 |
b1b0deae1cf1ba56fa3fae70bf7f9fec
|
|
| BLAKE2b-256 |
e43ce2bc24855c840512f3dee06e2b59b51f32f9a1212d7569420845bd3be7c2
|
Provenance
The following attestation bundles were made for gemmology_cdl_lsp-1.0.1.tar.gz:
Publisher:
pypi-publish.yml on gemmology-dev/cdl-lsp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gemmology_cdl_lsp-1.0.1.tar.gz -
Subject digest:
e22534534b81e48133b9c8756967dae2740b88dfbebeacf501112e171a02224c - Sigstore transparency entry: 855054710
- Sigstore integration time:
-
Permalink:
gemmology-dev/cdl-lsp@bae00d038491d7747ee37ac055c04c6066ff95d6 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/gemmology-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@bae00d038491d7747ee37ac055c04c6066ff95d6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file gemmology_cdl_lsp-1.0.1-py3-none-any.whl.
File metadata
- Download URL: gemmology_cdl_lsp-1.0.1-py3-none-any.whl
- Upload date:
- Size: 43.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c15188e475f4a360f0a437ccde8fff76ab2d3b8ea006e86c4f9387e3ef0b45b8
|
|
| MD5 |
390e80ad04ff390379212306a26a10a6
|
|
| BLAKE2b-256 |
d3ddc4777264443b400d8a9a463fa12e5d7dead284695c48a91ab3499835bdfc
|
Provenance
The following attestation bundles were made for gemmology_cdl_lsp-1.0.1-py3-none-any.whl:
Publisher:
pypi-publish.yml on gemmology-dev/cdl-lsp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gemmology_cdl_lsp-1.0.1-py3-none-any.whl -
Subject digest:
c15188e475f4a360f0a437ccde8fff76ab2d3b8ea006e86c4f9387e3ef0b45b8 - Sigstore transparency entry: 855054712
- Sigstore integration time:
-
Permalink:
gemmology-dev/cdl-lsp@bae00d038491d7747ee37ac055c04c6066ff95d6 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/gemmology-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@bae00d038491d7747ee37ac055c04c6066ff95d6 -
Trigger Event:
release
-
Statement type: