3 package Devel::REPL::Plugin::CompletionDriver::Keywords;
5 use Devel::REPL::Plugin;
6 use Devel::REPL::Plugin::Completion; # die early if cannot load
7 use B::Keywords qw/@Functions @Barewords/;
8 use namespace::autoclean;
12 $self->load_plugin('Completion');
15 around complete => sub {
17 my ($self, $text, $document) = @_;
19 my $last = $self->last_ppi_element($document);
22 unless $last->isa('PPI::Token::Word');
24 # don't complete keywords on foo->method
26 if $last->sprevious_sibling
27 && $last->sprevious_sibling->isa('PPI::Token::Operator')
28 && $last->sprevious_sibling->content eq '->';
30 my $re = qr/^\Q$last/;
33 grep { $_ =~ $re } @Functions, @Barewords;
42 Devel::REPL::Plugin::CompletionDriver::Keywords - Complete Perl keywords and operators
46 Shawn M Moore, C<< <sartak at gmail dot com> >>