3 package Devel::REPL::Plugin::CompletionDriver::LexEnv;
5 our $VERSION = '1.003027';
7 use Devel::REPL::Plugin;
8 use Devel::REPL::Plugin::Completion; # die early if cannot load
9 use namespace::autoclean;
13 $self->load_plugin('Completion');
16 around complete => sub {
18 my ($self, $text, $document) = @_;
20 my $last = $self->last_ppi_element($document);
23 unless $last->isa('PPI::Token::Symbol');
25 my ($sigil, $name) = split(//, $last, 2);
26 my $re = qr/^\Q$name/;
29 # ReadLine is weirdly inconsistent
30 map { $sigil eq '%' ? '%' . $_ : $_ }
32 map { substr($_, 1) } # drop lexical's sigil
33 '$_REPL', keys %{$self->lexical_environment->get_context('_')};
42 Devel::REPL::Plugin::CompletionDriver::LexEnv - Complete variable names in the REPL's lexical environment
46 Shawn M Moore, C<< <sartak at gmail dot com> >>