* bug#66162: [PATCH] Various fixes to lua-ts-mode font-locking
@ 2023-09-22 23:43 john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-30 23:19 ` Stefan Kangas
0 siblings, 1 reply; 2+ messages in thread
From: john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-09-22 23:43 UTC (permalink / raw)
To: 66162
[-- Attachment #1: Type: text/plain, Size: 171 bytes --]
Tags: patch
Here are some fixes around font-locking mostly to do with functions and
assignments; e.g.
f1 = function() end
now correctly marks f1 as a function name.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Various-fixes-to-lua-ts-mode-font-locking.patch --]
[-- Type: text/patch, Size: 3959 bytes --]
From df023cab8834477c63adf7fdc88afa1871c0fc96 Mon Sep 17 00:00:00 2001
From: john muhl <jm@pub.pink>
Date: Fri, 22 Sep 2023 18:36:18 -0500
Subject: [PATCH] Various fixes to lua-ts-mode font-locking
* lisp/progmodes/lua-ts-mode.el (lua-ts--font-lock-settings):
Identify functions and assignments in more places. Use constant
face for goto/labels.
---
lisp/progmodes/lua-ts-mode.el | 56 +++++++++++++++++++++++++----------
1 file changed, 40 insertions(+), 16 deletions(-)
diff --git a/lisp/progmodes/lua-ts-mode.el b/lisp/progmodes/lua-ts-mode.el
index 071953d3d2f..030a3585158 100644
--- a/lisp/progmodes/lua-ts-mode.el
+++ b/lisp/progmodes/lua-ts-mode.el
@@ -121,7 +121,9 @@ lua-ts--font-lock-settings
:feature 'constant
'((variable_list
attribute: (attribute (["<" ">"] (identifier))))
- @font-lock-constant-face)
+ @font-lock-constant-face
+ (goto_statement (identifier) @font-lock-constant-face)
+ (label_statement) @font-lock-constant-face)
:language 'lua
:feature 'operator
@@ -131,12 +133,6 @@ lua-ts--font-lock-settings
@font-lock-operator-face
(vararg_expression) @font-lock-operator-face)
- :language 'lua
- :feature 'property
- '((field name: (identifier) @font-lock-property-name-face)
- (dot_index_expression
- field: (identifier) @font-lock-property-use-face))
-
:language 'lua
:feature 'builtin
`(((identifier) @font-lock-builtin-face
@@ -150,8 +146,7 @@ lua-ts--font-lock-settings
name: (method_index_expression
method: (identifier) @font-lock-function-call-face))
(function_call
- name: (dot_index_expression
- table: (identifier) @font-lock-function-call-face)))
+ name: (dot_index_expression (identifier) @font-lock-function-call-face)))
:language 'lua
:feature 'punctuation
@@ -164,12 +159,7 @@ lua-ts--font-lock-settings
@font-lock-variable-use-face)
(function_call
name: (method_index_expression
- table: (identifier) @font-lock-variable-use-face))
- (goto_statement (identifier) @font-lock-variable-use-face))
-
- :language 'lua
- :feature 'assignment
- '((variable_list (identifier) @font-lock-variable-name-face))
+ table: (identifier) @font-lock-variable-use-face)))
:language 'lua
:feature 'number
@@ -199,9 +189,43 @@ lua-ts--font-lock-settings
:feature 'definition
'((function_declaration
name: (identifier) @font-lock-function-name-face)
+ (assignment_statement
+ (variable_list name: [(identifier)]) @font-lock-function-name-face
+ (expression_list value: (function_definition)))
+ (table_constructor
+ (field
+ name: (identifier) @font-lock-function-name-face
+ value: (function_definition)))
+ (function_declaration
+ name: (dot_index_expression (identifier) @font-lock-function-name-face))
+ (function_declaration
+ name: (method_index_expression (identifier) @font-lock-function-name-face))
+ (function_declaration
+ (method_index_expression
+ (dot_index_expression
+ table: (identifier) @font-lock-function-name-face
+ field: (identifier) @font-lock-property-name-face
+ )))
(parameters
name: (identifier) @font-lock-variable-name-face)
- (label_statement) @font-lock-variable-name-face)
+ (for_numeric_clause name: (identifier) @font-lock-variable-name-face))
+
+ :language 'lua
+ :feature 'property
+ '((field name: (identifier) @font-lock-property-name-face)
+ (dot_index_expression
+ field: (identifier) @font-lock-property-use-face))
+
+ :language 'lua
+ :feature 'assignment
+ '((variable_list
+ [(identifier)
+ (bracket_index_expression)]
+ @font-lock-variable-name-face)
+ (variable_list
+ (dot_index_expression
+ table: (identifier))
+ @font-lock-variable-name-face))
:language 'lua
:feature 'error
--
2.41.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-30 23:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-22 23:43 bug#66162: [PATCH] Various fixes to lua-ts-mode font-locking john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-30 23:19 ` Stefan Kangas
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).