Skip to content

Add stylish-haskell #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 8, 2015
Merged

Add stylish-haskell #39

merged 1 commit into from
Jan 8, 2015

Conversation

igniting
Copy link
Contributor

Run stylish-haskell on Haskell buffers every time they are saved.

@begriffs
Copy link
Owner

begriffs commented Jan 2, 2015

Oh good idea, thanks for the pull request. Is there a way to disable the auto-format-on-save though and make the reformatting happen manually on the whole buffer or a visual selection?

@igniting
Copy link
Contributor Author

igniting commented Jan 2, 2015

stylish-haskell formats only the import statements and the {-# LANGUAGE #-} pragmas. To use it, we have to call :%!stylish-haskell. I added vim-stylish-haskell which runs it automatically on save. I can remove the vim plugin, if it seems a better option.

@igniting
Copy link
Contributor Author

igniting commented Jan 5, 2015

I removed the vim plugin. Users would have to call %!stylish-haskell to run stylish-haskell.

@begriffs
Copy link
Owner

begriffs commented Jan 5, 2015

Thank you! What do you think about making it the default format program, so when you press gq on a selection it gets used (the format program is currently par)?

https://github.com/begriffs/haskell-vim-now/blob/master/.vimrc#L28

Maybe use stylish-haskell only for Haskell buffers and par for all the others.

@igniting
Copy link
Contributor Author

igniting commented Jan 5, 2015

That sounds great! I'll update the PR.

@igniting
Copy link
Contributor Author

igniting commented Jan 5, 2015

Updated

@begriffs
Copy link
Owner

begriffs commented Jan 8, 2015

Finally can you please add a note in the readme explaining this feature?

@igniting
Copy link
Contributor Author

igniting commented Jan 8, 2015

Done

begriffs added a commit that referenced this pull request Jan 8, 2015
@begriffs begriffs merged commit 24c1a0e into begriffs:master Jan 8, 2015
@begriffs
Copy link
Owner

begriffs commented Feb 5, 2015

Hey does this actually work for you? When I make a small selection and press gq I get an error

Language.Haskell.Stylish.Parse.parseModule: could ¬parse <unknown>:
  ParseFailed (SrcLoc "<unknown>.hs" 7 1) "TemplateHaskell is not enabled"

The region I selected didn't have any template haskell in it, so I'm not sure what's going on or if you get a similar error.

@igniting
Copy link
Contributor Author

igniting commented Feb 5, 2015

It works fine for me. Do you encounter this for every file? Someone had reported a similar error upstream haskell/stylish-haskell#3 , but that was long back.

@begriffs
Copy link
Owner

begriffs commented Feb 5, 2015

Maybe it was just the region I happened to select. It worried me that maybe it was breaking all the time for everyone, but if it works OK for you then it's fine. I'll wait until someone else submits an issue before looking into it further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants