help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

c++-ts-mode and namespace indentation


From: address@hidden address@hidden
Subject: c++-ts-mode and namespace indentation
Date: Wed, 6 Sep 2023 11:37:24 -0400 (EDT)

> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]