@@ -38,6 +38,7 @@ typedef enum {
38
38
K_FUNCTION ,
39
39
K_SCRIPT ,
40
40
K_HEREDOCLABEL ,
41
+ K_VARIABLE ,
41
42
} shKind ;
42
43
43
44
typedef enum {
@@ -87,7 +88,9 @@ static roleDefinition ZshFunctionRoles [] = {
87
88
{ true, 's', "script", "script files", \
88
89
.referenceOnly = true, ATTACH_ROLES (SCRIPT_ROLES) }, \
89
90
{ true, 'h', "heredoc", "labels for here document", \
90
- .referenceOnly = false, ATTACH_ROLES (HEREDOC_ROLES) }
91
+ .referenceOnly = false, ATTACH_ROLES (HEREDOC_ROLES) }, \
92
+ { true, 'v', "variable", "variables assigment (experimental)" }
93
+
91
94
92
95
static kindDefinition ShKinds [] = {
93
96
SH_KINDS_COMMON (ShScriptRoles , ShHeredocRoles , ),
@@ -456,6 +459,32 @@ static size_t handleZshKeyword (int keyword,
456
459
return vStringLength (token );
457
460
}
458
461
462
+ static bool handleVariableAssignment (vString * input )
463
+ {
464
+ const char * base = vStringValue (input );
465
+ const char * cp = base ;
466
+
467
+ while (* cp != '\0' )
468
+ {
469
+ if (* cp == '=' )
470
+ {
471
+ size_t len = cp - base ;
472
+ if (len > 0 )
473
+ {
474
+ vStringTruncate (input , len );
475
+ return true;
476
+ }
477
+ break ;
478
+ }
479
+ else if ( ((cp == base )?
480
+ isIdentChar0 : isIdentChar ) ((unsigned char )* cp ) )
481
+ cp ++ ;
482
+ else
483
+ break ;
484
+ }
485
+ return false;
486
+ }
487
+
459
488
typedef bool (* checkCharFunc ) (int );
460
489
static void findShTagsCommon (size_t (* keyword_handler ) (int ,
461
490
vString * ,
@@ -653,8 +682,9 @@ static void findShTagsCommon (size_t (* keyword_handler) (int,
653
682
while (isspace ((int ) * cp ))
654
683
++ cp ;
655
684
656
- if ((found_kind != K_SCRIPT )
657
- && * cp == '(' )
685
+ if (found_kind == K_SCRIPT )
686
+ ; /* Do NOTHING */
687
+ else if (* cp == '(' )
658
688
{
659
689
++ cp ;
660
690
while (isspace ((int ) * cp ))
@@ -680,6 +710,9 @@ static void findShTagsCommon (size_t (* keyword_handler) (int,
680
710
++ cp ;
681
711
}
682
712
}
713
+ else if (found_kind == K_NOTHING
714
+ && handleVariableAssignment (name ))
715
+ found_kind = K_VARIABLE ;
683
716
684
717
if (found_kind != K_NOTHING )
685
718
{
0 commit comments