Variable: csharp-ts-mode-hook

csharp-ts-mode-hook is a variable defined in csharp-mode.el.gz.

Value

nil

Documentation

Hook run after entering csharp-ts-mode.

No problems result if this variable is not bound. add-hook automatically binds it. (This is true for all hook variables.)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/csharp-mode.el.gz
;;;###autoload
(define-derived-mode csharp-ts-mode prog-mode "C#"
  "Major mode for editing C# code."
  :syntax-table (csharp--make-mode-syntax-table)

  (unless (treesit-ready-p 'c-sharp)
    (error "Tree-sitter for C# isn't available"))

  ;; Tree-sitter.
  (treesit-parser-create 'c-sharp)

  ;; Comments.
  (c-ts-common-comment-setup)

  (setq-local treesit-thing-settings
              `((c-sharp
                 (text
                  ,(regexp-opt '("comment"
                                 "verbatim_string-literal"
                                 "interpolated_verbatim_string-text"))))))

  ;; Indent.
  (setq-local treesit-simple-indent-rules csharp-ts-mode--indent-rules)

  ;; Electric
  (setq-local electric-indent-chars
              (append "{}():;," electric-indent-chars))

  ;; Navigation.
  (setq-local treesit-defun-type-regexp "declaration")
  (setq-local treesit-defun-name-function #'csharp-ts-mode--defun-name)

  ;; Font-lock.
  (setq-local treesit-font-lock-settings csharp-ts-mode--font-lock-settings)
  (setq-local treesit-font-lock-feature-list
              '(( comment definition)
                ( keyword string type directives)
                ( constant escape-sequence expression literal property)
                ( function bracket delimiter error)))

  ;; Imenu.
  (setq-local treesit-simple-imenu-settings
              '(("Class" "\\`class_declaration\\'" nil nil)
                ("Interface" "\\`interface_declaration\\'" nil nil)
                ("Enum" "\\`enum_declaration\\'" nil nil)
                ("Record" "\\`record_declaration\\'" nil nil)
                ("Struct" "\\`struct_declaration\\'" nil nil)
                ("Method" "\\`method_declaration\\'" nil nil)))

  (treesit-major-mode-setup)

  (add-to-list 'auto-mode-alist '("\\.cs\\'" . csharp-ts-mode)))