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

Improve scripts for haskell-language-server and ghci #2990

Merged
merged 7 commits into from
Oct 26, 2021

Conversation

rvl
Copy link
Contributor

@rvl rvl commented Oct 22, 2021

It now generates a custom HLS config on the fly. Instructions are in hie-direnv.yaml.

Issue Number

ADP-1229

@rvl rvl requested a review from Anviking October 22, 2021 10:20
@rvl rvl self-assigned this Oct 22, 2021
Copy link
Member

@Anviking Anviking left a comment

Choose a reason for hiding this comment

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

Awesome!

Seems to work as well as with what I previously used, after setting up direnv (and I imagine I won't have to regenerate it).

However, I still get hover not found for all symbols in

  • [...]Restore.hs
  • [...]local-cluster.hs
  • [...]exe/cardano-wallet.hs
  • lib/core/test/bench/db/Main.hs

🙁

E.g. with the following output

Found "/Users/anviking/IOHK/cardano-wallet/hie.yaml" for "/Users/anviking/IOHK/cardano-wallet/a"
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.4.0.0, Git revision 253547816ee216c53ee7dacc0ad3cac43e863d30 (dirty) x86_64 ghc-8.10.4
Current directory: /Users/anviking/IOHK/cardano-wallet
Operating system: darwin
Arguments: ["--lsp"]
Cradle directory: /Users/anviking/IOHK/cardano-wallet
Cradle type: Bios

Tool versions found on the $PATH
cabal:		3.4.0.0
stack:		2.7.3
ghc:		8.10.7


Consulting the cradle to get project GHC version...
Project GHC version: 8.10.7
haskell-language-server exe candidates: ["haskell-language-server-8.10.7","haskell-language-server"]
Launching haskell-language-server exe at:/Users/anviking/.ghcup/bin/haskell-language-server-8.10.7
haskell-language-server version: 1.4.0.0 (GHC: 8.10.7) (PATH: /Users/anviking/.ghcup/bin/haskell-language-server-8.10.7~1.4.0) (GIT hash: 253547816ee216c53ee7dacc0ad3cac43e863d30)
Starting (haskell-language-server)LSP server...
  with arguments: GhcideArguments {argsCommand = LSP, argsCwd = Nothing, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = False, argsLogFile = Nothing, argsThreads = 0, argsProjectGhcVersion = False}
  with plugins: [PluginId "pragmas",PluginId "floskell",PluginId "fourmolu",PluginId "tactics",PluginId "ormolu",PluginId "stylish-haskell",PluginId "retrie",PluginId "brittany",PluginId "callHierarchy",PluginId "class",PluginId "haddockComments",PluginId "eval",PluginId "importLens",PluginId "refineImports",PluginId "moduleName",PluginId "hlint",PluginId "splice",PluginId "ghcide-hover-and-symbols",PluginId "ghcide-code-actions-imports-exports",PluginId "ghcide-code-actions-type-signatures",PluginId "ghcide-code-actions-bindings",PluginId "ghcide-code-actions-fill-holes",PluginId "ghcide-completions",PluginId "ghcide-type-lenses",PluginId "ghcide-core"]
  in directory: /Users/anviking/IOHK/cardano-wallet
 Starting LSP server...
If you are seeing this in a terminal, you probably should have run WITHOUT the --lsp option!
Started LSP server in 0.00s
setInitialDynFlags cradle: Cradle {cradleRootDir = "/Users/anviking/IOHK/cardano-wallet", cradleOptsProg = CradleAction: Cabal}
2021-10-22 15:31:49.650343 [ThreadId 5] INFO hls:	Registering ide configuration: IdeConfiguration {workspaceFolders = fromList [NormalizedUri 7699462648287052475 "file:///Users/anviking/IOHK/cardano-wallet"], clientSettings = hashed (Just (Object (fromList [])))}
2021-10-22 15:31:49.684715 [ThreadId 84] INFO hls:	Consulting the cradle for "lib/core/test/bench/db/Main.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/anviking/IOHK/cardano-wallet", cradleOptsProg = CradleAction: Bios}
2021-10-22 15:31:49.708169 [ThreadId 94] INFO hie-bios:	Generating /private/tmp/nvimTPZXrR/HIE_BIOS_OUTPUT86709-0 for source file lib/core/test/bench/db/Main.hs.
2021-10-22 15:31:50.199913 [ThreadId 94] INFO hie-bios:	Finished.
2021-10-22 15:31:50.412493 [ThreadId 84] INFO hls:	Using interface files cache dir: /Users/anviking/.cache/ghcide/main-c8474e8495c9d1cd314726e560828967a4513812
2021-10-22 15:31:50.412938 [ThreadId 84] INFO hls:	Making new HscEnv[main]
haskell-language-server-8.10.7: loadArchive: Neither an archive, nor a fat archive: `/nix/store/3ssw9vhdymjwhxjaa4kzxcf40lbkczvx-clang-wrapper-7.1.0/bin/clang++'
haskell-language-server-8.10.7: loadArchive: Neither an archive, nor a fat archive: `/nix/store/3ssw9vhdymjwhxjaa4kzxcf40lbkczvx-clang-wrapper-7.1.0/bin/clang++'
2021-10-22 15:32:14.959867 [ThreadId 4882] INFO hls:	finish: Wingman.getMetaprogramsAtSpan.TypeCheck (took 20.36s)
haskell-language-server-8.10.7: loadArchive: Neither an archive, nor a fat archive: `/nix/store/3ssw9vhdymjwhxjaa4kzxcf40lbkczvx-clang-wrapper-7.1.0/bin/clang++'
haskell-language-server-8.10.7: loadArchive: Neither an archive, nor a fat archive: `/nix/store/3ssw9vhdymjwhxjaa4kzxcf40lbkczvx-clang-wrapper-7.1.0/bin/clang++'
2021-10-22 15:32:30.139963 [ThreadId 5951] INFO hls:	finish: Wingman.getMetaprogramsAtSpan.TypeCheck (took 0.00s)
2021-10-22 15:32:31.313371 [ThreadId 5967] INFO hls:	finish: Wingman.getMetaprogramsAtSpan.TypeCheck (took 0.00s)
2021-10-22 15:32:32.049401 [ThreadId 5983] INFO hls:	finish: Wingman.getMetaprogramsAtSpan.TypeCheck (took 0.00s)
2021-10-22 15:32:32.926618 [ThreadId 5999] INFO hls:	finish: Wingman.getMetaprogramsAtSpan.TypeCheck (took 0.00s)
2021-10-22 15:32:34.369133 [ThreadId 6015] INFO hls:	finish: Wingman.getMetaprogramsAtSpan.TypeCheck (took 0.00s)

