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