mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-11-28 15:56:28 +00:00
fix!: remove haskell module (#1418)
Given how slow the Haskell module is (#1240), it is slowing down the entire prompt from rendering when the module is active. This commit removes the module until we can find a faster way to retreive the Haskell version.
This commit is contained in:
parent
5584783d51
commit
428a78ebb5
@ -112,7 +112,6 @@ prompt_order = [
|
|||||||
"elm",
|
"elm",
|
||||||
"erlang",
|
"erlang",
|
||||||
"golang",
|
"golang",
|
||||||
"haskell",
|
|
||||||
"java",
|
"java",
|
||||||
"julia",
|
"julia",
|
||||||
"nim",
|
"nim",
|
||||||
@ -778,30 +777,6 @@ The module will be shown if any of the following conditions are met:
|
|||||||
[golang]
|
[golang]
|
||||||
symbol = "🏎💨 "
|
symbol = "🏎💨 "
|
||||||
```
|
```
|
||||||
## Haskell
|
|
||||||
|
|
||||||
The `haskell` module shows the currently installed version of Haskell Stack version.
|
|
||||||
The module will be shown if any of the following conditions are met:
|
|
||||||
|
|
||||||
- The current directory contains a `stack.yaml` file
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
| Variable | Default | Description |
|
|
||||||
| ---------- | ------------ | --------------------------------------------------------- |
|
|
||||||
| `symbol` | `"λ "` | The symbol used before displaying the version of Haskell. |
|
|
||||||
| `style` | `"bold red"` | The style for the module. |
|
|
||||||
| `disabled` | `false` | Disables the `haskell` module. |
|
|
||||||
|
|
||||||
|
|
||||||
### Example
|
|
||||||
|
|
||||||
```toml
|
|
||||||
# ~/.config/starship.toml
|
|
||||||
|
|
||||||
[haskell]
|
|
||||||
symbol = " "
|
|
||||||
```
|
|
||||||
|
|
||||||
## Hostname
|
## Hostname
|
||||||
|
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
use crate::config::{ModuleConfig, RootModuleConfig, SegmentConfig};
|
|
||||||
|
|
||||||
use ansi_term::{Color, Style};
|
|
||||||
use starship_module_config_derive::ModuleConfig;
|
|
||||||
|
|
||||||
#[derive(Clone, ModuleConfig)]
|
|
||||||
pub struct HaskellConfig<'a> {
|
|
||||||
pub symbol: SegmentConfig<'a>,
|
|
||||||
pub version: SegmentConfig<'a>,
|
|
||||||
pub style: Style,
|
|
||||||
pub disabled: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> RootModuleConfig<'a> for HaskellConfig<'a> {
|
|
||||||
fn new() -> Self {
|
|
||||||
HaskellConfig {
|
|
||||||
symbol: SegmentConfig::new("λ "),
|
|
||||||
version: SegmentConfig::default(),
|
|
||||||
style: Color::Red.bold(),
|
|
||||||
disabled: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,7 +17,6 @@ pub mod git_commit;
|
|||||||
pub mod git_state;
|
pub mod git_state;
|
||||||
pub mod git_status;
|
pub mod git_status;
|
||||||
pub mod go;
|
pub mod go;
|
||||||
pub mod haskell;
|
|
||||||
pub mod hg_branch;
|
pub mod hg_branch;
|
||||||
pub mod hostname;
|
pub mod hostname;
|
||||||
pub mod java;
|
pub mod java;
|
||||||
|
@ -36,7 +36,6 @@ impl<'a> RootModuleConfig<'a> for StarshipRootConfig<'a> {
|
|||||||
"elm",
|
"elm",
|
||||||
"erlang",
|
"erlang",
|
||||||
"golang",
|
"golang",
|
||||||
"haskell",
|
|
||||||
"java",
|
"java",
|
||||||
"julia",
|
"julia",
|
||||||
"nim",
|
"nim",
|
||||||
|
@ -28,7 +28,6 @@ pub const ALL_MODULES: &[&str] = &[
|
|||||||
"git_state",
|
"git_state",
|
||||||
"git_status",
|
"git_status",
|
||||||
"golang",
|
"golang",
|
||||||
"haskell",
|
|
||||||
"hg_branch",
|
"hg_branch",
|
||||||
"hostname",
|
"hostname",
|
||||||
"java",
|
"java",
|
||||||
|
@ -1,91 +0,0 @@
|
|||||||
use super::{Context, Module, RootModuleConfig, SegmentConfig};
|
|
||||||
|
|
||||||
use crate::configs::haskell::HaskellConfig;
|
|
||||||
use crate::utils;
|
|
||||||
|
|
||||||
/// Creates a module with the current Haskell Stack version
|
|
||||||
///
|
|
||||||
/// Will display the Haskell version if any of the following criteria are met:
|
|
||||||
/// - Current directory contains a `stack.yaml` file
|
|
||||||
/// - Current directory contains a `.cabal` file
|
|
||||||
/// - Current directory contains a `package.yaml` file
|
|
||||||
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|
||||||
let is_haskell_project = context
|
|
||||||
.try_begin_scan()?
|
|
||||||
.set_files(&["package.yaml", "stack.yaml", "package.yml", "stack.yml"])
|
|
||||||
.set_extensions(&["cabal"])
|
|
||||||
.is_match();
|
|
||||||
|
|
||||||
if !is_haskell_project {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
let haskell_version = utils::exec_cmd(
|
|
||||||
"stack",
|
|
||||||
&[
|
|
||||||
"--no-install-ghc",
|
|
||||||
"--lock-file",
|
|
||||||
"read-only",
|
|
||||||
"ghc",
|
|
||||||
"--",
|
|
||||||
"--numeric-version",
|
|
||||||
],
|
|
||||||
)?
|
|
||||||
.stdout;
|
|
||||||
let formatted_version = Some(format!("v{}", haskell_version.trim()))?;
|
|
||||||
|
|
||||||
let mut module = context.new_module("haskell");
|
|
||||||
let config: HaskellConfig = HaskellConfig::try_load(module.config);
|
|
||||||
module.set_style(config.style);
|
|
||||||
|
|
||||||
module.create_segment("symbol", &config.symbol);
|
|
||||||
module.create_segment("version", &SegmentConfig::new(&formatted_version));
|
|
||||||
|
|
||||||
Some(module)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use crate::modules::utils::test::render_module;
|
|
||||||
use ansi_term::Color;
|
|
||||||
use std::fs::File;
|
|
||||||
use std::io;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn folder_without_stack_yaml() -> io::Result<()> {
|
|
||||||
let dir = tempfile::tempdir()?;
|
|
||||||
let actual = render_module("haskell", dir.path(), None);
|
|
||||||
let expected = None;
|
|
||||||
assert_eq!(expected, actual);
|
|
||||||
dir.close()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn folder_with_hpack_file() -> io::Result<()> {
|
|
||||||
let dir = tempfile::tempdir()?;
|
|
||||||
File::create(dir.path().join("package.yaml"))?.sync_all()?;
|
|
||||||
let actual = render_module("haskell", dir.path(), None);
|
|
||||||
let expected = Some(format!("via {} ", Color::Red.bold().paint("λ v8.6.5")));
|
|
||||||
assert_eq!(expected, actual);
|
|
||||||
dir.close()
|
|
||||||
}
|
|
||||||
#[test]
|
|
||||||
fn folder_with_cabal_file() -> io::Result<()> {
|
|
||||||
let dir = tempfile::tempdir()?;
|
|
||||||
File::create(dir.path().join("test.cabal"))?.sync_all()?;
|
|
||||||
let actual = render_module("haskell", dir.path(), None);
|
|
||||||
let expected = Some(format!("via {} ", Color::Red.bold().paint("λ v8.6.5")));
|
|
||||||
assert_eq!(expected, actual);
|
|
||||||
dir.close()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn folder_with_stack_yaml() -> io::Result<()> {
|
|
||||||
let dir = tempfile::tempdir()?;
|
|
||||||
File::create(dir.path().join("stack.yaml"))?.sync_all()?;
|
|
||||||
let actual = render_module("haskell", dir.path(), None);
|
|
||||||
let expected = Some(format!("via {} ", Color::Red.bold().paint("λ v8.6.5")));
|
|
||||||
assert_eq!(expected, actual);
|
|
||||||
dir.close()
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,7 +17,6 @@ mod git_commit;
|
|||||||
mod git_state;
|
mod git_state;
|
||||||
mod git_status;
|
mod git_status;
|
||||||
mod golang;
|
mod golang;
|
||||||
mod haskell;
|
|
||||||
mod hg_branch;
|
mod hg_branch;
|
||||||
mod hostname;
|
mod hostname;
|
||||||
mod java;
|
mod java;
|
||||||
@ -72,7 +71,6 @@ pub fn handle<'a>(module: &str, context: &'a Context) -> Option<Module<'a>> {
|
|||||||
"git_state" => git_state::module(context),
|
"git_state" => git_state::module(context),
|
||||||
"git_status" => git_status::module(context),
|
"git_status" => git_status::module(context),
|
||||||
"golang" => golang::module(context),
|
"golang" => golang::module(context),
|
||||||
"haskell" => haskell::module(context),
|
|
||||||
"hg_branch" => hg_branch::module(context),
|
"hg_branch" => hg_branch::module(context),
|
||||||
"hostname" => hostname::module(context),
|
"hostname" => hostname::module(context),
|
||||||
"java" => java::module(context),
|
"java" => java::module(context),
|
||||||
@ -124,7 +122,6 @@ pub fn description(module: &str) -> &'static str {
|
|||||||
"git_state" => "The current git operation, and it's progress",
|
"git_state" => "The current git operation, and it's progress",
|
||||||
"git_status" => "Symbol representing the state of the repo",
|
"git_status" => "Symbol representing the state of the repo",
|
||||||
"golang" => "The currently installed version of Golang",
|
"golang" => "The currently installed version of Golang",
|
||||||
"haskell" => "The currently used version of Haskell",
|
|
||||||
"hg_branch" => "The active branch of the repo in your current directory",
|
"hg_branch" => "The active branch of the repo in your current directory",
|
||||||
"hostname" => "The system hostname",
|
"hostname" => "The system hostname",
|
||||||
"java" => "The currently installed version of Java",
|
"java" => "The currently installed version of Java",
|
||||||
|
Loading…
Reference in New Issue
Block a user