ansible.md

 1# Ansible
 2
 3Support for Ansible in Zed is provided via a community-maintained [Ansible extension](https://github.com/kartikvashistha/zed-ansible).
 4
 5- Tree-sitter: [zed-industries/tree-sitter-yaml](https://github.com/zed-industries/tree-sitter-yaml)
 6- Language Server: [ansible/vscode-ansible](https://github.com/ansible/vscode-ansible/tree/main/packages/ansible-language-server)
 7
 8## Setup
 9
10### File detection
11
12By default, to avoid mishandling non-Ansible YAML files, the Ansible Language is not associated with any file extensions by default. To change this behavior you can add a `"file_types"` section to the Zed settings inside your project (`.zed/settings.json`) or your Zed user settings (`~/.config/zed/settings.json`) to match your folder/naming conventions. For example:
13
14```json
15"file_types": {
16    "Ansible": [
17      "**.ansible.yml",
18      "**.ansible.yaml",
19      "**/defaults/*.yml",
20      "**/defaults/*.yaml",
21      "**/meta/*.yml",
22      "**/meta/*.yaml",
23      "**/tasks/*.yml",
24      "**/tasks/*.yaml",
25      "**/handlers/*.yml",
26      "**/handlers/*.yaml",
27      "**/group_vars/*.yml",
28      "**/group_vars/*.yaml",
29      "**/playbooks/*.yml",
30      "**/playbooks/*.yaml",
31      "**playbook*.yml",
32      "**playbook*.yaml"
33    ]
34  }
35```
36
37Feel free to modify this list as per your needs.
38
39### LSP Configuration
40
41LSP options for this extension can be configured under Zed's settings file. To get the best experience, add the following configuration under the `"lsp"` section in your `~/.zed/settings.json`:
42
43```json
44"lsp": {
45  // Note, the Zed Ansible extension prefixes all settings with `ansible`
46  // so instead of using `ansible.ansible.path` use `ansible.path`.
47  "ansible-language-server": {
48    "settings": {
49      "ansible": {
50        "path": "ansible"
51      },
52      "executionEnvironment": {
53        "enabled": false
54      },
55      "python": {
56        "interpreterPath": "python3"
57      },
58      "validation": {
59        "enabled": true,
60        // To enable linting, manually install ansible-lint and make sure it is your PATH
61        "lint": {
62          "enabled": true,
63          "path": "ansible-lint"
64        }
65      }
66    }
67  }
68}
69```
70
71This config was conveniently adopted from [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig/blob/ad32182cc4a03c8826a64e9ced68046c575fdb7d/lua/lspconfig/server_configurations/ansiblels.lua#L6-L23).
72
73A full list of options/settings, that can be passed to the server, can be found at the project's page [here](https://github.com/ansible/vscode-ansible/blob/5a89836d66d470fb9d20e7ea8aa2af96f12f61fb/docs/als/settings.md).
74Feel free to modify option values as needed.