1 package Devel::REPL::Plugin::CompletionDriver::Keywords;
2 use Devel::REPL::Plugin;
3 use B::Keywords qw/@Functions @Barewords/;
4 use namespace::clean -except => [ 'meta' ];
6 around complete => sub {
8 my ($self, $text, $document) = @_;
10 my $last = $self->last_ppi_element($document);
13 unless $last->isa('PPI::Token::Word');
15 # don't complete keywords on foo->method
17 if $last->sprevious_sibling
18 && $last->sprevious_sibling->isa('PPI::Token::Operator')
19 && $last->sprevious_sibling->content eq '->';
21 my $re = qr/^\Q$last/;
24 grep { $_ =~ $re } @Functions, @Barewords;
33 Devel::REPL::Plugin::CompletionDriver::Keywords - Complete Perl keywords and operators
37 Shawn M Moore, C<< <sartak at gmail dot com> >>