unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: john muhl via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 66162@debbugs.gnu.org
Subject: bug#66162: [PATCH] Various fixes to lua-ts-mode font-locking
Date: Fri, 22 Sep 2023 18:43:43 -0500	[thread overview]
Message-ID: <871qepzrhn.fsf@pub.pink> (raw)

[-- 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


             reply	other threads:[~2023-09-22 23:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-22 23:43 john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-09-30 23:19 ` bug#66162: [PATCH] Various fixes to lua-ts-mode font-locking Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871qepzrhn.fsf@pub.pink \
    --to=bug-gnu-emacs@gnu.org \
    --cc=66162@debbugs.gnu.org \
    --cc=jm@pub.pink \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).