2017-08-28 15:33:55 +00:00
#+TITLE : Lua layer
2015-06-10 16:44:30 +00:00
2019-05-07 08:53:56 +00:00
#+TAGS : general|layer|multi-paradigm|programming
2019-05-05 17:26:40 +00:00
2015-06-10 16:44:30 +00:00
[[file:img/lua.gif ]]
2019-05-07 20:05:06 +00:00
* Table of Contents :TOC_5_gh:noexport:
2017-05-22 14:16:12 +00:00
- [[#description ][Description ]]
- [[#features ][Features: ]]
- [[#install ][Install ]]
2019-11-12 03:29:50 +00:00
- [[#layer ][Layer ]]
- [[#backends ][Backends ]]
- [[#lsp ][LSP ]]
2019-11-30 23:39:37 +00:00
- [[#lua-mode ][Lua mode ]]
2018-12-05 03:03:03 +00:00
- [[#key-bindings ][Key bindings ]]
2019-11-12 03:29:50 +00:00
- [[#lsp-1 ][LSP ]]
2017-05-22 14:16:12 +00:00
- [[#commands ][Commands ]]
2015-06-10 16:44:30 +00:00
* Description
This layer adds support for editing Lua.
2015-06-10 21:16:01 +00:00
** Features:
2015-06-10 16:44:30 +00:00
- Editing lua files using [[https://github.com/immerrr/lua-mode ][lua-mode ]]
2020-04-02 16:41:28 +00:00
- Code-Completion with =lsp= or =company-lua=
2015-06-10 16:44:30 +00:00
- Sending code to a lua REPL
2016-02-17 14:01:10 +00:00
- Code linting using [[https://github.com/mpeterv/luacheck ][Luacheck ]]
2019-11-30 23:39:37 +00:00
- Cross references (definitions, references, rename...)
2015-06-10 16:44:30 +00:00
* Install
2019-11-12 03:29:50 +00:00
** Layer
2016-01-06 05:21:55 +00:00
To use this configuration layer, add it to your =~/.spacemacs= . You will need to
add =lua= to the existing =dotspacemacs-configuration-layers= list in this
file.
2015-06-10 16:44:30 +00:00
2016-02-17 14:01:10 +00:00
In order to enable code linting, install [[https://github.com/mpeterv/luacheck ][Luacheck ]].
2015-06-10 16:44:30 +00:00
2019-11-12 03:29:50 +00:00
** Backends
Supported backends are:
- =lsp-emmy= using clangd LSP server
2019-11-30 23:39:37 +00:00
- =lua-mode= using emacs package
2019-11-12 03:29:50 +00:00
*** LSP
2019-11-30 23:39:37 +00:00
LSP support is provided via the [[file:../../+tools/lsp/README.org ][LSP layer ]], currently only [[https://github.com/EmmyLua/EmmyLua-LanguageServer ][EmmyLua ]] is supported.
2019-11-12 03:29:50 +00:00
2020-04-02 16:41:28 +00:00
To use the =lsp-emmy= backend, please download the [[https://github.com/EmmyLua/EmmyLua-LanguageServer ][EmmyLua-LS-all.jar ]] and put it into =~/.emacs.d/= ,
2019-11-30 23:39:37 +00:00
then set the layer variable lua-backend to =lsp-emmy= .
2019-11-12 03:29:50 +00:00
2019-11-30 23:39:37 +00:00
=Lsp-emmy= requires a working java installation in the path as well as the path to the LSP server jar.
The java path and the path to the server executable can be configured as is shown below:
2019-11-30 23:48:29 +00:00
#+BEGIN_SRC elisp
2019-11-12 03:29:50 +00:00
(lua :variables
2019-11-30 23:39:37 +00:00
lua-backend 'lsp-emmy
2019-11-12 03:29:50 +00:00
lua-lsp-emmy-jar-path "~/.emacs.d/EmmyLua-LS-all.jar" ; default path
2019-11-30 23:39:37 +00:00
lua-lsp-emmy-java-path "java" ; default path
2019-11-12 03:29:50 +00:00
lua-lsp-emmy-enable-file-watchers t) ; enabled default
2019-11-30 23:48:29 +00:00
#+END_SRC
2019-11-12 03:29:50 +00:00
2019-11-30 23:39:37 +00:00
*** Lua mode
2020-04-02 16:41:28 +00:00
This backend provides support via pure emacs packages. It requires less setup than a full blown LSP setup
2019-11-30 23:39:37 +00:00
but also provides less features. To enable it just set the =lua-backend= to =nil= .
2019-11-12 03:29:50 +00:00
2018-12-05 03:03:03 +00:00
* Key bindings
2019-11-12 03:29:50 +00:00
** LSP
The default key bindings for the LSP implementations are defined and documented in
the [[file:../../+tools/lsp/README.org ][LSP layer ]].
2015-06-10 16:44:30 +00:00
** Commands
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2015-06-10 16:44:30 +00:00
|-------------+--------------------------------------------|
| ~SPC m d~ | lookup thing at point in lua documentation |
| ~SPC m s b~ | send buffer contents to REPL |
| ~SPC m s f~ | send current function to REPL |
| ~SPC m s l~ | send current line to REPL |
| ~SPC m s r~ | send current region to REPL |
2019-11-30 23:39:37 +00:00
| ~SPC m '~ | open repl buffer |