Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions php-ts-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
((parent-is "program") column-0 0)
((parent-is "comment") parent-bol 1)
((parent-is "declaration_list") parent-bol ,offset)
((parent-is "function_definition") parent-bol ,offset)
;; "compound_statement" contains the body of many statements.
;; For example function_definition, foreach_statement, etc.
((parent-is "compound_statement") parent-bol ,offset)
((parent-is "array_creation_expression") parent-bol ,offset)
((parent-is "base_clause") parent-bol ,offset)
Expand All @@ -85,8 +86,7 @@
((parent-is "switch_block") parent-bol ,offset)
((parent-is "case_statement") parent-bol ,offset)
((parent-is "assignment_expression") parent-bol ,offset)
((parent-is "return_statement") parent-bol ,offset)
)))
((parent-is "return_statement") parent-bol ,offset))))
"Tree-sitter indent rules.")

(defvar php-ts-mode--keywords
Expand Down
27 changes: 27 additions & 0 deletions tests/php-ts-mode-resources/indent.erts
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,30 @@ function ns_func(): void {
return;
}
=-=-=

Name: Function with an attribute

=-=
<?php

namespace Ns;

#[Attribute]
function with_an_attr(): void {
return;
}
=-=-=

Name: Function with two attributes

=-=
<?php

namespace Ns;

#[Attribute]
#[Attribute]
function with_two_attrs(): void {
return;
}
=-=-=