@var{parent}, and @var{bol}, and returns the first non-whitespace
character on the previous line.
-@item point-min
+@item column-0
This anchor is a function that is called with 3 arguments: @var{node},
-@var{parent}, and @var{bol}, and returns the beginning of the buffer.
-This is useful as the beginning of the buffer is always at column 0.
+@var{parent}, and @var{bol}, and returns the beginning of the current
+line, which is at column 0.
@item comment-start
This anchor is a function that is called with 3 arguments: @var{node},
"Indent rules supported by `c-ts-mode'.
MODE is either `c' or `cpp'."
(let ((common
- `(((parent-is "translation_unit") point-min 0)
- ((query "(ERROR (ERROR)) @indent") point-min 0)
+ `(((parent-is "translation_unit") column-0 0)
+ ((query "(ERROR (ERROR)) @indent") column-0 0)
((node-is ")") parent 1)
((node-is "]") parent-bol 0)
((node-is "else") parent-bol 0)
((parent-is "labeled_statement")
c-ts-mode--standalone-grandparent c-ts-mode-indent-offset)
- ((node-is "preproc") point-min 0)
- ((node-is "#endif") point-min 0)
- ((match "preproc_call" "compound_statement") point-min 0)
+ ((node-is "preproc") column-0 0)
+ ((node-is "#endif") column-0 0)
+ ((match "preproc_call" "compound_statement") column-0 0)
- ((n-p-gp nil "preproc" "translation_unit") point-min 0)
+ ((n-p-gp nil "preproc" "translation_unit") column-0 0)
((n-p-gp nil "\n" "preproc") great-grand-parent c-ts-mode--preproc-offset)
((parent-is "preproc") grand-parent c-ts-mode-indent-offset)
`((gnu
;; Prepend rules to set highest priority
((match "while" "do_statement") parent 0)
- (c-ts-mode--top-level-label-matcher point-min 1)
+ (c-ts-mode--top-level-label-matcher column-0 1)
,@common)
(k&r ,@common)
(linux
;; Reference:
;; https://www.kernel.org/doc/html/latest/process/coding-style.html,
;; and script/Lindent in Linux kernel repository.
- ((node-is "labeled_statement") point-min 0)
+ ((node-is "labeled_statement") column-0 0)
,@common)
(bsd
((node-is "}") parent-bol 0)
(defvar java-ts-mode--indent-rules
`((java
- ((parent-is "program") point-min 0)
+ ((parent-is "program") column-0 0)
((match "}" "element_value_array_initializer")
parent-bol 0)
- ((node-is "}") point-min c-ts-common-statement-offset)
+ ((node-is "}") column-0 c-ts-common-statement-offset)
((node-is ")") parent-bol 0)
((node-is "else") parent-bol 0)
((node-is "]") parent-bol 0)
c-ts-common-comment-start-after-first-star -1)
((parent-is "comment") prev-adaptive-prefix 0)
((parent-is "text_block") no-indent)
- ((parent-is "class_body") point-min c-ts-common-statement-offset)
+ ((parent-is "class_body") column-0 c-ts-common-statement-offset)
((parent-is "array_initializer") parent-bol java-ts-mode-indent-offset)
- ((parent-is "annotation_type_body") point-min c-ts-common-statement-offset)
- ((parent-is "interface_body") point-min c-ts-common-statement-offset)
- ((parent-is "constructor_body") point-min c-ts-common-statement-offset)
+ ((parent-is "annotation_type_body") column-0 c-ts-common-statement-offset)
+ ((parent-is "interface_body") column-0 c-ts-common-statement-offset)
+ ((parent-is "constructor_body") column-0 c-ts-common-statement-offset)
((parent-is "enum_body_declarations") parent-bol 0)
- ((parent-is "enum_body") point-min c-ts-common-statement-offset)
- ((parent-is "switch_block") point-min c-ts-common-statement-offset)
- ((parent-is "record_declaration_body") point-min c-ts-common-statement-offset)
+ ((parent-is "enum_body") column-0 c-ts-common-statement-offset)
+ ((parent-is "switch_block") column-0 c-ts-common-statement-offset)
+ ((parent-is "record_declaration_body") column-0 c-ts-common-statement-offset)
((query "(method_declaration (block _ @indent))") parent-bol java-ts-mode-indent-offset)
((query "(method_declaration (block (_) @indent))") parent-bol java-ts-mode-indent-offset)
((parent-is "local_variable_declaration") parent-bol java-ts-mode-indent-offset)
((parent-is "case_statement") parent-bol java-ts-mode-indent-offset)
((parent-is "labeled_statement") parent-bol java-ts-mode-indent-offset)
((parent-is "do_statement") parent-bol java-ts-mode-indent-offset)
- ((parent-is "block") point-min c-ts-common-statement-offset)))
+ ((parent-is "block") column-0 c-ts-common-statement-offset)))
"Tree-sitter indent rules.")
(defvar java-ts-mode--keywords
(defvar rust-ts-mode--indent-rules
`((rust
- ((parent-is "source_file") point-min 0)
+ ((parent-is "source_file") column-0 0)
((node-is ")") parent-bol 0)
((node-is "]") parent-bol 0)
((node-is "}") (and parent parent-bol) 0)
"Rules used for indentation.
Argument LANGUAGE is either `typescript' or `tsx'."
`((,language
- ((parent-is "program") point-min 0)
+ ((parent-is "program") column-0 0)
((node-is "}") parent-bol 0)
((node-is ")") parent-bol 0)
((node-is "]") parent-bol 0)
(goto-char bol)
(forward-line -1)
(skip-chars-forward " \t"))))
- (cons 'point-min (lambda (&rest _) (point-min)))
+ (cons 'column-0 (lambda (_n _p bol &rest _)
+ (save-excursion
+ (goto-char bol)
+ (line-beginning-position))))
;; TODO: Document.
(cons 'and (lambda (&rest fns)
(lambda (node parent bol &rest _)
Returns the first non-whitespace character on the previous line.
-point-min
+column-0
- Returns the beginning of buffer, which is always at column 0.
+ Returns the beginning of the current line, which is at column 0.
comment-start