Skip to content

Commit baec2f5

Browse files
committed
Show args and plugins when starting lsp server
1 parent 636524b commit baec2f5

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

exe/Main.hs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,25 @@ import Development.IDE.Types.Diagnostics
4848
import Development.IDE.Types.Location
4949
import Development.IDE.Types.Logger
5050
import 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)
5656
import GHC.Check (runTimeVersion, compileTimeVersionFromLibdir)
5757
-- import GhcMonad
5858
import HIE.Bios.Cradle
59-
import HIE.Bios.Environment (addCmdOpts)
59+
import HIE.Bios.Environment (addCmdOpts)
6060
import HIE.Bios.Types
61-
import HscTypes (HscEnv(..), ic_dflags)
61+
import HscTypes (HscEnv(..), ic_dflags)
6262
import qualified Language.Haskell.LSP.Core as LSP
6363
import Ide.Logger
6464
import Ide.Plugin
6565
import Ide.Plugin.Config
66+
import Ide.Types (IdePlugins, ipMap)
6667
import 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)
6970
import Module
7071
import NameCache
7172
import 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 ()
141145
main = 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

Comments
 (0)