1-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2-- SPDX-License-Identifier: Apache-2.0
4{-# LANGUAGE DuplicateRecordFields #-}
5{-# LANGUAGE OverloadedStrings #-}
6{-# LANGUAGE RankNTypes #-}
8module Development.IDE.LSP.Notifications
9 ( setHandlersNotifications
12import Language.Haskell.LSP.Types
13import Development.IDE.LSP.Server
14import qualified Language.Haskell.LSP.Core as LSP
15import qualified Language.Haskell.LSP.Types as LSP
17import Development.IDE.Types.Logger
18import Development.IDE.Core.Service
19import Development.IDE.Types.Location
21import Control.Monad.Extra
22import qualified Data.Set as S
24import Development.IDE.Core.FileStore
25import Development.IDE.Core.OfInterest
28whenUriFile :: Uri -> (NormalizedFilePath -> IO ()) -> IO ()
29whenUriFile uri act = whenJust (LSP.uriToFilePath uri) $ act . toNormalizedFilePath
31setHandlersNotifications :: PartialHandlers
32setHandlersNotifications = PartialHandlers $ \WithMessage{..} x -> return x
33 {LSP.didOpenTextDocumentNotificationHandler = withNotification (LSP.didOpenTextDocumentNotificationHandler x) $
34 \_ ide (DidOpenTextDocumentParams TextDocumentItem{_uri}) -> do
35 setSomethingModified ide
36 whenUriFile _uri $ \file -> do
37 modifyFilesOfInterest ide (S.insert file)
38 logInfo (ideLogger ide) $ "Opened text document: " <> getUri _uri
40 ,LSP.didChangeTextDocumentNotificationHandler = withNotification (LSP.didChangeTextDocumentNotificationHandler x) $
41 \_ ide (DidChangeTextDocumentParams VersionedTextDocumentIdentifier{_uri} _) -> do
42 setSomethingModified ide
43 logInfo (ideLogger ide) $ "Modified text document: " <> getUri _uri
45 ,LSP.didSaveTextDocumentNotificationHandler = withNotification (LSP.didSaveTextDocumentNotificationHandler x) $
46 \_ ide (DidSaveTextDocumentParams TextDocumentIdentifier{_uri}) -> do
47 setSomethingModified ide
48 logInfo (ideLogger ide) $ "Saved text document: " <> getUri _uri
50 ,LSP.didCloseTextDocumentNotificationHandler = withNotification (LSP.didCloseTextDocumentNotificationHandler x) $
51 \_ ide (DidCloseTextDocumentParams TextDocumentIdentifier{_uri}) -> do
52 setSomethingModified ide
53 whenUriFile _uri $ \file -> do
54 modifyFilesOfInterest ide (S.delete file)
55 logInfo (ideLogger ide) $ "Closed text document: " <> getUri _uri
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list