Ansible
Zed 中对 Ansible 的支持是通过社区维护的 Ansible 扩展提供的。
- Tree-sitter: zed-industries/tree-sitter-yaml
- 语言服务器: ansible/vscode-ansible
设置
文件检测
默认情况下,为了避免错误处理非 Ansible YAML 文件,Ansible 语言默认不与任何文件扩展名关联。 要更改此行为,您可以将 "file_types"
部分添加到项目中的 Zed 设置 (.zed/settings.json
) 或 Zed 用户设置 (~/.config/zed/settings.json
) 以匹配您的文件夹/命名约定。 例如
"file_types": {
"Ansible": [
"**.ansible.yml",
"**.ansible.yaml",
"**/defaults/*.yml",
"**/defaults/*.yaml",
"**/meta/*.yml",
"**/meta/*.yaml",
"**/tasks/*.yml",
"**/tasks/*.yml",
"**/tasks/*.yaml",
"**/handlers/*.yml",
"**/handlers/*.yaml",
"**/group_vars/*.yml",
"**/group_vars/*.yaml",
"**/playbooks/*.yaml",
"**/playbooks/*.yml",
"**playbook*.yaml",
"**playbook*.yml"
]
}
请根据您的需要随意修改此列表。
LSP 配置
此扩展的 LSP 选项可以在 Zed 的设置文件中配置。 为了获得最佳体验,请将以下配置添加到 ~/.zed/settings.json
中的 "lsp"
部分下
"lsp": {
// Note, the Zed Ansible extension prefixes all settings with `ansible`
// so instead of using `ansible.ansible.path` use `ansible.path`.
"ansible-language-server": {
"settings": {
"ansible": {
"path": "ansible"
},
"executionEnvironment": {
"enabled": false
},
"python": {
"interpreterPath": "python3"
},
"validation": {
"enabled": true,
// To enable linting, manually install ansible-lint and make sure it is your PATH
"lint": {
"enabled": true,
"path": "ansible-lint"
}
}
}
}
}
此配置方便地从 nvim-lspconfig 采用。
可以在项目的页面 这里 找到可以传递给服务器的选项/设置的完整列表。 请根据需要随意修改选项值。