vmware-archive / salt-vim

Vim files for editing Salt files
Other
248 stars 73 forks source link

auto-indentation broken #11

Closed FunTimeCoding closed 9 years ago

FunTimeCoding commented 11 years ago

when indenting using gg=G, the indentation does what its documented to do.

Every ':' the new line gets indented two more spaces. the problem is it never goes back.

base:
  'host1':
    - services.apache
    'host2':
      - services.apache

..it just never removes the two spaces again when it should.

whiteinge commented 11 years ago

I see that too. Thanks for reporting this.

FunTimeCoding commented 11 years ago

is there anything you can do about that? Im not that good at viml yet. Im also pondering to myself -how- the end of an indentation level can be detected by other means than the indentation itself.

my best guess is it shouldnt completely reindent everything, just make sure each value starts in steps of 2 spaces. everything further requires smart parsing of the salt state. and even there, I guess there could be overlapping situations where the indentation would have to guess whats right.

whiteinge commented 11 years ago

I think it should be possible. The way the indentation works now produces invalid yaml, so that's a start. Also it would make sense to try and continue the previous indentation for certain consecutive data types (list items, dictionary keys, etc).

Hopefully someone with some Viml foo will jump in here...or even someone without Viml foo that has some free time to figure it out. :)

gravyboat commented 9 years ago

@whiteinge Is this still an issue? It's been quite a while and I'm not sure if someone addressed it.

whiteinge commented 9 years ago

This is indeed still a thing.

basepi commented 9 years ago

Behavior is still there. The problem is that this particular parsing is a bit difficult -- we can't just de-indent on :, because sometimes we want : with no change in indent (if we're doing multiple keyword arguments, for example). I've never written vim indent files, but we would have to be able to look back at the previous line and see whether it begins in a - or not.

nacho-milanese commented 9 years ago

I fixed the bug for all the examples I tried with, but I was unable to push the code. As it's the first time I collaborate in someone else's code, I don't know what would be the best method to share my code with you

gravyboat commented 9 years ago

@nacho-milanese, Awesome! So you'd want to fork the repo (https://help.github.com/articles/fork-a-repo/), commit your code to your copy of the repo (the fork), then make a pull request against this repo which will automatically create an issue that we'll review and submit feedback on if needed, then merge back into the master branch. The document I linked explains all the steps (or has links to them) regarding how to fork, push your code, and create the PR depending on your familiarity with Git. If you run into any problems feel free to add a comment, otherwise we'll see you in the Pull Request!

nacho-milanese commented 9 years ago

Thanks @gravyboat Pull Request done. Tested against several salt .sls examples and it seems to fix the issue

whiteinge commented 9 years ago

37 is merged. Works like a charm! :smile:

gravyboat commented 9 years ago

@nacho-milanese Awesome thanks a bunch!