Subject: bug#65673: [PATCH emacs 0/1] Add lua-ts-mode

From: ~johnmuhl <[email-masked]>
Date: Thu, 31 Aug 2023 22:55:38 +0000

This email and patch were generated and sent using the web based
“Prepare a patchset” feature of Sourcehut. I hope it will be a useful
POC for how Emacs could integrate a forge based pull request style
workflow for occasional contributors with (hopefully) minimal hassle
for those with push access. If it causes too much annoyance I’m happy
to resend it the preferred way.

I’ve also CC’d a Sourcehut mailing list to test the patch review
feature so if this experiment continues it’d be good if we could keep
“~emacs/[email-masked]” included in any replies. Other than
that just do the usual patch review/handling.

The sr.ht hosted version of the Sourcehut forge is considered “Good
enough to recommend” by the GNU Ethical Repository Criteria in case
anyone wonders about that.

https://www.gnu.org/software/repo-criteria-evaluation.html

Discussion or questions about Sourcehut or the workflow should
probably go somewhere else but please CC me in that case.

Thanks.

////

This patch adds a lua-ts-mode for editing Lua files in Emacs >= 29.1.
It is comparable in features to the NonGNU ELPA lua-mode. Shortcomings
in the partially supported features are mentioned below.

| Feature                | lua-mode | lua-ts-mode |
|------------------------+----------+-------------|
| indentation ¹          | Yes      | Yes         |
| highlighting           | Yes      | Yes         |
| documentation lookup ² | Yes      | Yes         |
| imenu support ³        | Yes      | Partial     |
| hideshow support       | Yes      | Yes         |
| outline support        | No       | Yes         |
| flymake support ⁴      | Yes      | Yes         |
| which-func support     | No       | Yes         |
| inferior Lua ⁵         | Yes      | Partial     |

1. Indentation tries to follow the default EmmyLua style. This is the
   same formatter used by lua-ls so out of the box eglot-format and
   automatic indentation should agree about indents.

2. Both modes implement this feature by calling browse-url for the
   manual.html file that is normally distributed with Lua. lua-mode
   has a fallback that uses an online version, lua-ts-mode has no
   fallback but works with the online docs if customized.

3. I tried to follow the model used in other ts modes but it doesn’t
   seem like the results are very useful compared to Eglot/lua-ls. I’d
   like it to improve eventually but it’s low priority personally and
   wouldn’t oppose removing it for now.

4. Both modes require the Luacheck program to be installed.

5. The comint integration is the most basic. lua-mode supports things
   like "Send {buffer,region} to process" which I’d like to add but
   haven’t had time. Currently lua-ts-mode only supports starting an
   inferior Lua process and interacting with it directly.

The patch file is also available from:
https://git.sr.ht/~johnmuhl/emacs/commit/391699e.patch

Thanks again.

john muhl (1):
  Add lua-ts-mode

 admin/notes/tree-sitter/build-module/batch.sh |   1 +
 admin/notes/tree-sitter/build-module/build.sh |   3 +
 etc/NEWS                                      |   4 +
 lisp/progmodes/eglot.el                       |   2 +-
 lisp/progmodes/hideshow.el                    |   1 +
 lisp/progmodes/lua-ts-mode.el                 | 457 ++++++++++++++++++
 test/infra/Dockerfile.emba                    |   1 +
 test/infra/test-jobs.yml                      |   1 +
 .../lua-ts-mode-resources/indent.erts         | 152 ++++++
 test/lisp/progmodes/lua-ts-mode-tests.el      |  32 ++
 10 files changed, 653 insertions(+), 1 deletion(-)
 create mode 100644 lisp/progmodes/lua-ts-mode.el
 create mode 100644 test/lisp/progmodes/lua-ts-mode-resources/indent.erts
 create mode 100644 test/lisp/progmodes/lua-ts-mode-tests.el

-- 
2.38.5