GOSU Language Support for VSCode
This extension provides syntax highlighting and language support for the GOSU programming language in Visual Studio Code.
Features
Supported File Extensions
.gs - GOSU class files
.gsx - GOSU enhancement files
.gst - GOSU template files
.gsp - GOSU program files
Development Setup
Prerequisites
Building the Extension
Clone the repository:
git clone <repository-url>
cd gosu-language-support
Install dependencies:
npm install
Compile the TypeScript source:
npm run compile
Run tests (optional):
npm test
Installing Locally in VSCode
Method 1: Using VSCode Extension Development Host
Open the project in VSCode:
code .
Press F5 or go to Run > Start Debugging
- This will open a new VSCode window with the extension loaded
- The extension will be active in this development window
- Any changes you make will require reloading the window
Method 2: Package and Install as VSIX
Install the VSCode Extension Manager (if not already installed):
npm install -g @vscode/vsce
Package the extension:
vsce package
This creates a .vsix file (e.g., gosu-language-support-1.0.0.vsix )
Install the packaged extension:
code --install-extension gosu-language-support-1.0.0.vsix
Or manually in VSCode:
- Open VSCode
- Go to Extensions view (
Ctrl+Shift+X )
- Click the ... menu in the Extensions view
- Select Install from VSIX...
- Choose the generated
.vsix file
Reload VSCode to activate the extension
Method 3: Symlink to Extensions Directory
Find your VSCode extensions directory:
- Windows:
%USERPROFILE%\.vscode\extensions
- macOS:
~/.vscode/extensions
- Linux:
~/.vscode/extensions
Create a symlink (after building):
# Windows (run as Administrator)
mklink /D "%USERPROFILE%\.vscode\extensions\gosu-language-support" "C:\path\to\your\project"
# macOS/Linux
ln -s /path/to/your/project ~/.vscode/extensions/gosu-language-support
Reload VSCode
Development Commands
- Compile:
npm run compile - Compile TypeScript to JavaScript
- Watch:
npm run watch - Compile in watch mode for development
- Test:
npm test - Run all tests with Vitest
- Test Watch:
npm run test:watch - Run tests in watch mode
- Test Coverage:
npm run test:coverage - Run tests with coverage report
- Lint:
npm run lint - Run ESLint on source files
- Package:
vsce package - Create a .vsix package file
Project Structure
gosu-language-support/
├── src/ # TypeScript source files
│ ├── extension.ts # Main extension entry point
│ ├── extension.test.ts # Extension tests
│ └── utils/
│ ├── gosuUtils.ts # GOSU utility functions
│ └── gosuUtils.test.ts # Utility tests
├── syntaxes/
│ └── gosu.tmLanguage.json # TextMate grammar for syntax highlighting
├── examples/ # Example GOSU files
│ ├── HelloWorld.gs
│ ├── Enhancement.gsx
│ └── Interface.gs
├── out/ # Compiled JavaScript (generated)
├── language-configuration.json # Language configuration
├── package.json # Extension manifest
└── README.md
Testing
The extension uses Vitest for testing:
- Unit tests: Test utility functions and core logic
- Extension tests: Test extension activation and VSCode integration
- Mocked VSCode APIs: Tests run without requiring VSCode environment
Run tests:
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage
Debugging
- Open the project in VSCode
- Set breakpoints in your TypeScript source files
- Press F5 to start debugging
- Use the Extension Development Host window to test your extension
- Debug output appears in the original VSCode window's Debug Console
Publishing
To publish to the VSCode Marketplace:
Create a publisher account at Visual Studio Marketplace
Update package.json with your publisher name:
{
"publisher": "your-publisher-name"
}
Create a Personal Access Token in Azure DevOps
Login with vsce:
vsce login your-publisher-name
Publish:
vsce publish
Troubleshooting
Extension Not Loading
- Ensure you've compiled the TypeScript:
npm run compile
- Check the Developer Console for errors: Help > Toggle Developer Tools
- Verify the extension is installed: Extensions > Installed
Syntax Highlighting Not Working
- Check that GOSU files have the correct extensions (
.gs , .gsx , .gst , .gsp )
- Verify the language is detected: Check the language indicator in the status bar
- Reload VSCode window: Developer > Reload Window
Build Errors
- Ensure Node.js version 16 or higher is installed
- Clear node_modules and reinstall:
rm -rf node_modules package-lock.json && npm install
- Check TypeScript compilation:
npm run compile
Examples
The extension includes example GOSU files in the test-workspace/ directory:
sample.gs - Basic class and property examples
gosu-syntax-full-sample.gsx - GOSU enhancement features
GOSU Language Resources
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature
- Make your changes
- Add tests for new functionality
- Run tests:
npm test
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin feature/your-feature
- Submit a pull request
License
This extension is licensed under the MIT License. See the LICENSE file for details.
| |