feat(haskell): Add Haskell module (#3587)

* feat(haskell): add haskell module and implement ghc version detection

* feat(haskell): implement stack resolver version detection

* fix(haskell): handle more complex resolvers

* fix(haskell): rename resolver_version to snapshot

* fix(haskell): change default color to bold purple

* feat(haskell): add tests

* fix(haskell): format

* fix(haskell): replace incorrect `or` with `or_else`

* fix(haskell): use write_all instead of write

* fix(haskell): λ as Haskell icon by default

* fix(haskell): fix tests and add a real stack.yaml testcase

* fix(haskell): make clippy happy
This commit is contained in:
ksqsf
2022-03-18 14:45:51 +08:00
committed by GitHub
parent 6b6ad39958
commit 72fec559c5
10 changed files with 257 additions and 0 deletions
@@ -49,6 +49,9 @@ format = '([\[$all_status$ahead_behind\]]($style))'
[golang]
format = '\[[$symbol($version)]($style)\]'
[haskell]
format = '\[[$symbol($version)]($style)\]'
[helm]
format = '\[[$symbol($version)]($style)\]'
@@ -28,6 +28,9 @@ symbol = " "
[golang]
symbol = " "
[haskell]
symbol = " "
[hg_branch]
symbol = " "
+34
View File
@@ -217,6 +217,7 @@ $elixir\
$elm\
$erlang\
$golang\
$haskell\
$helm\
$java\
$julia\
@@ -1672,6 +1673,39 @@ By default the module will be shown if any of the following conditions are met:
format = "via [🏎💨 $version](bold cyan) "
```
## Haskell
The `haskell` module finds the current selected GHC version and/or the selected Stack snapshot.
By default the module will be shown if any of the following conditions are met:
- The current directory contains a `stack.yaml` file
- The current directory contains any `.hs`, `.cabal`, or `.hs-boot` file
### Options
| Option | Default | Description |
| ------------------- | ------------------------------------ | -------------------------------------------------- |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `symbol` | `"λ "` | A format string representing the symbol of Haskell |
| `detect_extensions` | `["hs", "cabal", "hs-boot"]` | Which extensions should trigger this module. |
| `detect_files` | `["stack.yaml", "cabal.project"]` | Which filenames should trigger this module. |
| `detect_folders` | `[]` | Which folders should trigger this module. |
| `style` | `"bold purple"` | The style for the module. |
| `disabled` | `false` | Disables the `haskell` module. |
### Variables
| Variable | Example | Description |
| ------------ | ----------- | --------------------------------------------------------------------------------------- |
| version | | `ghc_version` or `snapshot` depending on whether the current project is a Stack project |
| snapshot | `lts-18.12` | Currently selected Stack snapshot |
| ghc\_version | `9.2.1` | Currently installed GHC version |
| symbol | | Mirrors the value of option `symbol` |
| style\* | | Mirrors the value of option `style` |
*: This variable can only be used as a part of a style string
## Helm
The `helm` module shows the currently installed version of [Helm](https://helm.sh/).