@@ -193,11 +193,8 @@ type ReactorInput
193
193
194
194
-- ---------------------------------------------------------------------
195
195
196
- configVal :: c -> (Config -> c ) -> R c
197
- configVal defVal field = do
198
- gmc <- asksLspFuncs Core. config
199
- mc <- liftIO gmc
200
- return $ maybe defVal field mc
196
+ configVal :: (Config -> c ) -> R c
197
+ configVal field = field <$> getClientConfig
201
198
202
199
-- ---------------------------------------------------------------------
203
200
@@ -508,7 +505,11 @@ reactor inp diagIn = do
508
505
-- Important - Call this before requestDiagnostics
509
506
updatePositionMap uri changes
510
507
511
- queueDiagnosticsRequest diagIn DiagnosticOnChange tn uri ver
508
+ -- By default we don't run diagnostics on each change, unless configured
509
+ -- by the clietn explicitly
510
+ shouldRunDiag <- configVal diagnosticsOnChange
511
+ when shouldRunDiag
512
+ (queueDiagnosticsRequest diagIn DiagnosticOnChange tn uri ver)
512
513
513
514
-- -------------------------------
514
515
@@ -658,7 +659,7 @@ reactor inp diagIn = do
658
659
case mprefix of
659
660
Nothing -> callback []
660
661
Just prefix -> do
661
- snippets <- Hie. WithSnippets <$> configVal True completionSnippetsOn
662
+ snippets <- Hie. WithSnippets <$> configVal completionSnippetsOn
662
663
let hreq = IReq tn (req ^. J. id ) callback
663
664
$ lift $ Hie. getCompletions doc prefix snippets
664
665
makeRequest hreq
@@ -786,8 +787,8 @@ reactor inp diagIn = do
786
787
NotDidChangeConfiguration notif -> do
787
788
liftIO $ U. logs $ " reactor:didChangeConfiguration notification:" ++ show notif
788
789
-- if hlint has been turned off, flush the diagnostics
789
- diagsOn <- configVal True hlintOn
790
- maxDiagnosticsToSend <- configVal 50 maxNumberOfProblems
790
+ diagsOn <- configVal hlintOn
791
+ maxDiagnosticsToSend <- configVal maxNumberOfProblems
791
792
liftIO $ U. logs $ " reactor:didChangeConfiguration diagsOn:" ++ show diagsOn
792
793
-- If hlint is off, remove the diags. But make sure they get sent, in
793
794
-- case maxDiagnosticsToSend has changed.
@@ -808,18 +809,17 @@ reactor inp diagIn = do
808
809
getFormattingProvider :: R FormattingProvider
809
810
getFormattingProvider = do
810
811
providers <- asks formattingProviders
811
- lf <- asks lspFuncs
812
- mc <- liftIO $ Core. config lf
812
+ clientConfig <- getClientConfig
813
813
-- LL: Is this overengineered? Do we need a pluginFormattingProvider
814
814
-- or should we just call plugins straight from here based on the providerType?
815
- let providerName = formattingProvider (fromMaybe def mc)
815
+ let providerName = formattingProvider clientConfig
816
816
mProvider = Map. lookup providerName providers
817
817
case mProvider of
818
818
Nothing -> do
819
819
unless (providerName == " none" ) $ do
820
820
let msg = providerName <> " is not a recognised plugin for formatting. Check your config"
821
821
reactorSend $ NotShowMessage $ fmServerShowMessageNotification J. MtWarning msg
822
- reactorSend $ NotLogMessage $ fmServerLogMessageNotification J. MtWarning msg
822
+ reactorSend $ NotLogMessage $ fmServerLogMessageNotification J. MtWarning msg
823
823
return (\ _ _ _ -> return (IdeResultOk [] )) -- nop formatter
824
824
Just provider -> return provider
825
825
@@ -846,20 +846,20 @@ requestDiagnostics DiagnosticsRequest{trigger, file, trackingNumber, documentVer
846
846
847
847
diagFuncs <- asks diagnosticSources
848
848
lf <- asks lspFuncs
849
- mc <- liftIO $ Core. config lf
849
+ clientConfig <- getClientConfig
850
850
case Map. lookup trigger diagFuncs of
851
851
Nothing -> do
852
852
debugm $ " requestDiagnostics: no diagFunc for:" ++ show trigger
853
853
return ()
854
854
Just dss -> do
855
- dpsEnabled <- configVal ( Map. fromList [( " liquid " , False )]) getDiagnosticProvidersConfig
855
+ dpsEnabled <- configVal getDiagnosticProvidersConfig
856
856
debugm $ " requestDiagnostics: got diagFunc for:" ++ show trigger
857
857
forM_ dss $ \ (pid,ds) -> do
858
858
debugm $ " requestDiagnostics: calling diagFunc for plugin:" ++ show pid
859
859
let
860
860
enabled = Map. findWithDefault True pid dpsEnabled
861
861
publishDiagnosticsIO = Core. publishDiagnosticsFunc lf
862
- maxToSend = maybe 50 maxNumberOfProblems mc
862
+ maxToSend = maxNumberOfProblems clientConfig
863
863
sendOne (fileUri,ds') = do
864
864
debugm $ " LspStdio.sendone:(fileUri,ds')=" ++ show (fileUri,ds')
865
865
publishDiagnosticsIO maxToSend fileUri Nothing (Map. fromList [(Just pid,SL. toSortedList ds')])
@@ -896,8 +896,7 @@ requestDiagnostics DiagnosticsRequest{trigger, file, trackingNumber, documentVer
896
896
-- | get hlint and GHC diagnostics and loads the typechecked module into the cache
897
897
requestDiagnosticsNormal :: TrackingNumber -> J. Uri -> J. TextDocumentVersion -> R ()
898
898
requestDiagnosticsNormal tn file mVer = do
899
- lf <- asks lspFuncs
900
- mc <- liftIO $ Core. config lf
899
+ clientConfig <- getClientConfig
901
900
let
902
901
ver = fromMaybe 0 mVer
903
902
@@ -915,9 +914,9 @@ requestDiagnosticsNormal tn file mVer = do
915
914
hasSeverity sev (J. Diagnostic _ (Just s) _ _ _ _) = s == sev
916
915
hasSeverity _ _ = False
917
916
sendEmpty = publishDiagnostics maxToSend file Nothing (Map. fromList [(Just " ghcmod" ,SL. toSortedList [] )])
918
- maxToSend = maybe 50 maxNumberOfProblems mc
917
+ maxToSend = maxNumberOfProblems clientConfig
919
918
920
- let sendHlint = maybe True hlintOn mc
919
+ let sendHlint = hlintOn clientConfig
921
920
when sendHlint $ do
922
921
-- get hlint diagnostics
923
922
let reql = GReq tn (Just file) (Just (file,ver)) Nothing callbackl
0 commit comments