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' ];
8 $self->load_plugin('Completion');
11 around complete => sub {
13 my ($self, $text, $document) = @_;
15 my $last = $self->last_ppi_element($document);
18 unless $last->isa('PPI::Token::Word');
20 # don't complete keywords on foo->method
22 if $last->sprevious_sibling
23 && $last->sprevious_sibling->isa('PPI::Token::Operator')
24 && $last->sprevious_sibling->content eq '->';
26 my $re = qr/^\Q$last/;
29 grep { $_ =~ $re } @Functions, @Barewords;
38 Devel::REPL::Plugin::CompletionDriver::Keywords - Complete Perl keywords and operators
42 Shawn M Moore, C<< <sartak at gmail dot com> >>