I wondered if it could be related to haskell/haskell-language-server#1684, however it works in non-Main modules, and using a non-nix clang++ didn't seem to help either.

If it worked for you the reason would probably be macOS specific, though?

@Anviking
Copy link
Member

bors r+

iohk-bors bot added a commit that referenced this pull request Oct 22, 2021
2990: Improve scripts for haskell-language-server and ghci r=Anviking a=rvl

It now generates a custom HLS config on the fly. Instructions are in `hie-direnv.yaml`.

### Issue Number

ADP-1229


Co-authored-by: Rodney Lorrimar <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 22, 2021

Build failed:

rvl added 2 commits October 25, 2021 17:31
It's just a symlink to haskell-language-server, but should prevent the
wrong hls build being used if the user has their editor configured to
use haskell-language-server-wrapper.
This tool can be used for debugging the haskell-language-server
environment.
@rvl rvl force-pushed the rvl/adp-1229/gen-hie-bios branch from 8f299f4 to 2af712a Compare October 25, 2021 09:32
@rvl
Copy link
Contributor Author

rvl commented Oct 25, 2021

Thanks @Anviking, from that log it looks like your editor is picking up the wrong build of haskell-language-server. This may explain the loadArchive errors.

I added a haskell-language-server-wrapper symlink to the nix-shell, which should ensure that your editor runs the nix build of hls.

In the comments of hie-direnv.yaml I added some testing commands that you could try.

Here's what I get:

