@@ -253,6 +253,17 @@ Otherwise, the indentation is:
253253 (lambda (node )
254254 (string-match-p regexp (treesit-node-type node))))))
255255
256+ (defun julia-ts--grand-parent-bol (_n parent &rest _ )
257+ " Return the beginning of the line (non-space char) where the parent of the node PARENT is on."
258+ (save-excursion
259+ (goto-char (treesit-node-start (treesit-node-parent parent)))
260+ (back-to-indentation )
261+ (point )))
262+
263+ (defun julia-ts--grand-parent-first-sibling (_n parent &rest _ )
264+ " Return the start of the first child of the parent of the node PARENT."
265+ (treesit-node-start (treesit-node-child (treesit-node-parent parent) 0 )))
266+
256267(defvar julia-ts--treesit-indent-rules
257268 `((julia
258269 ((parent-is " abstract_definition" ) parent-bol 0 )
@@ -270,7 +281,7 @@ Otherwise, the indentation is:
270281 ((parent-is " curly_expression" ) parent-bol julia-ts-indent-offset)
271282 ((parent-is " parenthesized_expression" ) parent-bol julia-ts-indent-offset)
272283 ((parent-is " tuple_expression" ) parent-bol julia-ts-indent-offset)
273- ((parent-is " vector_expression " ) parent-bol julia-ts-indent-offset)
284+ ((parent-is " vector _expression " ) parent-bol julia-ts-indent-offset)
274285
275286 ; ; Match if the node is inside an assignment.
276287 ,@(if julia-ts-align-assignment-expressions-to-first-sibling
@@ -296,6 +307,16 @@ Otherwise, the indentation is:
296307 (list '((parent-is " parameter_list" ) first-sibling 1 ))
297308 (list '((parent-is " parameter_list" ) parent-bol julia-ts-indent-offset)))
298309
310+ ; ; The keyword parameters is a child of parameter list. Hence, we need to
311+ ; ; consider its grand parent to perform the alignment.
312+ ,@(if julia-ts-align-parameter-list-to-first-sibling
313+ (list '((n-p-gp nil " keyword_parameters" " parameter_list" )
314+ julia-ts--grand-parent-first-sibling
315+ 1 ))
316+ (list '((n-p-gp nil " keyword_parameters" " parameter_list" )
317+ julia-ts--grand-parent-bol
318+ julia-ts-indent-offset)))
319+
299320 ; ; This rule takes care of blank lines most of the time.
300321 (no-node parent-bol 0 )))
301322 " Tree-sitter indent rules for `julia-ts-mode' ." )
0 commit comments