@@ -48,24 +48,25 @@ import Development.IDE.Types.Diagnostics
4848import Development.IDE.Types.Location
4949import Development.IDE.Types.Logger
5050import Development.IDE.Types.Options
51- import Development.Shake (Action , action )
52- import DynFlags (gopt_set , gopt_unset ,
51+ import Development.Shake (Action , action )
52+ import DynFlags (gopt_set , gopt_unset ,
5353 updOptLevel )
54- import DynFlags (PackageFlag (.. ), PackageArg (.. ))
55- import GHC hiding (def )
54+ import DynFlags (PackageFlag (.. ), PackageArg (.. ))
55+ import GHC hiding (def )
5656import GHC.Check (runTimeVersion , compileTimeVersionFromLibdir )
5757-- import GhcMonad
5858import HIE.Bios.Cradle
59- import HIE.Bios.Environment (addCmdOpts )
59+ import HIE.Bios.Environment (addCmdOpts )
6060import HIE.Bios.Types
61- import HscTypes (HscEnv (.. ), ic_dflags )
61+ import HscTypes (HscEnv (.. ), ic_dflags )
6262import qualified Language.Haskell.LSP.Core as LSP
6363import Ide.Logger
6464import Ide.Plugin
6565import Ide.Plugin.Config
66+ import Ide.Types (IdePlugins , ipMap )
6667import Language.Haskell.LSP.Messages
67- import Language.Haskell.LSP.Types (LspId (IdInt ))
68- import Linker (initDynLinker )
68+ import Language.Haskell.LSP.Types (LspId (IdInt ))
69+ import Linker (initDynLinker )
6970import Module
7071import NameCache
7172import Packages
@@ -96,15 +97,16 @@ import Ide.Plugin.Pragmas as Pragmas
9697
9798-- ---------------------------------------------------------------------
9899
100+
101+
99102-- | The plugins configured for use in this instance of the language
100103-- server.
101104-- These can be freely added or removed to tailor the available
102105-- features of the server.
103- idePlugins :: T. Text -> Bool -> ( Plugin Config , [ T. Text ])
104- idePlugins pid includeExamples
105- = (asGhcIdePlugin ps, allLspCmdIds' pid ps)
106+
107+ idePlugins :: Bool -> IdePlugins
108+ idePlugins includeExamples = pluginDescToIdePlugins allPlugins
106109 where
107- ps = pluginDescToIdePlugins allPlugins
108110 allPlugins = if includeExamples
109111 then basePlugins ++ examplePlugins
110112 else basePlugins
@@ -113,7 +115,7 @@ idePlugins pid includeExamples
113115 -- applyRefactDescriptor "applyrefact"
114116 -- , brittanyDescriptor "brittany"
115117 -- , haddockDescriptor "haddock"
116- -- -- , hareDescriptor "hare"
118+ -- , hareDescriptor "hare"
117119 -- , hsimportDescriptor "hsimport"
118120 -- , liquidDescriptor "liquid"
119121 -- , packageDescriptor "package"
@@ -130,6 +132,8 @@ idePlugins pid includeExamples
130132 -- ,hfaAlignDescriptor "hfaa"
131133 ]
132134
135+ ghcIdePlugins :: T. Text -> IdePlugins -> (Plugin Config , [T. Text ])
136+ ghcIdePlugins pid ps = (asGhcIdePlugin ps, allLspCmdIds' pid ps)
133137
134138-- ---------------------------------------------------------------------
135139
@@ -141,14 +145,12 @@ main :: IO ()
141145main = do
142146 -- WARNING: If you write to stdout before runLanguageServer
143147 -- then the language server will not work
144- Arguments {.. } <- getArguments " haskell-language-server"
148+ args @ Arguments {.. } <- getArguments " haskell-language-server"
145149
146150 if argsVersion then ghcideVersion >>= putStrLn >> exitSuccess
147151 else hPutStrLn stderr {- see WARNING above -} =<< ghcideVersion
148152
149- -- LSP.setupLogger (optLogFile opts) ["hie", "hie-bios"]
150- -- $ if optDebugOn opts then L.DEBUG else L.INFO
151- LSP. setupLogger argsLogFile [" hie" , " hie-bios" ]
153+ LSP. setupLogger argsLogFile [" hls" , " hie-bios" ]
152154 $ if argsDebugOn then L. DEBUG else L. INFO
153155
154156 -- lock to avoid overlapping output on stdout
@@ -162,8 +164,8 @@ main = do
162164
163165 pid <- getPid
164166 let
165- (ps, commandIds) = idePlugins pid argsExamplePlugin
166- -- (ps, commandIds) = idePlugins pid True
167+ idePlugins' = idePlugins argsExamplePlugin
168+ (ps, commandIds) = ghcIdePlugins pid idePlugins'
167169 plugins = Completions. plugin <> CodeAction. plugin <>
168170 Plugin mempty HoverDefinition. setHandlersDefinition <>
169171 ps
@@ -174,6 +176,8 @@ main = do
174176 if argLSP then do
175177 t <- offsetTime
176178 hPutStrLn stderr " Starting (haskell-language-server)LSP server..."
179+ hPutStrLn stderr $ " with arguments: " <> show args
180+ hPutStrLn stderr $ " with plugins: " <> show (Map. keys $ ipMap idePlugins')
177181 hPutStrLn stderr " If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!"
178182 runLanguageServer options (pluginHandler plugins) getInitialConfig getConfigFromNotification $ \ getLspId event vfs caps -> do
179183 t <- t
@@ -183,7 +187,7 @@ main = do
183187 , optShakeProfiling = argsShakeProfiling
184188 , optTesting = argsTesting
185189 , optInterfaceLoadingDiagnostics = argsTesting
186- , optThreads = 1
190+ , optThreads = argsThread
187191 }
188192 debouncer <- newAsyncDebouncer
189193 initialise caps (mainRule >> pluginRules plugins >> action kick)
0 commit comments