diff --git a/src/Curry/LanguageServer/Handlers/Initialize.hs b/src/Curry/LanguageServer/Handlers/Initialize.hs index 1ba00ce..5e141e0 100644 --- a/src/Curry/LanguageServer/Handlers/Initialize.hs +++ b/src/Curry/LanguageServer/Handlers/Initialize.hs @@ -1,7 +1,7 @@ {-# LANGUAGE DataKinds, OverloadedStrings #-} module Curry.LanguageServer.Handlers.Initialize (initializeHandler) where -import qualified Curry.LanguageServer.Config as CFG +import Control.Lens ((^.)) import Curry.LanguageServer.FileLoader (fileLoader) import Curry.LanguageServer.Handlers.Diagnostics (emitDiagnostics) import Curry.LanguageServer.Utils.Logging (infoM) @@ -9,19 +9,22 @@ import qualified Curry.LanguageServer.Index.Store as I import Curry.LanguageServer.Monad (LSM) import Data.Maybe (maybeToList, fromMaybe) import qualified Data.Text as T +import qualified Language.LSP.Protocol.Lens as J import qualified Language.LSP.Protocol.Types as J import qualified Language.LSP.Protocol.Message as J import qualified Language.LSP.Server as S initializeHandler :: J.TMessage J.Method_Initialize -> LSM () initializeHandler req = do - infoM "Building index store..." - workspaceFolders <- fromMaybe [] <$> S.getWorkspaceFolders - let folderToPath (J.WorkspaceFolder uri _) = J.uriToFilePath uri - folders = maybeToList . folderToPath =<< workspaceFolders - mapM_ addDirToIndexStore folders - count <- I.getModuleCount - infoM $ "Indexed " <> T.pack (show count) <> " files" + let token = req ^. J.params . J.workDoneToken + S.withIndefiniteProgress "Initializing Curry..." token S.NotCancellable $ \updater -> do + infoM "Building index store..." + workspaceFolders <- fromMaybe [] <$> S.getWorkspaceFolders + let folderToPath (J.WorkspaceFolder uri _) = J.uriToFilePath uri + folders = maybeToList . folderToPath =<< workspaceFolders + mapM_ addDirToIndexStore folders + count <- I.getModuleCount + infoM $ "Indexed " <> T.pack (show count) <> " files" -- | Indexes a workspace folder recursively. addDirToIndexStore :: FilePath -> LSM ()