yining / vim-rustcexplain

view `rustc --explain` from inside Vim
2 stars 2 forks source link

spaces added to popup message breaks markdown formatting #2

Open dlyongemallo opened 2 weeks ago

dlyongemallo commented 2 weeks ago

In particular, this line adds a space before and after each line of the popup message.

The result is this (note that EOL whitespace is highlighted): Screenshot from 2024-06-14 09-31-37

These added spaces break markdown syntax detection. Removing the above line results in: Screenshot from 2024-06-14 09-32-14

This is slightly better as at least the markdown syntax highlighting is being applied. This could be improved further by annotating the code blocks as Rust:

Screenshot from 2024-06-14 09-32-47

Finally, making the title into a markdown heading and setting the conceallevel to 2, we get this much nicer output:

Screenshot from 2024-06-14 09-33-20

yining commented 2 weeks ago

Hi @dlyongemallo,

Thanks for raising the issue, and sorry for the late reply.

I will push a commit for the fix soon.

dlyongemallo commented 2 weeks ago

For annotating the code blocks, rustc seems not to have that as an output option, but I've implemented a workaround (from here):

Put this in a script:

#!/bin/bash

if [ "$1" = "--explain" ]
then
    shift
fi
if [ "$1" = "" ]
then
    echo "Usage: $0 <error code>"
    exit 1
fi
rustc --explain "$1" | sed '/^```/{s//&rust/;:a;n;//!ba}'

Then set rustcexplain_rustc_bin to point to this script.