oalders
oalders

Reputation: 5279

How to get readable Data::Printer output inside neovim?

I'm not sure what I need to tweak here. When I exec my Perl file from within neovim I get unreadable output. I'm using Data::Printer 1.000004

nvim --version
NVIM v0.7.0-dev+1135-gfdea15723
cat ~/.dataprinter
array_max = 5000
end_separator = 1
filters = DB, DateTime, JSON, URI
hash_separator = ' => '
index = 1
scalar_quotes = '
#!/usr/bin/env perl

use strict;
use warnings;
use feature qw( state );
use List::SomeUtils qw( part );

my $i = 0;
my @part = part { $i++ % 2 } 1 .. 8;

use DDP;
p @part;
~
~
~
~
~
~
~
~
~
~
~
~
~
~

:call ExecFile()
:!"/Users/olafalders/Documents/perl/part.pl"
^[[0;38;2;102;217;239m[^[[0m
    ^[[0;38;2;161;187;197m[0] ^[[0m^[[0;38;2;102;217;239m[^[[0m
            ^[[0;38;2;161;187;197m[0] ^[[0m^[[0;38;2;247;140;106m1^[[0m^[[0;38;2;102;217;239m,^[[0m
            ^[[0;38;2;161;187;197m[1] ^[[0m^[[0;38;2;247;140;106m3^[[0m^[[0;38;2;102;217;239m,^[[0m
            ^[[0;38;2;161;187;197m[2] ^[[0m^[[0;38;2;247;140;106m5^[[0m^[[0;38;2;102;217;239m,^[[0m
            ^[[0;38;2;161;187;197m[3] ^[[0m^[[0;38;2;247;140;106m7^[[0m^[[0;38;2;102;217;239m,^[[0m
        ^[[0;38;2;102;217;239m]^[[0m^[[0;38;2;102;217;239m,^[[0m
    ^[[0;38;2;161;187;197m[1] ^[[0m^[[0;38;2;102;217;239m[^[[0m
            ^[[0;38;2;161;187;197m[0] ^[[0m^[[0;38;2;247;140;106m2^[[0m^[[0;38;2;102;217;239m,^[[0m
            ^[[0;38;2;161;187;197m[1] ^[[0m^[[0;38;2;247;140;106m4^[[0m^[[0;38;2;102;217;239m,^[[0m
            ^[[0;38;2;161;187;197m[2] ^[[0m^[[0;38;2;247;140;106m6^[[0m^[[0;38;2;102;217;239m,^[[0m
            ^[[0;38;2;161;187;197m[3] ^[[0m^[[0;38;2;247;140;106m8^[[0m^[[0;38;2;102;217;239m,^[[0m
        ^[[0;38;2;102;217;239m]^[[0m^[[0;38;2;102;217;239m,^[[0m
^[[0;38;2;102;217;239m]^[[0m

The actual output should look like:

[
    [0] [
            [0] 1,
            [1] 3,
            [2] 5,
            [3] 7,
        ],
    [1] [
            [0] 2,
            [1] 4,
            [2] 6,
            [3] 8,
        ],
]

Upvotes: 0

Views: 121

Answers (1)

romainl
romainl

Reputation: 196789

Data::Printer describes itself as:

colored & full-featured pretty print of Perl data structures and objects

The garbage you see is the escape sequences used by the package to colorise the output, which is not understood by the shell in which the script is executed.

To solve your problem at the script/environment level, I'd suggest reading the documentation of the package, which mentions a colored property and a ANSI_COLORS_DISABLED environment variable. It should have been your first move.

To solve it at the editor level, I'd suggest using the built-in :help :terminal, which supports ANSI colours, instead of :!, which doesn't.

And, by the way, the quickfix window is not involved, here.

Upvotes: 3

Related Questions