Merge pull request #35 from conal/master
Auto-completion for compiler option flags and for pragmas
This commit is contained in:
commit
8e86f64f05
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,2 +1,9 @@
|
|||||||
dist/
|
dist/
|
||||||
elisp/*.elc
|
elisp/*.elc
|
||||||
|
*~
|
||||||
|
# Mac OS generates
|
||||||
|
# .DS_Store
|
||||||
|
|
||||||
|
# Where do these files come from? They're not readable.
|
||||||
|
# For instance, .#Help.page
|
||||||
|
# .#*
|
||||||
|
10
Flag.hs
Normal file
10
Flag.hs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
module Flag where
|
||||||
|
|
||||||
|
import DynFlags
|
||||||
|
import Types
|
||||||
|
|
||||||
|
listFlags :: Options -> IO String
|
||||||
|
listFlags opt = return $ convert opt $
|
||||||
|
[ "-f" ++ prefix ++ option
|
||||||
|
| (option,_,_) <- fFlags, prefix <- ["","no-"]
|
||||||
|
]
|
@ -11,6 +11,7 @@ import Data.Typeable
|
|||||||
import Data.Version
|
import Data.Version
|
||||||
import Info
|
import Info
|
||||||
import Lang
|
import Lang
|
||||||
|
import Flag
|
||||||
import Lint
|
import Lint
|
||||||
import List
|
import List
|
||||||
import Paths_ghc_mod
|
import Paths_ghc_mod
|
||||||
@ -31,6 +32,7 @@ usage = "ghc-mod version " ++ showVersion version ++ "\n"
|
|||||||
++ "Usage:\n"
|
++ "Usage:\n"
|
||||||
++ "\t ghc-mod list" ++ ghcOptHelp ++ "[-l]\n"
|
++ "\t ghc-mod list" ++ ghcOptHelp ++ "[-l]\n"
|
||||||
++ "\t ghc-mod lang [-l]\n"
|
++ "\t ghc-mod lang [-l]\n"
|
||||||
|
++ "\t ghc-mod flag [-l]\n"
|
||||||
++ "\t ghc-mod browse" ++ ghcOptHelp ++ "[-l] [-o] <module> [<module> ...]\n"
|
++ "\t ghc-mod browse" ++ ghcOptHelp ++ "[-l] [-o] <module> [<module> ...]\n"
|
||||||
++ "\t ghc-mod check" ++ ghcOptHelp ++ "<HaskellFile>\n"
|
++ "\t ghc-mod check" ++ ghcOptHelp ++ "<HaskellFile>\n"
|
||||||
++ "\t ghc-mod type" ++ ghcOptHelp ++ "<HaskellFile> <module> <expression>\n"
|
++ "\t ghc-mod type" ++ ghcOptHelp ++ "<HaskellFile> <module> <expression>\n"
|
||||||
@ -93,11 +95,13 @@ main = flip catches handlers $ do
|
|||||||
"info" -> withFile (infoExpr opt (safelist cmdArg 2) (safelist cmdArg 3)) (safelist cmdArg 1)
|
"info" -> withFile (infoExpr opt (safelist cmdArg 2) (safelist cmdArg 3)) (safelist cmdArg 1)
|
||||||
"lint" -> withFile (lintSyntax opt) (safelist cmdArg 1)
|
"lint" -> withFile (lintSyntax opt) (safelist cmdArg 1)
|
||||||
"lang" -> listLanguages opt
|
"lang" -> listLanguages opt
|
||||||
|
"flag" -> listFlags opt
|
||||||
"boot" -> do
|
"boot" -> do
|
||||||
mods <- listModules opt
|
mods <- listModules opt
|
||||||
langs <- listLanguages opt
|
langs <- listLanguages opt
|
||||||
|
flags <- listFlags opt
|
||||||
pre <- browseModule opt "Prelude"
|
pre <- browseModule opt "Prelude"
|
||||||
return $ mods ++ langs ++ pre
|
return $ mods ++ langs ++ flags ++ pre
|
||||||
cmd -> throw (NoSuchCommand cmd)
|
cmd -> throw (NoSuchCommand cmd)
|
||||||
putStr res
|
putStr res
|
||||||
where
|
where
|
||||||
|
@ -48,6 +48,8 @@ unloaded modules are loaded")
|
|||||||
(defvar ghc-module-names nil) ;; completion for "import"
|
(defvar ghc-module-names nil) ;; completion for "import"
|
||||||
(defvar ghc-merged-keyword nil) ;; completion for type/func/...
|
(defvar ghc-merged-keyword nil) ;; completion for type/func/...
|
||||||
(defvar ghc-language-extensions nil)
|
(defvar ghc-language-extensions nil)
|
||||||
|
(defvar ghc-option-flags nil)
|
||||||
|
(defvar ghc-pragma-names '("LANGUAGE" "OPTIONS_GHC"))
|
||||||
|
|
||||||
(defconst ghc-keyword-prefix "ghc-keyword-")
|
(defconst ghc-keyword-prefix "ghc-keyword-")
|
||||||
(defvar ghc-keyword-Prelude nil)
|
(defvar ghc-keyword-Prelude nil)
|
||||||
@ -56,12 +58,13 @@ unloaded modules are loaded")
|
|||||||
(defun ghc-comp-init ()
|
(defun ghc-comp-init ()
|
||||||
(let* ((syms '(ghc-module-names
|
(let* ((syms '(ghc-module-names
|
||||||
ghc-language-extensions
|
ghc-language-extensions
|
||||||
|
ghc-option-flags
|
||||||
ghc-keyword-Prelude))
|
ghc-keyword-Prelude))
|
||||||
(vals (ghc-boot (length syms))))
|
(vals (ghc-boot (length syms))))
|
||||||
(ghc-set syms vals))
|
(ghc-set syms vals))
|
||||||
(ghc-add ghc-module-names "qualified")
|
(ghc-add ghc-module-names "qualified")
|
||||||
(ghc-add ghc-module-names "hiding")
|
(ghc-add ghc-module-names "hiding")
|
||||||
(ghc-add ghc-language-extensions "LANGUAGE")
|
;; (ghc-add ghc-language-extensions "LANGUAGE")
|
||||||
(ghc-merge-keywords '("Prelude"))
|
(ghc-merge-keywords '("Prelude"))
|
||||||
(run-with-idle-timer ghc-idle-timer-interval 'repeat 'ghc-idle-timer))
|
(run-with-idle-timer ghc-idle-timer-interval 'repeat 'ghc-idle-timer))
|
||||||
|
|
||||||
@ -172,8 +175,16 @@ unloaded modules are loaded")
|
|||||||
ghc-module-names)
|
ghc-module-names)
|
||||||
((save-excursion
|
((save-excursion
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(looking-at "{-#"))
|
(looking-at "{-# LANGUAGE "))
|
||||||
ghc-language-extensions)
|
ghc-language-extensions)
|
||||||
|
((save-excursion
|
||||||
|
(beginning-of-line)
|
||||||
|
(looking-at "{-# OPTIONS_GHC "))
|
||||||
|
ghc-option-flags)
|
||||||
|
((save-excursion
|
||||||
|
(beginning-of-line)
|
||||||
|
(looking-at "{-# "))
|
||||||
|
ghc-pragma-names)
|
||||||
((or (bolp)
|
((or (bolp)
|
||||||
(let ((end (point)))
|
(let ((end (point)))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
|
@ -23,7 +23,7 @@ Data-Files: Makefile ghc.el ghc-func.el ghc-doc.el ghc-comp.el
|
|||||||
ghc-flymake.el ghc-command.el ghc-info.el ghc-ins-mod.el
|
ghc-flymake.el ghc-command.el ghc-info.el ghc-ins-mod.el
|
||||||
Executable ghc-mod
|
Executable ghc-mod
|
||||||
Main-Is: GHCMod.hs
|
Main-Is: GHCMod.hs
|
||||||
Other-Modules: List Browse Cabal CabalDev Check Info Lang Lint Types ErrMsg Paths_ghc_mod
|
Other-Modules: List Browse Cabal CabalDev Check Info Lang Flag Lint Types ErrMsg Paths_ghc_mod
|
||||||
if impl(ghc >= 6.12)
|
if impl(ghc >= 6.12)
|
||||||
GHC-Options: -Wall -fno-warn-unused-do-bind
|
GHC-Options: -Wall -fno-warn-unused-do-bind
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user