3 package Devel::REPL::Plugin::CompletionDriver::LexEnv;
4 # ABSTRACT: Complete variable names in the REPL's lexical environment
6 our $VERSION = '1.003027';
8 use Devel::REPL::Plugin;
9 use Devel::REPL::Plugin::Completion; # die early if cannot load
10 use namespace::autoclean;
14 $self->load_plugin('Completion');
17 around complete => sub {
19 my ($self, $text, $document) = @_;
21 my $last = $self->last_ppi_element($document);
24 unless $last->isa('PPI::Token::Symbol');
26 my ($sigil, $name) = split(//, $last, 2);
27 my $re = qr/^\Q$name/;
30 # ReadLine is weirdly inconsistent
31 map { $sigil eq '%' ? '%' . $_ : $_ }
33 map { substr($_, 1) } # drop lexical's sigil
34 '$_REPL', keys %{$self->lexical_environment->get_context('_')};
45 Shawn M Moore, C<< <sartak at gmail dot com> >>