@@ -48,24 +48,25 @@ import Development.IDE.Types.Diagnostics
48
48
import Development.IDE.Types.Location
49
49
import Development.IDE.Types.Logger
50
50
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 ,
53
53
updOptLevel )
54
- import DynFlags (PackageFlag (.. ), PackageArg (.. ))
55
- import GHC hiding (def )
54
+ import DynFlags (PackageFlag (.. ), PackageArg (.. ))
55
+ import GHC hiding (def )
56
56
import GHC.Check (runTimeVersion , compileTimeVersionFromLibdir )
57
57
-- import GhcMonad
58
58
import HIE.Bios.Cradle
59
- import HIE.Bios.Environment (addCmdOpts )
59
+ import HIE.Bios.Environment (addCmdOpts )
60
60
import HIE.Bios.Types
61
- import HscTypes (HscEnv (.. ), ic_dflags )
61
+ import HscTypes (HscEnv (.. ), ic_dflags )
62
62
import qualified Language.Haskell.LSP.Core as LSP
63
63
import Ide.Logger
64
64
import Ide.Plugin
65
65
import Ide.Plugin.Config
66
+ import Ide.Types (IdePlugins , ipMap )
66
67
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 )
69
70
import Module
70
71
import NameCache
71
72
import Packages
@@ -96,15 +97,16 @@ import Ide.Plugin.Pragmas as Pragmas
96
97
97
98
-- ---------------------------------------------------------------------
98
99
100
+
101
+
99
102
-- | The plugins configured for use in this instance of the language
100
103
-- server.
101
104
-- These can be freely added or removed to tailor the available
102
105
-- 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
106
109
where
107
- ps = pluginDescToIdePlugins allPlugins
108
110
allPlugins = if includeExamples
109
111
then basePlugins ++ examplePlugins
110
112
else basePlugins
@@ -113,7 +115,7 @@ idePlugins pid includeExamples
113
115
-- applyRefactDescriptor "applyrefact"
114
116
-- , brittanyDescriptor "brittany"
115
117
-- , haddockDescriptor "haddock"
116
- -- -- , hareDescriptor "hare"
118
+ -- , hareDescriptor "hare"
117
119
-- , hsimportDescriptor "hsimport"
118
120
-- , liquidDescriptor "liquid"
119
121
-- , packageDescriptor "package"
@@ -130,6 +132,8 @@ idePlugins pid includeExamples
130
132
-- ,hfaAlignDescriptor "hfaa"
131
133
]
132
134
135
+ ghcIdePlugins :: T. Text -> IdePlugins -> (Plugin Config , [T. Text ])
136
+ ghcIdePlugins pid ps = (asGhcIdePlugin ps, allLspCmdIds' pid ps)
133
137
134
138
-- ---------------------------------------------------------------------
135
139
@@ -141,14 +145,12 @@ main :: IO ()
141
145
main = do
142
146
-- WARNING: If you write to stdout before runLanguageServer
143
147
-- then the language server will not work
144
- Arguments {.. } <- getArguments " haskell-language-server"
148
+ args @ Arguments {.. } <- getArguments " haskell-language-server"
145
149
146
150
if argsVersion then ghcideVersion >>= putStrLn >> exitSuccess
147
151
else hPutStrLn stderr {- see WARNING above -} =<< ghcideVersion
148
152
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" ]
152
154
$ if argsDebugOn then L. DEBUG else L. INFO
153
155
154
156
-- lock to avoid overlapping output on stdout
@@ -162,8 +164,8 @@ main = do
162
164
163
165
pid <- getPid
164
166
let
165
- (ps, commandIds) = idePlugins pid argsExamplePlugin
166
- -- (ps, commandIds) = idePlugins pid True
167
+ idePlugins' = idePlugins argsExamplePlugin
168
+ (ps, commandIds) = ghcIdePlugins pid idePlugins'
167
169
plugins = Completions. plugin <> CodeAction. plugin <>
168
170
Plugin mempty HoverDefinition. setHandlersDefinition <>
169
171
ps
@@ -174,6 +176,8 @@ main = do
174
176
if argLSP then do
175
177
t <- offsetTime
176
178
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')
177
181
hPutStrLn stderr " If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!"
178
182
runLanguageServer options (pluginHandler plugins) getInitialConfig getConfigFromNotification $ \ getLspId event vfs caps -> do
179
183
t <- t
@@ -183,7 +187,7 @@ main = do
183
187
, optShakeProfiling = argsShakeProfiling
184
188
, optTesting = argsTesting
185
189
, optInterfaceLoadingDiagnostics = argsTesting
186
- , optThreads = 1
190
+ , optThreads = argsThread
187
191
}
188
192
debouncer <- newAsyncDebouncer
189
193
initialise caps (mainRule >> pluginRules plugins >> action kick)
0 commit comments