3 package Devel::REPL::Plugin::CompletionDriver::Keywords;
4 # ABSTRACT: Complete Perl keywords and operators
6 our $VERSION = '1.003029';
8 use Devel::REPL::Plugin;
9 use Devel::REPL::Plugin::Completion; # die early if cannot load
10 use B::Keywords qw/@Functions @Barewords/;
11 use namespace::autoclean;
15 $self->load_plugin('Completion');
18 around complete => sub {
20 my ($self, $text, $document) = @_;
22 my $last = $self->last_ppi_element($document);
25 unless $last->isa('PPI::Token::Word');
27 # don't complete keywords on foo->method
29 if $last->sprevious_sibling
30 && $last->sprevious_sibling->isa('PPI::Token::Operator')
31 && $last->sprevious_sibling->content eq '->';
33 my $re = qr/^\Q$last/;
36 grep { $_ =~ $re } @Functions, @Barewords;
47 Shawn M Moore, C<< <sartak at gmail dot com> >>