Simply passing GHC options to ghc-mod check command.
This commit is contained in:
parent
8051e7df2e
commit
cbed907038
2
Check.hs
2
Check.hs
@ -24,5 +24,5 @@ check opt fileName = withGHC $ checkIt `gcatch` handleErrMsg
|
|||||||
setTargetFile file
|
setTargetFile file
|
||||||
load LoadAllTargets
|
load LoadAllTargets
|
||||||
liftIO readLog
|
liftIO readLog
|
||||||
options = ["-Wall","-fno-warn-unused-do-bind"]
|
options = ["-Wall","-fno-warn-unused-do-bind"] ++ ghcOpts opt
|
||||||
++ map ("-i" ++) (checkIncludes opt)
|
++ map ("-i" ++) (checkIncludes opt)
|
||||||
|
@ -26,7 +26,7 @@ usage = "ghc-mod version 0.6.2\n"
|
|||||||
++ "\t ghc-mod list [-l]\n"
|
++ "\t ghc-mod list [-l]\n"
|
||||||
++ "\t ghc-mod lang [-l]\n"
|
++ "\t ghc-mod lang [-l]\n"
|
||||||
++ "\t ghc-mod browse [-l] [-o] <module> [<module> ...]\n"
|
++ "\t ghc-mod browse [-l] [-o] <module> [<module> ...]\n"
|
||||||
++ "\t ghc-mod check [-i inc] <HaskellFile>\n"
|
++ "\t ghc-mod check [-g GHC options] [-i inc] <HaskellFile>\n"
|
||||||
++ "\t ghc-mod type <HaskellFile> <module> <expression>\n"
|
++ "\t ghc-mod type <HaskellFile> <module> <expression>\n"
|
||||||
++ "\t ghc-mod info <HaskellFile> <module> <expression>\n"
|
++ "\t ghc-mod info <HaskellFile> <module> <expression>\n"
|
||||||
++ "\t ghc-mod lint [-h opt] <HaskellFile>\n"
|
++ "\t ghc-mod lint [-h opt] <HaskellFile>\n"
|
||||||
@ -39,6 +39,7 @@ defaultOptions :: Options
|
|||||||
defaultOptions = Options {
|
defaultOptions = Options {
|
||||||
convert = toPlain
|
convert = toPlain
|
||||||
, hlintOpts = []
|
, hlintOpts = []
|
||||||
|
, ghcOpts = []
|
||||||
, checkIncludes = []
|
, checkIncludes = []
|
||||||
, operators = False
|
, operators = False
|
||||||
, packageConfs = []
|
, packageConfs = []
|
||||||
@ -52,6 +53,9 @@ argspec = [ Option "l" ["tolisp"]
|
|||||||
, Option "h" ["hlintOpt"]
|
, Option "h" ["hlintOpt"]
|
||||||
(ReqArg (\h opts -> opts { hlintOpts = h : hlintOpts opts }) "hlintOpt")
|
(ReqArg (\h opts -> opts { hlintOpts = h : hlintOpts opts }) "hlintOpt")
|
||||||
"hint to be ignored"
|
"hint to be ignored"
|
||||||
|
, Option "g" ["ghcOpt"]
|
||||||
|
(ReqArg (\g opts -> opts { ghcOpts = g : ghcOpts opts }) "ghcOpt")
|
||||||
|
"extra GHC options"
|
||||||
, Option "o" ["operators"]
|
, Option "o" ["operators"]
|
||||||
(NoArg (\opts -> opts { operators = True }))
|
(NoArg (\opts -> opts { operators = True }))
|
||||||
"print operators, too"
|
"print operators, too"
|
||||||
|
1
Types.hs
1
Types.hs
@ -13,6 +13,7 @@ import GHC.Paths (libdir)
|
|||||||
data Options = Options {
|
data Options = Options {
|
||||||
convert :: [String] -> String
|
convert :: [String] -> String
|
||||||
, hlintOpts :: [String]
|
, hlintOpts :: [String]
|
||||||
|
, ghcOpts :: [String]
|
||||||
, checkIncludes :: [String]
|
, checkIncludes :: [String]
|
||||||
, operators :: Bool
|
, operators :: Bool
|
||||||
, packageConfs :: [FilePath]
|
, packageConfs :: [FilePath]
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(defvar ghc-hlint-options nil "*Hlint options")
|
(defvar ghc-hlint-options nil "*Hlint options")
|
||||||
|
(defvar ghc-ghc-options nil "*GHC options")
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
@ -45,18 +46,17 @@
|
|||||||
(let ((after-save-hook nil))
|
(let ((after-save-hook nil))
|
||||||
(save-buffer))
|
(save-buffer))
|
||||||
(let ((file (file-name-nondirectory (buffer-file-name))))
|
(let ((file (file-name-nondirectory (buffer-file-name))))
|
||||||
(list ghc-module-command (ghc-flymake-command file ghc-hlint-options))))
|
(list ghc-module-command (ghc-flymake-command file))))
|
||||||
|
|
||||||
(defvar ghc-flymake-command nil) ;; nil: check, t: lint
|
(defvar ghc-flymake-command nil) ;; nil: check, t: lint
|
||||||
|
|
||||||
(defun ghc-flymake-command (file opts)
|
(defun ghc-flymake-command (file)
|
||||||
(if ghc-flymake-command
|
(if ghc-flymake-command
|
||||||
(let ((hopts (ghc-mapconcat (lambda (x) (list "-h" x)) opts)))
|
(let ((hopts (ghc-mapconcat (lambda (x) (list "-h" x)) ghc-hlint-options)))
|
||||||
`(,@hopts "lint" ,file))
|
`(,@hopts "lint" ,file))
|
||||||
(if (null ghc-flymake-check-includes)
|
(let ((gopts (ghc-mapconcat (lambda (x) (list "-g" x)) ghc-ghc-options))
|
||||||
(list "check" file)
|
(includes (ghc-mapconcat (lambda (x) (list "-i" x)) ghc-flymake-check-includes)))
|
||||||
(let ((includes (ghc-mapconcat (lambda (x) (list "-i" x)) ghc-flymake-check-includes)))
|
`(,@gopts "check" ,@includes ,file))))
|
||||||
`("check" ,@includes ,file)))))
|
|
||||||
|
|
||||||
(defun ghc-flymake-toggle-command ()
|
(defun ghc-flymake-toggle-command ()
|
||||||
(interactive)
|
(interactive)
|
||||||
|
Loading…
Reference in New Issue
Block a user