Skip to content

Commit d1a232f

Browse files
authored
Merge pull request #33 from alanz/ormolu-plugin
Formatting via Ormolu plugin
2 parents 438ff8b + f18d916 commit d1a232f

File tree

13 files changed

+368
-110
lines changed

13 files changed

+368
-110
lines changed

.gitmodules

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1-
[submodule "ghcide"]
2-
path = ghcide
3-
url = https://github.com/digital-asset/ghcide.git
1+
# To remove a submodule you need to:
2+
#
3+
# Delete the relevant section from the .gitmodules file.
4+
# Stage the .gitmodules changes git add .gitmodules
5+
# Delete the relevant section from .git/config.
6+
# Run git rm --cached path_to_submodule (no trailing slash).
7+
# Run rm -rf .git/modules/path_to_submodule
8+
# Commit git commit -m "Removed submodule <name>"
9+
# Delete the now untracked submodule files
10+
# rm -rf path_to_submodule

cabal.project

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
packages:
22
./
3-
ghcide
3+
-- ghcide
44

55
tests: true
66

@@ -11,7 +11,4 @@ package ghcide
1111

1212
write-ghc-environment-files: never
1313

14-
-- pre-brexit
15-
-- A later version (2020-02-01T08:48:32Z) has a problem with a diamond
16-
-- dependency for cabal-helper and cabal-plan
17-
index-state: 2020-01-31T21:11:24Z
14+
index-state: 2020-02-04T19:45:47Z

exe/Main.hs

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,59 +8,65 @@
88
module Main(main) where
99

1010
import Arguments
11-
import Data.Maybe
12-
import Data.List.Extra
13-
import System.FilePath
1411
import Control.Concurrent.Extra
1512
import Control.Exception
1613
import Control.Monad.Extra
1714
import Control.Monad.IO.Class
1815
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
2022
import Development.IDE.Core.FileStore
2123
import Development.IDE.Core.OfInterest
22-
import Development.IDE.Core.Service
24+
import Development.IDE.Core.RuleTypes
2325
import Development.IDE.Core.Rules
26+
import Development.IDE.Core.Service
2427
import Development.IDE.Core.Shake
25-
import Development.IDE.Core.RuleTypes
28+
import Development.IDE.GHC.Util
29+
import Development.IDE.LSP.LanguageServer
2630
import Development.IDE.LSP.Protocol
27-
import Development.IDE.Types.Location
31+
import Development.IDE.Plugin
2832
import Development.IDE.Types.Diagnostics
29-
import Development.IDE.Types.Options
33+
import Development.IDE.Types.Location
3034
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
3539
import Language.Haskell.LSP.Messages
3640
import Language.Haskell.LSP.Types (LspId(IdInt))
3741
import Linker
38-
import Development.IDE.LSP.LanguageServer
3942
import System.Directory.Extra as IO
40-
import System.IO
4143
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
4947

5048
-- ---------------------------------------------------------------------
5149

5250
import Development.IDE.Plugin.CodeAction as CodeAction
5351
import Development.IDE.Plugin.Completions as Completions
5452
import Ide.Plugin.Example as Example
53+
import Ide.Plugin.Ormolu as Ormolu
5554

5655
-- ---------------------------------------------------------------------
5756

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.
5861
idePlugins :: Bool -> Plugin
5962
idePlugins includeExample
6063
= Completions.plugin <>
6164
CodeAction.plugin <>
65+
Ormolu.plugin <>
6266
if includeExample then Example.plugin else mempty
6367

68+
-- ---------------------------------------------------------------------
69+
6470
main :: IO ()
6571
main = do
6672
-- WARNING: If you write to stdout before runLanguageServer
@@ -100,7 +106,9 @@ main = do
100106
putStrLn "Report bugs at https://github.com/haskell/haskell-language-server/issues"
101107

102108
putStrLn $ "\nStep 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
104112
putStrLn $ "Found " ++ show (length files) ++ " files"
105113

106114
putStrLn "\nStep 2/6: Looking for hie.yaml files that control setup"
@@ -123,7 +131,11 @@ main = do
123131
let grab file = fromMaybe (head sessions) $ do
124132
cradle <- Map.lookup file filesToCradles
125133
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
127139

128140
putStrLn "\nStep 6/6: Type checking the files"
129141
setFilesOfInterest ide $ Set.fromList $ map toNormalizedFilePath files
@@ -164,7 +176,7 @@ showEvent lock (EventFileDiagnostics (toNormalizedFilePath -> file) diags) =
164176
showEvent lock e = withLock lock $ print e
165177

166178

167-
cradleToSession :: Cradle -> IO HscEnvEq
179+
cradleToSession :: Cradle a -> IO HscEnvEq
168180
cradleToSession cradle = do
169181
cradleRes <- getCompilerOptions "" cradle
170182
opts <- case cradleRes of

ghcide

Lines changed: 0 additions & 1 deletion
This file was deleted.

haskell-language-server.cabal

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ library
2929
exposed-modules:
3030
Ide.Cradle
3131
Ide.Plugin.Example
32+
Ide.Plugin.Ormolu
3233
Ide.Version
3334
other-modules:
3435
Paths_haskell_language_server
@@ -50,7 +51,7 @@ library
5051
, filepath
5152
, fuzzy
5253
, ghc
53-
, ghcide
54+
, ghcide >= 0.1
5455
, gitrev
5556
, haddock-library
5657
, hashable
@@ -77,6 +78,9 @@ library
7778
, transformers
7879
, unordered-containers
7980
, utf8-string
81+
if impl(ghc >= 8.6)
82+
build-depends: ormolu >= 0.0.3.1
83+
8084
ghc-options:
8185
-Wall
8286
-Wredundant-constraints
@@ -121,7 +125,7 @@ executable haskell-language-server
121125
, ghcide
122126
, gitrev
123127
, haskell-lsp
124-
, hie-bios >= 0.3.2 && < 0.4
128+
, hie-bios >= 0.4
125129
, hslogger
126130
, haskell-language-server
127131
, optparse-applicative

0 commit comments

Comments
 (0)