tpope/vim-haml

GetHamlIndent is being too aggressive

csexton opened this issue · 3 comments

Uncomfortably aggressive.

The common case were I have problems is when editing a line with html attributes, entering the closing brace } causes the line to be intended.

I am in normal mode, and have the following line:

%p{:class => "troll"

I edit the line, adding the closing brace and the line gets bumped over by two spaces, which breaks the intention level. This also happens when I edit the line, delete the closing brace and re-add it.

I worked around this, but removing the } from indentkeys, but this seems like the wrong way to do it. For now, I have the following in my .vimrc file:

autocmd FileType haml setlocal indentkeys=o,O,*<Return>,],0),!^F,=end,=else,=elsif,=rescue,=ensure,=when

Can you give more context as to when this happens? It makes sense, but for some reason it never happens to me.

Seems that this may be an edge case, or considered as-designed. The simplest situation I could come up with is a div that has no content:

.clear
%span{:class => "not-in-the-clear"}

The behavior seemed wrong because I was going back and editing existing code and vim-haml was "fixing" the indent for me.

Yeah, it's a rare moment I have to use a clear div nowadays. You can work around this by marking it up as .clear/. Other than that, the algorithm is already pretty delicately balanced, and I'm afraid to tweak it over an edge case like this.