• Stars
    star
    157
  • Rank 238,399 (Top 5 %)
  • Language
    Lua
  • License
    MIT License
  • Created about 13 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Lua REPL implemented in Lua for embedding in other programs

REPL.lua - a reusable Lua REPL written in Lua, and an alternative to /usr/bin/lua

This project has two uses:

  • An alternative to the standalone interpreter included with Lua, one that supports things like plugins, tab completion, and automatic insertion of return in front of expressions.

  • A REPL library you may embed in your application, to provide all of the niceties of the standalone interpreter included with Lua and then some.

Many software projects have made the choice to embed Lua in their projects to allow their users some extra flexibility. Some of these projects would also like to provide a Lua REPL in their programs for debugging or rapid development. Most Lua programmers are familiar with the standalone Lua interpreter as a Lua REPL; however, it is bound to the command line. Until now, Lua programmers would have to implement their own REPL from scratch if they wanted to include one in their programs. This project aims to provide a REPL implemented in pure Lua that almost any project can make use of.

This library also includes an example application (rep.lua), which serves as an alternative to the standalone interpreter included with Lua. If the lua-linenoise library is installed, it uses linenoise for history and tab completion; otherwise, it tries to use rlwrap for basic line editing. If you would like the arrow keys to work as expected rather than printing things like ^[[A, please install the lua-linenoise library or the rlwrap program.

Project Goals

  • Provide REPL logic to Lua programs that include this module.

  • Be extensible through polymorphism and plugins.

  • Abstract away I/O, so you can run this REPL on the command line or in your own event loop and expect the same behavior.

Building

Compatibility

The current version of the software runs on Lua 5.1, LuaJIT ?.? etc. A port to Lua 5.2 is envisaged, but is not at this stage a priority. Since it is written purely in Lua, it should work on any platform that has one of those versions of Lua installed.

XXX Check which version of LuaJIT this works with XXX Check that it works with other Lua interpreters

Installation

You can install lua-repl via LuaRocks:

luarocks install luarepl

You can also install it by hand by copying the repl directory to a location in your package.path, and copying rep.lua to somewhere in your PATH.

Recommended packages

rep.lua works best if you also have linenoise installed, available from https://github.com/hoelzro/lua-linenoise. rep.lua will fallback to using rlwrap if you have that as well; without either of these, you will have command editing, history, or other features generally provided by readline.

Features

rep.lua prints the results of simple expressions without requiring a return or a = in front of it. If linenoise is installed, it also offers persistent history and tab completion. It also offers a number of plugins; see plugins.md for a list of plugins that come with lua-repl.

Backwards Compatibility Changes

Removal of default plugins in 0.8

Lua REPL 0.8 breaks backwards compatability by disabling the loading of the default plugins (currently linenoise, rlwrap, history, completion, and autoreturn) if an rcfile is found for a user. This is so that plugins may not be forced onto a user if they don't want them, or play tricks with their setup (see issue #47). If you would like to continue using these plugins, please put the following code into your ~/.rep.lua:

if repl.VERSION >= 0.8 then
  -- default plugins
  repl:loadplugin 'linenoise'
  repl:loadplugin 'history'
  repl:loadplugin 'completion'
  repl:loadplugin 'autoreturn'
end

-- suppress warning message
repl.quiet_default_plugins = true

As mentioned in the code snippet, repl.quiet_default_plugins suppresses the warning. You can remove this after upgrading to Lua REPL 0.8.

More Repositories

1

lua-term

Terminal operations for Lua
Lua
134
star
2

linotify

Inotify bindings for Lua
C
95
star
3

pluto

Heavy Duty Persistence for Lua
C
79
star
4

obvious

Widget library for the awesome window manager
Lua
65
star
5

lua-linenoise

Lua bindings for linenoise with UTF-8 support (https://github.com/yhirose/linenoise/tree/utf8-support)
C
47
star
6

linux-fake-battery-module

Fake Battery Module for the Linux kernel
C
41
star
7

tw-full-text-search

Full text search plugin for TiddlyWiki powered by lunr.js
JavaScript
25
star
8

ansicolors

ANSI terminal color manipulation for Lua.
Lua
23
star
9

lunr-mutable-indexes

Mutable indexes for lunr.js 2.1.x
JavaScript
20
star
10

git-pisect

Parallel regression finder for Git
Perl
20
star
11

sqlite-lua-extension

A SQLite extension that embeds a Lua interpreter into SQLite
C
19
star
12

lua-procure

A Pure Lua implementation of require()
Perl
18
star
13

idea-fight

A web application for helping you decide the priorities of your ideas
Elm
17
star
14

useful-scripts

Scripts from my private ~/bin-tage
Perl
16
star
15

vim-split-navigate

An experimental method for jumping to lines on screen
Vim Script
11
star
16

ruby-keepass

Ruby binding for libkpass
C
11
star
17

lua-typical

Fancy type names for Lua
Lua
10
star
18

awesome-config

My Awesome configuration
Lua
10
star
19

dotfiles

My dotfiles
Perl
9
star
20

queqiao

A higher-level interface for writing Vim plugins in Lua
Lua
9
star
21

twitter-reply-tracker

Provides a mechanism for tracking replies to a tweet, as well as a UI for searching them
TypeScript
8
star
22

term-drawille

Draw to your terminal using Braille characters
Perl
8
star
23

luabdb

A Berkeley DB binding for Lua.
C
8
star
24

vimfiles

My $HOME/.vim directory
Vim Script
7
star
25

vim-elm-help

Offline Elm documentation access in your editor
Perl
7
star
26

sahara-sync

A free software (AGPL) alternative to Dropbox
Perl
7
star
27

luaperl

A Lua-Perl bridge for Lua
C
7
star
28

luael

Libedit bindings for Lua.
C
7
star
29

tiddlywiki-first-class-urls

An experimental plugin to make importing tiddlers easier
JavaScript
7
star
30

elm-drag

Track dragging motions when the mouse is down
Elm
6
star
31

tw-progress-bar

Progress bar widget for TiddlyWiki
JavaScript
6
star
32

elm-typing-tutor

A typing tutor for Russian written in Elm
Elm
6
star
33

language-of-the-month

Programming projects for language of the month (http://hoelz.ro/blog/language-of-the-month)
Elixir
6
star
34

firefox-keepass-autofill

Automatically fill in username/password combinations from a Keepass database.
JavaScript
5
star
35

semantic-diff

Semantic diff tool for Python 2
Python
5
star
36

autopilot

A daemon that allows you to automate actions to occur on changes in your computer's state
C
4
star
37

p6-xapian

Xapian bindings for Perl 6
Perl 6
4
star
38

vim-temporal-marks

Temporal marks for Vim
Vim Script
4
star
39

harbour-sudoku

Sudoku application for SailfishOS
QML
4
star
40

lua-proctitle

Set your process' name from Lua so that it shows up differently in programs like ps or netstat
C
4
star
41

p6-io-string

IO::String for Perl6
Perl 6
4
star
42

zsh-config

My ZSH configuration
Shell
4
star
43

inline-lua

Perl extension for embedding Lua scripts into Perl code
C
4
star
44

app-musicfind

Musicfind is a tool similar to find(1), but for manipulating music files
Perl
3
star
45

tw-modern-jasmine

Jasmine 3.x plugin for TiddlyWiki
JavaScript
3
star
46

dist-zilla-plugin-test-localbrew

Verify that your distribution tests well in a fresh perlbrew
Perl
3
star
47

plack-middleware-options

Implements HTTP OPTIONS method for Plack
Perl
3
star
48

Mac-FSEvents

Release history of Mac-FSEvents
C
3
star
49

sqlite-attribute-vtable

Attributes virtual table extension for SQLite
C
3
star
50

sqlite-lua-vtable

Implement SQLite virtual tables using Lua
C
3
star
51

p6-native-resources

Boilerplate helper for bundling native code
Perl 6
3
star
52

lua-tracer

Reload-free print debugging for Lua
Lua
3
star
53

bashrc

Bash configuration
Shell
3
star
54

hexe

An XMPP chatbot written in Perl 6
Perl 6
3
star
55

devel-repl-plugin-editor

Drop into your favorite editor from Devel::REPL
Perl
3
star
56

wwid

A todo list manager that tells you what to do
Perl
2
star
57

text-dokuwiki

Perl implementation of the DokuWiki parser
Perl
2
star
58

p6-priorityqueue

A priority queue data structure for Perl 6
Perl 6
2
star
59

lua-iterators

A Lua library for manipulating iterators
2
star
60

bash-completion-plugins-perlbrew

Perlbrew completion for bash
Perl
2
star
61

plack-test-anyevent

Test streaming PSGI-based applications using AnyEvent
Perl
2
star
62

plack-middleware-recorder

PSGI middleware for recording requests
Perl
2
star
63

p6-test-meta

A test library for testing test libraries
Perl
2
star
64

advent-of-code

Solutions to Advent of Code
Go
2
star
65

perl6-syntax

Editor support for Perl 6
Vim Script
2
star
66

elm-jargon

A repository of terminology used by the Elm community.
2
star
67

p6-algorithm-lcs

Implementation of longest common subsequence in Perl 6
Perl 6
2
star
68

p6-pod-eod

Moves declarative POD blocks to the end of the POD
Perl 6
2
star
69

devel-trace-syscall

Print a stack trace whenever a system call is made
Perl
2
star
70

track-spotify-plays

Lambda function to log my recently played songs from Spotify
Python
2
star
71

dzil-config

My Dist::Zilla configuration
Perl
1
star
72

mytrace

strace for MySQL
C
1
star
73

devel-repl-plugin-lazyload

Lazily load modules in your Devel::REPL
Perl
1
star
74

app-intelligentsia

Intelligentsia is a Identica/Twitter client written in Perl.
Perl
1
star
75

cpan-highlight

Google Chrome extension to highlight source code viewed on the CPAN
JavaScript
1
star
76

bash-completion-plugins-dzil

Bash::Completion support for Dist::Zilla
Perl
1
star
77

smart-alloc

A memory allocator for C
C
1
star
78

perl-power-tools

Slides for my Perl Power Tools Talk
JavaScript
1
star
79

xmpp-talk

The XMPP presentation I'm giving at MadMongers in December
TeX
1
star
80

bash-completion-plugin-test

Module for testing Bash::Completion plugins
Perl
1
star
81

perl-objectivec

Objective-C bridge for Perl
C
1
star
82

p6-class-contract

Class invariants for Perl 6
Perl 6
1
star
83

dzil-talk

The Dist::Zilla talk I'm giving at MadMongers in September
1
star
84

elm-tetris

An implementation of Tetris in Elm
Elm
1
star
85

pyweek-2014

PyWeek entry for 2014
Python
1
star
86

dev-study

Implementations of algorithms for study exercises
C
1
star
87

term-emulator

A Perl module to interpret and handle terminal escape sequences
Perl
1
star
88

blog

Source code and pages for my blog
JavaScript
1
star
89

plack-middleware-acme-yadayada

Middleware for handling the yada yada operator
Perl
1
star
90

luarepl-evlib

Use luarepl with an asynchronous event loop
C
1
star
91

vimlint

A lint-style tool for Vimscript
1
star
92

p6-algorithm-elo

Implementation of the Elo chess algorithm for Perl 6
Perl 6
1
star
93

mazes-for-programmers

https://pragprog.com/titles/jbmaze/mazes-for-programmers/
PostScript
1
star
94

mail-scripts

Perl scripts for organizing my e-mail
Perl
1
star
95

fx-zoom-lock

Prevents zooming on webpages
JavaScript
1
star
96

plack-middleware-setaccept

Sets the Accept header based on the suffix or query params of a request
Perl
1
star
97

lua-talk

The sources for the talk I'm giving to HackersNL in November 2012
Lua
1
star
98

ghoti

An offline issue browser for GitHub
Ruby
1
star
99

dancer-plugin-couchdb

CouchDB plugin for Dancer
Perl
1
star
100

anyevent-webservice-tracks

Access Tracks' API from AnyEvent
Perl
1
star