Commit graph

33 commits

Author SHA1 Message Date
john muhl
08b62132dd Add 'lua-ts-mode' to 'interpreter-mode-alist'
* lisp/progmodes/lua-ts-mode.el: Enable 'lua-ts-mode' for Lua
scripts based on their interpreter line.  (Bug#74951)
2024-12-21 12:53:21 +02:00
john muhl
4f2a21cc2a Don't restrict 'lua-ts-send-file' to 'lua-ts-mode'
* lisp/progmodes/lua-ts-mode.el (lua-ts-send-file): Remove
restriction on interactive use.  Unlike related send-* commands
it can be useful to send a file to the Lua interpreter outside of
a 'lua-ts-mode' buffer.  (Bug#74705)
2024-12-07 15:28:14 +02:00
john muhl
6f6a92624e Avoid loading 'rx' at runtime in 'lua-ts-mode'
* lisp/progmodes/lua-ts-mode.el (lua-ts-inferior-lua):
Replace 'rx-to-string' and substitution with 'rx' and 'literal'.
(Bug#74499)

(cherry picked from commit e71d714a81)
2024-11-24 10:37:22 +02:00
john muhl
27aacbd172 Fix some 'lua-ts-mode' options (Bug#74235)
* lisp/progmodes/lua-ts-mode.el (lua-ts-luacheck-program):
(lua-ts-inferior-program): Switch to 'file' type and remove 'nil'
as a choice.
(lua-ts-inferior-lua): Ensure 'lua-ts-inferior-program' is set.
2024-11-14 10:23:49 +02:00
john muhl
d592832504 Improve comment indenting in 'lua-ts-mode'
* lisp/progmodes/lua-ts-mode.el (lua-ts--simple-indent-rules):
Align single line comments with the surrounding context.
(lua-ts--comment-first-sibling-matcher): Check that comment is
the first sibling.
(lua-ts--multi-line-comment-start): New function.
* test/lisp/progmodes/lua-ts-mode-resources/indent.erts:
Add tests.  (Bug#74298)
2024-11-14 10:14:46 +02:00
Yuan Fu
1ea0d9b891
Revert "Set treesit-primary-parser for tree-sitter modes"
This reverts commit ed57faafc7.
2024-10-08 17:33:11 -07:00
Yuan Fu
ed57faafc7
Set treesit-primary-parser for tree-sitter modes
I debated whether to do this, since technically speaking it's
not needed for single-language modes.  But ultimately it's
better to be explicit and set a good example with builtin modes.

* lisp/progmodes/cmake-ts-mode.el (cmake-ts-mode):
* lisp/progmodes/csharp-mode.el (csharp-ts-mode):
* lisp/progmodes/dockerfile-ts-mode.el (dockerfile-ts-mode):
* lisp/progmodes/go-ts-mode.el (go-ts-mode):
(go-mod-ts-mode):
* lisp/progmodes/heex-ts-mode.el (heex-ts-mode):
* lisp/progmodes/java-ts-mode.el (java-ts-mode):
* lisp/progmodes/json-ts-mode.el (json-ts-mode):
* lisp/progmodes/lua-ts-mode.el (lua-ts-mode):
* lisp/progmodes/python.el (python-ts-mode):
* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode):
* lisp/progmodes/rust-ts-mode.el (rust-ts-mode):
* lisp/progmodes/sh-script.el:
* lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode):
(tsx-ts-mode):
* lisp/textmodes/css-mode.el (css-ts-mode):
* lisp/textmodes/html-ts-mode.el (html-ts-mode):
* lisp/textmodes/toml-ts-mode.el (toml-ts-mode):
* lisp/textmodes/yaml-ts-mode.el (yaml-ts-mode): Set
treesit-primary-parser.
2024-10-07 17:24:32 -07:00
john muhl
63058e1153 Tag interactive commands in 'lua-ts-mode'
* lisp/progmodes/lua-ts-mode.el (lua-ts-send-buffer)
(lua-ts-send-file, lua-ts-send-region): Mark inferior interaction
commands that are only relevant in Lua buffers.  (Bug#73586)
2024-10-01 21:35:24 +02:00
john muhl
c477443ab8 ; Fix typo in lua-ts-mode.el
* lisp/progmodes/lua-ts-mode.el: Fix typo.  (Bug#71736)
2024-06-28 01:01:38 +02:00
john muhl
6e5e4d6193 ; Add 'eglot-ensure' option to 'lua-ts-mode-hook'
* lisp/progmodes/lua-ts-mode.el (lua-ts-mode-hook): Add an option to
enable Eglot from the lua-ts-mode-hook.  (Bug#71736)
2024-06-28 00:59:36 +02:00
Eli Zaretskii
733ff78581 ; Fix byte-compilation warnings in lua-ts-mode.el
* lisp/progmodes/lua-ts-mode.el (treesit-node-eq)
(treesit-node-prev-sibling): Declare.
2024-05-11 13:54:35 +03:00
john muhl
73d2b829f0
Improve indentation in 'lua-ts-mode' (bug#70785)
* lisp/progmodes/lua-ts-mode.el (lua-ts--simple-indent-rules):
- Ignore comments when aligning arguments, parameters and fields.
- Apply simpler rules to simpler usage of anonymous functions.
- Better handling of table as a function argument.
(lua-ts--comment-first-sibling-matcher):
(lua-ts--first-real-sibling-anchor):
(lua-ts--last-arg-function-call-matcher):
(lua-ts--top-level-function-call-matcher): New function.
(lua-ts--g-parent):
(lua-ts--g-g-parent): New function.
(lua-ts--g-g-g-parent): Use it.
* test/lisp/progmodes/lua-ts-mode-resources/indent.erts:
Add tests.
2024-05-08 20:36:37 -07:00
john muhl
c493f28cc9 Fix which-function error in 'lua-ts-mode' (bug#70515)
* lisp/progmodes/lua-ts-mode.el (lua-ts-mode): Remove incorrect
usage of 'which-func-functions'.
* test/lisp/progmodes/lua-ts-mode-tests.el
(lua-ts-test-which-function): Add test.
* test/lisp/progmodes/lua-ts-mode-resources/which-function.lua:
New file.
2024-04-25 18:39:30 +03:00
john muhl
d5d61618c8 Mark Flymake regions more accurately in 'lua-ts-mode'
* lisp/progmodes/lua-ts-mode.el (lua-ts-flymake-luacheck): Use
the end position provided by Luacheck rather than relying on
'thing-at-point' to guess where the end should be.  (Bug#70167)
2024-04-13 11:11:18 +03:00
john muhl
f412892b79 ; Remove unneeded group in lua-ts-mode defcustoms
* lisp/progmodes/lua-ts-mode.el (lua-ts-mode-hook):
(lua-ts-indent-offset):
(lua-ts-luacheck-program):
(lua-ts-inferior-buffer):
(lua-ts-inferior-program):
(lua-ts-inferior-options):
(lua-ts-inferior-startfile):
(lua-ts-inferior-prompt):
(lua-ts-inferior-prompt-continue):
(lua-ts-inferior-history):
(lua-ts-indent-continuation-lines): Remove :group.  (bug#69910)
2024-03-23 09:24:18 +02:00
john muhl
d3ca7c68c7 ; Open inferior Lua buffer in a window, not a frame
* lisp/progmodes/lua-ts-mode.el (lua-ts-inferior-lua): Replace
'display-buffer-pop-up-window' with
'display-buffer-pop-up-frame'.  (bug#69909)
2024-03-23 09:23:21 +02:00
Stefan Monnier
c79a509384 Add non-TS modes as extra parent of TS modes (bug#68246)
Record the fact that TS modes are alternatives to the non-TS
modes using the new `derived-mode-add-parents` functionality.
Do the same for long standing similar issues with CPerl-mode.

* lisp/textmodes/yaml-ts-mode.el (yaml-ts-mode):
* lisp/textmodes/toml-ts-mode.el (toml-ts-mode):
* lisp/textmodes/html-ts-mode.el (html-ts-mode):
* lisp/textmodes/css-mode.el (css-ts-mode):
* lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode, tsx-ts-mode):
* lisp/progmodes/sh-script.el (bash-ts-mode):
* lisp/progmodes/rust-ts-mode.el (rust-ts-mode):
* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode):
* lisp/progmodes/python.el (python-ts-mode):
* lisp/progmodes/lua-ts-mode.el (lua-ts-mode):
* lisp/progmodes/json-ts-mode.el (json-ts-mode):
* lisp/progmodes/js.el (js-ts-mode):
* lisp/progmodes/java-ts-mode.el (java-ts-mode):
* lisp/progmodes/heex-ts-mode.el (heex-ts-mode):
* lisp/progmodes/go-ts-mode.el (go-ts-mode, go-mod-ts-mode):
* lisp/progmodes/elixir-ts-mode.el (elixir-ts-mode):
* lisp/progmodes/dockerfile-ts-mode.el (dockerfile-ts-mode):
* lisp/progmodes/csharp-mode.el (csharp-ts-mode):
* lisp/progmodes/cmake-ts-mode.el (cmake-ts-mode):
* lisp/progmodes/c-ts-mode.el (c-ts-mode, c++-ts-mode):
Add non-TS mode as extra parent.

* lisp/progmodes/cperl-mode.el (cperl-mode): Add `perl-mode` as
extra parent.
2024-03-09 10:29:06 -05:00
john muhl
35d99b1ec7 ; Update URL of the tree-sitter-lua grammar
* admin/notes/tree-sitter/build-module/build.sh:
* lisp/progmodes/lua-ts-mode.el:
* test/infra/Dockerfile.emba: Use the new URL.  (bug#69304)
2024-02-21 18:45:46 +02:00
john muhl
84e4f1259b Eagerly indent first field in tables in 'lua-ts-mode'
* lisp/progmodes/lua-ts-mode.el (lua-ts--simple-indent-rules):
Properly indent the first field of a table when it appears on a
line by itself.  (Bug#69088)
2024-02-17 10:57:19 +02:00
Juri Linkov
3b90e5052c Tree-sitter support for outline-minor-mode (bug#68824)
* doc/emacs/text.texi (Outline Format): Add 'outline-search-function'.

* doc/lispref/elisp.texi (Top): Add new menu item "Outline Minor Mode"
after "Imenu".

* doc/lispref/modes.texi (Modes): Add new menu item "Outline Minor Mode"
after "Imenu".
(Major Mode Conventions): Mention "Outline Minor Mode" with @pxref.
(Outline Minor Mode): New node.

* doc/lispref/parsing.texi (Tree-sitter Major Modes): Mention
'treesit-outline-predicate' with @pxref.

* lisp/treesit.el (treesit-outline-predicate): New buffer-local variable.
(treesit-outline-predicate--from-imenu): New internal function.
(treesit-outline-search, treesit-outline-level): New functions.
(treesit-major-mode-setup): Set up treesit-outline-predicate,
outline-search-function and outline-level.

* lisp/progmodes/c-ts-mode.el (c-ts-mode--outline-predicate):
New internal function.
(c-ts-base-mode): Set 'treesit-outline-predicate' to
'c-ts-mode--outline-predicate'.

* lisp/progmodes/heex-ts-mode.el (heex-ts-mode): Kill inherited
local variables 'outline-heading-end-regexp', 'outline-regexp',
'outline-level'.

* lisp/progmodes/lua-ts-mode.el (lua-ts-mode): Remove 'outline-regexp'.
Suggested by john muhl <jm@pub.pink>.

* lisp/textmodes/html-ts-mode.el (html-ts-mode): Kill inherited
local variables 'outline-heading-end-regexp', 'outline-regexp',
'outline-level'.
2024-02-12 20:18:24 +02:00
john muhl
a66069c50c Support indented continuation lines in lua-ts-mode
* lisp/progmodes/lua-ts-mode.el (lua-ts--simple-indent-rules):
Add a rule to indent multi-line assignments and if statements.
(lua-ts-indent-continuation-lines): New user option.
* test/lisp/progmodes/lua-ts-mode-resources/indent.erts: Add
tests.  (Bug#68279)
2024-01-11 21:51:23 +01:00
Po Lu
070cb32463 ; Add 2024 to copyright years 2024-01-02 10:30:05 +08:00
john muhl
51a296014b Fix comint-next/previous-prompt in lua-ts-mode
* lisp/progmodes/lua-ts-mode.el (lua-ts-inferior-lua): Don't set
'comint-use-prompt-regexp'.  (Bug#67616)
2023-12-16 11:36:05 +02:00
nverno
f5e7aaed66 Fix: add comint hook locally in lua-ts-inferior-lua
* lisp/progmodes/lua-ts-mode.el (lua-ts-inferior-lua): Add
'comint-preoutput-filter-functions' hook locally.  (Bug#67616)
2023-12-16 11:35:02 +02:00
Eli Zaretskii
b26852ef97 ; Fix last change. 2023-12-02 15:50:45 +02:00
john muhl
4835c9913b Improve font-locking in lua-ts-mode (bug#67554)
* lisp/progmodes/lua-ts-mode.el (lua-ts-mode): Move property
highlighting to level 4.
(lua-ts--keywords): Remove `true', `false' and `nil' from
keywords.
(lua-ts--font-lock-settings): Highlight assignments, functions
and labels in more places. Distinguish comment delimiters.
(lua-ts--comment-font-lock): New function.
2023-12-02 15:46:47 +02:00
nverno
f054e9924c Fix font-lock for string escapes in lua-ts-mode
* lua-ts-mode.el (lua-ts--font-lock-settings): Apply font-lock
to the entire string containing an escape sequence. (Bug#67135)
2023-11-15 15:07:12 +02:00
john muhl
03d2e26108 Fix flymake integration in lua-ts-mode (Bug#67152)
* lisp/progmodes/lua-ts-mode.el (lua-ts-flymake-luacheck): Use
'flymake-diag-region' to mark highlighted region.
2023-11-15 15:00:59 +02:00
john muhl
e76eaecbde Improve imenu support in lua-ts-mode
* lisp/progmodes/lua-ts-mode.el (lua-ts-mode): Include require
statements and remove anonymous entries.
(lua-ts--named-function-p, lua-ts--require-name-function)
(lua-ts--require-p): New functions.
* lisp/speedbar.el (speedbar-supported-extension-expressions):
Add Lua to the list of supported file types.  (Bug#66465)
2023-10-25 16:49:31 +03:00
john muhl
1c261e0a6c Various improvements to lua-ts-mode (Bug#66159)
* lisp/progmodes/lua-ts-mode.el (lua-ts-mode): Improve movement.
(lua-ts--simple-indent-rules): Improve indentation rules.
(lua-ts-mode-map): Add key bindings and menus.
(lua-ts-mode-hook): Make hook available in Customize.
(lua-ts-inferior-history, lua-ts-inferior--write-history): Add option
to read/write an input history file.
(lua-ts-inferior-lua, lua-ts-send-buffer, lua-ts-send-file)
(lua-ts-send-region, lua-ts-inferior-prompt)
(lua-ts-inferior-prompt-continue): Support for sending buffer,
file or region to the inferior process.
(lua-ts-show-process-buffer, lua-ts-hide-process-buffer)
(lua-ts-kill-process): New functions.
(lua-ts-inferior-prompt-regexp): Remove option.
* test/lisp/progmodes/lua-ts-mode-resources/indent.erts:
* test/lisp/progmodes/lua-ts-mode-resources/movement.erts: Add
tests.
2023-10-23 10:07:52 +02:00
john muhl
a838bcb23c Support lua-ts-mode in align.el
* lisp/align.el (align-rules-list): Add lua-ts-mode.  (Bug#66466)
* lisp/progmodes/lua-ts-mode.el (lua-ts-mode): Indent region
before aligning.
* test/lisp/align-tests.el (align-lua):
* test/lisp/align-resources/lua-ts-mode.erts: Add tests.
2023-10-21 12:25:25 +02:00
john muhl
6dd1565fcf 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.  (Bug#66162)
2023-10-01 01:17:36 +02:00
bug-gnu-emacs@gnu.org
b6659e98a4 bug#65673: Add lua-ts-mode
* lisp/progmodes/lua-ts-mode.el:
* test/lisp/progmodes/lua-ts-mode-resources/indent.erts:
* test/lisp/progmodes/lua-ts-mode-tests.el: New files.
* etc/NEWS: Mention the new mode.
* lisp/progmodes/eglot.el (eglot-server-programs):
* lisp/progmodes/hideshow.el (hs-special-modes-alist):
Support 'lua-ts-mode'.
* admin/notes/tree-sitter/build-module/batch.sh:
* admin/notes/tree-sitter/build-module/build.sh: Add Lua.
* test/infra/Dockerfile.emba:
* test/infra/test-jobs.yml: Include lua-ts-mode tests.
2023-09-16 13:01:43 +03:00