Skip to content

Commit be0c6e2

Browse files
committed
Update README.md to enhance installation instructions and add usage examples
1 parent 97ebb12 commit be0c6e2

File tree

3 files changed

+188
-24
lines changed

3 files changed

+188
-24
lines changed

README.md

Lines changed: 121 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
Intelligent syntax highlighting and validation for Python template strings (PEP 750).
44

55
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6+
[![VSCode Marketplace](https://img.shields.io/visual-studio-marketplace/v/koxudaxi.t-linter.svg)](https://marketplace.visualstudio.com/items?itemName=koxudaxi.t-linter)
7+
[![PyPI](https://img.shields.io/pypi/v/t-linter.svg)](https://pypi.org/project/t-linter/)
8+
9+
## Overview
10+
11+
t-linter provides intelligent syntax highlighting and linting for Python template strings (PEP 750) through multiple distribution channels:
12+
13+
- **🔧 Command-line tool**: Install via PyPI (`pip install t-linter`) for direct CLI usage and LSP server
14+
- **🎨 VSCode Extension**: Install from the Visual Studio Code Marketplace for seamless editor integration
615

716
## Features
817

@@ -13,33 +22,135 @@ Intelligent syntax highlighting and validation for Python template strings (PEP
1322

1423
## Installation
1524

16-
Install using pip:
25+
### Option 1: VSCode Extension (Recommended for VSCode users)
1726

27+
**Step 1: Install the t-linter binary**
28+
First, install the language server via PyPI:
1829
```bash
1930
pip install t-linter
2031
```
2132

22-
## Usage
33+
**Step 2: Install the VSCode extension**
34+
Install the extension from the Visual Studio Code Marketplace:
2335

24-
Run the language server:
36+
1. Open VSCode
37+
2. Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
38+
3. Search for "t-linter"
39+
4. Click Install on "T-Linter - Python Template Strings Highlighter & Linter" by koxudaxi
2540

26-
```bash
27-
t-linter lsp
28-
```
41+
**Step 3: Configure the server path (if needed)**
42+
If t-linter is not in your PATH, configure the server path in VSCode settings:
43+
44+
1. **Find your t-linter path** by running in terminal:
45+
```bash
46+
which t-linter # macOS/Linux
47+
where t-linter # Windows
48+
```
49+
50+
2. Open VSCode Settings (Ctrl+, / Cmd+,)
51+
3. Search for "t-linter.serverPath"
52+
4. Set the full path to your t-linter executable:
53+
- **Windows**: `C:\Users\YourName\AppData\Local\Programs\Python\Python3xx\Scripts\t-linter.exe`
54+
- **macOS**: `/opt/homebrew/bin/t-linter` or `/usr/local/bin/t-linter`
55+
- **Linux**: `/home/yourname/.local/bin/t-linter` or `/usr/local/bin/t-linter`
2956

30-
Check files:
57+
**[→ Install from VSCode Marketplace](https://marketplace.visualstudio.com/items?itemName=koxudaxi.t-linter)**
58+
59+
### Option 2: PyPI Package Only (CLI tool and LSP server)
60+
61+
For command-line usage or integration with other editors, install only the PyPI package:
3162

3263
```bash
33-
t-linter check file.py
64+
pip install t-linter
3465
```
3566

36-
## Development
67+
This provides the `t-linter` command-line tool and LSP server without the VSCode extension.
3768

38-
For development, you can also build from source:
69+
**[→ View on PyPI](https://pypi.org/project/t-linter/)**
70+
71+
### Option 3: Build from Source
72+
73+
For development or bleeding-edge features:
3974

4075
```bash
4176
git clone https://github.com/koxudaxi/t-linter
4277
cd t-linter
4378
cargo install --path crates/t-linter
4479
```
4580

81+
## Usage
82+
83+
### VSCode Extension
84+
After installing both the PyPI package and VSCode extension, t-linter will automatically provide syntax highlighting for Python template strings.
85+
86+
**Troubleshooting**: If syntax highlighting doesn't work:
87+
1. Ensure `t-linter` is installed: Run `t-linter --version` in terminal
88+
2. Check the server path in VSCode settings: `t-linter.serverPath`
89+
3. Restart VSCode after making changes
90+
91+
### Command Line Interface
92+
If you installed via PyPI, you can use t-linter from the command line:
93+
94+
**Run the language server** (for editor integration):
95+
```bash
96+
t-linter lsp
97+
```
98+
99+
**Check individual files**:
100+
```bash
101+
t-linter check file.py
102+
```
103+
104+
**Get statistics** about template strings in a file:
105+
```bash
106+
t-linter stats file.py
107+
```
108+
109+
## Quick Start Example
110+
111+
Here's how to use template strings with automatic syntax highlighting:
112+
113+
```python
114+
from typing import Annotated
115+
from string.templatelib import Template
116+
117+
# HTML template with syntax highlighting
118+
page: Annotated[Template, "html"] = t"""
119+
<!DOCTYPE html>
120+
<html>
121+
<head>
122+
<title>{title}</title>
123+
<style>
124+
body { font-family: Arial, sans-serif; }
125+
.highlight { color: #007acc; }
126+
</style>
127+
</head>
128+
<body>
129+
<h1 class="highlight">{heading}</h1>
130+
<p>{content}</p>
131+
</body>
132+
</html>
133+
"""
134+
135+
# SQL query with syntax highlighting
136+
query: Annotated[Template, "sql"] = t"""
137+
SELECT u.name, u.email, p.title
138+
FROM users u
139+
JOIN posts p ON u.id = p.author_id
140+
WHERE u.created_at > {start_date}
141+
ORDER BY u.name
142+
"""
143+
144+
# Type aliases for reusable templates (Python 3.12+)
145+
type css = Annotated[Template, "css"]
146+
type js = Annotated[Template, "javascript"]
147+
148+
styles: css = t"""
149+
.container {
150+
max-width: 1200px;
151+
margin: 0 auto;
152+
padding: {padding}px;
153+
}
154+
"""
155+
```
156+

editors/vscode/README.md

Lines changed: 67 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Intelligent syntax highlighting and validation for Python template strings (PEP 750) with embedded language support.
44

5+
![T-Linter in action](images/img.png)
6+
57
## Features
68

79
- 🎨 **Smart Syntax Highlighting** - Automatic detection and highlighting of embedded languages
@@ -21,21 +23,57 @@ Intelligent syntax highlighting and validation for Python template strings (PEP
2123

2224
- Visual Studio Code 1.74.0 or higher
2325
- Python 3.9+ (PEP 750 template strings require Python 3.14+)
24-
- `t-linter` language server (installed automatically or manually)
26+
- `t-linter` language server (must be installed via PyPI)
2527

2628
## Installation
2729

28-
### Option 1: Install from VSCode Marketplace
29-
1. Open VSCode
30-
2. Go to Extensions (Ctrl+Shift+X)
31-
3. Search for "t-linter"
32-
4. Click Install
30+
**⚠️ Important**: This extension requires the t-linter language server to be installed separately.
3331

34-
### Option 2: Install t-linter manually
32+
### Step 1: Install the t-linter language server
3533
```bash
3634
pip install t-linter
3735
```
3836

37+
### Step 2: Install the VSCode extension
38+
1. Open VSCode
39+
2. Go to Extensions (Ctrl+Shift+X)
40+
3. Search for "t-linter"
41+
4. Click Install on "T-Linter - Python Template Strings Highlighter & Linter" by koxudaxi
42+
43+
### Step 3: Configure server path (if needed)
44+
If the extension can't find the t-linter binary automatically:
45+
46+
1. **Find your t-linter path**:
47+
```bash
48+
which t-linter # macOS/Linux
49+
where t-linter # Windows
50+
```
51+
52+
2. **Set the path in VSCode settings**:
53+
- Open Settings (Ctrl+, / Cmd+,)
54+
- Search for `t-linter.serverPath`
55+
- Enter the full path to your t-linter executable
56+
57+
### Optional: PEP 750 Support with Patched Pyright
58+
59+
Since PEP 750 template strings (`t"..."`) are not yet supported in the official Pyright extension, you can install a patched version that adds PEP 750 t-string support:
60+
61+
1. **Download the patched Pyright extension**:
62+
- Go to [Patched Pyright Releases](https://github.com/koxudaxi/pyright/releases/tag/untagged-7b5f847f7a434b72a328)
63+
- Download the `.vsix` file
64+
65+
2. **Install the patched extension**:
66+
- Open VSCode
67+
- Press `Ctrl+Shift+P` (Cmd+Shift+P on macOS)
68+
- Type "Extensions: Install from VSIX..."
69+
- Select the downloaded `.vsix` file
70+
71+
3. **Disable the original Pyright extension** (if installed):
72+
- Go to Extensions tab
73+
- Find "Pyright" and click "Disable"
74+
75+
This patched version enables Pyright to recognize and type-check PEP 750 template strings, providing better integration with t-linter for comprehensive template string analysis.
76+
3977
## Usage
4078

4179
### Basic Example
@@ -101,19 +139,34 @@ This extension contributes the following commands:
101139
## Troubleshooting
102140

103141
### Language server not found
104-
If you see "t-linter binary not found", install it using:
105-
```bash
106-
pip install t-linter
107-
```
142+
If you see "t-linter binary not found":
143+
144+
1. **Ensure t-linter is installed**:
145+
```bash
146+
pip install t-linter
147+
```
148+
149+
2. **Verify installation**:
150+
```bash
151+
t-linter --version
152+
```
153+
154+
3. **Configure server path manually**:
155+
- Find the path: `which t-linter` (macOS/Linux) or `where t-linter` (Windows)
156+
- Set `t-linter.serverPath` in VSCode settings
157+
- Restart VSCode
108158

109159
### No syntax highlighting
110-
1. Ensure Python semantic highlighting is enabled
111-
2. Check that your template strings use the `t"..."` syntax
112-
3. Verify type annotations are correctly formatted
160+
1. Ensure both the PyPI package AND VSCode extension are installed
161+
2. Check that Python semantic highlighting is enabled in VSCode
162+
3. Verify your template strings use the `t"..."` syntax
163+
4. Ensure type annotations are correctly formatted
164+
5. Try restarting the language server: `Ctrl+Shift+P` → "T-Linter: Restart Server"
113165

114166
### Performance issues
115167
- Disable `t-linter.enableTypeChecking` if you don't need cross-module type resolution
116168
- Set `t-linter.trace.server` to "off" in production
169+
- Restart VSCode after changing settings
117170

118171
## Known Issues
119172

editors/vscode/images/img.png

62.2 KB
Loading

0 commit comments

Comments
 (0)