5
5
module Main (main ) where
6
6
7
7
import Data.Function ((&) )
8
- import Development.IDE.Types.Logger (Priority (Debug , Info ),
8
+ import Development.IDE.Types.Logger (Priority (Debug , Info , Error ),
9
9
WithPriority (WithPriority , priority ),
10
10
cfilter , cmapWithPrio ,
11
11
makeDefaultStderrRecorder ,
12
- withDefaultRecorder )
12
+ withDefaultRecorder , renderStrict , layoutPretty , defaultLayoutOptions , Doc )
13
13
import Ide.Arguments (Arguments (.. ),
14
14
GhcideArguments (.. ),
15
15
getArguments )
16
16
import Ide.Main (defaultMain )
17
17
import qualified Ide.Main as IdeMain
18
18
import qualified Plugins
19
- import Prettyprinter (Pretty (pretty ))
19
+ import Prettyprinter (Pretty (pretty ), vcat )
20
+ import Development.IDE.Plugin.LSPWindowShowMessageRecorder (makeLspShowMessageRecorder )
21
+ import Data.Text (Text )
22
+ import Ide.PluginUtils (pluginDescToIdePlugins )
20
23
21
24
data Log
22
25
= LogIdeMain IdeMain. Log
@@ -33,6 +36,7 @@ main = do
33
36
-- parser to get logging arguments first or do more complicated things
34
37
pluginCliRecorder <- cmapWithPrio pretty <$> makeDefaultStderrRecorder Nothing Info
35
38
args <- getArguments " haskell-language-server" (Plugins. idePlugins (cmapWithPrio LogPlugins pluginCliRecorder) False )
39
+ (lspRecorder, lspRecorderPlugin) <- makeLspShowMessageRecorder
36
40
37
41
let (minPriority, logFilePath, includeExamplePlugins) =
38
42
case args of
@@ -42,9 +46,23 @@ main = do
42
46
_ -> (Info , Nothing , False )
43
47
44
48
withDefaultRecorder logFilePath Nothing minPriority $ \ textWithPriorityRecorder -> do
45
- let recorder =
46
- textWithPriorityRecorder
47
- & cfilter (\ WithPriority { priority } -> priority >= minPriority)
48
- & cmapWithPrio pretty
49
+ let
50
+ recorder = cmapWithPrio pretty $ mconcat
51
+ [textWithPriorityRecorder
52
+ & cfilter (\ WithPriority { priority } -> priority >= minPriority)
53
+ , lspRecorder
54
+ & cfilter (\ WithPriority { priority } -> priority >= Error )
55
+ & cmapWithPrio renderDoc
56
+ ]
57
+ plugins = Plugins. idePlugins (cmapWithPrio LogPlugins recorder) includeExamplePlugins
49
58
50
- defaultMain (cmapWithPrio LogIdeMain recorder) args (Plugins. idePlugins (cmapWithPrio LogPlugins recorder) includeExamplePlugins)
59
+ defaultMain (cmapWithPrio LogIdeMain recorder) args (pluginDescToIdePlugins [lspRecorderPlugin] <> plugins)
60
+
61
+ renderDoc :: Doc a -> Text
62
+ renderDoc d = renderStrict $ layoutPretty defaultLayoutOptions $ vcat
63
+ [" Unhandled exception, please check your setup and/or the [issue tracker](" <> issueTrackerUrl <> " ): "
64
+ ,d
65
+ ]
66
+
67
+ issueTrackerUrl :: Doc a
68
+ issueTrackerUrl = " https://github.com/haskell/haskell-language-server/issues"
0 commit comments