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