Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subcradle for Setup.hs #179

Closed
wants to merge 1 commit into from
Closed

Add subcradle for Setup.hs #179

wants to merge 1 commit into from

Conversation

jneira
Copy link
Member

@jneira jneira commented Jun 28, 2020

@jneira jneira requested a review from fendor June 28, 2020 21:17
Comment on lines +9 to +15
- path: ./Setup.hs
config:
cradle:
direct:
arguments:
- "-package Cabal"
- "-package base"
Copy link
Collaborator

@fendor fendor Jun 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this works correctly for stack. Will the correct cradle be shown (e.g. in logs)? Almost definitely not, it will be a multi-cradle from now on, instead of Stack. So this might kill the hls-wrapper, since it decides based on the cradle type the ghc version.

Copy link
Member Author

@jneira jneira Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm, maybe were you thinking in hie instead hls?

About stack and cradle, the issue is the direct cradle assumes you have ghc on path and that is not the common case for stack. We could remove the subcradle or add a comment, cause the load of setup will fail anyway, but with a diff error.

Copy link
Collaborator

@fendor fendor Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm, maybe were you thinking in hie instead hls?

I was rather thinking of a work-arounds for experts. You can make it work if you really know what you are doing, but I dont think this works for the average case. E.g. since this will longer be identified as a stack cradle, rather a multi-cradle, hls-wrapper wont do what we expect.

We probably need more support for it via hie-bios.

Comment on lines +9 to +15
- path: ./Setup.hs
config:
cradle:
direct:
arguments:
- "-package Cabal"
- "-package base"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as for the stack based hie.yaml: not sure if the hls-wrapper trips over it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm, i tested it with the cabal hie.yaml and hls-wrapper and hls start fine. Setup.hs is loaded correctly in the editor. Will test with the stack hie.yaml...

