Replies: 3 comments 3 replies
-
Seems to be an issue with php-ts-mode's upstream treesit indent settings, and should really be corrected upstream, but since it's a built-in package, I'd rather fix it for all users and incorporate it into the module. Give this advice a try: ;;; add to $DOOMDIR/config.el
(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)))))) If you've identified other inconsistencies, let me know and I can add them to this advice. |
Beta Was this translation helpful? Give feedback.
-
@hlissner it indents correctly... when it works. 😞 In most cases, pressing tab simply does nothing... Tried invoking In some files it works on some lines, usually at the beginning of the file, and not on the rest. In others (most of them actually) it doesn't work at all. Is there some kind of debug option I can activate to try and figure out what's happening (or not) when I press tab? |
Beta Was this translation helpful? Give feedback.
-
@hlissner more quirks: If you have chained method calls with closures as parameters, should be: $someObject->method()
->anotherMethod(function () {
// Closure body should be at this level
})
->someOtherMethod(); and instead it is: $someObject->method()
->anotherMethod(function () {
// Closure body is at this level
})
->someOtherMethod(); |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi.
Not really sure if this is the place to ask this since it's not directly Doom related but here it goes.
Since using
tree-sitter
, instead ofphp-mode
Emacs usesphp-ts-mode
for PHP buffers. The indentation behavior of this mode is not (at least as I see it) correct.Following PSR-12 recommendation, indentation should be in 4 spaces increments but that's not always the case.
Example: chained method calls:
should be:
php-mode
even has an option to lineup cascading chained method calls but I disabled it because it doesn't followPSR-12
.There are other quirks, namely with closures (both short and long form).
May seem picky but codebase consistency is very important and I'm struggling to comply to PSR-12 now.
Is there some configuration I can change to "fix" this behavior?
php-ts-mode-indent-style
is set topsr2
.Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions