@@ -38,6 +38,7 @@ typedef enum {
3838 K_FUNCTION ,
3939 K_SCRIPT ,
4040 K_HEREDOCLABEL ,
41+ K_VARIABLE ,
4142} shKind ;
4243
4344typedef enum {
@@ -87,7 +88,9 @@ static roleDefinition ZshFunctionRoles [] = {
8788 { true, 's', "script", "script files", \
8889 .referenceOnly = true, ATTACH_ROLES (SCRIPT_ROLES) }, \
8990 { 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+
9194
9295static kindDefinition ShKinds [] = {
9396 SH_KINDS_COMMON (ShScriptRoles , ShHeredocRoles , ),
@@ -456,6 +459,32 @@ static size_t handleZshKeyword (int keyword,
456459 return vStringLength (token );
457460}
458461
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+
459488typedef bool (* checkCharFunc ) (int );
460489static void findShTagsCommon (size_t (* keyword_handler ) (int ,
461490 vString * ,
@@ -653,8 +682,9 @@ static void findShTagsCommon (size_t (* keyword_handler) (int,
653682 while (isspace ((int ) * cp ))
654683 ++ cp ;
655684
656- if ((found_kind != K_SCRIPT )
657- && * cp == '(' )
685+ if (found_kind == K_SCRIPT )
686+ ; /* Do NOTHING */
687+ else if (* cp == '(' )
658688 {
659689 ++ cp ;
660690 while (isspace ((int ) * cp ))
@@ -680,6 +710,9 @@ static void findShTagsCommon (size_t (* keyword_handler) (int,
680710 ++ cp ;
681711 }
682712 }
713+ else if (found_kind == K_NOTHING
714+ && handleVariableAssignment (name ))
715+ found_kind = K_VARIABLE ;
683716
684717 if (found_kind != K_NOTHING )
685718 {
0 commit comments