rodney@tethys:~/iohk/cw/pr % hie-bios check lib/core/src/Cardano/Wallet.hs
rodney@tethys:~/iohk/cw/pr % haskell-language-server lib/shelley/exe/cardano-wallet.hs
haskell-language-server version: 1.4.0.0 (GHC: 8.10.7) (PATH: /nix/store/34xwln6fzs40lwivm9pclsx2hkp3l7vm-haskell-language-server-exe-haskell-language-server-1.4.0.0/bin/haskell-language-server)
 ghcide setup tester in /home/rodney/iohk/cw/pr.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/4: Finding files to test in /home/rodney/iohk/cw/pr
Found 1 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle
  (/home/rodney/iohk/cw/pr/hie.yaml)

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
2021-10-25 17:31:42.28961497 [ThreadId 43] INFO hls:	Consulting the cradle for "lib/shelley/exe/cardano-wallet.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/rodney/iohk/cw/pr", cradleOptsProg = CradleAction: Bios}
2021-10-25 17:31:42.32516425 [ThreadId 52] INFO hie-bios:	Generating /run/user/1000/HIE_BIOS_OUTPUT2655395-0 for source file lib/shelley/exe/cardano-wallet.hs.
2021-10-25 17:31:42.840574631 [ThreadId 52] INFO hie-bios:	Dependencies written to /run/user/1000/HIE_BIOS_DEPS2655395-1.
2021-10-25 17:31:42.846623278 [ThreadId 52] INFO hie-bios:	Finished.
2021-10-25 17:31:43.07360846 [ThreadId 43] INFO hls:	Using interface files cache dir: /home/rodney/.cache/ghcide/main-9d7bde88c05e94b04150f557b8030d8a38e0bfa8
2021-10-25 17:31:43.074079817 [ThreadId 43] INFO hls:	Making new HscEnv[main]
2021-10-25 17:32:54.01129697 [ThreadId 15019] INFO hls:	finish: User TypeCheck (took 1m07s)
2021-10-25 17:32:54.02603143 [ThreadId 15030] INFO hls:	finish: GetHie (took 0.01s)
2021-10-25 17:32:54.02612492 [ThreadId 15031] INFO hls:	finish: GenerateCore (took 0.00s)

Completed (1 file worked, 0 files failed)

@Anviking
Copy link
Member

Thanks @rvl, it works now!! ✨

In nix-shell or outside after running direnv reload:

  1. create typo in restore-bench.hs -> shows error immediately
  2. Add type Foo in Primitive.Types
  3. Import it in restore-bench.hs -> it's available reasonably immediately, and I can jump to definition
  4. show-references seems to work across package boundaries

For record, I can't run hie-bios

$ hie-bios check lib/core/src/Cardano/Wallet.hs
Segmentation fault: 11

for some reason, but 🤷‍♂️

rvl added 5 commits October 26, 2021 13:44
This silences the ModuleName LSP code lens which unnecessarily
suggests qualifying the module name.

It also makes the various Main modules easier to distinguish from each
other.
@rvl rvl force-pushed the rvl/adp-1229/gen-hie-bios branch from f7815b6 to 927c8b8 Compare October 26, 2021 05:44
@rvl
Copy link
Contributor Author

rvl commented Oct 26, 2021

Great!

bors r+

iohk-bors bot added a commit that referenced this pull request Oct 26, 2021
2990: Improve scripts for haskell-language-server and ghci r=rvl a=rvl

It now generates a custom HLS config on the fly. Instructions are in `hie-direnv.yaml`.

### Issue Number

ADP-1229


Co-authored-by: Rodney Lorrimar <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 26, 2021

Build failed:

@Anviking
Copy link
Member

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 26, 2021

Build succeeded:

@iohk-bors iohk-bors bot merged commit dc6e664 into master Oct 26, 2021
@iohk-bors iohk-bors bot deleted the rvl/adp-1229/gen-hie-bios branch October 26, 2021 14:37
iohk-bors bot added a commit that referenced this pull request Nov 4, 2021
3001: Fix haskell-language-server / direnv config r=Anviking a=rvl

Last minute shell script change in #2990 broke it - oops.

This PR also adds a CI step to check the hls config.

### Issue Number

ADP-1229


Co-authored-by: Rodney Lorrimar <[email protected]>
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