Full log opening `Setup.hs` with vscode
haskell-lsp:Starting up server ...
2020-06-28 23:37:39.3858016 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":3396,"clientInfo":{"name":"vscode","version":"1.46.1"},"rootPath":"d:\\dev\\ws\\haskell\\hls","rootUri":"file:///d%3A/dev/ws/haskell/hls","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,"tagSupport":{"valueSet":[1,2]}},"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,"tagSupport":{"valueSet":[1]}},"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}},"contextSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":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,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true},"declaration":{"dynamicRegistration":true,"linkSupport":true},"selectionRange":{"dynamicRegistration":true},"callHierarchy":{"dynamicRegistration":true},"semanticTokens":{"dynamicRegistration":true,"tokenTypes":["comment","keyword","number","regexp","operator","namespace","type","struct","class","interface","enum","typeParameter","function","member","macro","variable","parameter","property","label"],"tokenModifiers":["declaration","documentation","static","abstract","deprecated","async","readonly"]}},"window":{"workDoneProgress":true}},"trace":"off","workspaceFolders":[{"uri":"file:///d%3A/dev/ws/haskell/hls","name":"hls"}]}}
2020-06-28 23:37:39.3887979 [ThreadId 4] - haskell-lsp:initializeRequestHandler: setting current dir to project root:d:\dev\ws\haskell\hls
2020-06-28 23:37:39.5498014 [ThreadId 6] - <--2--{"result":{"capabilities":{"typeDefinitionProvider":true,"foldingRangeProvider":false,"textDocumentSync":{"openClose":true,"change":2,"save":{}},"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":true}},"implementationProvider":true,"documentRangeFormattingProvider":true,"documentHighlightProvider":true,"executeCommandProvider":{"commands":["9856:ghcide:typesignature.add","9856:pragmas:addPragma"]},"renameProvider":true,"colorProvider":false,"definitionProvider":true,"hoverProvider":true,"codeActionProvider":true,"completionProvider":{"triggerCharacters":["."],"resolveProvider":false},"codeLensProvider":{},"documentSymbolProvider":true,"documentFormattingProvider":true}},"jsonrpc":"2.0","id":0}
2020-06-28 23:37:39.5908022 [ThreadId 4] - ---> {"jsonrpc":"2.0","method":"initialized","params":{}}
2020-06-28 23:37:39.591804 [ThreadId 4] - ---> {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"languageServerHaskell":{"hlintOn":true,"maxNumberOfProblems":100,"diagnosticsOnChange":true,"liquidOn":false,"completionSnippetsOn":true,"formatOnImportOn":true,"formattingProvider":"floskell","trace":{"server":"messages"},"logFile":"C:\\TEMP\\hls.log","serverVariant":"haskell-language-server","serverExecutablePath":"","enableHIE":true,"hieVariant":"haskell-language-server"}}}}
2020-06-28 23:37:39.591804 [ThreadId 4] - ---> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///d%3A/dev/ws/haskell/hls/Setup.hs","languageId":"haskell","version":1,"text":"import Distribution.Simple\r\nmain = defaultMain\r\n"}}}
2020-06-28 23:37:39.5928019 [ThreadId 14] - Set files of interest to: [NormalizedFilePath "D:\\dev\\ws\\haskell\\hls\\Setup.hs"]
2020-06-28 23:37:39.6038029 [ThreadId 14] - Restarting build session (aborting the previous one took 0.00s)
2020-06-28 23:37:39.6038029 [ThreadId 13] - Finishing build session(exception: AsyncCancelled)
2020-06-28 23:37:39.6048031 [ThreadId 14] - Opened text document: file:///d%3A/dev/ws/haskell/hls/Setup.hs
2020-06-28 23:37:39.6118013 [ThreadId 45] - Consulting the cradle for "D:\\dev\\ws\\haskell\\hls\\Setup.hs"
2020-06-28 23:37:39.6168033 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"token":0},"method":"window/workDoneProgress/create","id":0}
2020-06-28 23:37:39.6168033 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"begin","cancellable":false,"title":"Setting up project hls"},"token":0},"method":"$/progress"}
2020-06-28 23:37:39.6208055 [ThreadId 45] - Session loading result: Right (ComponentOptions {componentOptions = ["-package Cabal","-package base"], componentRoot = "D:\\dev\\ws\\haskell\\hls", componentDependencies = []})
2020-06-28 23:37:39.6228041 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"end"},"token":0},"method":"$/progress"}
2020-06-28 23:37:39.6248054 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":0,"result":null}
2020-06-28 23:37:39.6248054 [ThreadId 4] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":0,\"result\":null}"
2020-06-28 23:37:39.6738039 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":1,"method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///d%3A/dev/ws/haskell/hls/Setup.hs"}}}
2020-06-28 23:37:39.6748011 [ThreadId 6] - <--2--{"result":[],"jsonrpc":"2.0","id":1}
2020-06-28 23:37:39.9848024 [ThreadId 45] - Using interface files cache dir: C:\Users\atrey\AppData\Local\ghcide\main-d1af3913b26f652a47f22da321009249cf7a996d
2020-06-28 23:37:39.9848024 [ThreadId 45] - Making new HscEnv[main]
2020-06-28 23:37:40.0528019 [ThreadId 45] - New Component Cache HscEnvEq: (([],Just HscEnvEq 10),fromList [("D:\\dev\\ws\\haskell\\hls\\hie.yaml",Just 2020-06-27 22:14:42.5867603 UTC)])
2020-06-28 23:37:40.0548053 [ThreadId 22] - Finishing build session(exception: AsyncCancelled)
2020-06-28 23:37:40.0558035 [ThreadId 45] - Restarting build session (aborting the previous one took 0.00s)
2020-06-28 23:37:40.0608024 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"registrations":[{"registerOptions":{"watchers":[{"kind":5,"globPattern":"D:\\dev\\ws\\haskell\\hls\\hie.yaml"}]},"method":"workspace/didChangeWatchedFiles","id":"D:\\dev\\ws\\haskell\\hls\\hie.yaml"}]},"method":"client/registerCapability","id":1}
2020-06-28 23:37:40.0658028 [ThreadId 93] - finish: C:GetParsedModule (took 0.01s)
2020-06-28 23:37:40.067803 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"registrations":[{"registerOptions":{"watchers":[{"kind":5,"globPattern":"D:\\dev\\ws\\haskell\\hls\\Prelude.hs"}]},"method":"workspace/didChangeWatchedFiles","id":"D:\\dev\\ws\\haskell\\hls\\Prelude.hs"}]},"method":"client/registerCapability","id":2}
2020-06-28 23:37:40.0738051 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"registrations":[{"registerOptions":{"watchers":[{"kind":5,"globPattern":"D:\\dev\\ws\\haskell\\hls\\Prelude.lhs"}]},"method":"workspace/didChangeWatchedFiles","id":"D:\\dev\\ws\\haskell\\hls\\Prelude.lhs"}]},"method":"client/registerCapability","id":3}
2020-06-28 23:37:40.0758032 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"registrations":[{"registerOptions":{"watchers":[{"kind":5,"globPattern":"D:\\dev\\ws\\haskell\\hls\\Distribution\\Simple.hs"}]},"method":"workspace/didChangeWatchedFiles","id":"D:\\dev\\ws\\haskell\\hls\\Distribution\\Simple.hs"}]},"method":"client/registerCapability","id":4}
2020-06-28 23:37:40.0767994 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"registrations":[{"registerOptions":{"watchers":[{"kind":5,"globPattern":"D:\\dev\\ws\\haskell\\hls\\Distribution\\Simple.lhs"}]},"method":"workspace/didChangeWatchedFiles","id":"D:\\dev\\ws\\haskell\\hls\\Distribution\\Simple.lhs"}]},"method":"client/registerCapability","id":5}
2020-06-28 23:37:40.1498041 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":1,"result":null}
2020-06-28 23:37:40.150804 [ThreadId 4] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":null}"
2020-06-28 23:37:40.150804 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":2,"result":null}
2020-06-28 23:37:40.150804 [ThreadId 4] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":2,\"result\":null}"
2020-06-28 23:37:40.1538075 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":3,"result":null}
2020-06-28 23:37:40.1538075 [ThreadId 4] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":3,\"result\":null}"
2020-06-28 23:37:40.1548054 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":4,"result":null}
2020-06-28 23:37:40.1548054 [ThreadId 4] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":4,\"result\":null}"
2020-06-28 23:37:40.155803 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":5,"result":null}
2020-06-28 23:37:40.1568037 [ThreadId 4] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":5,\"result\":null}"
2020-06-28 23:37:40.1838032 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":6,"result":null}
2020-06-28 23:37:40.1838032 [ThreadId 4] - haskell-lsp:Got reply message:"{\"jsonrpc\":\"2.0\",\"id\":6,\"result\":null}"
2020-06-28 23:37:40.1838032 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"token":"31"},"method":"window/workDoneProgress/create","id":6}
2020-06-28 23:37:40.1848031 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"begin","title":"Processing"},"token":"31"},"method":"$/progress"}
2020-06-28 23:37:40.2528035 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":2,"method":"textDocument/codeLens","params":{"textDocument":{"uri":"file:///d%3A/dev/ws/haskell/hls/Setup.hs"}}}
2020-06-28 23:37:40.2538162 [ThreadId 127] - Plugin.makeCodeLens (ideLogger)
2020-06-28 23:37:40.2538162 [ThreadId 6] - <--2--{"result":[],"jsonrpc":"2.0","id":2}
2020-06-28 23:37:40.2918029 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"report","message":"2/3"},"token":"31"},"method":"$/progress"}
2020-06-28 23:37:40.4658004 [ThreadId 6] - <--2--{"jsonrpc":"2.0","params":{"value":{"kind":"end"},"token":"31"},"method":"$/progress"}
2020-06-28 23:37:40.4918029 [ThreadId 131] - finish: C:TypeCheck (took 0.24s)
2020-06-28 23:38:11.4919534 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":3,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///d%3A/dev/ws/haskell/hls/Setup.hs"},"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}},"context":{"diagnostics":[]}}}
2020-06-28 23:38:11.492951 [ThreadId 131] - finish: CodeAction (took 0.00s)
2020-06-28 23:38:11.6659502 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":4,"method":"textDocument/codeLens","params":{"textDocument":{"uri":"file:///d%3A/dev/ws/haskell/hls/Setup.hs"}}}
2020-06-28 23:38:11.6659502 [ThreadId 4] - ---> {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":3}}
2020-06-28 23:38:11.67195 [ThreadId 14] - Cancelled request IdInt 3
2020-06-28 23:38:11.6729497 [ThreadId 137] - Plugin.makeCodeLens (ideLogger)
2020-06-28 23:38:11.6729497 [ThreadId 6] - <--2--{"error":{"code":-32800,"message":""},"jsonrpc":"2.0","id":3}
2020-06-28 23:38:11.676951 [ThreadId 6] - <--2--{"result":[{"command":{"command":"9856:ghcide:typesignature.add","arguments":[{"changes":{"file:///d%3A/dev/ws/haskell/hls/Setup.hs":[{"range":{"start":{"line":1,"character":0},"end":{"line":1,"character":0}},"newText":"main :: IO ()\n"}]}}],"title":"main :: IO ()"},"range":{"start":{"line":1,"character":0},"end":{"line":1,"character":4}}}],"jsonrpc":"2.0","id":4}
2020-06-28 23:38:12.70595 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":5,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///d%3A/dev/ws/haskell/hls/Setup.hs"},"position":{"line":1,"character":10}}}
2020-06-28 23:38:12.7069494 [ThreadId 140] - GhcIde.hover entered (ideLogger)
2020-06-28 23:38:12.7069494 [ThreadId 140] - Hover request at position 2:11 in file: d:\dev\ws\haskell\hls\Setup.hs
2020-06-28 23:38:12.7079472 [ThreadId 6] - <--2--{"result":null,"jsonrpc":"2.0","id":5}
2020-06-28 23:38:16.9340577 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":6,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///d%3A/dev/ws/haskell/hls/Setup.hs"},"position":{"line":1,"character":14}}}
2020-06-28 23:38:16.9350519 [ThreadId 143] - GhcIde.hover entered (ideLogger)
2020-06-28 23:38:16.9350519 [ThreadId 143] - Hover request at position 2:15 in file: d:\dev\ws\haskell\hls\Setup.hs
2020-06-28 23:38:16.9360605 [ThreadId 6] - <--2--{"result":null,"jsonrpc":"2.0","id":6}
2020-06-28 23:38:21.868392 [ThreadId 147] - finish: CodeAction:PackageExports (took 10.37s)
2020-06-28 23:38:21.868392 [ThreadId 147] - finish: C:TypeCheck (took 0.00s)
2020-06-28 23:38:21.882386 [ThreadId 150] - finish: C:GetHieFile (took 0.01s)
2020-06-28 23:38:21.882386 [ThreadId 150] - finish: C:GetHieFile (took 0.00s)
2020-06-28 23:38:27.4400854 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":7,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///d%3A/dev/ws/haskell/hls/Setup.hs"},"position":{"line":1,"character":15}}}
2020-06-28 23:38:27.4410853 [ThreadId 152] - GhcIde.hover entered (ideLogger)
2020-06-28 23:38:27.4410853 [ThreadId 152] - Hover request at position 2:16 in file: d:\dev\ws\haskell\hls\Setup.hs
2020-06-28 23:38:27.4410853 [ThreadId 150] - finish: C:GetHieFile (took 0.00s)
2020-06-28 23:38:27.442077 [ThreadId 6] - <--2--{"result":{"contents":{"kind":"markdown","value":"\n```haskell\ndefaultMain :: IO ()\n```\n\n*Defined in `Distribution.Simple'*\n*\t*\t*\n\n```haskell\n_ :: IO ()\n```\n"},"range":{"start":{"line":1,"character":7},"end":{"line":1,"character":18}}},"jsonrpc":"2.0","id":7}
2020-06-28 23:38:27.4440755 [ThreadId 161] - finish: C:GetDocMap (took 0.00s)
[client] run command: "haskell-language-server-wrapper --lsp"
[client] debug command: "haskell-language-server-wrapper --lsp -d -l C:\TEMP\hls.log"
[client] server cwd: undefined
ghcide version: 0.1.0.0 (GHC: 8.8.3) (PATH: D:\bin\haskell-language-server-wrapper.exe)
ghcide version: 0.1.0.0 (GHC: 8.8.3) (PATH: D:\bin\haskell-language-server-8.8.3.exe)
Starting (haskell-language-server)LSP server...
  with arguments: Arguments {argLSP = True, argsCwd = Nothing, argFiles = [], argsVersion = False, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = True, argsLogFile = Just "C:\\TEMP\\hls.log", argsThreads = 0}
  with plugins: [PluginId "brittany",PluginId "floskell",PluginId "ghcide",PluginId "ormolu",PluginId "pragmas",PluginId "stylish-haskell"]
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
 Started LSP server in 0.01s
Data.HashMap.Base.(!): key not found
CallStack (from HasCallStack):
  error, called at .\\Data\\HashMap\\Base.hs:733:16 in unordered-con_-0.2.11.0-09d3bcadcbbc35431f4f2b870445379868b957e4:Data.HashMap.Base
  !, called at src\Development\IDE\Import\DependencyInformation.hs:107:40 in ghcide-0.2.0-f48ca2d7a046601fa7ce760c0ae0c1852d7fc5e2:Development.IDE.Import.DependencyInformation

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, this case ought to work until haskell/hie-bios#207 is merged. Then an existing cabal.project might redefine the the ghc location.

@jneira
Copy link
Member Author

jneira commented Oct 5, 2020

Closing as it would be not beginner firendly and it is not strictly needed

@jneira jneira closed this Oct 5, 2020
@jneira jneira deleted the setuphs branch October 10, 2020 14:32
pepeiborra pushed a commit that referenced this pull request Dec 27, 2020
)

We would like to use the rule without caching its artifacts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants