TCL Language Support for VS Code
Enhanced TCL language support for Visual Studio Code with comprehensive syntax highlighting and language features.If you have any modification suggestions, please contact the author at email: wangxin01013235@163.com.
Features
Syntax Highlighting
- Comments: Single-line comments starting with
#
- Variables: Support for
$var, ${var}, and array variables $arr(index)
- Function Calls: Command substitution with
[func args] syntax
- Strings: Double-quoted strings with variable and command substitution
- Numbers: Support for integers, floats, hexadecimal (0x), and octal (0o) numbers
- Colors: Color value support for
#RRGGBB and #RRGGBBAA formats
- Braces: Content within
{} braces
- Namespaces: Namespace declarations and
ns::func syntax
- Keywords: TCL control structures and commands
- Escapes: Escape for special characters such as
\n, \t, and \"
Language Features
- Bracket Matching: Automatic bracket pairing for
{}, [], ()
- Auto-closing: Automatic closing of brackets and quotes
- Surrounding Pairs: Support for surrounding selections with brackets
Theme Support
- Custom dark theme optimized for TCL syntax highlighting
- Distinct colors for different syntax elements
Installation
From VS Code Marketplace
- Open VS Code
- Go to Extensions (Ctrl+Shift+X)
- Search for "TCL Language Support"
- Click Install
Manual Installation
- Download the
.vsix file from the releases page
- In VS Code, go to Extensions
- Click the "..." menu and select "Install from VSIX..."
- Choose the downloaded file
Usage
Basic Usage
- Open any
.tcl file
- The file will automatically be recognized as TCL
- Syntax highlighting will be applied
Example TCL Code
# This is a comment
set var1 "Hello World"
set var2 123
set var3 3.14
# Function definition
proc myfunc {arg1 arg2} {
return [expr {$arg1 + $arg2}]
}
# Function call
set result [myfunc 10 20]
# Namespace
namespace eval myns {
proc test {} {
puts "namespace test"
}
}
# Variables in strings
set msg "Result: $result, Calc: [expr {$var2 + 10}]"
Supported Syntax Elements
Variables
$var - Simple variable
${var} - Braced variable
$arr(index) - Array variable
Function Calls
[func args] - Command substitution
[expr {$a + $b}] - Expression evaluation
- Nested calls:
[func1 [func2 arg]]
Numbers
123 - Integer
3.14 - Float
0xFF - Hexadecimal
0o755 - Octal
1.23e-4 - Scientific notation
Colors
#FFAA00 - RGB color value
#FFAA00FF - RGBA color value
Strings
"Hello World" - Double-quoted string
"Hello $name, your age is $age" - Variable substitution
"Result: [myfunc 10 20]" - Command substitution
"$var" - Variable interpolation
Keywords
if, else, switch, case, default, for, foreach, while, do, continue, break, return, proc, namespace, namespace eval, variable, array etc.
Escapes
\n - Newline
\t - Tab
\" - Double-quote
Configuration
Theme Selection
- Open VS Code Settings (Ctrl+,)
- Search for "Color Theme"
- Select "TCL Theme" from the dropdown
Language Configuration
The extension provides language configuration for:
- Comments
- Bracket matching
- Auto-closing pairs
- Surrounding pairs
Development
Building from Source
- Clone the repository
- Install dependencies:
npm install
- Build the extension:
npm run build
Testing
- Open the project in VS Code
- Press F5 to launch extension development host
- Open a
.tcl file to test syntax highlighting
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
Issues
If you encounter any issues or have feature requests, please:
- Check existing issues first
- Create a new issue with detailed description
- Include sample code that reproduces the problem
License
This extension is licensed under the MIT License. See the LICENSE file for details.
Changelog
0.0.1
- Initial release
- Basic TCL syntax highlighting
- Support for variables, functions, strings, numbers
- Custom theme support
- Language configuration
Acknowledgments
- TCL/Tk community for language specifications
- VS Code team for the excellent extension API
- Contributors and users for feedback and suggestions
| |