# Ansible-lint --fix

**URL:** <https://forum.ansible.com/t/ansible-lint-fix/39983>\
**Category:** Get Help\
**Tags:** ansible-lint\
**Created:** [February 2, 2025, 11:13pm UTC](https://forum.ansible.com/t/ansible-lint-fix/39983 "2025-02-02T23:13:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bitozoid](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@bitozoid](https://forum.ansible.com/u/bitozoid)\
**Post date:** [February 2, 2025, 11:13pm UTC](https://forum.ansible.com/t/ansible-lint-fix/39983/1 "2025-02-02T23:13:23Z")

</div>

Hi!

I’m trying to set up my developing environment with LazyVim with ansible enabled. Afaik it installs ansible-lint and sets up ansible-language-server.

When I save a file, it seems to run some reformatter. I would say it is the ansible-lint fixer. Can anyone explain to me how is this working?

I have ansible code like this:

```auto
property:
  "{{ some long jinja expression that
          I would like to keep indented
      the way I write it }}"

```

However, the reformatter is modifying it into something like:

```auto
property: "{{ some long jinja expression that
      I would like to keep indented
      the way I write it }}"

```

Can you help me understand what’s going on? Is it the ansible-lint --fix? What property can I setup in the config to avoid this reformatting?

---

<div class="post-metadata">

**Author:** ![nwerker](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/nwerker/32/1270_2.png) [@nwerker](https://forum.ansible.com/u/nwerker)\
**Post date:** [February 3, 2025, 10:09pm UTC](https://forum.ansible.com/t/ansible-lint-fix/39983/2 "2025-02-03T22:09:01Z")

</div>

Hey there,

I’m running a similar setup with neovim and ansible LSP via Mason!

The rules that ansible lint autofix actually can fix on it’s own are well documented [here](https://ansible.readthedocs.io/projects/lint/autofix/).

Ansible lint is getting used to lint the file and provide you with linting feedback, for instance error messages and highlighting those, but should not actually change your code. Afaik it does not use ansible-lint --fix, but you could cross check this with copying examples of provided documentation and if your setup manages to autofix these.

I’d guess that this is due to your LSP setup trying to help you writing “valid” YAML. This also doesn’t necessarily has to be the ansible LSP maybe rather some kind of YAML LSP. So its probably rather an code syntax validation than a linting thingy.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![bitozoid](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@bitozoid](https://forum.ansible.com/u/bitozoid)\
**Post date:** [February 4, 2025, 12:17am UTC](https://forum.ansible.com/t/ansible-lint-fix/39983/3 "2025-02-04T00:17:30Z")

</div>

Thanks a lot for your answer.

I did browse the documentation but I didn’t find this specific case. It seems that `ansible-lint` acts as a reformatter that also reformats yaml, so that’s why I thought it was the one to blame.

---

<div class="post-metadata">

**Author:** ![Denney-tech](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/denney-tech/32/1556_2.png) [@Denney-tech](https://forum.ansible.com/u/Denney-tech)\
**Post date:** [February 4, 2025, 1:21am UTC](https://forum.ansible.com/t/ansible-lint-fix/39983/4 "2025-02-04T01:21:38Z")

</div>

This is a feature of LazyVim, and here’s a discussion with a few ways to disable or customize the feature:  
[Best way to disable auto-format on save completely · LazyVim/LazyVim · Discussion #141 · GitHub](https://github.com/LazyVim/LazyVim/discussions/141)

---

<div class="post-metadata">

**Author:** ![bitozoid](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@bitozoid](https://forum.ansible.com/u/bitozoid)\
**Post date:** [February 4, 2025, 9:42am UTC](https://forum.ansible.com/t/ansible-lint-fix/39983/5 "2025-02-04T09:42:36Z")

</div>

Thanks!

I was digging and found this.

- LazyVim uses both LSP and a formatter.
- LSP is managed via `nvim-lspconfig`, but the installation of the required tools is managed via `mason` and `mason-lspconfig.nvim` (this one also manages file type association).
- Formatting is managed via `conform.nvim` and the `autoformat` option. It seems that lazyvim sets `prettier` for yaml formatting (also installed via `mason`).

So that, on save it is `conform.nvim` the one calling `prettier` which is running using its default configuration.

And finally, `prettier-ignore` did the trick.

```yaml
# prettier-ignore
property:
  "{{ some long jinja expression that
          I would like to keep indented
      the way I write it }}"

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [March 6, 2025, 9:43am UTC](https://forum.ansible.com/t/ansible-lint-fix/39983/6 "2025-03-06T09:43:31Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
