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

feat: add Haxe support #4395

Merged
merged 18 commits into from Dec 4, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
90 changes: 90 additions & 0 deletions .github/config-schema.json
Expand Up @@ -644,6 +644,36 @@
}
]
},
"haxe": {
"default": {
"detect_extensions": [
"hx",
"hxml"
],
"detect_files": [
"project.xml",
"Project.xml",
"application.xml",
"haxelib.json",
"hxformat.json",
".haxerc"
],
"detect_folders": [
".haxelib",
"haxe_libraries"
],
"disabled": false,
"format": "via [$symbol($version )]($style)",
"style": "bold fg:202",
"symbol": "⌘ ",
"version_format": "v${raw}"
},
"allOf": [
{
"$ref": "#/definitions/HaxeConfig"
}
]
},
"helm": {
"default": {
"detect_extensions": [],
Expand Down Expand Up @@ -3095,6 +3125,66 @@
},
"additionalProperties": false
},
"HaxeConfig": {
"type": "object",
"properties": {
"format": {
"default": "via [$symbol($version )]($style)",
"type": "string"
},
"version_format": {
"default": "v${raw}",
"type": "string"
},
"symbol": {
"default": "⌘ ",
"type": "string"
},
"style": {
"default": "bold fg:202",
"type": "string"
},
"disabled": {
"default": false,
"type": "boolean"
},
"detect_extensions": {
"default": [
"hx",
"hxml"
],
"type": "array",
"items": {
"type": "string"
}
},
"detect_files": {
"default": [
"project.xml",
"Project.xml",
"application.xml",
"haxelib.json",
"hxformat.json",
".haxerc"
],
"type": "array",
"items": {
"type": "string"
}
},
"detect_folders": {
"default": [
".haxelib",
"haxe_libraries"
],
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false
},
"HelmConfig": {
"type": "object",
"properties": {
Expand Down
3 changes: 3 additions & 0 deletions docs/.vuepress/public/presets/toml/bracketed-segments.toml
Expand Up @@ -61,6 +61,9 @@ format = '\[[$symbol($version)]($style)\]'
[haskell]
format = '\[[$symbol($version)]($style)\]'

[haxe]
format = '\[[$symbol($version)]($style)\]'

[helm]
format = '\[[$symbol($version)]($style)\]'

Expand Down
3 changes: 3 additions & 0 deletions docs/.vuepress/public/presets/toml/nerd-font-symbols.toml
Expand Up @@ -34,6 +34,9 @@ symbol = " "
[haskell]
symbol = " "

[haxe]
symbol = "⌘ "

[hg_branch]
symbol = " "

Expand Down
3 changes: 3 additions & 0 deletions docs/.vuepress/public/presets/toml/no-runtime-versions.toml
Expand Up @@ -37,6 +37,9 @@ format = 'via [$symbol]($style)'
[golang]
format = 'via [$symbol]($style)'

[haxe]
format = 'via [$symbol]($style)'

[helm]
format = 'via [$symbol]($style)'

Expand Down
42 changes: 42 additions & 0 deletions docs/config/README.md
Expand Up @@ -239,6 +239,7 @@ $elm\
$erlang\
$golang\
$haskell\
$haxe\
$helm\
$java\
$julia\
Expand Down Expand Up @@ -1858,6 +1859,47 @@ By default the module will be shown if any of the following conditions are met:

*: This variable can only be used as a part of a style string

## Haxe

The `haxe` module shows the currently installed version of [Haxe](https://haxe.org/).
By default the module will be shown if any of the following conditions are met:

- The current directory contains a `project.xml`, `Project.xml`, `application.xml`, `haxelib.json`, `hxformat.json` or `.haxerc` file
- The current directory contains a `.haxelib` or a `haxe_libraries` directory
- The current directory contains a file with the `.hx` or `.hxml` extension

### Options

| Option | Default | Description |
| ------------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
| `version_format` | `"v${raw}"` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` |
| `detect_extensions` | `["hx", "hxml"]` | Which extensions should trigger this module. |
| `detect_files` | `["project.xml", "Project.xml", "application.xml", "haxelib.json", "hxformat.json", ".haxerc"]` | Which filenames should trigger this module. |
| `detect_folders` | `[".haxelib", "haxe_libraries"]` | Which folders should trigger this modules. |
| `symbol` | `"⌘ "` | A format string representing the symbol of Helm. |
| `style` | `"bold fg:202"` | The style for the module. |
| `disabled` | `false` | Disables the `haxe` module. |

### Variables

| Variable | Example | Description |
| -------- | -------- | ------------------------------------ |
| version | `v4.2.5` | The version of `haxe` |
| 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

### Example

```toml
# ~/.config/starship.toml

[haxe]
format = "via [⌘ $version](bold fg:202) "
```

## Helm

The `helm` module shows the currently installed version of [Helm](https://helm.sh/).
Expand Down
41 changes: 41 additions & 0 deletions src/configs/haxe.rs
@@ -0,0 +1,41 @@
use serde::{Deserialize, Serialize};

#[derive(Clone, Deserialize, Serialize)]
#[cfg_attr(
feature = "config-schema",
derive(schemars::JsonSchema),
schemars(deny_unknown_fields)
)]
#[serde(default)]
pub struct HaxeConfig<'a> {
pub format: &'a str,
pub version_format: &'a str,
pub symbol: &'a str,
pub style: &'a str,
pub disabled: bool,
pub detect_extensions: Vec<&'a str>,
pub detect_files: Vec<&'a str>,
pub detect_folders: Vec<&'a str>,
}

impl<'a> Default for HaxeConfig<'a> {
fn default() -> Self {
HaxeConfig {
format: "via [$symbol($version )]($style)",
version_format: "v${raw}",
symbol: "⌘ ",
style: "bold fg:202",
disabled: false,
detect_extensions: vec!["hx", "hxml"],
detect_files: vec![
"project.xml",
"Project.xml",
"application.xml",
AlexHaxe marked this conversation as resolved.
Show resolved Hide resolved
"haxelib.json",
"hxformat.json",
".haxerc",
],
detect_folders: vec![".haxelib", "haxe_libraries"],
}
}
}
3 changes: 3 additions & 0 deletions src/configs/mod.rs
Expand Up @@ -34,6 +34,7 @@ pub mod git_state;
pub mod git_status;
pub mod go;
pub mod haskell;
pub mod haxe;
pub mod helm;
pub mod hg_branch;
pub mod hostname;
Expand Down Expand Up @@ -161,6 +162,8 @@ pub struct FullConfig<'a> {
#[serde(borrow)]
haskell: haskell::HaskellConfig<'a>,
#[serde(borrow)]
haxe: haxe::HaxeConfig<'a>,
#[serde(borrow)]
helm: helm::HelmConfig<'a>,
#[serde(borrow)]
hg_branch: hg_branch::HgBranchConfig<'a>,
Expand Down
1 change: 1 addition & 0 deletions src/configs/starship_root.rs
Expand Up @@ -53,6 +53,7 @@ pub const PROMPT_ORDER: &[&str] = &[
"erlang",
"golang",
"haskell",
"haxe",
"helm",
"java",
"julia",
Expand Down
1 change: 1 addition & 0 deletions src/module.rs
Expand Up @@ -42,6 +42,7 @@ pub const ALL_MODULES: &[&str] = &[
"git_status",
"golang",
"haskell",
"haxe",
"helm",
"hg_branch",
"hostname",
Expand Down