2017-12-21 21:38:47 +08:00
---
title: "SpaceVim lang#lua layer"
2021-06-21 20:39:29 +08:00
description: "This layer is for Lua development, provides autocompletion, syntax checking, and code format for Lua files."
2017-12-21 21:38:47 +08:00
---
2018-06-23 14:37:41 +08:00
# [Available Layers](../../) >> lang#lua
2017-12-21 21:38:47 +08:00
<!-- vim - markdown - toc GFM -->
2018-06-23 14:37:41 +08:00
- [Description ](#description )
- [Install ](#install )
2019-02-02 11:14:05 +08:00
- [Features ](#features )
2018-06-23 14:37:41 +08:00
- [Key bindings ](#key-bindings )
2019-02-02 11:14:05 +08:00
- [General Key bindings ](#general-key-bindings )
2018-06-23 14:37:41 +08:00
- [Running current script ](#running-current-script )
2019-02-02 11:14:05 +08:00
- [Inferior REPL process ](#inferior-repl-process )
2017-12-21 21:38:47 +08:00
<!-- vim - markdown - toc -->
## Description
2019-02-03 20:51:01 +08:00
This layer is for Lua development.
2017-12-21 21:38:47 +08:00
2018-06-23 14:37:41 +08:00
## Install
2017-12-21 21:38:47 +08:00
2021-06-21 20:39:29 +08:00
To use this configuration layer, update your custom configuration file with:
2018-06-23 14:37:41 +08:00
```toml
[[layers]]
name = "lang#lua"
```
2019-02-02 11:14:05 +08:00
## Features
2017-12-21 21:38:47 +08:00
2019-02-02 11:14:05 +08:00
- syntax checking
- code formatting
- code completion
- repl support
- code runner
2017-12-21 21:38:47 +08:00
## Key bindings
2019-02-02 11:14:05 +08:00
### General Key bindings
| Key Binding | Description |
| ----------- | ------------------------------------------------ |
2019-02-03 20:51:01 +08:00
| `SPC l b` | compile current Lua buffer |
2019-02-02 11:14:05 +08:00
### Running current script
2021-06-21 20:39:29 +08:00
To run a Lua script, you can press `SPC l r` to run the current file without losing focus, and the result will be shown in a runner buffer.
2019-02-02 11:14:05 +08:00
2017-12-21 21:38:47 +08:00
### Inferior REPL process
2019-02-03 20:51:01 +08:00
Start a `lua -i` or `luap` inferior REPL process with `SPC l s i` . You may change the REPL command by layer the option `repl_command` . For example, if you want to use `lua.repl` , load this layer via:
2017-12-21 21:38:47 +08:00
2019-02-02 11:14:05 +08:00
```toml
[[layers]]
name = "lang#lua"
repl_command = "~/.luarocks/lib/luarocks/rocks-5.3/luarepl/0.8-1/bin/rep.lua"
2017-12-21 21:38:47 +08:00
```
Send code to inferior process commands:
2019-02-03 20:51:01 +08:00
| Key Bindings | Descriptions |
| ------------ | ------------------------------------------------ |
| `SPC l s b` | send buffer and keep code buffer focused |
| `SPC l s l` | send line and keep code buffer focused |
| `SPC l s s` | send selection text and keep code buffer focused |