Skip to content

Commit 30e3b91

Browse files
committed
feat: Introduce initial VS Code extension and Language Server Protocol for the chen language.
1 parent f95e735 commit 30e3b91

35 files changed

+3978
-34
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*.iml
55

66
# Project exclude paths
7-
/node_modules/
7+
node_modules/
88
.cache
99
dist
1010
*.exe

Cargo.lock

Lines changed: 33 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lsp/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target
2+
Cargo.lock

lsp/CHANGELOG.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Chen Lang LSP 更新日志
2+
3+
## [0.2.0] - 2026-01-04
4+
5+
### 新增功能 ✨
6+
7+
#### 1. 实时语法诊断
8+
9+
- 集成 chen_lang 解析器进行语法检查
10+
- 打开文件时自动检测错误
11+
- 编辑时实时更新诊断信息
12+
- 显示详细的错误位置和消息
13+
14+
#### 2. 跳转到定义 (Go to Definition)
15+
16+
- 支持函数定义跳转
17+
- 支持变量声明跳转
18+
- 精确定位到符号定义位置
19+
- 兼容所有主流编辑器
20+
21+
#### 3. 查找引用 (Find References)
22+
23+
- 查找符号的所有使用位置
24+
- 智能词边界检测
25+
- 避免部分匹配
26+
- 显示完整的引用列表
27+
28+
#### 4. 重命名符号 (Rename Symbol)
29+
30+
- 智能重命名变量和函数
31+
- 自动更新所有引用
32+
- 保持代码一致性
33+
- 支持撤销操作
34+
35+
### 改进 🔧
36+
37+
- 优化文档同步性能
38+
- 改进符号提取算法
39+
- 增强错误消息的可读性
40+
- 更新所有文档和示例
41+
42+
### 技术细节 📋
43+
44+
**新增文件:**
45+
46+
- `FEATURES.md` - 详细功能使用指南
47+
- `test_features.ch` - 功能测试文件
48+
- `CHANGELOG.md` - 更新日志
49+
50+
**修改文件:**
51+
52+
- `src/server.rs` - 添加新的 LSP 方法实现
53+
- `src/bin.rs` - 修复导入和初始化问题
54+
- `README.md` - 更新功能列表
55+
- `DEV.md` - 更新开发状态
56+
57+
**新增方法:**
58+
59+
- `analyze()` - 语法分析和诊断
60+
- `collect_symbols()` - 收集符号信息
61+
- `find_references()` - 查找符号引用
62+
- `goto_definition()` - 跳转到定义
63+
- `references()` - 引用查询
64+
- `rename()` - 符号重命名
65+
66+
### 已知问题 🐛
67+
68+
1. 当前只支持单文件内的引用查找
69+
2. 使用简单的文本匹配,可能在复杂情况下不够精确
70+
3. 不区分不同作用域的同名变量
71+
72+
### 下一步计划 🚀
73+
74+
- [ ] 实现跨文件引用和跳转
75+
- [ ] 添加更精确的语义分析
76+
- [ ] 实现代码格式化
77+
- [ ] 添加代码片段支持
78+
- [ ] 实现语义高亮
79+
- [ ] 添加代码折叠功能
80+
81+
---
82+
83+
## [0.1.0] - 2025-12-XX
84+
85+
### 初始版本
86+
87+
#### 基础功能
88+
89+
- 文档同步 (did_open, did_change, did_close)
90+
- 关键字补全
91+
- 悬停提示
92+
- 文档符号提取
93+
- 增量文档更新
94+
95+
#### 编辑器支持
96+
97+
- VS Code 配置
98+
- Neovim 配置
99+
- Helix 配置
100+
- Vim 配置
101+
- Emacs 配置
102+
103+
#### 文档
104+
105+
- README.md - 基本说明
106+
- USAGE.md - 使用指南
107+
- DEV.md - 开发指南
108+
- SYNTAX_HIGHLIGHTING.md - 语法高亮配置
109+
110+
---
111+
112+
## 版本说明
113+
114+
版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/) 规范:
115+
116+
- **主版本号**:不兼容的 API 修改
117+
- **次版本号**:向下兼容的功能性新增
118+
- **修订号**:向下兼容的问题修正

lsp/Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
name = "chen_lang_lsp"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]
7+
chen_lang = { path = ".." }
8+
tower-lsp = "0.20"
9+
tokio = { version = "1", features = ["rt-multi-thread", "io-std", "macros"] }
10+
serde = { version = "1", features = ["derive"] }
11+
serde_json = "1.0"
12+
tracing = "0.1"
13+
tracing-subscriber = "0.3"
14+
ropey = "1.6"
15+
dashmap = "6"
16+
anyhow = "1"
17+
18+
[lib]
19+
name = "chen_lang_lsp"
20+
path = "src/lib.rs"
21+
22+
[[bin]]
23+
name = "chen_lang_lsp"
24+
path = "src/bin.rs"

0 commit comments

Comments
 (0)