Function: lua-ts-mode
lua-ts-mode is an autoloaded, interactive and byte-compiled function
defined in lua-ts-mode.el.gz.
Signature
(lua-ts-mode)
Documentation
Major mode for editing Lua files, powered by tree-sitter.
C-c C-c lua-ts-send-buffer
C-c C-l lua-ts-send-file
C-c C-n lua-ts-inferior-lua
C-c C-r lua-ts-send-region
In addition to any hooks its parent mode prog-mode might have run,
this mode runs the hook lua-ts-mode-hook, as the final or penultimate
step during initialization.
Probably introduced at or before Emacs version 30.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/lua-ts-mode.el.gz
;;;###autoload
(define-derived-mode lua-ts-mode prog-mode "Lua"
"Major mode for editing Lua files, powered by tree-sitter.
\\{lua-ts-mode-map}"
:syntax-table lua-ts--syntax-table
(use-local-map lua-ts-mode-map)
(when (treesit-ready-p 'lua)
(treesit-parser-create 'lua)
;; Comments.
(setq-local comment-start "--")
(setq-local comment-start-skip "--\\s-*")
(setq-local comment-end "")
;; Font-lock.
(setq-local treesit-font-lock-settings lua-ts--font-lock-settings)
(setq-local treesit-font-lock-feature-list
'((comment definition)
(keyword string)
(assignment builtin constant number)
(bracket
delimiter
escape
function
operator
property
punctuation
variable)))
;; Indent.
(setq-local treesit-simple-indent-rules lua-ts--simple-indent-rules)
;; Navigation.
(setq-local treesit-defun-name-function #'lua-ts--defun-name-function)
(setq-local treesit-defun-type-regexp
(rx (or "function_declaration" "function_definition")))
(setq-local treesit-thing-settings
`((lua
(function ,(rx (or "function_declaration"
"function_definition")))
(keyword ,(regexp-opt lua-ts--keywords 'symbols))
(loop-statement ,(rx (or "do_statement"
"for_statement"
"repeat_statement"
"while_statement")))
(sentence (or function
loop-statement
,(rx (or "assignment_statement"
"comment"
"field"
"function_call"
"if_statement"
"return_statement"
"variable_declaration"))))
(sexp (or function
keyword
loop-statement
,(rx (or "arguments"
"parameters"
"parenthesized_expression"
"string"
"table_constructor"))))
(text "comment"))))
;; Imenu/Outline/Which-function.
(setq-local treesit-simple-imenu-settings
`(("Requires"
"\\`function_call\\'"
lua-ts--require-p
lua-ts--require-name-function)
("Variables" "\\`variable_declaration\\'" nil nil)
(nil
"\\`\\(?:f\\(?:ield\\|unction_declaration\\)\\)\\'"
lua-ts--named-function-p
nil)))
;; Align.
(setq-local align-indent-before-aligning t)
(treesit-major-mode-setup))
(add-hook 'flymake-diagnostic-functions #'lua-ts-flymake-luacheck nil 'local))