3 package Devel::REPL::Plugin::CompletionDriver::Keywords;
4 use Devel::REPL::Plugin;
5 use Devel::REPL::Plugin::Completion; # die early if cannot load
6 use B::Keywords qw/@Functions @Barewords/;
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::Word');
23 # don't complete keywords on foo->method
25 if $last->sprevious_sibling
26 && $last->sprevious_sibling->isa('PPI::Token::Operator')
27 && $last->sprevious_sibling->content eq '->';
29 my $re = qr/^\Q$last/;
32 grep { $_ =~ $re } @Functions, @Barewords;
41 Devel::REPL::Plugin::CompletionDriver::Keywords - Complete Perl keywords and operators
45 Shawn M Moore, C<< <sartak at gmail dot com> >>