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/funcs.el
2020-08-26 22:46:21 +02:00

51 lines
1.5 KiB
EmacsLisp
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;;; funcs.el --- Lua Layer functions File for Spacemacs
;;
;; Copyright (c) 2012-2019 Sylvain Benner & Contributors
;;
;; Author: Lin Sun <sunlin7@yahoo.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(defun spacemacs//lua-setup-backend ()
"Conditionally setup lua backend."
(setq lua-indent-level 2
lua-indent-string-contents t)
(spacemacs/declare-prefix-for-mode 'lua-mode "mh" "help")
(spacemacs/declare-prefix-for-mode 'lua-mode "ms" "REPL")
(spacemacs/declare-prefix-for-mode 'lua-mode "mg" "goto")
(spacemacs/set-leader-keys-for-major-mode 'lua-mode
"hd" 'lua-search-documentation
"sb" 'lua-send-buffer
"sf" 'lua-send-defun
"sl" 'lua-send-current-line
"sr" 'lua-send-region
"'" 'lua-show-process-buffer)
(pcase lua-backend
(`lsp-emmy (spacemacs//lua-setup-lsp-emmy))))
(defun spacemacs//lua-setup-company ()
"Conditionally setup company based on backend."
(pcase lua-backend
(_ (spacemacs//lua-setup-company-lua))))
;; LSP Lua
(defun spacemacs//lua-setup-lsp-emmy ()
"Setup LSP Lua."
(when lua-lsp-emmy-java-path
(setq lsp-clients-emmy-lua-java-path lua-lsp-emmy-java-path))
(when lua-lsp-emmy-jar-path
(setq lsp-clients-emmy-lua-jar-path (expand-file-name lua-lsp-emmy-jar-path)))
(setq lsp-enable-file-watchers lua-lsp-emmy-enable-file-watchers)
(lsp))
;; Lua mode
(defun spacemacs//lua-setup-company-lua ()
(spacemacs|add-company-backends
:backends company-lua
:modes lua-mode)
(company-mode))