A powerful Language Server Protocol (LSP) implementation for Go templates with type checking and advanced features.
+------------------+
| VSCode/Editor |
+--------+---------+
|
| LSP Protocol
|
+--------+---------+
| Template LSP |
| Server |
+--------+---------+
|
+------------+------------+
| |
+--------+--------+ +--------+--------+
| Go Template | | Type System |
| Parser | | Analyzer |
+----------------+ +----------------+
- 🎯 Go template parsing and validation
- 🔍 Type checking for template variables
- 💡 Intelligent code completion
- 📝 Hover information
- 🎨 Semantic token highlighting
- 🐛 Error diagnostics
- 🔄 Live template validation
The extension provides rich semantic highlighting for:
{{ .Name }} // Variable access
{{ .GetAge }} // Method calls
{{ if .Ready }} // Keywords
{{ range . }} // Block delimiters
Supported token types:
- Delimiters (
{{
,}}
) - Functions
- Variables
- Types
- Strings
- Comments
- Keywords
- Operators
- Install the extension from VSCode marketplace
- Make sure you have Go installed
- Open a workspace with Go templates
- Create a Go template file (
.tmpl
or.gotmpl
) - Add type annotations:
{{- /*gotype: mypackage.MyType*/ -}} {{ .Field }}
- Enjoy rich IDE features!
- Go 1.21+
- VSCode
# Install dependencies
go mod tidy
# Run tests
go test ./...
# Build the extension
task build
graph TD
A[Editor] -->|LSP| B[LSP Server]
B --> C[Template Parser]
B --> D[Type Checker]
C --> E[AST]
D --> F[Go Types]
E --> G[Semantic Tokens]
F --> H[Type Information]
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
MIT License - see LICENSE file for details