mirror of
https://github.com/doomemacs/doomemacs
synced 2025-09-22 16:21:04 -05:00
fix(php): treesit: PSR-2 indentation for chained methods
Before: public function someMethod() { return $this->doSomething() ->doSomethingElse() ->andDoOneLastThing(); } After: public function someMethod() { return $this->doSomething() ->doSomethingElse() ->andDoOneLastThing(); } Fix: doomemacs/community#36
This commit is contained in:
@@ -82,7 +82,23 @@
|
|||||||
html css ; requires :lang (web +tree-sitter)
|
html css ; requires :lang (web +tree-sitter)
|
||||||
javascript jsdoc)) ; requires :lang (javascript +tree-sitter)
|
javascript jsdoc)) ; requires :lang (javascript +tree-sitter)
|
||||||
:config
|
:config
|
||||||
(+php-common-config 'php-ts-mode))
|
(+php-common-config 'php-ts-mode)
|
||||||
|
|
||||||
|
;; HACK: This advice fixes PSR-2/12 indentation of chained methods and makes
|
||||||
|
;; room for any future corrections.
|
||||||
|
;; REVIEW: PR these corrections upstream.
|
||||||
|
(defadvice! +php--correct-indent-styles-a (fn &rest args)
|
||||||
|
:around #'php-ts-mode--get-indent-style
|
||||||
|
(let ((rules (apply fn args)))
|
||||||
|
(if (functionp php-ts-mode-indent-style)
|
||||||
|
rules
|
||||||
|
`((php
|
||||||
|
,@(pcase php-ts-mode-indent-style
|
||||||
|
(`psr2
|
||||||
|
`(((parent-is "member_call_expression") parent-bol php-ts-mode-indent-offset)))
|
||||||
|
;; Room for other corrections
|
||||||
|
)
|
||||||
|
,@(cadr rules)))))))
|
||||||
|
|
||||||
|
|
||||||
(use-package! php-refactor-mode
|
(use-package! php-refactor-mode
|
||||||
|
Reference in New Issue
Block a user