Skip to content

Commit

Permalink
Report progress for Curry initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed Oct 14, 2024
1 parent 0d641f3 commit 31f5f6f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/Curry/LanguageServer/Handlers/Initialize.hs
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
{-# 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)
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

Check warning on line 20 in src/Curry/LanguageServer/Handlers/Initialize.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Defined but not used: ‘updater’

Check warning on line 20 in src/Curry/LanguageServer/Handlers/Initialize.hs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Defined but not used: ‘updater’

Check warning on line 20 in src/Curry/LanguageServer/Handlers/Initialize.hs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Defined but not used: `updater'
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 ()
Expand Down

0 comments on commit 31f5f6f

Please sign in to comment.