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

ASCII color codes are displayed inline for rust_analyzer #2760

Closed
lindhe opened this issue Aug 11, 2023 · 2 comments
Closed

ASCII color codes are displayed inline for rust_analyzer #2760

lindhe opened this issue Aug 11, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@lindhe
Copy link

lindhe commented Aug 11, 2023

Description

Sometimes, the error printed as ASCII color codes in the string from rust_analyzer. It makes the error very hard to read. Could this be caused by an underlying library? I had a quick look at the trait definition I used, and didn't find any offending color codes there.

Neovim version

NVIM v0.10.0-dev
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Run "nvim -V1 -v" for more info

Nvim-lspconfig version

No response

Operating system and version

Ubuntu 22.04

Affected language servers

rust_analyzer

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
  2. Optionally run cargo check.

  3. Open src/main.rs with Vim.

Actual behavior

The same thing, just without the ASCII color codes printed. Ideally, they would be encoded into colors, but if that's hard then they should be stripped.

Expected behavior

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

Minimal config

local on_attach = function(client, bufnr)
  -- Enable completion triggered by <c-x><c-o>
  vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
end

require("mason").setup()
require("mason-lspconfig").setup({
  ensure_installed = {
    "rust_analyzer",
  },
  automatic_installation = true,
})

require('lspconfig')['rust_analyzer'].setup {
    on_attach = on_attach,
}

LSP log

https://gist.github.com/lindhe/07979ad869c5f19ff50728e4b7af0da0

@lindhe lindhe added the bug Something isn't working label Aug 11, 2023
@glepnir
Copy link
Member

glepnir commented Aug 11, 2023

I think it's more like a rust-analyzer issue. vs code
have the same problem

@glepnir
Copy link
Member

glepnir commented Aug 11, 2023

you can use vim.lsp.with to reformat the message by using regex remove these ascii color code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants