Groovy Language Server and VSCode Extension

A Visual Studio Code extension that provides Language Server Protocol (LSP) support for Groovy and Jenkinsfile
Features
- 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
⚠️ Note: the default syntax highlighting for Groovy files is provided by a
TextMate rule embedded in VS
Code, not by this extension.
Jenkins specific features
- Syntax Highlighting: Full TextMate grammar support for Jenkinsfile
Extension Settings
| Setting |
Description |
Default |
| groovy.jenkins.sharedLibrary.srcPath |
Relative path to the Jenkins shared library src directory (containing classes and methods) |
src |
| groovy.jenkins.sharedLibrary.varsPath |
Relative path to the Jenkins shared library vars directory (containing global functions) |
vars |
Supported File Extensions
.groovy - Standard Groovy files
.gvy - Groovy script files
.gy - Groovy files
.gsh - Groovy shell scripts
Jenkinsfile, .jenkins, .pipeline - Jenkins 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
│ └── jenkinsfile.tmLanguage.json
└── 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 (or Jenkinsfile) files. Sample files can be found in groovy/folder
License
GPLv3
Contributing
Contributions are welcome! Feel free to:
- Report bugs
- Suggest new features
- Submit pull requests
Changelog
Check https://github.com/djukxe/groovy-vscode/releases