8
8
module Main (main ) where
9
9
10
10
import Arguments
11
- import Data.Maybe
12
- import Data.List.Extra
13
- import System.FilePath
14
11
import Control.Concurrent.Extra
15
12
import Control.Exception
16
13
import Control.Monad.Extra
17
14
import Control.Monad.IO.Class
18
15
import Data.Default
19
- import System.Time.Extra
16
+ import Data.List.Extra
17
+ import qualified Data.Map.Strict as Map
18
+ import Data.Maybe
19
+ import qualified Data.Set as Set
20
+ import qualified Data.Text as T
21
+ import qualified Data.Text.IO as T
20
22
import Development.IDE.Core.FileStore
21
23
import Development.IDE.Core.OfInterest
22
- import Development.IDE.Core.Service
24
+ import Development.IDE.Core.RuleTypes
23
25
import Development.IDE.Core.Rules
26
+ import Development.IDE.Core.Service
24
27
import Development.IDE.Core.Shake
25
- import Development.IDE.Core.RuleTypes
28
+ import Development.IDE.GHC.Util
29
+ import Development.IDE.LSP.LanguageServer
26
30
import Development.IDE.LSP.Protocol
27
- import Development.IDE.Types.Location
31
+ import Development.IDE.Plugin
28
32
import Development.IDE.Types.Diagnostics
29
- import Development.IDE.Types.Options
33
+ import Development.IDE.Types.Location
30
34
import Development.IDE.Types.Logger
31
- import Development.IDE.GHC.Util
32
- import Development.IDE.Plugin
33
- import qualified Data.Text as T
34
- import qualified Data.Text.IO as T
35
+ import Development.IDE.Types.Options
36
+ import Development.Shake ( Action , action )
37
+ import GHC hiding ( def )
38
+ import HIE.Bios
35
39
import Language.Haskell.LSP.Messages
36
40
import Language.Haskell.LSP.Types (LspId (IdInt ))
37
41
import Linker
38
- import Development.IDE.LSP.LanguageServer
39
42
import System.Directory.Extra as IO
40
- import System.IO
41
43
import System.Exit
42
- import Development.Shake (Action , action )
43
- import qualified Data.Set as Set
44
- import qualified Data.Map.Strict as Map
45
-
46
- import GHC hiding (def )
47
-
48
- import HIE.Bios
44
+ import System.FilePath
45
+ import System.IO
46
+ import System.Time.Extra
49
47
50
48
-- ---------------------------------------------------------------------
51
49
52
50
import Development.IDE.Plugin.CodeAction as CodeAction
53
51
import Development.IDE.Plugin.Completions as Completions
54
52
import Ide.Plugin.Example as Example
53
+ import Ide.Plugin.Ormolu as Ormolu
55
54
56
55
-- ---------------------------------------------------------------------
57
56
57
+ -- The plugins configured for use in this instance of the language
58
+ -- server.
59
+ -- These can be freely added or removed to tailor the available
60
+ -- features of the server.
58
61
idePlugins :: Bool -> Plugin
59
62
idePlugins includeExample
60
63
= Completions. plugin <>
61
64
CodeAction. plugin <>
65
+ Ormolu. plugin <>
62
66
if includeExample then Example. plugin else mempty
63
67
68
+ -- ---------------------------------------------------------------------
69
+
64
70
main :: IO ()
65
71
main = do
66
72
-- WARNING: If you write to stdout before runLanguageServer
@@ -100,7 +106,9 @@ main = do
100
106
putStrLn " Report bugs at https://github.com/haskell/haskell-language-server/issues"
101
107
102
108
putStrLn $ " \n Step 1/6: Finding files to test in " ++ dir
103
- files <- nubOrd <$> expandFiles (argFiles ++ [" ." | null argFiles])
109
+ files <- expandFiles (argFiles ++ [" ." | null argFiles])
110
+ -- LSP works with absolute file paths, so try and behave similarly
111
+ files <- nubOrd <$> mapM canonicalizePath files
104
112
putStrLn $ " Found " ++ show (length files) ++ " files"
105
113
106
114
putStrLn " \n Step 2/6: Looking for hie.yaml files that control setup"
@@ -123,7 +131,11 @@ main = do
123
131
let grab file = fromMaybe (head sessions) $ do
124
132
cradle <- Map. lookup file filesToCradles
125
133
Map. lookup cradle cradlesToSessions
126
- ide <- initialise def mainRule (pure $ IdInt 0 ) (showEvent lock) (logger Info ) (defaultIdeOptions $ return $ return . grab) vfs
134
+
135
+ let options =
136
+ (defaultIdeOptions $ return $ return . grab)
137
+ { optShakeProfiling = argsShakeProfiling }
138
+ ide <- initialise def mainRule (pure $ IdInt 0 ) (showEvent lock) (logger Info ) options vfs
127
139
128
140
putStrLn " \n Step 6/6: Type checking the files"
129
141
setFilesOfInterest ide $ Set. fromList $ map toNormalizedFilePath files
@@ -164,7 +176,7 @@ showEvent lock (EventFileDiagnostics (toNormalizedFilePath -> file) diags) =
164
176
showEvent lock e = withLock lock $ print e
165
177
166
178
167
- cradleToSession :: Cradle -> IO HscEnvEq
179
+ cradleToSession :: Cradle a -> IO HscEnvEq
168
180
cradleToSession cradle = do
169
181
cradleRes <- getCompilerOptions " " cradle
170
182
opts <- case cradleRes of
0 commit comments