This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+lang/lua
2021-02-13 20:50:39 +00:00
..
img
config.el [lua] more lsp backends for lua 2021-02-13 20:50:39 +00:00
funcs.el [lua] more lsp backends for lua 2021-02-13 20:50:39 +00:00
layers.el update copyright to 2020 2020-09-23 21:25:01 +02:00
packages.el update copyright to 2020 2020-09-23 21:25:01 +02:00
README.org [lua] more lsp backends for lua 2021-02-13 20:50:39 +00:00

Lua layer

/TakeV/spacemacs/media/commit/ca0fe33c8d417ab1cfba86a1f76bed1d1ad72c70/layers/+lang/lua/img/lua.gif

Description

This layer adds support for editing Lua.

Features:

  • Editing lua files using lua-mode
  • Code-Completion with lsp or company-lua
  • Sending code to a lua REPL
  • Code linting using Luacheck
  • Cross references (definitions, references, rename…)

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 Luacheck.

Backends

Supported backends are:

  • lsp-emmy-lua using emmy LSP server
  • lsp-lua-language-server using lua-language-server.
  • lsp-lua-lsp using lua-lsp.
  • lua-mode using emacs package

LSP

LSP support is provided via the LSP layer, currently EmmyLua, lua-language-server and lua-lsp are supported.

To use the lsp-emmy-lua backend, please download the EmmyLua-LS-all.jar and put it into ~/.emacs.d/, and then set the layer variable lua-backend to lsp-emmy-lua.

lsp-emmy-lua 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:

  (lua :variables
       lua-backend 'lsp-emmy
       lsp-clients-emmy-lua-jar-path "~/.emacs.d/.cache/lsp/EmmyLua-LS-all.jar" ; default path
       lsp-clients-emmy-lua-java-path "java") ; default path

To use the lsp-lua-language-server backend, please follow lua-language-server to compile the standalone binary, and then set the layer variable lua-backend to lsp-lua-language-server, and the variables for binary and main entry such as the example below:

  (lua :variables
       lua-backend 'lsp-lua-language-server
       lsp-clients-lua-language-server-bin "~/.emacs.d/.cache/lsp/lua-language-server/bin/Linux/lua-language-server" ; default path
       lsp-clients-lua-language-server-main-location "~/.emacs.d/.cache/lsp/lua-language-server/main.lua") ; default path

Lua mode

This backend provides support via pure emacs packages. It requires less setup than a full blown LSP setup but also provides less features. To enable it just set the lua-backend to nil.

Key bindings

LSP

The default key bindings for the LSP implementations are defined and documented in the 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
SPC m ' open repl buffer