unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Randy Taylor <dev@rjt.dev>
Cc: Yuan Fu <casouri@gmail.com>, Eli Zaretskii <eliz@gnu.org>,
	60025@debbugs.gnu.org
Subject: bug#60025: [PATCH] Add go-ts-mode and go-mod-ts-mode
Date: Thu, 15 Dec 2022 08:20:46 +0100	[thread overview]
Message-ID: <87y1r9w2sx.fsf@thornhill.no> (raw)
In-Reply-To: <7fPZo7wRGoWPnr5djOSL0gsOE-Q15-l2y-INvJ7z5QXOpXmV_ct4soqgJTYtHZ6EReO3ROGRS_VYnKkYNH6j1CghKfMbRXMmanEB-eaANjk=@rjt.dev>

Randy Taylor <dev@rjt.dev> writes:

> On Wednesday, December 14th, 2022 at 16:27, Theodor Thornhill <theo@thornhill.no> wrote:
>> 
>> Yeah, I seem to remember seeing these \n nodes in the go-mode I made
>> some time ago. There is no node there, so no-node is the rule that
>> matches, as there is no parent. I believe you can solve it with
>> something like
>> 
>> 
>> (defun go-backward-up-list ()
>> (lambda (node parent bol &rest _)
>> (save-excursion
>> (backward-up-list 1 nil t)
>> (back-to-indentation)
>> (point))))
>> 
>> and use some variant of that. Now you can find a different node without
>> relying on there being a node where you start.
>
> Thanks Theo, that worked perfectly. We should consider adding
> something like this to the documentation somewhere, since I didn't see
> anything like this anywhere (although maybe I missed it).

I'm glad!  Could be part of a tips and tricks or something?

[...]

> +(defvar go-ts-mode--indent-rules
> +  `((go
> +     ((node-is ")") parent-bol 0)
> +     ((node-is "]") parent-bol 0)
> +     ((node-is "}") parent-bol 0)
> +     ((node-is "labeled_statement") no-indent)
> +     ((parent-is "argument_list") parent-bol go-ts-mode-indent-offset)
> +     ((parent-is "block") parent-bol go-ts-mode-indent-offset)
> +     ((parent-is "const_declaration") parent-bol go-ts-mode-indent-offset)
> +     ((parent-is "default_case") parent-bol go-ts-mode-indent-offset)
> +     ((parent-is "expression_case") parent-bol go-ts-mode-indent-offset)
> +     ((parent-is "expression_switch_statement") parent-bol 0)
> +     ((parent-is "field_declaration_list") parent-bol go-ts-mode-indent-offset)
> +     ((parent-is "import_spec_list") parent-bol go-ts-mode-indent-offset)
> +     ((parent-is "labeled_statement") parent-bol go-ts-mode-indent-offset)
> +     ((parent-is "literal_value") parent-bol go-ts-mode-indent-offset)
> +     ((parent-is "type_spec") parent-bol go-ts-mode-indent-offset)
> +     ((parent-is "var_declaration") parent-bol go-ts-mode-indent-offset)
> +     (no-node parent-bol 0)))
> +  "Tree-sitter indent rules for `go-ts-mode'.")

No rules for comment?

[...]

> +;; go.mod support.
> +
> +(defvar go-mod-ts-mode--syntax-table
> +  (let ((table (make-syntax-table)))
> +    (modify-syntax-entry ?/   ". 124b" table)
> +    (modify-syntax-entry ?\n  "> b"    table)
> +    table)
> +  "Syntax table for `go-mod-ts-mode'.")
> +
> +(defvar go-mod-ts-mode--indent-rules
> +  `((gomod
> +     ((node-is ")") parent-bol 0)
> +     ((parent-is "exclude_directive") parent-bol go-ts-mode-indent-offset)
> +     ((parent-is "module_directive") parent-bol go-ts-mode-indent-offset)
> +     ((parent-is "replace_directive") parent-bol go-ts-mode-indent-offset)
> +     ((parent-is "require_directive") parent-bol go-ts-mode-indent-offset)
> +     ((parent-is "retract_directive") parent-bol go-ts-mode-indent-offset)
> +     ((go-mod-ts-mode--in-directive-p) no-indent go-ts-mode-indent-offset)
> +     (no-node no-indent 0)))
> +  "Tree-sitter indent rules for `go-mod-ts-mode'.")

No rules for comment here either?

Theo





  reply	other threads:[~2022-12-15  7:20 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-13  2:13 bug#60025: [PATCH] Add go-ts-mode and go-mod-ts-mode Randy Taylor
2022-12-13 12:25 ` Eli Zaretskii
2022-12-13 19:39   ` Randy Taylor
2022-12-14 12:02     ` Eli Zaretskii
2022-12-14 16:21       ` Randy Taylor
2022-12-14 19:55         ` Yuan Fu
2022-12-14 20:54           ` Randy Taylor
2022-12-14 21:27             ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-14 21:56               ` Randy Taylor
2022-12-15  2:15               ` Randy Taylor
2022-12-15  7:20                 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-12-15 16:40                   ` Randy Taylor
2022-12-15 18:06                     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-15 19:45                       ` Randy Taylor
2022-12-15 19:59                         ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-15 20:09                           ` Randy Taylor
2022-12-15 22:22                             ` Randy Taylor
2022-12-14  2:22 ` Yuan Fu
2022-12-16  1:22 ` Yuan Fu
2022-12-16  2:05   ` Randy Taylor

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=87y1r9w2sx.fsf@thornhill.no \
    --to=bug-gnu-emacs@gnu.org \
    --cc=60025@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=dev@rjt.dev \
    --cc=eliz@gnu.org \
    --cc=theo@thornhill.no \
    /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).