vim2hs icon indicating copy to clipboard operation
vim2hs copied to clipboard

Follow tibbe's style guide better

Open dag opened this issue 12 years ago • 6 comments

I thought I was following it mostly, but seems I either misread it or it changed since I first read it (probably the former).

The main concern is that vim2hs is meant to be used with shiftwidth=2 and then does things like &sw * 2 for function body indentation, so you can dedent a where once to get the style advocated in tibbe's guide.

However I've since realized tibbe's guide suggests shiftwidth=4 for everything except exceptions like where. It would therefore be better to make vim2hs work with that, and then automatically dedent where by &sw / 2 instead.

https://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md

There might be other areas where we could improve as well. I don't like everything in the style guide and have done some things differently in vim2hs because of personal taste, but it's probably better to standardize on something, anything.

dag avatar Mar 20 '13 23:03 dag

i think tibbes suggestion on shiftwidth=4 (i don't read that into the text btw) is sound, because the 4 char indentation is very dominant in this style and other plugins will do the right thing most of the time with sw.

so, i changed autoload/vim2hs/haskell/editing.vim to work with 4 char shiftwidth (these are only 7 lines).

relatedly, shouldn't vim2hs be more opinionated and simply set sw? sw=2 is not the vim default (that is 8 afair). that certainly should be behind a default-on flag though.

opinions?

ibotty avatar Jun 19 '13 10:06 ibotty

Also I wish the syntax highlighting would encourage these lists

[ elem1
, elem2
, elem3
...

rather than

[ elem1,
  elem2,
  elem3,
...

selection_007

Afaik this is something that is encouraged by most haskell style guidlines, including tibbe's.

Tarrasch avatar Nov 15 '13 20:11 Tarrasch

Ah, that's a bug in the type signature highlighting. It shouldn't be highlighted here because it can't be done consistently and reliably, so they're both wrong. The correct highlighting would be as in the second example except for fileName. I tend to put the opening bracket on the first line too, lined up with the commas, which avoids this bug (and is probably why I've never noticed it) and is also the style tibbe recommends.

dag avatar Nov 16 '13 10:11 dag

Ah, thanks for clarifying @dag :)

Out of curiosity, would it be a easy fix to only highlight the signatures if they don't start with spaces? I mean to start the regex with a $.

Tarrasch avatar Nov 16 '13 13:11 Tarrasch

It would, but then it doesn't work for type classes and instances. It's what I do in vim-haskell though (vim2hs rewrite effort, #45).

dag avatar Nov 16 '13 14:11 dag

Ah, looking forward to your rewrite then! :)

Tarrasch avatar Nov 16 '13 14:11 Tarrasch