1-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2-- SPDX-License-Identifier: Apache-2.0
4{-# LANGUAGE OverloadedStrings #-}
6-- | Go to the definition of a variable.
7module Development.IDE.LSP.Definition
8 ( setHandlersDefinition
11import Language.Haskell.LSP.Types
12import Development.IDE.Types.Location
14import Development.IDE.Types.Logger
15import Development.IDE.Core.Rules
16import Development.IDE.Core.Service
17import Development.IDE.LSP.Server
18import qualified Language.Haskell.LSP.Core as LSP
19import Language.Haskell.LSP.Messages
21import qualified Data.Text as T
23-- | Go to the definition of a variable.
26 -> TextDocumentPositionParams
27 -> IO LocationResponseParams
28gotoDefinition ide (TextDocumentPositionParams (TextDocumentIdentifier uri) pos) = do
29 mbResult <- case uriToFilePath' uri of
31 logInfo (ideLogger ide) $
32 "Definition request at position " <> T.pack (showPosition pos) <>
33 " in file: " <> T.pack path
34 runAction ide $ getDefinition (toNormalizedFilePath path) pos
35 Nothing -> pure Nothing
36 pure $ case mbResult of
37 Nothing -> MultiLoc []
38 Just loc -> SingleLoc loc
41setHandlersDefinition :: PartialHandlers
42setHandlersDefinition = PartialHandlers $ \WithMessage{..} x -> return x{
43 LSP.definitionHandler = withResponse RspDefinition $ const gotoDefinition
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