spacemacs/layers/+lang/lua/README.org
2019-11-30 22:55:35 +01:00

80 lines
2.6 KiB
Org Mode

#+TITLE: Lua layer
#+TAGS: general|layer|multi-paradigm|programming
[[file:img/lua.gif]]
* Table of Contents :TOC_5_gh:noexport:
- [[#description][Description]]
- [[#features][Features:]]
- [[#install][Install]]
- [[#layer][Layer]]
- [[#backends][Backends]]
- [[#lsp][LSP]]
- [[#features-1][Features]]
- [[#key-bindings][Key bindings]]
- [[#lsp-1][LSP]]
- [[#commands][Commands]]
* Description
This layer adds support for editing Lua.
** Features:
- LSP with EmmyLua-LS-all.
- Editing lua files using [[https://github.com/immerrr/lua-mode][lua-mode]]
- Sending code to a lua REPL
- Code linting using [[https://github.com/mpeterv/luacheck][Luacheck]]
* Install
** Layer
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.
In order to enable code linting, install [[https://github.com/mpeterv/luacheck][Luacheck]].
** Backends
Supported backends are:
- =lsp-emmy= using clangd LSP server
*** LSP
LSP support is provided via the [[file:../../+tools/lsp/README.org][LSP layer]], currently only EmmyLua is supported,
- [[https://github.com/EmmyLua/EmmyLua-LanguageServer][lsp-emmy]]
To use the =lsp-emmy= backend, please download the [[https://github.com/EmmyLua/EmmyLua-LanguageServer][EmmyLua-LS-all.jar]] and put
into =~/.emacs.d/=, then set the layer variables lsp-backend for =lua=:
#+begin_src elisp
(lua :variables lsp-backend 'lsp-emmy)
#+end_src
The complete layer variables are:
#+begin_src elisp
(lua :variables
lsp-backend 'lsp-emmy
lua-lsp-emmy-jar-path "~/.emacs.d/EmmyLua-LS-all.jar" ; default path
lua-lsp-emmy-enable-file-watchers t) ; enabled default
#+end_src
**** Features
- Cross references (definitions, references, rename...)
- Completion with =company-lsp=
- Syntax checking via flycheck (lsp-ui-flycheck)
- Cross-platform - functional on Windows, Linux and macOS.
- Refer https://github.com/EmmyLua/EmmyLua-LanguageServer for details.
* Key bindings
** LSP
The default key bindings for the LSP implementations are defined and documented in
the [[file:../../+tools/lsp/README.org][LSP layer]].
** Commands
| Key binding | Description |
|-------------+--------------------------------------------|
| ~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 |