pearofducks / ansible-vim

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

Starting a new module after blank line does not unindent #32

Closed sean-abbott closed 7 years ago

sean-abbott commented 7 years ago

When I'm trying to start a new module after I've finished one, this plugin always indents to the level of the previous module's keys. i.e.:

- name: "ensure staged init file is populated"                                                         
  become: yes
  template:
    src: "_etc_init.d_staged_service.j2"
    dest: "/etc/init.d/{{ staged_service }}"
    owner: "root"
    group: "root"
    mode: "0755"

    - name: "this shouldn't be indented"

This is super frustrating.

Thanks for the great plugin! I really generally love it!

pearofducks commented 7 years ago

Fair point, try this branch: https://github.com/pearofducks/ansible-vim/tree/newline-indent

Note: I try not to break current experiences, so if this gets merged it will probably be enabled via a flag.

sean-abbott commented 7 years ago

If I put two newlines between the end of a block and the beginning of a new one, it doesn't happen. Still happens with only one newline.

Thanks!

(If it matters, ubuntu 16.04 vim: VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:44:48) Included patches: 1-1689 Extra patches: 8.0.0056 )

pearofducks commented 7 years ago

To clarify...

This (with a spare newline there) works, where 'works' is "resets indentation":

- name: "ensure staged init file is populated"                                                         
  become: yes
  template:
    src: "_etc_init.d_staged_service.j2"
    dest: "/etc/init.d/{{ staged_service }}"
    owner: "root"
    group: "root"
    mode: "0755"

- name: "this shouldn't be indented"

right?

sean-abbott commented 7 years ago

It does not, actually:

https://asciinema.org/a/bi5yk7p5u2lfjfpsh3n8340m8

I mean, it's possible that I just need a better typing workflow, but ideally, if I hit enter twice, it would reset indentation without needing to exit insert mode.

Good enough be not forcing indentation if I exit insert mode and re-enter it (as I did in the video, but it still forced indentation).

Sorry if I'm being a pain. I double checked the auto-detection to make sure that it should be picked up as an ansible file, and I doublechecked when I edited it's picked up as an ansible file. Both are true.

Thanks!

pearofducks commented 7 years ago

No trouble at all, I agree with the use-case.

Somehow git and I disagreed. Update the newline-indent branch and things should work now. :)

sean-abbott commented 7 years ago

OMG that's heaven. Thank you so much!

pearofducks commented 7 years ago

This will be merged to master soon, and already here is controlled via flag to enable:

let g:ansible_unindent_after_newline = 1