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