tsl-devkit/vim/README.md

84 lines
1.8 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# TSL Tools for Vim
<p align="left">
<strong>强大的 TSL 语言开发工具集</strong><br>
为 VSCode 提供完整的 TSL 语言支持
</p>
<p align="left">
<img src="https://img.shields.io/badge/Vim-%3E%3D9.0-green.svg" alt="Vim">
</p>
## 🚀 快速安装
### 1⃣ 基础语法高亮
#### 手动安装
```bash
# 创建语法目录(如果不存在)
mkdir -p ~/.vim/syntax/
# 复制语法文件
cp vim/tsl.vim ~/.vim/syntax/
```
#### 配置文件关联
在你的 `~/.vimrc`
```vim
" 自动识别 .tsl 和 .tsf 文件
autocmd BufNewFile,BufRead *.ts[lf] setf tsl
" 或者分开设置
autocmd BufNewFile,BufRead *.tsl setf tsl
autocmd BufNewFile,BufRead *.tsf setf tsl
```
### 2⃣ LSP 语言服务器配置
TSL 提供完整的 LSP 支持,包括代码补全、错误检查、跳转定义等功能。
#### 使用 coc.nvim
编辑 `~/.vim/coc-settings.json` 或运行 `:CocConfig`
```json
{
"languageserver": {
"tsl-server": {
"command": "tsl-server",
"args": ["--log=info", "--log=stderr", "--interpreter=~/tsl64"],
"filetypes": ["tsl", "tsf"]
}
}
}
```
| 参数 | 说明 | 默认值 |
| -------------------- | -------------------------------- | -------- |
| `--log` | 日志级别 (trace/info/warn/error) | `info` |
| `--log-stderr` | 输出日志到标准错误 | - |
| `--log-file=PATH` | 输出日志到文件 | - |
| `--interpreter=PATH` | TSL 解释器路径 | 自动检测 |
更多参数使用`tsl-server --help`获取
### 3⃣ 代码片段配置
#### coc-snippets
1. 安装 coc-snippets
```vim
:CocInstall coc-snippets
```
2. 配置片段文件路径:
```json
{
"snippets.textmateSnippetsRoots": ["~/.vim/snippets"]
}
```