1-- Copyright (c) 2019 The DAML Authors. All rights reserved.
2-- SPDX-License-Identifier: Apache-2.0
4{-# LANGUAGE RankNTypes #-}
7module Development.IDE.Types.Options
9 , IdeReportProgress(..)
10 , clientSupportsProgress
11 , IdePkgLocationOptions(..)
16import Development.Shake
17import Development.IDE.GHC.Util
18import GHC hiding (parseModule, typecheckModule)
19import GhcPlugins as GHC hiding (fst3, (<>))
20import qualified Language.Haskell.LSP.Types.Capabilities as LSP
22data IdeOptions = IdeOptions
23 { optPreprocessor :: GHC.ParsedSource -> ([(GHC.SrcSpan, String)], GHC.ParsedSource)
24 -- ^ Preprocessor to run over all parsed source trees, generating a list of warnings
25 -- along with a new parse tree.
26 , optGhcSession :: IO (FilePath -> Action HscEnvEq)
27 -- ^ Setup a GHC session for a given file, e.g. @Foo.hs@.
28 -- The 'IO' will be called once, then the resulting function will be applied once per file.
29 -- It is desirable that many files get the same 'HscEnvEq', so that more IDE features work.
30 -- You should not use 'newCacheIO' to get that caching, because of
31 -- https://github.com/ndmitchell/shake/issues/725.
32 , optPkgLocationOpts :: IdePkgLocationOptions
33 -- ^ How to locate source and @.hie@ files given a module name.
34 , optExtensions :: [String]
35 -- ^ File extensions to search for code, defaults to Haskell sources (including @.hs@)
38 -- ^ Number of threads to use. Use 0 for number of threads on the machine.
39 , optShakeProfiling :: Maybe FilePath
40 -- ^ Set to 'Just' to create a directory of profiling reports.
41 , optReportProgress :: IdeReportProgress
42 -- ^ Whether to report progress during long operations.
43 , optLanguageSyntax :: String
44 -- ^ the ```language to use
45 , optNewColonConvention :: Bool
46 -- ^ whether to use new colon convention
49newtype IdeReportProgress = IdeReportProgress Bool
51clientSupportsProgress :: LSP.ClientCapabilities -> IdeReportProgress
52clientSupportsProgress caps = IdeReportProgress $ fromMaybe False $
53 LSP._progress =<< LSP._window (caps :: LSP.ClientCapabilities)
55defaultIdeOptions :: IO (FilePath -> Action HscEnvEq) -> IdeOptions
56defaultIdeOptions session = IdeOptions
57 {optPreprocessor = (,) []
58 ,optGhcSession = session
59 ,optExtensions = ["hs", "lhs"]
60 ,optPkgLocationOpts = defaultIdePkgLocationOptions
62 ,optShakeProfiling = Nothing
63 ,optReportProgress = IdeReportProgress False
64 ,optLanguageSyntax = "haskell"
65 ,optNewColonConvention = False
69-- | The set of options used to locate files belonging to external packages.
70data IdePkgLocationOptions = IdePkgLocationOptions
71 { optLocateHieFile :: PackageConfig -> Module -> IO (Maybe FilePath)
72 -- ^ Locate the HIE file for the given module. The PackageConfig can be
73 -- used to lookup settings like importDirs.
74 , optLocateSrcFile :: PackageConfig -> Module -> IO (Maybe FilePath)
75 -- ^ Locate the source file for the given module. The PackageConfig can be
76 -- used to lookup settings like importDirs. For DAML, we place them in the package DB.
77 -- For cabal this could point somewhere in ~/.cabal/packages.
80defaultIdePkgLocationOptions :: IdePkgLocationOptions
81defaultIdePkgLocationOptions = IdePkgLocationOptions f f
82 where f _ _ = return Nothing
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list