title | date | tags | ||
---|---|---|---|---|
Using ghcide with Obelisk |
2020-06-08 |
|
{.ui .warning .message} This is not officially supported by Obelisk.
Obelisk has experimental support for ghcide.
To try out the experimental ghcide
support:
- Install a
ghcide
plugin for your editor. - Add
__withGhcide = true;
to your Obelisk project'sdefault.nix
(inside the call toproject
). With this setting,ob shell
will provideghcide
as well. - Add
hie-bios.sh
to the root of your project:cat > hie-bios.sh <<'EOF' #!/usr/bin/env bash source "$HOME/.bash_profile"; # NOTE: Some editors need help finding 'ob' and this assumes that `ob` is made available on your `$PATH` in `.bash_profile` ob internal export-ghci-configuration > "$HIE_BIOS_OUTPUT" EOF chmod +x hie-bios.sh
- Note: In some projects you need to use
ob internal export-ghci-configuration --use-relative-paths
in this script instead. This is known to happen when your project contains symlinks to other packages.
- Note: In some projects you need to use
- Add
hie.yaml
to the root of your project:echo 'cradle: { bios: { program: hie-bios.sh } }' > hie.yaml
- Test the configuration with
ob shell ghcide
. Assuming your project compiles and works withghcide
otherwise, this should succeed. - Start your editor in a way that it can access the appropriate
ghcide
:- This can sometimes be achieved with
ob shell 'start my editor'
. - If you can't easily start your editor in a way that it inherits your shell, you may need to customize how your
ghcide
plugin findsghcide
or create a customghcide
replacement script that you install globally. For example, for Visual Studio Code on macOS adding a script calledghcide
to yourPATH
like the one below will causeghcide
from each project'sob shell
to be used:#!/usr/bin/env bash source "$HOME/.bash_profile" # NOTE: This assumes that `ob` is made available on your `$PATH` in `.bash_profile` ob shell "ghcide $@"
- This can sometimes be achieved with