Lumerical Script Language Support for VS Code

A Visual Studio Code extension that provides syntax highlighting, code snippets, and language support for Lumerical Script Language (.lsf files).
Features
📝 Syntax Highlighting
- Full syntax highlighting for Lumerical Script Language (MATLAB-like syntax)
- Support for all Lumerical built-in commands (765+ commands)
- Color coding for:
- Keywords:
if, else, elseif, for, while, switch, case, otherwise, try, catch, break, continue, return, end, function
- Data types:
double, single, int8-64, uint8-64, logical, char, string, struct, cell, table
- Constants:
pi, eps0, inf, NaN, true, false, i, j, realmax, realmin
- Operators: arithmetic, logical, relational, transpose, field access, line continuation
- Strings: single and double quoted with escape sequences
- Numbers: integers, floats, scientific notation
- Comments: line comments with
#
💡 Intelligent Code Snippets
- 765+ Lumerical commands with auto-completion
- Snippets automatically insert command with parentheses:
command($1)
- Quick access to common Lumerical functions and operations
🔧 Language Features
- Bracket matching and auto-closing
- Comment toggling with
#
- Code folding for blocks
- Syntax-aware highlighting
Installation
From VS Code Marketplace
- Open VS Code
- Go to Extensions view (Ctrl+Shift+X)
- Search for "Lumerical Script Language"
- Click Install
Manual Installation
- Download the
.vsix package from Releases
- Open VS Code
- Go to Extensions view (Ctrl+Shift+X)
- Click "..." menu and select "Install from VSIX..."
- Select the downloaded file
From Source
git clone https://github.com/ErwenL/lumerical-script-language.git
cd lumerical-script-language
npm install
npm run compile
Then press F5 to open a new VS Code window with the extension loaded.
Usage
Creating Lumerical Script Files
- Create a new file with
.lsf extension
- VS Code will automatically recognize it as Lumerical Script
- Start typing Lumerical commands - syntax highlighting will activate immediately
Using Code Snippets
- Type the prefix of a Lumerical command (e.g.,
add2d)
- Press
Ctrl+Space to trigger IntelliSense
- Select the desired command from the list
- Press
Tab to navigate through snippet placeholders
Example Script
# Sample Lumerical script
x = 5;
y = 3.14;
z = 1i + 2j;
# Constants and operators
a = pi;
sum = x + y;
transpose_matrix = matrix';
# Control flow
if x > 0
disp('positive');
else
disp('non-positive');
end
# Lumerical specific commands
add2drect;
selectall;
Syntax Support Details
Supported Language Elements
- Control Structures:
if, else, elseif, for, while, switch, case, otherwise, try, catch
- Functions:
function definitions and calls
- Operators:
- Arithmetic:
+, -, *, /, ^, .*, ./, .\, .^
- Logical:
&, &&, |, ||, ~, ==, ~=, ~==
- Relational:
>, >=, <, <=
- Transpose:
', .'
- Field access:
. (for property access)
- Line continuation:
...
- Data Types: All MATLAB-compatible numeric and container types
- Literals: Matrix
[], cell {}, string "" and ''
- Comments: Single line with
#
File Association
- Primary extension:
.lsf
- Language ID:
lumscript
- Language name: "Lumerical Script"
Configuration
The extension works out of the box with no configuration required. However, you can customize the following in your VS Code settings:
{
"[lumscript]": {
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.formatOnSave": false
}
}
Known Issues
- Limited semantic analysis (syntax highlighting only)
- No parameter hints for Lumerical command arguments
- No integrated documentation lookup
These limitations are due to the lack of public Lumerical Script Language specification. Contributions to improve these areas are welcome!
Development
Project Structure
lumerical-script-language/
├── syntaxes/
│ └── lumscript.tmLanguage.json # TextMate grammar for syntax highlighting
├── language-configuration.json # Language configuration
├── snippets.json # Code snippets (765+ commands)
├── references/
│ ├── lumscript_command.csv # Command database
│ ├── matlab.json # MATLAB grammar reference
│ └── python_example.json # Python grammar reference
├── package.json # Extension manifest
└── sample.lsf # Example script
Building from Source
- Clone the repository
- Install dependencies:
npm install
- Open in VS Code:
code .
- Press
F5 to start debugging
Testing
- Open the
sample.lsf file in the project
- Verify syntax highlighting appears correctly
- Test code snippets by typing command prefixes
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
Areas for contribution:
- Improve grammar coverage
- Add more code snippets with parameters
- Implement Language Server Protocol (LSP) features
- Add integrated documentation
Release Notes
0.0.1
- Initial release
- Basic syntax highlighting for Lumerical Script Language
- 765+ code snippets for Lumerical commands
- Language configuration for
.lsf files
- Support for MATLAB-like syntax elements
License
This extension is licensed under the MIT License.
Acknowledgments
- Based on MATLAB and Python TextMate grammars
- Command list sourced from Lumerical documentation
- Inspired by the need for better Lumerical script editing tools
Support
- Issues: Report bugs or request features on GitHub Issues
- Questions: Use GitHub Discussions for questions and discussions
Enjoy better Lumerical script editing with VS Code! 🚀
| |