summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatan Kushner <hello@matchai.dev>2020-07-06 13:00:52 -0400
committerGitHub <noreply@github.com>2020-07-06 13:00:52 -0400
commit428a78ebb5f5088ac482ea1eba15d9d36cd474f7 (patch)
tree15a5c8cb565fb652aae0b7193e86e486a1080263
parent5584783d51e9c36f001f49e6ccf22f867e4cb131 (diff)
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.
-rw-r--r--docs/config/README.md25
-rw-r--r--src/configs/haskell.rs23
-rw-r--r--src/configs/mod.rs1
-rw-r--r--src/configs/starship_root.rs1
-rw-r--r--src/module.rs1
-rw-r--r--src/modules/haskell.rs91
-rw-r--r--src/modules/mod.rs3
7 files changed, 0 insertions, 145 deletions
diff --git a/docs/config/README.md b/docs/config/README.md
index 95a89bb3f..01750a601 100644
--- a/docs/config/README.md
+++ b/docs/config/README.md
@@ -112,7 +112,6 @@ prompt_order = [
"elm",
"erlang",
"golang",
- "haskell",
"java",
"julia",
"nim",
@@ -778,30 +777,6 @@ The module will be shown if any of the following conditions are met:
[golang]
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
diff --git a/src/configs/haskell.rs b/src/configs/haskell.rs
deleted file mode 100644
index b7e29e497..000000000
--- a/src/configs/haskell.rs
+++ /dev/null
@@ -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,
- }
- }
-}
diff --git a/src/configs/mod.rs b/src/configs/mod.rs
index 48badefbc..e0a3f470b 100644
--- a/src/configs/mod.rs
+++ b/src/configs/mod.rs
@@ -17,7 +17,6 @@ pub mod git_commit;
pub mod git_state;
pub mod git_status;
pub mod go;
-pub mod haskell;
pub mod hg_branch;
pub mod hostname;
pub mod java;
diff --git a/src/configs/starship_root.rs b/src/configs/starship_root.rs
index f42481257..1fdc61af2 100644
--- a/src/configs/starship_root.rs
+++ b/src/configs/starship_root.rs
@@ -36,7 +36,6 @@ impl<'a> RootModuleConfig<'a> for StarshipRootConfig<'a> {
"elm",
"erlang",
"golang",
- "haskell",
"java",
"julia",
"nim",
diff --git a/src/module.rs b/src/module.rs
index aa1ad1553..1630591b6 100644
--- a/src/module.rs
+++ b/src/module.rs
@@ -28,7 +28,6 @@ pub const ALL_MODULES: &[&str] = &[
"git_state",
"git_status",
"golang",
- "haskell",
"hg_branch",
"hostname",
"java",
diff --git a/src/modules/haskell.rs b/src/modules/haskell.rs
deleted file mode 100644
index 9977809ce..000000000
--- a/src/modules/haskell.rs
+++ /dev/null
@@ -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()
- }
-}
diff --git a/src/modules/mod.rs b/src/modules/mod.rs
index 1a73a1a22..4ab8bf321 100644
--- a/src/modules/mod.rs
+++ b/src/modules/mod.rs
@@ -17,7 +17,6 @@ mod git_commit;
mod git_state;
mod git_status;
mod golang;
-mod haskell;
mod hg_branch;
mod hostname;
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_status" => git_status::module(context),
"golang" => golang::module(context),
- "haskell" => haskell::module(context),
"hg_branch" => hg_branch::module(context),
"hostname" => hostname::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_status" => "Symbol representing the state of the repo",
"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",
"hostname" => "The system hostname",
"java" => "The currently installed version of Java",