Change indentation in c-ts-mode
This commit is contained in:
24
init.el
24
init.el
@ -1888,6 +1888,7 @@ otherwise, call `bibtex-find-text'."
|
|||||||
(nthcdr 1 rules))))))
|
(nthcdr 1 rules))))))
|
||||||
|
|
||||||
;; c-ts-mode
|
;; c-ts-mode
|
||||||
|
(setopt ff-ignore-include t)
|
||||||
(defun my/find-other-file (&optional in-other-window event)
|
(defun my/find-other-file (&optional in-other-window event)
|
||||||
"Like `ff-find-other-file', but respect configuration variables.
|
"Like `ff-find-other-file', but respect configuration variables.
|
||||||
IN-OTHER-WINDOW and EVENT are the same as the original command."
|
IN-OTHER-WINDOW and EVENT are the same as the original command."
|
||||||
@ -1905,9 +1906,30 @@ EVENT is the same as the original command."
|
|||||||
:after evil
|
:after evil
|
||||||
:hook ((c-ts-mode c++-ts-mode) . my/eglot-if-trusted)
|
:hook ((c-ts-mode c++-ts-mode) . my/eglot-if-trusted)
|
||||||
:init
|
:init
|
||||||
|
(defun my/-c-ts-in-doc-comment-p (&optional include-end)
|
||||||
|
(when-let ((node (treesit-thing-at-point "comment" 'toplevel))
|
||||||
|
(start (treesit-node-start node))
|
||||||
|
(end (treesit-node-end node)))
|
||||||
|
(and (> (point) (+ start 2))
|
||||||
|
(eql (char-after (+ start 1)) ?*)
|
||||||
|
(memql (char-after (+ start 2)) '(?* ?!))
|
||||||
|
(or include-end
|
||||||
|
(<= (point) (- end 2))))))
|
||||||
|
(defun my/c-ts-newline (&optional arg)
|
||||||
|
"Insert ARG newlines as with `newline'.
|
||||||
|
If inside a comment and in multi-line comment mode, act as
|
||||||
|
`default-indent-new-line'."
|
||||||
|
(interactive "*P")
|
||||||
|
(when (and arg (< (prefix-numeric-value arg) 0))
|
||||||
|
(user-error "Count cannot be negative"))
|
||||||
|
(if (my/-c-ts-in-doc-comment-p)
|
||||||
|
(dotimes (_ (prefix-numeric-value arg))
|
||||||
|
(default-indent-new-line))
|
||||||
|
(newline arg t)))
|
||||||
(setq-default c-ts-mode-indent-offset 4)
|
(setq-default c-ts-mode-indent-offset 4)
|
||||||
(setopt ff-ignore-include t)
|
|
||||||
:config
|
:config
|
||||||
|
(dolist (sym '(c-ts-mode-map c++-ts-mode-map))
|
||||||
|
(keymap-set (symbol-value sym) "<remap> <newline>" #'my/c-ts-newline))
|
||||||
(evil-define-key 'normal 'c-ts-mode-map
|
(evil-define-key 'normal 'c-ts-mode-map
|
||||||
"go" #'my/find-other-file
|
"go" #'my/find-other-file
|
||||||
"gO" #'my/find-other-file-other-window)
|
"gO" #'my/find-other-file-other-window)
|
||||||
|
Reference in New Issue
Block a user