README.md (5244B)
1 # Lua mode 2 3 [![Build Status](https://travis-ci.org/immerrr/lua-mode.svg?branch=master)](https://travis-ci.org/immerrr/lua-mode) 4 [![MELPA](https://melpa.org/packages/lua-mode-badge.svg)](https://melpa.org/#/lua-mode) 5 [![MELPA Stable](https://stable.melpa.org/packages/lua-mode-badge.svg)](https://stable.melpa.org/#/lua-mode) 6 [![NonGNU ELPA](https://elpa.nongnu.org/nongnu/lua-mode.svg)](https://elpa.nongnu.org/nongnu/lua-mode.html) 7 8 **lua-mode** is a major mode for editing Lua sources in Emacs. 9 10 11 If you have a problem or a suggestion about **lua-mode**, please, let me know about it via github's [Issue Tracker](https://github.com/immerrr/lua-mode/issues). 12 13 ## INSTALLATION 14 15 ### MELPA INSTALLATION 16 17 **lua-mode**'s officially supported installation method is from [MELPA](https://melpa.org/#/) archive. 18 19 To get started, enable installing packages from MELPA: 20 21 ```lisp 22 (require 'package) 23 (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) 24 (package-initialize) 25 ``` 26 27 To fetch the list of packages you can do 28 29 ``` 30 <M-x> package-refresh-contents 31 ``` 32 33 And after that **lua-mode** can be installed with 34 35 ``` 36 <M-x> package-install "lua-mode" 37 ``` 38 39 Please, refer to [MELPA documentation](https://melpa.org/#/getting-started) and [Emacs documentation on 40 packages](https://www.gnu.org/software/emacs/manual/html_node/emacs/Packages.html) for further information. 41 42 ### EL-GET INSTALLATION 43 44 [El-get](https://github.com/dimitri/el-get) is a package manager which greatly simplifies adding 45 modules to your Emacs and keeping them up-to-date. Once you have **el-get** set up, 46 **lua-mode** can also be installed with 47 48 <M-x> el-get-install "lua-mode" 49 50 and updating is no more than 51 52 <M-x> el-get-update "lua-mode" 53 54 Please, consult with [el-get documentation](https://github.com/dimitri/el-get/blob/master/README.md) for further information. 55 56 ### MANUAL INSTALLATION 57 58 To install, you need to make sure that `lua-mode.el` is on your load-path (and optionally byte-compile 59 it) and to set up Emacs to automatically enable **lua-mode** for `*.lua` files or ones that contain lua 60 hash-bang line (`#!/usr/bin/lua`). Putting this snippet to `.emacs` should be enough in most cases: 61 ```lisp 62 ;;;; This snippet enables lua-mode 63 64 ;; This line is not necessary, if lua-mode.el is already on your load-path 65 (add-to-list 'load-path "/path/to/directory/where/lua-mode-el/resides") 66 67 (autoload 'lua-mode "lua-mode" "Lua editing mode." t) 68 (add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode)) 69 (add-to-list 'interpreter-mode-alist '("lua" . lua-mode)) 70 ``` 71 72 ## FEATURES 73 74 - syntactic indentation & highlighting (including multiline literals/comments) 75 - evaluation of lines/regions/functions/files in Lua subprocess or direct interaction with its REPL 76 - documentation lookup (using online/offline reference manual, e.g. [string.find](http://www.lua.org/manual/5.1/manual.html#pdf-string.find)) 77 - [imenu](http://www.gnu.org/software/emacs/manual/html_node/emacs/Imenu.html) integration 78 - [HideShow](http://www.gnu.org/software/emacs/manual/html_node/emacs/Hideshow.html) integration 79 - [Flymake](https://www.gnu.org/software/emacs/manual/html_mono/flymake.html) integration for on-the-fly linting. The [luacheck](https://github.com/lunarmodules/luacheck) program is required for this. It can be installed e.g. via luarocks. 80 81 ## CUSTOMIZATION 82 83 The following variables are available for customization (see more via `M-x customize-group lua`): 84 85 - Var `lua-indent-level` (default `3`): indentation offset in spaces 86 - Var `lua-indent-string-contents` (default `nil`): set to `t` if you like to have contents of multiline strings to be indented like comments 87 - Var `lua-indent-nested-block-content-align` (default `t`) set to `nil` to stop aligning the content of nested blocks with the open parenthesis 88 - Var `lua-indent-close-paren-align` (default `t`) set to `t` to align close parenthesis with the open parenthesis rather than with the beginning of the line 89 - Var `lua-mode-hook`: list of functions to execute when lua-mode is initialized 90 - Var `lua-documentation-url` (default `"http://www.lua.org/manual/5.1/manual.html#pdf-"`): base URL for documentation lookup 91 - Var `lua-documentation-function` (default `browse-url`): function used to show documentation (`eww` is a viable alternative for Emacs 25) 92 93 ## LUA SUBPROCESS CREATION 94 95 - Var `lua-default-application` (default `"lua"`): command to start up the subprocess (REPL) 96 - Var `lua-default-command-switches` (default `"-i"`): arguments to pass to the subprocess on startup (make sure `-i` is there if you expect working with Lua shell interactively) 97 - Cmd `lua-start-process`: start new REPL process, usually happens automatically 98 - Cmd `lua-kill-process`: kill current REPL process 99 100 ## LUA SUBPROCESS INTERACTION 101 102 - Cmd `lua-show-process-buffer`: switch to REPL buffer 103 - Cmd `lua-hide-process-buffer`: hide window showing REPL buffer 104 - Var `lua-always-show`: show REPL buffer after sending something 105 - Cmd `lua-send-buffer`: send whole buffer 106 - Cmd `lua-send-current-line`: send current line 107 - Cmd `lua-send-defun`: send current top-level function 108 - Cmd `lua-send-region`: send active region 109 - Cmd `lua-restart-with-whole-file`: restart REPL and send whole buffer