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