pearofducks / ansible-vim

A vim plugin for syntax highlighting Ansible's common filetypes
MIT License
800 stars 98 forks source link

Arrays of modules overindented #126

Closed alan-strohm closed 3 years ago

alan-strohm commented 3 years ago

Example:

test:
  - role: foo
  - role: bar

While in insert mode, pressing ^F or at the end of the line 3 results in the following:

test:
  - role: foo
    - role: bar

Expected: no change in the indent.

Suggested fix (I'd be happy to send a pull request): InGetAnsibleIndent, check to see if the current line matches array_entry. If so, return its current indent level (i.e. don't change the indentation). Alternatively, I could imagine always keeping the current indent level for any line with non-whitespace characters. The statement about gg=G in the README makes me think that indenting existing (e.g. non-empty) lines is not intended to be supported at this time.

pearofducks commented 3 years ago

Yep, I see this is working fine in the yaml filetype, so I'm up for fixing/improving this behavior for sure!