Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
/result*
lcov.info
.direnv/
17 changes: 17 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ Don't reload for `README.md` files:

ghciwatch --reload-glob '!src/**/README.md'

Track warnings across recompilations to prevent them from disappearing:

ghciwatch --track-warnings

## Arguments
<dl>

Expand Down Expand Up @@ -88,6 +92,19 @@ Don't interrupt reloads when files change.

Depending on your workflow, `ghciwatch` may feel more responsive with this set.

</dd>
<dt><a id="--track-warnings" href="#--track-warnings"><code>--track-warnings</code></a></dt><dd>

Track warnings across recompilations.

When enabled, warnings will be preserved in memory even when files are recompiled due to dependency changes, helping prevent "ephemeral warnings" from being missed.

This feature addresses the common issue where GHC warnings disappear when files are recompiled due to dependency changes (without the file itself changing). With `--track-warnings`, warnings persist until the file is directly modified or removed.

Tracked warnings are displayed with the same formatting and colors as fresh warnings, and are included in the error file output when using `--error-file`.

Can also be enabled by setting the `GHCIWATCH_TRACK_WARNINGS` environment variable to any value.

</dd>
<dt><a id="--completions" href="#--completions"><code>--completions &lt;COMPLETIONS&gt;</code></a></dt><dd>

Expand Down
7 changes: 7 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ pub struct Opts {
#[arg(long, hide = true)]
pub tui: bool,

/// Track warnings across recompilations.
///
/// When enabled, warnings will be preserved in memory even when files are recompiled
/// due to dependency changes, helping prevent "ephemeral warnings" from being missed.
#[arg(long, env = "GHCIWATCH_TRACK_WARNINGS")]
pub track_warnings: bool,

/// Generate Markdown CLI documentation.
#[cfg(feature = "clap-markdown")]
#[arg(long, hide = true)]
Expand Down
3 changes: 3 additions & 0 deletions src/ghci/compilation_log.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::ghci::parse::CompilationResult;
use crate::ghci::parse::CompilationSummary;
use crate::ghci::parse::CompilingModule;
use crate::ghci::parse::GhcDiagnostic;
use crate::ghci::parse::GhcMessage;
use crate::ghci::parse::Severity;
Expand All @@ -9,6 +10,7 @@ use crate::ghci::parse::Severity;
pub struct CompilationLog {
pub summary: Option<CompilationSummary>,
pub diagnostics: Vec<GhcDiagnostic>,
pub compiled_modules: Vec<CompilingModule>,
}

impl CompilationLog {
Expand All @@ -24,6 +26,7 @@ impl Extend<GhcMessage> for CompilationLog {
match message {
GhcMessage::Compiling(module) => {
tracing::debug!(module = %module.name, path = %module.path, "Compiling");
self.compiled_modules.push(module);
}
GhcMessage::Diagnostic(diagnostic) => {
if let GhcDiagnostic {
Expand Down
6 changes: 6 additions & 0 deletions src/ghci/error_log.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use camino::Utf8Path;
use camino::Utf8PathBuf;
use miette::IntoDiagnostic;
use tokio::fs::File;
Expand All @@ -23,6 +24,11 @@ impl ErrorLog {
Self { path }
}

/// Get the path for this error log writer, if any.
pub fn path(&self) -> Option<&Utf8Path> {
self.path.as_deref()
}

/// Write the error log, if any, with the given compilation summary and diagnostic messages.
#[instrument(skip(self, log), name = "error_log_write", level = "debug")]
pub async fn write(&mut self, log: &CompilationLog) -> miette::Result<()> {
Expand Down
Loading