Open osa1 opened 8 years ago
I'm planning to collect examples where the indenter does things one does not expect in this thread. Additionally I'm going to push fixes to the branch indentation
. Indenting is hard and very brittle, I'm thankful for edge cases where things fall apart since I can only check if it's behaving correctly for the code I write.
(I haven't tried the indentation
branch yet, but I added one more example here because it looked quite different than the first example)
EDIT: Added one more example.
Thanks a lot, it looks like I didn't handle the pragmas and block comments correctly when checking for nesting. I've pushed another fix on the indentation
branch that should deal with these. Please give them a try and tell me if that fixes the issue for this case.
I'm afraid I don't understand the comment indentation example. You start with a somewhat unusual example:
main :: IO ()
main = do
-- blah blah blah <- why is this indented at all?
-- line1
li-- line2
line3
The indenter aligns by looking at the previous line is you indent that it will use that line to do the indentation. Can you describe what kind of effect you would like the have under which circumstances?
I just tried indentation
branch and it works great, thanks!
About the unusual example: In the code base I'm working on we have all kinds of crazy coding styles and things are very inconsistent. We don't have exactly that function, but we have similarly indented comment blocks followed by de-indented code blocks and haskell-vim tries to indent the code blocks in these cases.
But I agree that it's unusual and maybe we can just ignore that.
No problem. Thanks for bringing these issues to my attention. If you find anything or have an idea how we can support more unusual indentation styles without breaking things and without diminishing convenience just let me know. I will leave this issue open for a while just in case you find something else that bothers you :)
By the way, these changes are now on master
.
I ran into a similar case:
foo =
{ field = bar "("
}
... insert a comma directly below the {
...
foo =
{ field = bar "("
,
}
... and it jumps forward, beneath the (
.
Is this also covered by the changes you made in indendation
?
I have pushed a change onto the indentation branch that should deal with this. Can you check if this fixes your problem and maybe take a shallow look if something else breaks because of this?
Sure, but I'm (embarrassingly) not exactly sure how to test the changes. I use vundle to manage my vim packages and I don't believe there's any support for pointing at a particular branch/commit hash. It just downloads master/HEAD.
Doesn't vundle
keep git repos of the plugins? If so you could simply fetch the branch and check it out manually.
Ah, it does. Looks good, thanks! I'll report any other weird behavior I come across.
I have merged this into master
.
Another annoying one:
foobarlongname = [
blah
, what
,█
^
Cursor here
Press space...
foobarlongname = [
blah
, what
, █
^
Cursor here
Also, it doesn't seem to go away with g:haskell_indent_disable=1
. Is that intended?
Oh, that's weird... I manually went into my plugin folder and git pull
'd, now it works fine. Not sure why :PlugInstall
wasn't updating properly.
This is intended behavior since I'm using comma-first and align them with the enclosing delimiter.
I'm having issues with indentation as well. Given the following code block:
[ (NS spotify spotify (className =? "Spotify") doFullFloat ) ]
If I go to the position before the closing ] and do a linebreak and insert a comma I end up with the following code (_ is the cursor):
[ (NS spotify spotify (className =? "Spotify") doFullFloat )
,_]
Adding a space would now result in the following code:
[ (NS spotify spotify (className =? "Spotify") doFullFloat )
, ]
Any spaces added anywhere on the line would try and match up the comma with the opening parenthesis on the first line and not the opening bracket which (in my opinion) is the correct and expected behavior.
This is indeed an interesting specimen… I have to take a closer look at that.
@xintron I have pushed a fix with 40011132d4ffae60e7a5db04faef1a198a822ad9 but I'm not quite sure why this happens, there seems to be some odd edge case regarding synstack()
which I somewhat fail to wrap my head around.
I'm currently building a test suite for these cases so hopefully this will make the indentation more robust.
Issue #97 has an additional case where indentation doesn't seem to be working quite right.
I'm collecting some problems with the indentation here, with examples.
.
. E.g. something like-- | This is a function.
--
will be automatically added. Remove those.In this code:
I want to unpack
y
too, so I move the cursor right beforeInt
and type{-#
. At this point when I add a space the line gets indented like this:(
_
indicates the cursor)The line isn't indented back after the pragma is completely added:
Suppose I have this:
I want to comment-out
line1
andline2
, so I move my cursor to the beginning of line1 and switch to vertical insert mode, selecting thel
column ofline1
andline2
, switching to insert mode withI
and typing--
. Once I insert that last space, things get indented and I get this:This is a bit hard to explain, so I recorded it here https://asciinema.org/a/5h44shozwdzmla82t6a8nqvn2
(more will come here)