rust-lang / rust-lang/rust-analyzer

ASCII color codes are displayed inline for for editors

Open
#15,443 21 comments 0 reactions 1 assignee View on GitHub

@ShoyuVanilla is already working on this.

Since Oct 20, 2025.

A-diagnostics C-support
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Sometimes, the error shown in Vim (and apparently VS Code too) is printed with ASCII color codes showing in the string from rust_analyzer. It makes the error very hard to read. See https://github.com/neovim/nvim-lspconfig/issues/2760.

It seems to me like rust-analyzer does not properly distinguish between being executed in a terminal environment or not, and decide from that whether to print ASCII color codes or skip them.

In terminal:

Screenshot from 2023-08-11 16-16-58

In editor:

Screenshot from 2023-08-11 10-51-47

Steps to reproduce

  1. Create the following crate:
cargo new -q foo
cd foo
cargo add -q rocket@0.5.0-rc.3
cat <<EOF > src/main.rs
use rocket::UriDisplayPath;

fn main() {
    println!("Hello, world!");
}

#[derive(UriDisplayPath)]
pub enum Foo {
    Bar,
}
EOF
  1. Optionally run cargo check.
  2. Open src/main.rs with Vim.

Other info

rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)

Mason reports rust-analyzer 2023-08-07.

rustc version: (eg. output of rustc -V)

$ rustc -V
rustc 1.71.1 (eb26296b5 2023-08-03)

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

Not sure, nothing I've set explicitly at least. I run NeoVim with rust-lang/rust.vim and rust_analyzer for lspconfig installed via Mason.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.