Using ghcide with Obelisk

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’s default.nix (inside the call to project). With this setting, ob shell will provide ghcide as well.
  • Add to the root of your project:
      cat > <<'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"	
      chmod +x	
    • 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.
  • Add hie.yaml to the root of your project:
      echo 'cradle: { bios: { program: } }' > hie.yaml	
  • Test the configuration with ob shell ghcide. Assuming your project compiles and works with ghcide 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 finds ghcide or create a custom ghcide replacement script that you install globally. For example, for Visual Studio Code on macOS adding a script called ghcide to your PATH like the one below will cause ghcide from each project’s ob 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 $@"