Skip to content
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

[Haskell layer] HLint.hs in project root seems to be ignored #753

Closed
tekul opened this issue Mar 3, 2015 · 16 comments
Closed

[Haskell layer] HLint.hs in project root seems to be ignored #753

tekul opened this issue Mar 3, 2015 · 16 comments

Comments

@tekul
Copy link

tekul commented Mar 3, 2015

I just started using emacs/spacemacs, so apologies if I've missed something obvious.

I have an HLint.hs file in my project root folder containing

ignore "Use camelCase" = ""

So, for example, I get

$ hlint Broch/OpenID/Discovery.hs
No suggestions (1 ignored)

However, when viewing the file in emacs, I get a "Use camelCase" flycheck warning for the data type in that file.

Is there a way I can configure options for hlint or get the file picked up?

@syl20bnr
Copy link
Owner

syl20bnr commented Mar 4, 2015

There are no options available at the flycheck level (https://flycheck.readthedocs.org/en/latest/guide/languages.html#el.flycheck-checker.haskell-hlint).
You can try at the HLint level (https://github.com/ndmitchell/hlint#ignoring-hints).

@syl20bnr
Copy link
Owner

syl20bnr commented Mar 4, 2015

If flycheck is ignoring it then a PR may be required to add options for the checker.
Do you know what parameters should be pass to HLint to make it work with your file ?

@tekul
Copy link
Author

tekul commented Mar 4, 2015

What I'm doing is pretty much as described in the second link you've posted (section above the on. Normally hlint detects the file HLint.hs in the current directory automatically when you run the hlint command:

http://community.haskell.org/~ndm/darcs/hlint/hlint.htm#customization

You can see my HLint.hs file here.

Hence you can see it ignoring the camel-case warning when executed from the command line above, and in my vi setup, the warning is also hidden in the editor.

I think it's most likely because the hlint command isn't being run from the root directory, but from the subdirectory where the source file is (emacs seems to change directory based on which file you're looking at, unlike vi), since if I copy the HLint.hs to the subdirectory, the warning in the editor disappears.

Ideally I'd prefer not to have an HLint.hs file in every submodule in my project though :). I don't really know enough yet to work out whether this is anything to do with the spacemacs Haskell code or with some of the stuff it pulls in. Feel free to close this is it's not relevant.

@bjarkevad
Copy link
Contributor

This sounds like it requires some looking-into. I'll see if it has something to do with spacemacs.

@syl20bnr
Copy link
Owner

syl20bnr commented Mar 5, 2015

I looked into this and it is the expected behavior from flycheck, the checker is defined with source-in-place which uses the working directory of the current buffer.

@tekul
Copy link
Author

tekul commented Mar 5, 2015

Thanks for taking the time to look into this. I discovered a flycheck-haskell-hlint-executable variable by grepping for hlint occurrences in all the cached elisp code, so I tried customizing that, with

(custom-set-variables
 '(flycheck-haskell-hlint-executable "/Users/luke/.cabal/bin/hlint --ignore='Use camelCase'")
 )

in my .spacemaces. This command works as expected on the command line, but unfortunately not in emacs, where it seems to break hlint checking. Flycheck stops showing other errors which I know are there.

@syl20bnr
Copy link
Owner

syl20bnr commented Mar 5, 2015

Cool ! So I think it is possible to add an option to the checker to pass the additional arguments. You can then use emacs local variables mechanism.
I'll finish to setup my haskell environment tonight and check to add the support for it in Flycheck.

In the meantime, can you provide a mini haskell file which highlights the issue ? I'll use it to populate the functional tests of flycheck.

@tekul
Copy link
Author

tekul commented Mar 5, 2015

I'm quite confused now :/. I just did an update from spacemacs and I can't find any references to flycheck-haskell-hlint-executable (usign ack) though it still appears in the list if if I use SPC : customize-variable. So I'm not actually sure where it comes from anymore. I can find a few references to it in other people's emacs configurations if I search github. Looking at the flycheck.el file, it looks more like the command is hard-coded, but I'm a bit clueless about elisp and emacs in general.

A Haskell file with any non camel-case variables should show the warning, but I don't want it as I use underscores a lot in JSON data types so that they translate directly to the correct JSON format.

So the following source file would show the warning, for not_camel:

main :: IO ()
main = indefined

not_camel :: Int
not_camel = undefined

@tekul
Copy link
Author

tekul commented Mar 5, 2015

Ok, I see now that the flycheck-haskell-hlint-executable variable is created using a macro, which is why I can't find it directly using grep/ack. I still can't get it to work directly with a --ignore argument, but I found a workaround by using a bash script, mylint:

#! /bin/bash -e

src=$1

hlint --ignore="Use camelCase" $src

and setting

'(flycheck-haskell-hlint-executable "myhlint")

@PierreR
Copy link
Contributor

PierreR commented Jun 5, 2015

@tekul could you let me know where you set up '(flycheck-haskell-hlint-executable "myhlint") exactly. I have been trying a couple of ways but each time I lose flycheck hlint completely (even if the exec does work on the command line and is n the emacs path). Thx

@tekul
Copy link
Author

tekul commented Jun 5, 2015

Hi. I have it in my custom-set-variables section:

;; Do not write anything in this section. This is where Emacs will
;; auto-generate custom variable definitions.
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(evil-escape-key-sequence "jk")
 '(flycheck-haskell-hlint-executable "myhlint")
 '(desktop-save-mode t)
  )

It still seems to be working OK. To be honest I'd forgotten about it :).

@PierreR
Copy link
Contributor

PierreR commented Jun 5, 2015

Thanks for the tip.

@tekul
Copy link
Author

tekul commented Sep 16, 2015

For reference, the latest version of flycheck now has several variables which allow you to pass ignore rules to hlint directly, which should get round these issues:

flycheck/flycheck#682

It also claims to read the HLint.hs file from the project root, but that doesn't seem to be working for me.

@TheBB TheBB closed this as completed Oct 22, 2015
@TheBB
Copy link
Contributor

TheBB commented Oct 22, 2015

In any case this is a flycheck problem, so I will close this issue now.

@d12frosted
Copy link
Contributor

@tekul just tested - it's working for me. Is it still the case?

@tekul
Copy link
Author

tekul commented Nov 6, 2015

I just checked again, and yes, it does seem to be working. Thanks!

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

No branches or pull requests

6 participants