From a32946ed22acc62ca63a7900b07a72f7648de6b9 Mon Sep 17 00:00:00 2001 From: fwcd Date: Mon, 14 Oct 2024 16:59:14 +0200 Subject: [PATCH] Move diagnostic reporting back into the initialized notification handler --- src/Curry/LanguageServer/Handlers.hs | 2 ++ src/Curry/LanguageServer/Handlers/Initialize.hs | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Curry/LanguageServer/Handlers.hs b/src/Curry/LanguageServer/Handlers.hs index 8748be8..aa7e137 100644 --- a/src/Curry/LanguageServer/Handlers.hs +++ b/src/Curry/LanguageServer/Handlers.hs @@ -1,6 +1,7 @@ module Curry.LanguageServer.Handlers (handlers) where import Curry.LanguageServer.Handlers.Cancel (cancelHandler) +import Curry.LanguageServer.Handlers.Initialize (initializedHandler) import Curry.LanguageServer.Handlers.TextDocument.CodeAction (codeActionHandler) import Curry.LanguageServer.Handlers.TextDocument.CodeLens (codeLensHandler) import Curry.LanguageServer.Handlers.TextDocument.Completion (completionHandler) @@ -29,6 +30,7 @@ handlers _caps = mconcat , codeLensHandler , signatureHelpHandler -- Notification handlers + , initializedHandler , didOpenHandler , didChangeHandler , didSaveHandler diff --git a/src/Curry/LanguageServer/Handlers/Initialize.hs b/src/Curry/LanguageServer/Handlers/Initialize.hs index 5e141e0..2dcef6b 100644 --- a/src/Curry/LanguageServer/Handlers/Initialize.hs +++ b/src/Curry/LanguageServer/Handlers/Initialize.hs @@ -1,5 +1,5 @@ {-# LANGUAGE DataKinds, OverloadedStrings #-} -module Curry.LanguageServer.Handlers.Initialize (initializeHandler) where +module Curry.LanguageServer.Handlers.Initialize (initializeHandler, initializedHandler) where import Control.Lens ((^.)) import Curry.LanguageServer.FileLoader (fileLoader) @@ -26,12 +26,14 @@ initializeHandler req = do count <- I.getModuleCount infoM $ "Indexed " <> T.pack (show count) <> " files" +initializedHandler :: S.Handlers LSM +initializedHandler = S.notificationHandler J.SMethod_Initialized $ \_nt -> do + entries <- I.getModuleList + mapM_ (uncurry emitDiagnostics) entries + -- | Indexes a workspace folder recursively. addDirToIndexStore :: FilePath -> LSM () addDirToIndexStore dirPath = do fl <- fileLoader cfg <- S.getConfig I.addWorkspaceDir cfg fl dirPath - entries <- I.getModuleList - mapM_ (uncurry emitDiagnostics) entries - \ No newline at end of file