Groovy Language Server and VSCode Extension

A Visual Studio Code extension that provides Language Server Protocol (LSP) support for Groovy, enabling rich language features like syntax highlighting, code completion, diagnostics, and more.
Features
- Syntax Highlighting: Full TextMate grammar support for Groovy syntax
- Code Completion: Intelligent keyword and context-aware suggestions
- Go to Definition: Jump to the definition of classes, methods, properties, and variables
- Document Symbols: Navigate classes, methods, and properties with the outline view
- Diagnostics: Real-time syntax validation and error detection
- Hover Information: Display documentation for keywords and symbols
- Language Configuration: Auto-closing brackets, comment toggling, and proper indentation
Supported File Extensions
.groovy - Standard Groovy files
.gvy - Groovy script files
.gy - Groovy files
.gsh - Groovy shell scripts
Installation
From Source
Clone or navigate to this repository
Install dependencies:
npm install
Compile the extension:
npm run compile
Open VSCode and press F5 to launch the Extension Development Host
Package as VSIX
To package the extension for distribution:
npm install -g @vscode/vsce
vsce package
This creates a .vsix file that can be installed in VSCode via:
- Extensions panel →
... menu → Install from VSIX
Development
Project Structure
groovy-vscode/
├── client
│ ├── src
│ │ └── extension.ts
│ └── syntaxes
└── server
└── src
├── server.ts
├── test
│ └── languageServer.test.ts
└── utils.ts
Building
# Compile both client and server
npm run ci
# Watch mode (auto-compile on changes)
npm run watch
Debugging
- Open the project in VSCode
- Press
F5 or select "Launch Client" from the debug panel
- A new VSCode window (Extension Development Host) will open
- Open or create a
.groovy file to test the extension
To debug both client and server:
- Select "Client + Server" compound configuration
- Set breakpoints in either
client/src/extension.ts or server/src/server.ts
Future Enhancements
- Find References
- Rename refactoring
Testing the Extension
Before publishing, test the packaged extension:
Install the .vsix file locally in VS Code:
- Open VS Code
- Extensions panel →
... menu → Install from VSIX
- Select the generated
.vsix file
Test all features with .groovy files. Some files can be found in groovy/folder
Requirements
- Node.js 24.0 or higher
- VSCode 1.107.0 or higher
License
GPLv3
Contributing
Contributions are welcome! Feel free to:
- Report bugs
- Suggest new features
- Submit pull requests
Changelog
1.0.1
- Various maintenance (integration with github actions and megalinter)
- Remove code duplication, cleanup
- bump some dependencies
- Add icon
1.0.0 (Initial Release)
- Syntax highlighting via TextMate grammar
- Go to Definition for classes, methods, properties, and variables
- Document symbols (outline view)
- Hover information for keywords
- Basic syntax diagnostics
- Language configuration (brackets, comments, auto-closing)