Function: lua-mode

lua-mode is an autoloaded, interactive and byte-compiled function defined in lua-mode.el.gz.

Signature

(lua-mode)

Documentation

Major mode for editing Lua code.

In addition to any hooks its parent mode prog-mode might have run, this mode runs the hook lua-mode-hook, as the final or penultimate step during initialization.

C-M-u lua-backward-up-list
C-c C-f lua-search-documentation
C-c C-l lua-send-buffer

Probably introduced at or before Emacs version 31.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/lua-mode.el.gz
;;;###autoload
(define-derived-mode lua-mode prog-mode "Lua"
  "Major mode for editing Lua code."
  :abbrev-table lua-mode-abbrev-table
  :syntax-table lua-mode-syntax-table
  (setq-local font-lock-defaults '(lua-font-lock-keywords ; keywords
                                   nil                    ; keywords-only
                                   nil                    ; case-fold
                                   nil                    ; syntax-alist
                                   nil))                  ; syntax-begin

  (setq-local syntax-propertize-function
              'lua--propertize-multiline-bounds)

  (setq-local parse-sexp-lookup-properties t)
  (setq-local indent-line-function 'lua-indent-line)
  (setq-local beginning-of-defun-function 'lua-beginning-of-proc)
  (setq-local end-of-defun-function 'lua-end-of-proc)
  (setq-local comment-start lua-comment-start)
  (setq-local comment-start-skip lua-comment-start-skip)
  (setq-local comment-use-syntax t)
  (setq-local fill-paragraph-function #'lua--fill-paragraph)
  (with-no-warnings
    (setq-local comment-use-global-state t))
  (setq-local imenu-generic-expression lua-imenu-generic-expression)
  (when (boundp 'electric-indent-chars)
    ;; If electric-indent-chars is not defined, electric indentation is
    ;; done via `lua-mode-map'.
    (setq-local electric-indent-chars
                (append electric-indent-chars lua--electric-indent-chars)))
  (add-hook 'flymake-diagnostic-functions #'lua-flymake nil t)

  ;; Hide-show setup
  (setq-local hs-block-start-regexp (regexp-opt (mapcar 'car lua-sexp-alist) 'words))
  (setq-local hs-block-end-regexp (regexp-opt (mapcar 'cdr lua-sexp-alist) 'words))
  (setq-local hs-forward-sexp-function #'lua-forward-sexp))