Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(commands): add "ansible.server.showMetaData" command #24

Merged
merged 1 commit into from Aug 10, 2022

Conversation

yaegassy
Copy link
Owner

Description

Addd a command to display various information using the update/ansible-metadata notifications.

In vscode-ansible, it seems to be used in the status-bar.

DEMO (mp4)

coc-ansible-show-metadata-command.mp4

@yaegassy yaegassy merged commit f23131a into master Aug 10, 2022
@yaegassy yaegassy deleted the feat/commands-show-meta-data branch August 10, 2022 01:26
harleypig added a commit to harleypig/dotvim that referenced this pull request Feb 27, 2024
…` integration in Ansible development environment.

# Aider chat conversation:

USER: https://raw.githubusercontent.com/yaegassy/coc-ansible/master/README.md:

    # coc-ansible

    [ansible-language-server](https://github.com/ansible/ansible-language-server) extension for [coc.nvim](https://github.com/neoclide/coc.nvim)

    <img width="780" alt="coc-ansible-demo" src="https://user-images.githubusercontent.com/188642/133183623-7eb4529b-cf4b-4778-adfe-b57105194b7c.gif">

    ## Install

    **CocInstall**:

    ```vim
    :CocInstall @yaegassy/coc-ansible
    ```

    > scoped packages

    **vim-plug**:

    ```vim
    Plug 'yaegassy/coc-ansible', {'do': 'yarn install --frozen-lockfile'}
    ```

    ## Note

    ### [!! Very important !!] Filetype related

    1. The "filetype" must be `yaml.ansible` for this extension to work.

       If you install ansible's vim plugin, `yaml.ansible` filetype will be added automatically, which is very useful (e.g. [pearofducks/ansible-vim](https://github.com/pearofducks/ansible-vim) or [sheerun/vim-polyglot](https://github.com/sheerun/vim-polyglot)).

    2. You also need to set `g:coc_filetype_map` in `.vimrc/init.vim`.

       ```vim
       let g:coc_filetype_map = {
         \ 'yaml.ansible': 'ansible',
         \ }
       ```

    ## Requirements (Tools)

    - [Ansible 2.9+](https://docs.ansible.com/ansible/latest/index.html)
    - [Ansible Lint](https://ansible-lint.readthedocs.io/en/latest/) (required, unless you disable linter support)
      - [TIPS] `coc-ansible` will **automatically disable the feature** if `ansible-lint` is not found
    - [yamllint](https://yamllint.readthedocs.io/en/stable/) (optional)

    > If you also install `yamllint`, `ansible-lint` will detect it and incorporate into the linting process. Any findings reported by `yamllint` will be exposed in coc.nvim as errors/warnings.

    ## Bult-in install

    coc-ansible allows you to create an extension-only "venv" and install `ansible`, `ansible-lint` and `yamllint`.

    `yamllint` will be installed by setting `ansible.builtin.isWithYamllint` to `true` (default: `false`).

    You can also specify the version of each tool. (setting: `ansible.bultin.ansibleVersion`, `ansible.bultin.ansibleLintVersion`, `ansible.bultin.yamllintVersion`)

    ---

    The first time you use coc-ansible, if ansible, ansible-lint is not detected, you will be prompted to do a built-in installation.

    You can also run the installation command manually.

    ```
    :CocCommand ansible.builtin.installRequirementsTools
    ```

    ## Configuration options

    - `ansible.enable`: Enable coc-ansible extension, default: `true`
    - `ansible.disableProgressNotifications`: Disable progress notifications from ansible-language-server, default: `false`
    - `ansible.builtin.isWithYamllint`: Whether to install yamllint the built-in installer, default: `false`
    - `ansible.builtin.ansibleVersion`: Version of `ansible` for built-in install, default: `""`
    - `ansible.builtin.ansibleLintVersion`: Version of `ansible-lint` for built-in install, default: `""`
    - `ansible.builtin.force`: Whether to force builtin tools instead those in the PATH, default: `false`
    - `ansible.builtin.yamllintVersion`: Version of `yamllint` for built-in install, default: `""`
    - `ansible.ansible.useFullyQualifiedCollectionNames`: Always use fully qualified collection names (FQCN) when inserting a module name. Disabling it will only use FQCNs when necessary, default: `true`
    - `ansible.python.interpreterPath`: Path to the python/python3 executable. This settings may be used to make the extension work with ansible and ansible-lint installations in a python virtual environment, default: `""`
    - `ansible.validation.enabled`: Toggle validation provider. If enabled and ansible-lint is disabled, validation falls back to ansible-playbook --syntax-check, default: `true`
    - `ansible.validation.lint.enabled`: Toggle usage of ansible-lint, default: `true`
    - `ansible.validation.lint.arguments`: Optional command line arguments to be appended to ansible-lint invocation, default `""`
    - `ansible.completion.provideRedirectModules`: Toggle redirected module provider when completing modules, default: `true`
    - `ansible.completion.provideModuleOptionAliases`: Toggle alias provider when completing module options, default: `true`
    - `ansible.ansibleDoc.path`: Path to the ansible-doc executable, default: `ansible-doc`
    - `ansible.ansibleDoc.enableSplitRight`: Use vertical belowright for ansible-doc terminal window, default: `true`
    - `ansible.ansibleNavigator.path`: Points to the ansible-navigator executable, default: `"ansible-navigator"`
    - `ansible.dev.serverPath`: Absolute path to ansible language server module. If it is not set, use the extention's server module. (For develop and check), default: `""`
    - `ansibleServer.trace.server`: Traces the communication between coc.nvim and the ansible language server, default: `"off"`

    ## Commands

    **Command List**:

    > :CocCommand [CommandName]
    >
    > **e.g.** :CocCommand ansible.server.restart

    - `ansible.builtin.installRequirementsTools`: Install `ansible`, `ansible-lint` and `yamllint` (optional) with extension's venv
      - It will be installed in this path:
        - Mac/Linux:
          - `~/.config/coc/extensions/@yaegassy/coc-ansible-data/ansible/venv/bin/ansible`
          - `~/.config/coc/extensions/@yaegassy/coc-ansible-data/ansible/venv/bin/ansible-lint`
          - `~/.config/coc/extensions/@yaegassy/coc-ansible-data/ansible/venv/bin/yamllint`
        - Windows:
          - `~/AppData/Local/coc/extensions/@yaegassy/coc-ansible-data/ansible/venv/Scripts/ansible.exe`
          - `~/AppData/Local/coc/extensions/@yaegassy/coc-ansible-data/ansible/venv/Scripts/ansible-lint.exe`
          - `~/AppData/Local/coc/extensions/@yaegassy/coc-ansible-data/ansible/venv/Scripts/yamllint.exe`
      - **[Note]** `ansible` is a very large tool and will take some time to install
    - `ansible.server.restart`: Restart ansible language server
    - `ansible.server.showMetaData`: Show ansible-metadata for ansible language server | [DEMO](yaegassy/coc-ansible#24)
    - `ansible.server.resyncAnsibleInventory`: Resync Ansible Inventory | [DEMO](yaegassy/coc-ansible#25)
    - `ansible.ansbileDoc.showInfo`: Run the `ansible-doc` command in a terminal window with various options to display information about the plugins | [DEMO](yaegassy/coc-ansible#22 (comment))
    - `ansible.ansbileDoc.showSnippets`: Run the `ansible-doc` command in a terminal window with various options to display a snippets of the plugins | [DEMO](yaegassy/coc-ansible#22 (comment))

    **Example of command key mapping**:

    ```vim
    " Quickly view a list of all coc.nvim commands
    nnoremap <silent> <C-p> :<C-u>CocCommand<CR>
    ```

    ## Code Actions

    **Example key mapping (Code Action related)**:

    ```vim
    nmap <silent> ga <Plug>(coc-codeaction-line)
    ```

    **Usage**:

    In the line with diagnostic message, enter the mapped key (e.g. `ga`) and you will see a list of code actions that can be performed.

    **Actions**:

    - `Ignoring rules for current line (# noqa [ruleId])` | [DEMO](yaegassy/coc-ansible#13)
      - Requires `ansible-lint` "v6.8.1" or later.
    - `Show web documentation for [ruleId]` | [DEMO](yaegassy/coc-ansible#21 (comment))
      - Requires `ansible-lint` "v6.8.1" or later.

    ## Thanks

    - [ansible/ansible-language-server](https://github.com/ansible/ansible-language-server)
    - [ansible/vscode-ansible](https://github.com/ansible/vscode-ansible)

    ## License

    MIT

    ---

    > This extension is built with [create-coc-extension](https://github.com/fannheyward/create-coc-extension)

ASSISTANT: Based on the information provided from the `coc-ansible` README, it seems that there are several important aspects that need to be reflected in the `ansible.md` documentation to match the core requirements and the capabilities of `coc-ansible`.

Please let me know if you would like me to update the `ansible.md` documentation to include details such as the requirement of the `yaml.ansible` filetype, the configuration of `g:coc_filetype_map`, and the built-in installation options provided by `coc-ansible`.

USER: please update ansible.md to reflect the information in the coc-ansible readme.

ASSISTANT: ```diff
--- docs/ansible.md
+++ docs/ansible.md
@@ ... @@
 ### Plugins and Extensions Used

-* [vim-ansible](https://github.com/pearofducks/ansible-vim) (vim plugin) - Provides Ansible syntax highlighting.
+* [vim-ansible](https://github.com/pearofducks/ansible-vim) (vim plugin) - Provides Ansible syntax highlighting and sets the `yaml.ansible` filetype.
 * [coc-ansible](https://github.com/neoclide/coc.nvim/wiki/Using-coc-extensions#implemented-coc-extensions) (coc extension) - Offers auto-completion and other language features for Ansible.

@@ ... @@
 ### Configuration Files Used

-* .vim/pack/settings/start/settings/ftplugin/yaml.vim - Configures Vim to recognize YAML files, which are commonly used by Ansible.
+* .vim/pack/settings/start/settings/ftplugin/yaml.vim - Configures Vim to recognize YAML files, which are commonly used by Ansible.
+* .vim/coc-settings.json - Contains the `g:coc_filetype_map` setting to map `yaml.ansible` to `ansible` for `coc-ansible` extension.

@@ ... @@
 ### Language Server

-* No specific language server for Ansible, but YAML language servers can provide additional features.
+* [ansible-language-server](https://github.com/ansible/ansible-language-server) - Provides features like auto-completion, linting, and syntax highlighting for Ansible. It is used by the `coc-ansible` extension.

@@ ... @@
 ### Linting and Static Analysis

-* ansible-lint and yamllint can be integrated using ALE or CoC.
+* ansible-lint and yamllint can be integrated using ALE or CoC. `coc-ansible` can also perform linting with `ansible-lint` and optionally with `yamllint` if it is installed.

@@ ... @@
 ### Formatting and Beautification

-* None specific for Ansible, but YAML formatting tools can be used.
+* None specific for Ansible, but YAML formatting tools can be used. `coc-ansible` provides a built-in installation option for `ansible-lint` and `yamllint`.

@@ ... @@
 ### Error Highlighting

-* ALE or CoC can be configured to highlight errors using ansible-lint and yamllint.
+* ALE or CoC can be configured to highlight errors using ansible-lint and yamllint. `coc-ansible` will automatically disable linting features if `ansible-lint` is not found.

@@ ... @@
 ### Filetype Detection

-* Vim automatically detects .yml and .yaml files. Additional configuration can be added for Ansible-specific file types.
+* Vim automatically detects .yml and .yaml files. The `vim-ansible` plugin sets the `yaml.ansible` filetype, which is required by `coc-ansible`.

@@ ... @@
+### Built-in Installation
+
+* `coc-ansible` provides a built-in installation option for `ansible`, `ansible-lint`, and optionally `yamllint` within an extension-only virtual environment. This can be triggered manually with the `:CocCommand ansible.builtin.installRequirementsTools` command or will prompt on first use if these tools are not detected.
+
+### Commands
+
+* `coc-ansible` adds several commands to manage the Ansible development environment, such as restarting the language server, showing metadata, resyncing inventory, and displaying plugin information with `ansible-doc`.
+
+### Configuration Options
+
+* `coc-ansible` offers various configuration options to customize the behavior of the Ansible language server and related tools. These options can be set in the `.vim/coc-settings.json` file.
+
+### Code Actions
+
+* `coc-ansible` provides code actions that can be invoked with a mapped key in Vim. These actions include ignoring linting rules for the current line and showing web documentation for specific rules.
+
```

USER: UnifiedDiffNoMatch: hunk failed to apply!

docs/ansible.md does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in docs/ansible.md!

docs/ansible.md does not contain these 4 exact lines in a row:
```
### Configuration Files Used

* .vim/pack/settings/start/settings/ftplugin/yaml.vim - Configures Vim to recognize YAML files, which are commonly used by Ansible.

```

UnifiedDiffNoMatch: hunk failed to apply!

docs/ansible.md does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in docs/ansible.md!

docs/ansible.md does not contain these 4 exact lines in a row:
```
### Error Highlighting

* ALE or CoC can be configured to highlight errors using ansible-lint and yamllint.

```

ASSISTANT: I apologize for the confusion. Let's try updating the `ansible.md` documentation again with the correct diff that will apply cleanly to the current contents of the file. Here is the revised diff:

```diff
--- docs/ansible.md
+++ docs/ansible.md
@@ ... @@
 ### Plugins and Extensions Used

-* [vim-ansible](https://github.com/pearofducks/ansible-vim) (vim plugin) - Provides Ansible syntax highlighting and sets the `yaml.ansible` filetype.
+* [vim-ansible](https://github.com/pearofducks/ansible-vim) (vim plugin) - Provides Ansible syntax highlighting and sets the `yaml.ansible` filetype, which is required by `coc-ansible`.
 * [coc-ansible](https://github.com/neoclide/coc.nvim/wiki/Using-coc-extensions#implemented-coc-extensions) (coc extension) - Offers auto-completion and other language features for Ansible.

@@ ... @@
 ### Configuration Files Used

-* - .vim/pack/settings/start/settings/ftplugin/yaml.vim - Configures Vim to recognize YAML files, which are commonly used by Ansible.
+* .vim/pack/settings/start/settings/ftplugin/yaml.vim - Configures Vim to recognize YAML files, which are commonly used by Ansible.
+* .vimrc or init.vim - Should include the `g:coc_filetype_map` setting to map `yaml.ansible` to `ansible` for `coc-ansible` extension.

@@ ... @@
 ### Language Server

-* - No specific language server for Ansible, but YAML language servers can be used to enhance development experience.
+* [ansible-language-server](https://github.com/ansible/ansible-language-server) - Provides features like auto-completion, linting, and syntax highlighting for Ansible. It is used by the `coc-ansible` extension.

@@ ... @@
 ### Linting and Static Analysis

-* - ansible-lint and yamllint can be integrated with Vim using ALE or CoC to provide linting and static analysis.
+* ansible-lint and yamllint can be integrated using ALE or CoC. `coc-ansible` can also perform linting with `ansible-lint` and optionally with `yamllint` if it is installed.

@@ ... @@
 ### Formatting and Beautification

-* - No specific formatter for Ansible, but YAML formatters can be used to format Ansible playbooks and roles.
+* None specific for Ansible, but YAML formatting tools can be used. `coc-ansible` provides a built-in installation option for `ansible-lint` and `yamllint`.

@@ ... @@
 ### Error Highlighting

-* - ALE or CoC can be configured to highlight errors using ansible-lint and yamllint.
+* ALE or CoC can be configured to highlight errors using ansible-lint and yamllint. `coc-ansible` will automatically disable linting features if `ansible-lint` is not found.

@@ ... @@
 ### Filetype Detection

-* - Vim automatically detects .yml and .yaml files. Additional configuration can be added for Ansible-specific file types.
+* Vim automatically detects .yml and .yaml files. The `vim-ansible` plugin sets the `yaml.ansible` filetype, which is required by `coc-ansible`.

@@ ... @@
+### Built-in Installation
+
+* `coc-ansible` provides a built-in installation option for `ansible`, `ansible-lint`, and optionally `yamllint` within an extension-only virtual environment. This can be triggered manually with the `:CocCommand ansible.builtin.installRequirementsTools` command or will prompt on first use if these tools are not detected.
+
+### Commands
+
+* `coc-ansible` adds several commands to manage the Ansible development environment, such as restarting the language server, showing metadata, resyncing inventory, and displaying plugin information with `ansible-doc`.
+
+### Configuration Options
+
+* `coc-ansible` offers various configuration options to customize the behavior of the Ansible language server and related tools. These options can be set in the `.vim/coc-settings.json` file.
+
+### Code Actions
+
+* `coc-ansible` provides code actions that can be invoked with a mapped key in Vim. These actions include ignoring linting rules for the current line and showing web documentation for specific rules.
+
```

Please ensure that the current contents of `ansible.md` match the context lines in the diff above. If there are any discrepancies, let me know so I can adjust the diff accordingly.

USER: UnifiedDiffNoMatch: hunk failed to apply!

docs/ansible.md does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in docs/ansible.md!

docs/ansible.md does not contain these 4 exact lines in a row:
```
### Configuration Files Used

* - .vim/pack/settings/start/settings/ftplugin/yaml.vim - Configures Vim to recognize YAML files, which are commonly used by Ansible.

```

UnifiedDiffNoMatch: hunk failed to apply!

docs/ansible.md does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in docs/ansible.md!

docs/ansible.md does not contain these 4 exact lines in a row:
```
### Language Server

* - No specific language server for Ansible, but YAML language servers can be used to enhance development experience.

```

UnifiedDiffNoMatch: hunk failed to apply!

docs/ansible.md does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in docs/ansible.md!

docs/ansible.md does not contain these 4 exact lines in a row:
```
### Linting and Static Analysis

* - ansible-lint and yamllint can be integrated with Vim using ALE or CoC to provide linting and static analysis.

```

UnifiedDiffNoMatch: hunk failed to apply!

docs/ansible.md does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in docs/ansible.md!

docs/ansible.md does not contain these 4 exact lines in a row:
```
### Formatting and Beautification

* - No specific formatter for Ansible, but YAML formatters can be used to format Ansible playbooks and roles.

```

UnifiedDiffNoMatch: hunk failed to apply!

docs/ansible.md does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in docs/ansible.md!

docs/ansible.md does not contain these 4 exact lines in a row:
```
### Error Highlighting

* - ALE or CoC can be configured to highlight errors using ansible-lint and yamllint.

```

UnifiedDiffNoMatch: hunk failed to apply!

docs/ansible.md does not contain lines that match the diff you provided!
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The diff needs to apply cleanly to the lines in docs/ansible.md!

docs/ansible.md does not contain these 4 exact lines in a row:
```
### Filetype Detection

* - Vim automatically detects .yml and .yaml files. Additional configuration can be added for Ansible-specific file types.

```

ASSISTANT: I apologize for the oversight. Let's create a new diff that will apply cleanly to the `ansible.md` file. Here is the updated diff:

```diff
--- docs/ansible.md
+++ docs/ansible.md
@@ ... @@
 ### Plugins and Extensions Used

-* [vim-ansible](https://github.com/pearofducks/ansible-vim) (vim plugin) - Provides Ansible syntax highlighting and sets the `yaml.ansible` filetype, which is required by `coc-ansible`.
+* [vim-ansible](https://github.com/pearofducks/ansible-vim) (vim plugin) - Provides Ansible syntax highlighting and sets the `yaml.ansible` filetype, which is required by `coc-ansible`.
 * [coc-ansible](https://github.com/neoclide/coc.nvim/wiki/Using-coc-extensions#implemented-coc-extensions) (coc extension) - Offers auto-completion and other language features for Ansible.

@@ ... @@
 ### Configuration Files Used

-* - .vim/pack/settings/start/settings/ftplugin/yaml.vim - Configures Vim to recognize YAML files, which are commonly used by Ansible.
+* .vim/pack/settings/start/settings/ftplugin/yaml.vim - Configures Vim to recognize YAML files, which are commonly used by Ansible.
+* .vimrc or init.vim - Should include the `g:coc_filetype_map` setting to map `yaml.ansible` to `ansible` for `coc-ansible` extension.

@@ ... @@
 ### Language Server

-* - No specific language server for Ansible, but YAML language servers can be used to enhance development experience.
+* [ansible-language-server](https://github.com/ansible/ansible-language-server) - Provides features like auto-completion, linting, and syntax highlighting for Ansible. It is used by the `coc-ansible` extension.

@@ ... @@
 ### Linting and Static Analysis

-* - ansible-lint and yamllint can be integrated with Vim using ALE or CoC to provide linting and static analysis.
+* ansible-lint and yamllint can be integrated using ALE or CoC. `coc-ansible` can also perform linting with `ansible-lint` and optionally with `yamllint` if it is installed.

@@ ... @@
 ### Formatting and Beautification

-* - No specific formatter for Ansible, but YAML formatters can be used to format Ansible playbooks and roles.
+* None specific for Ansible, but YAML formatting tools can be used. `coc-ansible` provides a built-in installation option for `ansible-lint` and `yamllint`.

@@ ... @@
 ### Error Highlighting

-* - ALE or CoC can be configured to highlight errors using ansible-lint and yamllint.
+* ALE or CoC can be configured to highlight errors using ansible-lint and yamllint. `coc-ansible` will automatically disable linting features if `ansible-lint` is not found.

@@ ... @@
 ### Filetype Detection

-* - Vim automatically detects .yml and .yaml files. Additional configuration can be added for Ansible-specific file types.
+* Vim automatically detects .yml and .yaml files. The `vim-ansible` plugin sets the `yaml.ansible` filetype, which is required by `coc-ansible`.

@@ ... @@
+### Built-in Installation
+
+* `coc-ansible` provides a built-in installation option for `ansible`, `ansible-lint`, and optionally `yamllint` within an extension-only virtual environment. This can be triggered manually with the `:CocCommand ansible.builtin.installRequirementsTools` command or will prompt on first use if these tools are not detected.
+
+### Commands
+
+* `coc-ansible` adds several commands to manage the Ansible development environment, such as restarting the language server, showing metadata, resyncing inventory, and displaying plugin information with `ansible-doc`.
+
+### Configuration Options
+
+* `coc-ansible` offers various configuration options to customize the behavior of the Ansible language server and related tools. These options can be set in the `.vim/coc-settings.json` file.
+
+### Code Actions
+
+* `coc-ansible` provides code actions that can be invoked with a mapped key in Vim. These actions include ignoring linting rules for the current line and showing web documentation for specific rules.
+
```

Please ensure that the current contents of `ansible.md` match the context lines in the diff above. If there are any discrepancies, let me know so I can adjust the diff accordingly.

USER: I added these *read-write* files: .vim/coc-settings.json, .vimrc

ASSISTANT: Given the information from the `coc-ansible` README and the current contents of the `ansible.md` file, I will now create a diff that reflects the necessary updates to the documentation. Here is the updated diff for `ansible.md`:

```diff
--- docs/ansible.md
+++ docs/ansible.md
@@ -1,6 +1,6 @@
 ## Ansible

-This document outlines the support for Ansible development within the development environment.
+This document outlines the support for Ansible development within the Vim environment, integrating the `coc-ansible` extension for enhanced functionality.

 ### External Packages Used
@@ -9,7 +9,7 @@
 - yamllint

 ### Plugins and Extensions Used
-
+* [coc-ansible](https://github.com/yaegassy/coc-ansible) (coc extension) - Provides auto-completion, linting, and other language features for Ansible, using the `ansible-language-server`.
 * [vim-ansible](https://github.com/pearofducks/ansible-vim) (vim plugin) - Provides Ansible syntax highlighting.

@@ -18,7 +18,7 @@

 - .vim/pack/settings/start/settings/ftplugin/yaml.vim - Configures Vim to recognize YAML files, which are commonly used by Ansible.

-### Language Server
+### Language Server and Linting

 * [ansible-language-server](https://github.com/ansible/ansible-language-server) - Provides features like auto-completion, linting, and syntax highlighting for Ansible. It is used by the `coc-ansible` extension.
@@ -27,7 +27,7 @@
 - ansible-lint and yamllint can be integrated using ALE or CoC. `coc-ansible` can also perform linting with `ansible-lint` and optionally with `yamllint` if it is installed.

 ### Auto Completion
-
+* Auto-completion for Ansible is provided by `coc-ansible`, which utilizes the `ansible-language-server`.
 * Provided by the coc-ansible extension through CoC.

@@ -36,7 +36,7 @@

 * None specific for Ansible, but YAML formatting tools can be used. `coc-ansible` provides a built-in installation option for `ansible-lint` and `yamllint`.

-### Error Highlighting
+### Error Highlighting and Code Actions

 * ALE or CoC can be configured to highlight errors using ansible-lint and yamllint. `coc-ansible` will automatically disable linting features if `ansible-lint` is not found.
@@ -45,7 +45,7 @@

 * Built-in Vim settings can be used for folding YAML structures.

-### Snippets
+### Snippets and Commands

 - Snippets for Ansible tasks can be added to UltiSnips or a similar snippet plugin.
@@ -54,7 +54,7 @@

 * None specific for Ansible, but YAML schemas can be validated using a YAML language server.

-### Version Control Integration
+### Version Control Integration and Configuration Options

 - Vim's built-in features or plugins like fugitive.vim can be used for version control integration.
@@ -63,7 +63,7 @@

 * Built-in Vim settings for YAML files provide comment support.

-### Filetype Detection
+### Filetype Detection and Built-in Installation

 * Vim automatically detects .yml and .yaml files. Additional configuration can be added for Ansible-specific file types.
@@ -72,3 +72,19 @@
 This setup ensures a robust development environment for Ansible within Vim, leveraging the power of plugins and extensions to provide a rich set of features.

+### Built-in Installation
+
+* `coc-ansible` provides a built-in installation option for `ansible`, `ansible-lint`, and optionally `yamllint` within an extension-only virtual environment. This can be triggered manually with the `:CocCommand ansible.builtin.installRequirementsTools` command or will prompt on first use if these tools are not detected.
+
+### Commands
+
+* `coc-ansible` adds several commands to manage the Ansible development environment, such as restarting the language server, showing metadata, resyncing inventory, and displaying plugin information with `ansible-doc`.
+
+### Configuration Options
+
+* `coc-ansible` offers various configuration options to customize the behavior of the Ansible language server and related tools. These options can be set in the `.vim/coc-settings.json` file.
+
+### Code Actions
+
+* `coc-ansible` provides code actions that can be invoked with a mapped key in Vim. These actions include ignoring linting rules for the current line and showing web documentation for specific rules.
+
```

Now, let's update the `.vimrc` and `.vim/coc-settings.json` files to include the necessary configuration for `coc-ansible`:

For `.vimrc`:

```diff
--- .vimrc
+++ .vimrc
@@ ... @@
 " This list has to exist before coc is loaded.
 let g:coc_global_extensions = [
     \ 'coc-diagnostic',
     \ 'coc-docker',
     \ 'coc-json',
     \ 'coc-pyright',
     \ 'coc-sh',
     \ 'coc-toml',
     \ 'coc-vimlsp',
+    \ '@yaegassy/coc-ansible',
     \]

@@ ... @@
 " Load all plugins in .vim/pack/*/start
 " This is done by default, it's not needed.
 "packloadall!
+
+" Map yaml.ansible filetype to ansible for coc-ansible extension
+let g:coc_filetype_map = {
+    \ 'yaml.ansible': 'ansible',
+    \}
```

For `.vim/coc-settings.json`:

```diff
--- .vim/coc-settings.json
+++ .vim/coc-settings.json
@@ ... @@
   "diagnostic.virtualTextFormat": " >>> %severity: %message {%source}",

   "coc.preferences.currentFunctionSymbolAutoUpdate": true,
   "coc.preferences.extensionUpdateCheck": "daily",
   "coc.preferences.formatOnSave": false,
   "coc.preferences.useQuickfixForLocations": true,

+  "ansible.enable": true,
+  "ansible.ansible.useFullyQualifiedCollectionNames": true,
+  "ansible.validation.enabled": true,
+  "ansible.validation.lint.enabled": true,
+
   "colors.enable": true,

   "list.alignColumns": true,
```

Please ensure that the current contents of `.vimrc` and `.vim/coc-settings.json` match the context lines in the diffs above. If there are any discrepancies, let me know so I can adjust the diffs accordingly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant