hx-lsp
一个提供了自定义代码片段 snippets 和 Code Action 的 lsp 工具。
提供了基本的功能,还在改进中,欢迎提供 pr。
功能
- Completion: snippets
- CodeAction: actions
安装
git clone https://github.com/erasin/hx-lsp.git
cd hx-lsp
cargo install --path .
在 https://github.com/erasin/helix-config/ 中有示例代码,另外我自己使用的分支已经合并了 helix#9081 Add a snippet system。
使用
修改 helix 的语言配置文件 languages.toml, 修改下面文件任何一个即可
$XDG_CONFIG_HOME/helix/languages.tomlhelix 配置文件WORKSPACE_ROOT/.helix/languages.toml项目下配置文件
比如为 markdown 追加支持。
[language-server.hx-lsp]
command = "hx-lsp"
[[language]]
name = "markdown"
language-servers = [ "marksman", "markdown-oxide", "hx-lsp" ]
关于
language id建议参考 helix/languages.toml 文件和 helix wiki language server configurations。
配置文件
配置文件支持 jsonc 格式,即支持注释内容,但不支持多余的 ,。
注释样式支持
// ...,/* ... */,# ...。
Snippets 文件加载路径
$XDG_CONFIG_HOME/helix/snippets/WORKSPACE_ROOT/.helix/snippets/
Actions 配置加载路径
$XDG_CONFIG_HOME/helix/actions/WORKSPACE_ROOT/.helix/actions/
配置在 textDocument/didOpen 时候加载 language id 同名 lang_id.json 文件。
暂不支持配置文件的动态加载,修改配置文件后,可以使用
:lsp-restart重启来重新加载文件。
Completion: snippets
Code snippets
兼容 vscode snippets 格式。同样文件后缀支持 全局后缀.code-snippets 和 语言包后缀.json。
为了更好的使用 snippet 建议 heliix 合并 helix#9081 Add a snippet system 以支持 smart-tab。
.
└── snippets
├── global.code-snippets
├── html.json
└── markdown.json
snipet 格式:
- name:
String唯一内容,用于索引 - prefix:
String或Vec<String>提供给 helix 编辑器的补全列表使用 - body:
String或Vec<String> - description:
Option<String>提示内容
{
"markdown a": { // name
"prefix": "mda", // string
"body": "mda in .helix: ${1:abc} : ${2:cde}", // string
"description": "test a info content in .helix"
},
"markdown b": {
"prefix": [ // array
"mdb"
],
"body": "mdb: ${1:abc} : ${2:cde}", // string
"description": "test b info content"
},
"markdown c": {
"prefix": [ // array
"mdc",
"mdd"
],
"body": [ // array
"mda: ${1:abc} : ${2:cde}",
"test"
],
"description": "test c,d info content"
}
}
CodeAction: actions
.
└── actions
├── html.json
└── markdown.json
snipet 格式:
- title:
Stringhelix 显示条目内容 - catch:
String捕捉内容,regex 适配内容的时候,显示 code action - shell:
String或Vec<String>执行的 shell 脚本 - description:
Option<String>提示内容
{
"tmux split window helix": {
"title": "tmux split window in project",
"catch": "fn",
"shell": [
"tmux split-window -h",
"tmux send project"
],
"description": "tmux split and open helix in project"
}
}
Ext Link: https://github.com/erasin/hx-lsp
评论区
写评论还没有评论