emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/csharp-mode e30ed5e 393/459: Indent feature parity with


From: ELPA Syncer
Subject: [elpa] externals/csharp-mode e30ed5e 393/459: Indent feature parity with previous implementation
Date: Sun, 22 Aug 2021 14:00:08 -0400 (EDT)

branch: externals/csharp-mode
commit e30ed5e8b0ad66701cb30eab0bf796aa9201edc3
Author: Theodor Thornhill <theo@thornhill.no>
Commit: Theodor Thornhill <theo@thornhill.no>

    Indent feature parity with previous implementation
---
 csharp-mode.el | 83 +++++++++++++++++++++++++++++-----------------------------
 1 file changed, 42 insertions(+), 41 deletions(-)

diff --git a/csharp-mode.el b/csharp-mode.el
index 93a046d..80bc80e 100644
--- a/csharp-mode.el
+++ b/csharp-mode.el
@@ -148,7 +148,7 @@
       (add-to-list 'compilation-error-regexp-alist-alist regexp)
       (add-to-list 'compilation-error-regexp-alist (car regexp)))))
 
-(defcustom csharp-indent-offset 4
+(defcustom csharp-mode-indent-offset 4
   "Indent offset for csharp-mode"
   :type 'number
   :group 'csharp)
@@ -174,46 +174,47 @@
 Key bindings:
 \\{csharp-mode-map}"
   :group 'csharp
-  (setq tree-sitter-indent-csharp-scopes
-        '((indent-all . ;; these nodes are always indented
-                      (anonymous_object_creation_expression
-                       switch_body
-                       switch_section))
-          (indent-rest . ;; if parent node is one of these and node is not 
first → indent
-                       (namespace_declaration
-                        using_statement
-                        class_declaration
-                        struct_declaration
-                        method_declaration
-                        object_creation_expression
-                        array_creation_expression
-                        lambda_expression
-                        local_function_statement
-                        enum_declaration
-                        for_each_statement
-                        if_statement
-                        try_statement))
-          (indent-body . ;; if parent node is one of these and current node is 
in middle → indent
-                       ())
-
-          (paren-indent . ;; if parent node is one of these → indent to paren 
opener
-                        ())
-          (align-char-to . ;; chaining char → node types we move parentwise to 
find the first chaining char
-                         ())
-          (aligned-siblings . ;; siblings (nodes with same parent) should be 
aligned to the first child
-                            (parameter))
-
-          (multi-line-text . ;; if node is one of these, then don't modify the 
indent
-                           ;; this is basically a peaceful way out by saying 
"this looks like something
-                           ;; that cannot be indented using AST, so best I 
leave it as-is"
-                           (comment preprocessor_call label_name))
-          (outdent . ;; these nodes always outdent (1 shift in opposite 
direction)
-                   ("}"))
-          )
-        )
-  (when (boundp 'electric-indent-inhibit)
-    (setq electric-indent-inhibit t))
-  (setq-local indent-line-function #'tree-sitter-indent-line-and-debug)
+  (setq-local tree-sitter-indent-offset csharp-mode-indent-offset)
+  (setq-local tree-sitter-indent-current-scopes
+              '((indent-all . ;; these nodes are always indented
+                            (accessor_declaration
+                             break_statement
+                             "."))
+                (indent-rest . ;; if parent node is one of these and node is 
not first → indent
+                             (
+                              switch_section
+                              ))
+                (indent-body . ;; if parent node is one of these and current 
node is in middle → indent
+                             (block
+                              anonymous_object_creation_expression
+                              enum_member_declaration_list
+                              initializer_expression
+                              expression_statement
+                              declaration_list
+                              switch_body))
+
+                (paren-indent . ;; if parent node is one of these → indent to 
paren opener
+                              ())
+                (align-char-to . ;; chaining char → node types we move 
parentwise to find the first chaining char
+                               ())
+                (aligned-siblings . ;; siblings (nodes with same parent) 
should be aligned to the first child
+                                  (parameter))
+
+                (multi-line-text . ;; if node is one of these, then don't 
modify the indent
+                                 ;; this is basically a peaceful way out by 
saying "this looks like something
+                                 ;; that cannot be indented using AST, so best 
I leave it as-is"
+                                 (comment
+                                  preprocessor_call
+                                  labeled_statement))
+                (outdent . ;; these nodes always outdent (1 shift in opposite 
direction)
+                         (;; "}"
+                          case_switch_label
+                          ))
+                )
+              )
+  ;; (when (boundp 'electric-indent-inhibit)
+  ;;   (setq electric-indent-inhibit t))
+  (setq-local indent-line-function #'tree-sitter-indent-line)
 
   ;; https://github.com/ubolonton/emacs-tree-sitter/issues/84
   (unless font-lock-defaults



reply via email to

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