unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "xzhou@xeechou.net xzhou@xeechou.net" <xzhou@xeechou.net>
To: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: c++-ts-mode and namespace indentation
Date: Wed, 6 Sep 2023 11:37:24 -0400 (EDT)	[thread overview]
Message-ID: <1233373768.1916206.1694014644263@privateemail.com> (raw)

> Date: Thu, 24 Aug 2023 09:04:55 +0000
> From: Louis-Guillaume Gagnon <gagnonlg@protonmail.com>
> 
> I've recently switched to the new c++-ts-mode (a game changer for source
> code featuring deeply nested templates!). I'm quite pleased with it, but
> I can't figure out how to make it such that a namespace block doesn't
> increase the indentation level.  I previously achieved this with
> (c-set-offset 'innamespace 0); Can anyone spell out how to achieve this
> under treesitter?

Hi,


I managed to create an simple function to archive the same goal

  (defun my/indent-rules ()
    `(;;here is my custom rules
      ((parent-is "namespace_definition") parent-bol 0)
      ,@(alist-get 'bsd (c-ts-mode--indent-styles 'cpp)))
    )


Then you would simply (setq c-ts-mode-indent-style #'my-indent-style). I 
followed some guides here: https://casouri.github.io/note/2023/tree-sitter-starter-guide/html-manual/Parser_002dbased-Indentation.html.


Regards,

Xichen


             reply	other threads:[~2023-09-06 15:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-06 15:37 xzhou@xeechou.net xzhou@xeechou.net [this message]
2023-09-15  2:56 ` c++-ts-mode and namespace indentation Yuan Fu
  -- strict thread matches above, loose matches on Subject: below --
2023-08-24  9:04 Louis-Guillaume Gagnon
2023-08-25 17:50 ` Eli Zaretskii

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=1233373768.1916206.1694014644263@privateemail.com \
    --to=xzhou@xeechou.net \
    --cc=gagnonlg@protonmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /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.
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).