Skip to content

Formatting via Ormolu plugin #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
[submodule "ghcide"]
path = ghcide
url = https://github.com/digital-asset/ghcide.git
# To remove a submodule you need to:
#
# Delete the relevant section from the .gitmodules file.
# Stage the .gitmodules changes git add .gitmodules
# Delete the relevant section from .git/config.
# Run git rm --cached path_to_submodule (no trailing slash).
# Run rm -rf .git/modules/path_to_submodule
# Commit git commit -m "Removed submodule <name>"
# Delete the now untracked submodule files
# rm -rf path_to_submodule
7 changes: 2 additions & 5 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
packages:
./
ghcide
-- ghcide

tests: true

Expand All @@ -11,7 +11,4 @@ package ghcide

write-ghc-environment-files: never

-- pre-brexit
-- A later version (2020-02-01T08:48:32Z) has a problem with a diamond
-- dependency for cabal-helper and cabal-plan
index-state: 2020-01-31T21:11:24Z
index-state: 2020-02-04T19:45:47Z
60 changes: 36 additions & 24 deletions exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,59 +8,65 @@
module Main(main) where

import Arguments
import Data.Maybe
import Data.List.Extra
import System.FilePath
import Control.Concurrent.Extra
import Control.Exception
import Control.Monad.Extra
import Control.Monad.IO.Class
import Data.Default
import System.Time.Extra
import Data.List.Extra
import qualified Data.Map.Strict as Map
import Data.Maybe
import qualified Data.Set as Set
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Development.IDE.Core.FileStore
import Development.IDE.Core.OfInterest
import Development.IDE.Core.Service
import Development.IDE.Core.RuleTypes
import Development.IDE.Core.Rules
import Development.IDE.Core.Service
import Development.IDE.Core.Shake
import Development.IDE.Core.RuleTypes
import Development.IDE.GHC.Util
import Development.IDE.LSP.LanguageServer
import Development.IDE.LSP.Protocol
import Development.IDE.Types.Location
import Development.IDE.Plugin
import Development.IDE.Types.Diagnostics
import Development.IDE.Types.Options
import Development.IDE.Types.Location
import Development.IDE.Types.Logger
import Development.IDE.GHC.Util
import Development.IDE.Plugin
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Development.IDE.Types.Options
import Development.Shake (Action, action)
import GHC hiding (def)
import HIE.Bios
import Language.Haskell.LSP.Messages
import Language.Haskell.LSP.Types (LspId(IdInt))
import Linker
import Development.IDE.LSP.LanguageServer
import System.Directory.Extra as IO
import System.IO
import System.Exit
import Development.Shake (Action, action)
import qualified Data.Set as Set
import qualified Data.Map.Strict as Map

import GHC hiding (def)

import HIE.Bios
import System.FilePath
import System.IO
import System.Time.Extra

-- ---------------------------------------------------------------------

import Development.IDE.Plugin.CodeAction as CodeAction
import Development.IDE.Plugin.Completions as Completions
import Ide.Plugin.Example as Example
import Ide.Plugin.Ormolu as Ormolu

-- ---------------------------------------------------------------------

-- The plugins configured for use in this instance of the language
-- server.
-- These can be freely added or removed to tailor the available
-- features of the server.
idePlugins :: Bool -> Plugin
idePlugins includeExample
= Completions.plugin <>
CodeAction.plugin <>
Ormolu.plugin <>
if includeExample then Example.plugin else mempty

-- ---------------------------------------------------------------------

main :: IO ()
main = do
-- WARNING: If you write to stdout before runLanguageServer
Expand Down Expand Up @@ -100,7 +106,9 @@ main = do
putStrLn "Report bugs at https://github.com/haskell/haskell-language-server/issues"

putStrLn $ "\nStep 1/6: Finding files to test in " ++ dir
files <- nubOrd <$> expandFiles (argFiles ++ ["." | null argFiles])
files <- expandFiles (argFiles ++ ["." | null argFiles])
-- LSP works with absolute file paths, so try and behave similarly
files <- nubOrd <$> mapM canonicalizePath files
putStrLn $ "Found " ++ show (length files) ++ " files"

putStrLn "\nStep 2/6: Looking for hie.yaml files that control setup"
Expand All @@ -123,7 +131,11 @@ main = do
let grab file = fromMaybe (head sessions) $ do
cradle <- Map.lookup file filesToCradles
Map.lookup cradle cradlesToSessions
ide <- initialise def mainRule (pure $ IdInt 0) (showEvent lock) (logger Info) (defaultIdeOptions $ return $ return . grab) vfs

let options =
(defaultIdeOptions $ return $ return . grab)
{ optShakeProfiling = argsShakeProfiling }
ide <- initialise def mainRule (pure $ IdInt 0) (showEvent lock) (logger Info) options vfs

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


cradleToSession :: Cradle -> IO HscEnvEq
cradleToSession :: Cradle a -> IO HscEnvEq
cradleToSession cradle = do
cradleRes <- getCompilerOptions "" cradle
opts <- case cradleRes of
Expand Down
1 change: 0 additions & 1 deletion ghcide
Submodule ghcide deleted from 913aa5
8 changes: 6 additions & 2 deletions haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ library
exposed-modules:
Ide.Cradle
Ide.Plugin.Example
Ide.Plugin.Ormolu
Ide.Version
other-modules:
Paths_haskell_language_server
Expand All @@ -50,7 +51,7 @@ library
, filepath
, fuzzy
, ghc
, ghcide
, ghcide >= 0.1
, gitrev
, haddock-library
, hashable
Expand All @@ -77,6 +78,9 @@ library
, transformers
, unordered-containers
, utf8-string
if impl(ghc >= 8.6)
build-depends: ormolu >= 0.0.3.1

ghc-options:
-Wall
-Wredundant-constraints
Expand Down Expand Up @@ -121,7 +125,7 @@ executable haskell-language-server
, ghcide
, gitrev
, haskell-lsp
, hie-bios >= 0.3.2 && < 0.4
, hie-bios >= 0.4
, hslogger
, haskell-language-server
, optparse-applicative
Expand Down
Loading