When I open only Main.hs file and try to go to definition of foo I get "Definition not Found". When I do the same thing but first I open Lib.hs (where function foo is defined) and then I open Main.hs there is no error and I can get to definition of foo.
Log from first scenario:
## versions
vim version: NVIM v0.4.3
node version: v13.13.0
coc.nvim version: 0.0.77-817efd5108
term: screen
platform: linux
## Output channel: snippets
[Info 12:13:31 AM] Using ultisnips directories: UltiSnips /home/xps/.config/coc/ultisnips
[Info 12:13:31 AM] Using ultisnips python command: pyx
## Output channel: languageserver.haskell
2020-04-21 00:13:32.135839293 [ThreadId 4] - run entered for hie-wrapper(hie-wrapper) Version 1.3, Git revision 78eb87b221481d81b8764c821ab3d673e9768464 (3873 commits) x86_64 ghc-8.8.3
2020-04-21 00:13:32.136317753 [ThreadId 4] - Current directory:/home/xps/simple
2020-04-21 00:13:32.136372424 [ThreadId 4] - Operating system:linux
2020-04-21 00:13:32.136400704 [ThreadId 4] - args:["--lsp","--debug"]
2020-04-21 00:13:32.136478462 [ThreadId 4] - Found "/home/xps/simple/hie.yaml" for "/home/xps/simple/File.hs"
2020-04-21 00:13:32.157000317 [ThreadId 4] - Module "/home/xps/simple/File.hs" is loaded by Cradle: Cradle {cradleRootDir = "/home/xps/simple", cradleOptsProg = CradleAction: Stack}
2020-04-21 00:13:32.157211248 [ThreadId 4] - Cradle directory:/home/xps/simple
2020-04-21 00:13:32.157354404 [ThreadId 4] - Executing Stack GHC with args: --numeric-version
2020-04-21 00:13:32.530568304 [ThreadId 4] - GHC Output: "Just "8.8.3""
2020-04-21 00:13:32.530651054 [ThreadId 4] - Project GHC version:8.8.3
2020-04-21 00:13:32.530688413 [ThreadId 4] - hie exe candidates :["hie-8.8.3","hie-8.8","hie"]
2020-04-21 00:13:32.531111812 [ThreadId 4] - found hie exe at:/usr/bin/hie-8.8.3
2020-04-21 00:13:32.531154789 [ThreadId 4] - args:["--lsp","--debug"]
2020-04-21 00:13:32.531201836 [ThreadId 4] - launching ....
2020-04-21 00:13:32.536475905 [ThreadId 4] - Run entered for HIE(hie-8.8.3) Version 1.3, Git revision 78eb87b221481d81b8764c821ab3d673e9768464 (3873 commits) x86_64 ghc-8.8.3
2020-04-21 00:13:32.537718779 [ThreadId 4] - Operating as a LSP server on stdio
2020-04-21 00:13:32.53781528 [ThreadId 4] - Current directory:/home/xps/simple
2020-04-21 00:13:32.53796411 [ThreadId 4] - Operating system:linux
2020-04-21 00:13:32.538021885 [ThreadId 4] - args:["--lsp","--debug"]
2020-04-21 00:13:32.53816839 [ThreadId 4] -
haskell-lsp:Starting up server ...
2020-04-21 00:13:32.538416251 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":139460,"rootPath":"/home/xps/simple","rootUri":"file:///home/xps/simple","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional"},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"versionSupport":false},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}}},"definition":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"typeDefinition":{"dynamicRegistration":true},"implementation":{"dynamicRegistration":true},"declaration":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true},"selectionRange":{"dynamicRegistration":true}},"window":{"workDoneProgress":true}},"initializationOptions":{"languageServerHaskell":{}},"trace":"off","workspaceFolders":[{"uri":"file:///home/xps/simple","name":"simple"}],"workDoneToken":"4d59205b-0b69-4688-9810-d0ef6cf83db9"}}
2020-04-21 00:13:32.541179392 [ThreadId 4] - haskell-lsp:initializeRequestHandler: setting current dir to project root:/home/xps/simple
2020-04-21 00:13:32.54128803 [ThreadId 4] - Dummy Cradle file result: /home/xps/simple/File.hs
2020-04-21 00:13:32.541371951 [ThreadId 4] - Found "/home/xps/simple/hie.yaml" for "/home/xps/simple/File.hs"
2020-04-21 00:13:32.542416124 [ThreadId 4] - Module "/home/xps/simple/File.hs" is loaded by Cradle: Cradle {cradleRootDir = "/home/xps/simple", cradleOptsProg = CradleAction: Stack}
2020-04-21 00:13:32.542727022 [ThreadId 4] - Executing Stack GHC with args: --numeric-version
2020-04-21 00:13:32.910932689 [ThreadId 4] - GHC Output: "Just "8.8.3""
2020-04-21 00:13:32.911040761 [ThreadId 9] - Executing Stack GHC with args: --print-libdir
2020-04-21 00:13:32.911294924 [ThreadId 10] - ****** reactor: top of loop
2020-04-21 00:13:32.911431242 [ThreadId 5] - <--2--{"result":{"capabilities":{"typeDefinitionProvider":true,"foldingRangeProvider":false,"textDocumentSync":{"openClose":true,"change":2,"willSave":false,"willSaveWaitUntil":false,"save":{"includeText":false}},"workspace":{},"implementationProvider":true,"documentRangeFormattingProvider":true,"documentHighlightProvider":true,"executeCommandProvider":{"commands":["139505:applyrefact:applyOne","139505:applyrefact:applyAll","139505:generic:type","139505:ghcmod:check","139505:ghcmod:type","139505:ghcmod:casesplit","139505:hsimport:import","139505:package:add","139505:pragmas:addPragma"]},"renameProvider":false,"colorProvider":false,"definitionProvider":true,"hoverProvider":true,"codeActionProvider":true,"completionProvider":{"triggerCharacters":["."],"resolveProvider":true},"documentSymbolProvider":true,"documentFormattingProvider":true,"referencesProvider":true}},"jsonrpc":"2.0","id":0}
2020-04-21 00:13:32.914078971 [ThreadId 4] - ---> {"jsonrpc":"2.0","method":"initialized","params":{}}
2020-04-21 00:13:32.914229892 [ThreadId 10] - ****** reactor: got message number:0
2020-04-21 00:13:32.91429789 [ThreadId 10] - ****** reactor: processing Initialized Notification
2020-04-21 00:13:32.914347343 [ThreadId 10] - ****** reactor: top of loop
2020-04-21 00:13:32.914427324 [ThreadId 5] - <--2--{"jsonrpc":"2.0","params":{"type":4,"message":"Using hie version: Version 1.3, Git revision 78eb87b221481d81b8764c821ab3d673e9768464 (3873 commits) x86_64 ghc-8.8.3"},"method":"window/logMessage"}
2020-04-21 00:13:32.915983863 [ThreadId 4] - ---> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///home/xps/simple/app/Main.hs","languageId":"haskell","version":1,"text":"module Main where\n\nimport Lib\n\nmain :: IO ()\nmain = foo\n"}}}
2020-04-21 00:13:32.916126698 [ThreadId 10] - ****** reactor: got message number:1
2020-04-21 00:13:32.916178659 [ThreadId 10] - ****** reactor: processing NotDidOpenTextDocument
2020-04-21 00:13:32.916223109 [ThreadId 10] - requestDiagnostics: no diagFunc for:DiagnosticOnOpen
2020-04-21 00:13:32.916256532 [ThreadId 10] - ****** reactor: top of loop
Using hie version: Version 1.3, Git revision 78eb87b221481d81b8764c821ab3d673e9768464 (3873 commits) x86_64 ghc-8.8.3
2020-04-21 00:13:33.296327677 [ThreadId 9] - GHC Output: "Just "/home/xps/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3""
2020-04-21 00:13:33.299072653 [ThreadId 15] - ghcDispatcher: top of loop
2020-04-21 00:13:33.299139462 [ThreadId 15] - ghcDispatcher:got request 0 with id: Nothing
2020-04-21 00:13:33.299254376 [ThreadId 15] - ghcDispatcher: top of loop
2020-04-21 00:13:33.299298229 [ThreadId 15] - ghcDispatcher:got request 1 with id: Nothing
2020-04-21 00:13:33.299341932 [ThreadId 15] - ghcDispatcher:Processing request as version matches
2020-04-21 00:13:33.299444148 [ThreadId 15] - New cradle: /home/xps/simple/app/Main.hs
2020-04-21 00:13:33.299764363 [ThreadId 15] - Found "/home/xps/simple/hie.yaml" for "/home/xps/simple/app/Main.hs"
2020-04-21 00:13:33.299502854 [ThreadId 16] - ideDispatcher: top of loop
2020-04-21 00:13:33.299956799 [ThreadId 15] - Module "/home/xps/simple/app/Main.hs" is loaded by Cradle: Cradle {cradleRootDir = "/home/xps/simple", cradleOptsProg = CradleAction: Stack}
2020-04-21 00:13:33.300080816 [ThreadId 5] - <--2--{"jsonrpc":"2.0","params":{"type":4,"message":"Using hoogle db at: /home/xps/.hoogle/default-haskell-5.0.17.hoo"},"method":"window/logMessage"}
2020-04-21 00:13:33.300135949 [ThreadId 15] - Found cradle: Cradle {cradleRootDir = "/home/xps/simple", cradleOptsProg = CradleAction: Stack}
Using hoogle db at: /home/xps/.hoogle/default-haskell-5.0.17.hoo
2020-04-21 00:13:33.300750629 [ThreadId 5] - <--2--{"jsonrpc":"2.0","params":{"token":0},"method":"window/workDoneProgress/create","id":0}
2020-04-21 00:13:33.300852598 [ThreadId 5] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"begin","cancellable":false,"title":"Initializing Stack project","percentage":0},"token":0},"method":"$/progress"}
2020-04-21 00:13:33.301704316 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":0,"result":null}
2020-04-21 00:13:33.301783095 [ThreadId 4] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":0,\"result\":null}"
2020-04-21 00:13:33.301862886 [ThreadId 10] - ****** reactor: got message number:2
2020-04-21 00:13:33.301925945 [ThreadId 10] - reactor:got RspFromClient:ResponseMessage {_jsonrpc = "2.0", _id = IdRspInt 0, _result = Just Null, _error = Nothing}
2020-04-21 00:13:33.301981941 [ThreadId 10] - ****** reactor: top of loop
2020-04-21 00:13:33.730487169 [ThreadId 23] - Using main module: 1. Package `simple' component simple:exe:simple-exe with main-is file: /home/xps/simple/app/Main.hs
2020-04-21 00:13:33.815139993 [ThreadId 23] - Building all executables for `simple' once. After a successful build of all of them, only specified executables will be rebuilt.
2020-04-21 00:13:34.117307878 [ThreadId 23] - simple> configure (lib + exe)
2020-04-21 00:13:34.492821615 [ThreadId 23] - Configuring simple-0.1.0.0...
2020-04-21 00:13:34.693224103 [ThreadId 23] - simple> initial-build-steps (lib + exe)
2020-04-21 00:13:34.79911277 [ThreadId 23] - The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
2020-04-21 00:13:34.799181606 [ThreadId 23] - Configuring GHCi with the following packages: simple
2020-04-21 00:13:35.334439063 [ThreadId 32] - /home/xps/simple/.stack-work/install/x86_64-linux-tinfo6/ebdbb0da9abcdee79623d607831fe92d930efbfbceafe5446f7b69956dd4c872/8.8.3/pkgdb:/home/xps/.stack/snapshots/x86_64-linux-tinfo6/ebdbb0da9abcdee79623d607831fe92d930efbfbceafe5446f7b69956dd4c872/8.8.3/pkgdb:/home/xps/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.3/lib/ghc-8.8.3/package.conf.d
2020-04-21 00:13:35.440377379 [ThreadId 20] - Modules in the cradle: ["/home/xps/simple/src/Lib.hs","/home/xps/simple/app/Main.hs"]
2020-04-21 00:13:35.440480821 [ThreadId 20] - Cradle set succesfully
2020-04-21 00:13:35.440664537 [ThreadId 20] - haskell-lsp:persistFileVFS: Writing virtual file: uri = NormalizedUri 8711931852446917854 "file:///home/xps/simple/app/Main.hs", virtual file = "/tmp/haskell-lsp139505/Main.hs-00000-8711931852446917854.hs"
2020-04-21 00:13:35.458383972 [ThreadId 5] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"report","percentage":50,"message":"Lib"},"token":0},"method":"$/progress"}
2020-04-21 00:13:35.458470395 [ThreadId 5] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"report","percentage":100,"message":"Main"},"token":0},"method":"$/progress"}
2020-04-21 00:13:35.599716026 [ThreadId 15] - ghcDispatcher: top of loop
2020-04-21 00:13:35.599771638 [ThreadId 15] - ghcDispatcher:got request 1 with id: Nothing
2020-04-21 00:13:35.599832639 [ThreadId 15] - ghcDispatcher:Processing request as version matches
2020-04-21 00:13:35.599936567 [ThreadId 15] - Reusing cradle
2020-04-21 00:13:35.599995629 [ThreadId 15] - setTypecheckedModule: before ghc-mod
2020-04-21 00:13:35.60003837 [ThreadId 15] - Loading file
2020-04-21 00:13:35.600087203 [ThreadId 15] - setTypecheckedModule: before ghc-mod
2020-04-21 00:13:35.600112657 [ThreadId 15] - Loading file
2020-04-21 00:13:35.601910992 [ThreadId 45] - setTargets: [("/home/xps/simple/app/Main.hs","/tmp/haskell-lsp139505/Main.hs-00000-8711931852446917854.hs")]
2020-04-21 00:13:35.601995516 [ThreadId 5] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"end"},"token":0},"method":"$/progress"}
2020-04-21 00:13:35.603599041 [ThreadId 45] - modGraph: [ModLocation {ml_hs_file = Just "/home/xps/simple/src/Lib.hs", ml_hi_file = "/home/xps/.cache/hie-bios/14efb41aef54545a9a6d6207b255b12f672dd8bb/Lib.hi", ml_obj_file = "/home/xps/simple/.stack-work/odir/Lib.o", ml_hie_file = "/home/xps/simple/src/Lib.hie"},ModLocation {ml_hs_file = Just "/tmp/haskell-lsp139505/Main.hs-00000-8711931852446917854.hs", ml_hi_file = "/home/xps/.cache/hie-bios/14efb41aef54545a9a6d6207b255b12f672dd8bb/Main.hi", ml_obj_file = "/home/xps/simple/.stack-work/odir/Main.o", ml_hie_file = "/tmp/haskell-lsp139505/Main.hs-00000-8711931852446917854.hie"}]
2020-04-21 00:13:35.603785061 [ThreadId 45] - init-plugins(loaded):0
2020-04-21 00:13:35.603815662 [ThreadId 45] - init-plugins(specified):0
2020-04-21 00:13:35.613372424 [ThreadId 45] - loaded /home/xps/simple/app/Main.hs - /tmp/haskell-lsp139505/Main.hs-00000-8711931852446917854.hs
2020-04-21 00:13:35.61343521 [ThreadId 45] - Typechecked modules for: Just "/tmp/haskell-lsp139505/Main.hs-00000-8711931852446917854.hs"
2020-04-21 00:13:35.624787042 [ThreadId 15] - File, loaded
2020-04-21 00:13:35.624957134 [ThreadId 15] - setTypecheckedModule: after ghc-mod
2020-04-21 00:13:35.624992635 [ThreadId 15] - Diags: fromList []
2020-04-21 00:13:35.625037049 [ThreadId 15] - setTypecheckedModule: Did get typechecked module for: "/home/xps/simple/app/Main.hs"
2020-04-21 00:13:35.626006996 [ThreadId 15] - setTypecheckedModule: done
2020-04-21 00:13:35.626812155 [ThreadId 15] - Diags: [(NormalizedUri 8711931852446917854 "file:///home/xps/simple/app/Main.hs",[])]
2020-04-21 00:13:35.627615436 [ThreadId 15] - ghcDispatcher: top of loop
2020-04-21 00:13:35.721684436 [ThreadId 5] - <--2--{"jsonrpc":"2.0","params":{"uri":"file:///home/xps/simple/app/Main.hs","diagnostics":[]},"method":"textDocument/publishDiagnostics"}
2020-04-21 00:13:35.72181131 [ThreadId 5] - <--2--{"jsonrpc":"2.0","params":{"token":1},"method":"window/workDoneProgress/create","id":1}
2020-04-21 00:13:35.721856495 [ThreadId 5] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"begin","cancellable":false,"title":"loading","percentage":0},"token":1},"method":"$/progress"}
2020-04-21 00:13:35.721901041 [ThreadId 5] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"report","percentage":50,"message":"Lib"},"token":1},"method":"$/progress"}
2020-04-21 00:13:35.721940534 [ThreadId 5] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"report","percentage":100,"message":"Main"},"token":1},"method":"$/progress"}
2020-04-21 00:13:35.721976757 [ThreadId 5] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"end"},"token":1},"method":"$/progress"}
2020-04-21 00:13:35.722013496 [ThreadId 5] - <--2--{"jsonrpc":"2.0","params":{"uri":"file:///home/xps/simple/app/Main.hs","diagnostics":[]},"method":"textDocument/publishDiagnostics"}
2020-04-21 00:13:35.7226174 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":1,"result":null}
2020-04-21 00:13:35.722688527 [ThreadId 4] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":null}"
2020-04-21 00:13:35.722757988 [ThreadId 10] - ****** reactor: got message number:3
2020-04-21 00:13:35.722814349 [ThreadId 10] - reactor:got RspFromClient:ResponseMessage {_jsonrpc = "2.0", _id = IdRspInt 1, _result = Just Null, _error = Nothing}
2020-04-21 00:13:35.722863363 [ThreadId 10] - ****** reactor: top of loop
2020-04-21 00:13:41.131370057 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///home/xps/simple/app/Main.hs"},"position":{"line":5,"character":9}}}
2020-04-21 00:13:41.131514571 [ThreadId 10] - ****** reactor: got message number:4
2020-04-21 00:13:41.131561111 [ThreadId 10] - reactor:got DefinitionRequest:RequestMessage {_jsonrpc = "2.0", _id = IdInt 1, _method = TextDocumentDefinition, _params = TextDocumentPositionParams {_textDocument = TextDocumentIdentifier {_uri = Uri {getUri = "file:///home/xps/simple/app/Main.hs"}}, _position = Position {_line = 5, _character = 9}, _workDoneToken = Nothing}}
2020-04-21 00:13:41.131604817 [ThreadId 10] - ****** reactor: top of loop
2020-04-21 00:13:41.131636647 [ThreadId 16] - ideDispatcher: got request 4 with id: IdInt 1
2020-04-21 00:13:41.132019186 [ThreadId 16] - ideDispatcher: top of loop
2020-04-21 00:13:41.132079203 [ThreadId 5] - <--2--{"result":[],"jsonrpc":"2.0","id":1}
Thank you for your report!
This is a known issue #1566 and similar exist.
It wont be fixed in HIE due to architectural problems and because hls aims to solve these problems.
I created a simple stack project with following structure:
Main.hs
Lib.hs
When I open only
Main.hs
file and try to go to definition offoo
I get "Definition not Found". When I do the same thing but first I openLib.hs
(where functionfoo
is defined) and then I openMain.hs
there is no error and I can get to definition of foo.Log from first scenario:
Log from second scenario: