haskell-vim
haskell-vim copied to clipboard
Incorrect indentation with data declaration
If I start with this file:
And I hit <Enter>
, <Comma>
, <Space>
, I get this:
However, I was expecting to get this:
This does not seem correct. I have confirmed that if I remove the Plug 'neovimhaskell/haskell-vim'
line from my .vimrc
file, the problem does not exist.
I'm seeing this behavior too.
I git bisected it and it appears to be caused by commit e6937cb8fbb95c.
For the time being, using haskell-vim at commit 27cbc4b758f5 (which is the direct parent of commit e6937cb8fb) appears to mitigate this problem.
Hmm, using commit 27cbc4b seems to have some problems of its own.
Also, it looks like @raichoo is collecting bad examples of indentation at #73. The information on this thread can probably be moved to there. Then this thread can be closed.
I currently can't reproduce this with recent neovim
and my setup (which is pretty minimal in terms of plugins).
I'm currently using haskell-vim
in regular vim
, not neovim
.
I haven't tested in neovim
, but I'm guessing that there is some difference in how either the indentation stuff works, or the results of the vim-provided built-in functions.
My usual guess is that some other plugin might be interfering. It sort of became a reflex to think that but it happened to be the case surprisingly often.
Thanks for the tip! I'll have to try disabling some of my other haskell-related plugins and see if I can determine which one is to blame.
@cdepillabout Did you ever pinpoint what it was. I am seeing this behavior in neovim.
@raichoo Also similar to @centromere if I remove Plug 'neovimhaskell/haskell-vim'
then I see the expected indentation.
@codedmart Sorry, I haven't had time yet to try to pinpoint the reason.
@raichoo Any guess as to what would be interfering? With 'neovimhaskell/haskell-vim'
I see the indentation issue. Without 'neovimhaskell/haskell-vim'
I don't see the issue anymore.
@codedmart I'm using neovim v0.2.2 and able to get rid of this problem with
autocmd FileType haskell :setlocal nosmartindent
don't know whether or not this will introduce other problems though.
I've played around with this and it seems like the culprit is probably haskell-vim
. I've tried disabling all my other plugins, as well as most of my other vim options, and nothing fixes this.
However, if I disable haskell-vim
and just use the normal indentation for vim from Haskell, indentation works correctly. I'm going to look at the haskell-vim source code and try to figure out what is going wrong.
I've also now tried neovim, and it seems like the problem doesn't improve.
Just to make sure we're all on the same page, here is a complete description of the problem I am seeing:
-
Imagine I am writing a
data
declaration. I start by writing something like the following:data Foobar = Foobar { foo :: Int
My cursor is right after the
t
inInt
. -
Here, I press enter to go to the next line. The cursor is correctly lined up under the open bracket
{
:data Foobar = Foobar { foo :: Int _
-
From here, I press
,
to insert a comma, and then space. Right after I press space,haskell-vim
changes the indentation to the following:data Foobar = Foobar { foo :: Int , _
You can see that the comma has been indented two spaces when it should not be.
-
If you manually go in and de-dent the comma, then when you go to the next line it will be indented correctly.
For example, if I have the following:
data Foobar = Foobar { foo :: Int , bar :: Char_
My cursor is right after the
r
inChar
. If I press enter here, the next line will be indented correctly. It will not do an extra indent after pressing,
.
The above problem also happens with any sort of tuple, lists, etc.
I believe that the offending code is the following:
https://github.com/neovimhaskell/haskell-vim/blob/b1ac46807835423c4a4dd063df6d5b613d89c731/indent/haskell.vim#L160-L188
My guess is that this somehow plays poorly with autoindent
(which I have on).
Commenting out these lines fixes this for me:
https://github.com/neovimhaskell/haskell-vim/blob/master/indent/haskell.vim#L182-L186