Skip to content

Instantly share code, notes, and snippets.

@DinoChiesa
Created July 23, 2025 21:19
Show Gist options
  • Save DinoChiesa/2bf2a500e46b53a30f17162bb525a4b7 to your computer and use it in GitHub Desktop.
Save DinoChiesa/2bf2a500e46b53a30f17162bb525a4b7 to your computer and use it in GitHub Desktop.
Emacs - Adjust csharp-ts-mode indentation rules
(eval-after-load "csharp-mode"
'(progn
;; Adjustments for indentation.
;; This one is for the open curly for the using statement.
;; (The using _directive_ (for import at top of file) is different.)
(setf (cdr (car csharp-ts-mode--indent-rules))
(cons
'((parent-is "using_statement") parent-bol 0)
(cdr (car csharp-ts-mode--indent-rules))))
;; This rule is for the opening curly brace on anonymous lambdas, when the
;; open curly is on a new line.
(setf (cdr (car csharp-ts-mode--indent-rules))
(cons
'((parent-is "lambda_expression") parent-bol 0)
(cdr (car csharp-ts-mode--indent-rules))))
(setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment