From 8df6ab9a0da8917921fc659026aeae2b3c6fd7dd Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Tue, 22 Jul 2014 16:47:29 -0400 Subject: [PATCH] Update syntax to support using variables (create using the 'set' keyword) in the various commands (e.g. bindsym, client.*, background, etc). The use-case for this change came about from using j4-make-config (https://github.com/okraits/j4-make-config). --- Syntax/i3wm_config.YAML-tmLanguage | 197 +++++++++--- Syntax/i3wm_config.tmLanguage | 474 ++++++++++++++++++++++++++--- 2 files changed, 594 insertions(+), 77 deletions(-) diff --git a/Syntax/i3wm_config.YAML-tmLanguage b/Syntax/i3wm_config.YAML-tmLanguage index ec89e15..f3e1dc9 100644 --- a/Syntax/i3wm_config.YAML-tmLanguage +++ b/Syntax/i3wm_config.YAML-tmLanguage @@ -5,7 +5,6 @@ scopeName: source.i3wm_config fileTypes: [i3/config, config] uuid: bb9ebd33-1b88-4310-acef-41720bcac38f - patterns: - name: criteria match: \[(.*)\] @@ -14,10 +13,10 @@ patterns: # Chapter 4, Configuring i3 - name: comment - match: ((#).*) + match: (\#)(.*) captures: - '1': {name: comment} - '2': {name: comment.source.i3wm_config} + '1': {name: comment.line.number-sign.i3wm_config} + '2': {name: comment.line.i3wm_config} - name: font_pango match: (font\ pango\:)\s*([- ,\w]*) @@ -100,13 +99,22 @@ patterns: '3': {name: constant.string.i3wm_config} # set $mod Mod4 -- name: set +- name: set1 match: (set)\s*(\$\w*)\s*(\w*) captures: '1': {name: keyword.control.i3wm_config} - '2': {name: meta.scope.variable.other.i3wm_config} + '2': {name: variable.other.i3wm_config} '3': {name: constant.language.i3wm_config} +# set $mod #012345 +- name: set2 + match: (set)\s*(\$\w*)\s*(#\w{6}) + captures: + '1': {name: keyword.control.i3wm_config} + '2': {name: variable.other.i3wm_config} + '3': {name: constant.other.i3wm_config} + + #assign command - name: assign match: (assign)\s*\[(.*)]\s*(→)?\s*([\w\d]*) @@ -133,44 +141,86 @@ patterns: '3': {name: constant.string.i3wm_config} # client.focused -- name: client_focused - match: (client.focused)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) +- name: client_focused1 + match: (client\.focused)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) captures: '1': {name: keyword.control.i3wm_config} - '2': {name: constant.string.i3wm_config} - '3': {name: constant.string.i3wm_config} - '4': {name: constant.string.i3wm_config} - '5': {name: constant.string.i3wm_config} + '2': {name: constant.other.i3wm_config} + '3': {name: constant.other.i3wm_config} + '4': {name: constant.other.i3wm_config} + '5': {name: constant.other.i3wm_config} + +- name: client_focused2 + match: (client\.focused)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*) + captures: + '1': {name: keyword.control.i3wm_config} + '2': {name: variable.other.i3wm_config} + '3': {name: variable.other.i3wm_config} + '4': {name: variable.other.i3wm_config} + '5': {name: variable.other.i3wm_config} + + # client.focused_inactive -- name: client_focused_inactive - match: (client\.focused\_inactive)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) +- name: client_focused_inactive1 + match: (client\.focused_inactive)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) captures: '1': {name: keyword.control.i3wm_config} - '2': {name: constant.string.i3wm_config} - '3': {name: constant.string.i3wm_config} - '4': {name: constant.string.i3wm_config} - '5': {name: constant.string.i3wm_config} + '2': {name: constant.other.i3wm_config} + '3': {name: constant.other.i3wm_config} + '4': {name: constant.other.i3wm_config} + '5': {name: constant.other.i3wm_config} + +- name: client_focused_inactive2 + match: (client\.focused_inactive)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*) + captures: + '1': {name: keyword.control.i3wm_config} + '2': {name: variable.other.i3wm_config} + '3': {name: variable.other.i3wm_config} + '4': {name: variable.other.i3wm_config} + '5': {name: variable.other.i3wm_config} + + # client.unfocused -- name: client_unfocused +- name: client_unfocused1 match: (client\.unfocused)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) captures: '1': {name: keyword.control.i3wm_config} - '2': {name: constant.string.i3wm_config} - '3': {name: constant.string.i3wm_config} - '4': {name: constant.string.i3wm_config} - '5': {name: constant.string.i3wm_config} + '2': {name: constant.other.i3wm_config} + '3': {name: constant.other.i3wm_config} + '4': {name: constant.other.i3wm_config} + '5': {name: constant.other.i3wm_config} + +- name: client_unfocused2 + match: (client\.unfocused)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*) + captures: + '1': {name: keyword.control.i3wm_config} + '2': {name: variable.other.i3wm_config} + '3': {name: variable.other.i3wm_config} + '4': {name: variable.other.i3wm_config} + '5': {name: variable.other.i3wm_config} + # client.urgent -- name: client_urgent +- name: client_urgent1 match: (client\.urgent)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) captures: '1': {name: keyword.control.i3wm_config} - '2': {name: constant.string.i3wm_config} - '3': {name: constant.string.i3wm_config} - '4': {name: constant.string.i3wm_config} - '5': {name: constant.string.i3wm_config} + '2': {name: constant.other.i3wm_config} + '3': {name: constant.other.i3wm_config} + '4': {name: constant.other.i3wm_config} + '5': {name: constant.other.i3wm_config} + +- name: client_urgent2 + match: (client\.urgent)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*) + captures: + '1': {name: keyword.control.i3wm_config} + '2': {name: variable.other.i3wm_config} + '3': {name: variable.other.i3wm_config} + '4': {name: variable.other.i3wm_config} + '5': {name: variable.other.i3wm_config} + # ipc-socket - name: ipc_socket @@ -320,27 +370,34 @@ patterns: # background - name: background - match: (background)\s*(#\w{6}) + match: (background)\s*([#$\w]*) captures: '1': {name: keyword.control.i3wm_config} '2': {name: constant.language.i3wm_config} # statusline -- name: statusline +- name: statusline1 match: (statusline)\s*(#\w{6}) captures: '1': {name: keyword.control.i3wm_config} '2': {name: constant.language.i3wm_config} +- name: statusline2 + match: (statusline)\s*(\$\w*) + captures: + '1': {name: keyword.control.i3wm_config} + '2': {name: variable.other.i3wm_config} + + # separator - name: separator - match: (separator)\s*(#\w{6}) + match: (separator)\s*([#$\w]*) captures: '1': {name: keyword.control.i3wm_config} '2': {name: constant.language.i3wm_config} # focused_workspace -- name: focused_workspace +- name: focused_workspace1 match: (focused_workspace)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) captures: '1': {name: keyword.control.i3wm_config} @@ -349,8 +406,18 @@ patterns: '4': {name: constant.language.i3wm_config} '5': {name: constant.language.i3wm_config} +- name: focused_workspace2 + match: (focused_workspace)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*) + captures: + '1': {name: keyword.control.i3wm_config} + '2': {name: variable.other.i3wm_config} + '3': {name: variable.other.i3wm_config} + '4': {name: variable.other.i3wm_config} + '5': {name: variable.other.i3wm_config} + + # active_workspace -- name: active_workspace +- name: active_workspace1 match: (active_workspace)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) captures: '1': {name: keyword.control.i3wm_config} @@ -359,9 +426,19 @@ patterns: '4': {name: constant.language.i3wm_config} '5': {name: constant.language.i3wm_config} +- name: active_workspace2 + match: (active_workspace)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*) + captures: + '1': {name: keyword.control.i3wm_config} + '2': {name: variable.other.i3wm_config} + '3': {name: variable.other.i3wm_config} + '4': {name: variable.other.i3wm_config} + '5': {name: variable.other.i3wm_config} + + # inactive_workspace -- name: inactive_workspace - match: (inactive_workspace)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) +- name: inactive_workspace1 + match: (inactive_workspace)\s*([#\$\w]*)\s*([#\$\w]*)\s*([#\$\w]*) captures: '1': {name: keyword.control.i3wm_config} '2': {name: constant.language.i3wm_config} @@ -369,8 +446,18 @@ patterns: '4': {name: constant.language.i3wm_config} '5': {name: constant.language.i3wm_config} +- name: inactive_workspace2 + match: (inactive_workspace)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*) + captures: + '1': {name: keyword.control.i3wm_config} + '2': {name: variable.other.i3wm_config} + '3': {name: variable.other.i3wm_config} + '4': {name: variable.other.i3wm_config} + '5': {name: variable.other.i3wm_config} + + # urgent_workspace -- name: urgent_workspace +- name: urgent_workspace1 match: (urgent_workspace)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) captures: '1': {name: keyword.control.i3wm_config} @@ -379,6 +466,15 @@ patterns: '4': {name: constant.language.i3wm_config} '5': {name: constant.language.i3wm_config} +- name: urgent_workspace2 + match: (urgent_workspace)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*) + captures: + '1': {name: keyword.control.i3wm_config} + '2': {name: variable.other.i3wm_config} + '3': {name: variable.other.i3wm_config} + '4': {name: variable.other.i3wm_config} + '5': {name: variable.other.i3wm_config} + # Chapter 6, List of commands - name: bindcode @@ -476,6 +572,7 @@ patterns: '1': {name: keyword.control.i3wm_config} '2': {name: constant.language.i3wm_config} + # rename workspace to # rename workspace to - name: rename_workspace @@ -506,21 +603,43 @@ patterns: # move workspace # move workspace number - name: move_workspace - match: (move)\s*(workspace)\s*(next|prev|next_on_output|prev_on_output|back_and_forth|(?:\w)*|(?:\d*\s*\w*)) + match: (move)\s*(workspace)\s*(next|prev|next_on_output|prev_on_output|back_and_forth|(?:\w)*|(?:\d*\s*\w*))(\$\w*){0,1} captures: '1': {name: keyword.control.i3wm_config} '2': {name: keyword.control.i3wm_config} '3': {name: constant.language.i3wm_config} + '4': {name: variable.other.i3wm_config} # move [window|container] [to] workspace +- name: move__window_or_container1 + match: (move)\s*(window|container)\s*(to)?\s*(workspace)?\s*(\$\w*) + captures: + '1': {name: keyword.control.i3wm_config} + '2': {name: keyword.control.i3wm_config} + '3': {name: keyword.control.i3wm_config} + '4': {name: keyword.control.i3wm_config} + '5': {name: variable.other.i3wm_config} + # move [window|container] [to] workspace number +- name: move__window_or_container2 + match: (move)\s*(window|container)\s*(to)?\s*(workspace)?\s*(\d*)\s*(\$?\w*)? + captures: + '1': {name: keyword.control.i3wm_config} + '2': {name: keyword.control.i3wm_config} + '3': {name: keyword.control.i3wm_config} + '4': {name: variable.other.i3wm_config} + '5': {name: constant.numeric.i3wm_config} + '6': {name: variable.other.i3wm_config} + # move [window|container] [to] workspace -- name: move__window_or_container - match: (move)\s*(window|container)\s*(to)? +- name: move__window_or_container3 + match: (move)\s*(window|container)\s*(to)?\s*(workspace)\s*(prev|next|current) captures: '1': {name: keyword.control.i3wm_config} '2': {name: keyword.control.i3wm_config} '3': {name: keyword.control.i3wm_config} + '4': {name: constant.language.i3wm_config} + # resize_mode - name: resize_mode diff --git a/Syntax/i3wm_config.tmLanguage b/Syntax/i3wm_config.tmLanguage index 49dc1ba..79858a7 100644 --- a/Syntax/i3wm_config.tmLanguage +++ b/Syntax/i3wm_config.tmLanguage @@ -35,18 +35,18 @@ name comment match - ((#).*) + (\#)(.*) captures 1 name - comment + comment.line.number-sign.i3wm_config 2 name - comment.source.i3wm_config + comment.line.i3wm_config @@ -286,7 +286,7 @@ name - set + set1 match (set)\s*(\$\w*)\s*(\w*) captures @@ -299,7 +299,7 @@ 2 name - meta.scope.variable.other.i3wm_config + variable.other.i3wm_config 3 @@ -308,6 +308,30 @@ + + name + set2 + match + (set)\s*(\$\w*)\s*(#\w{6}) + captures + + 1 + + name + keyword.control.i3wm_config + + 2 + + name + variable.other.i3wm_config + + 3 + + name + constant.other.i3wm_config + + + name assign @@ -387,9 +411,9 @@ name - client_focused + client_focused1 match - (client.focused)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) + (client\.focused)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) captures 1 @@ -400,30 +424,30 @@ 2 name - constant.string.i3wm_config + constant.other.i3wm_config 3 name - constant.string.i3wm_config + constant.other.i3wm_config 4 name - constant.string.i3wm_config + constant.other.i3wm_config 5 name - constant.string.i3wm_config + constant.other.i3wm_config name - client_focused_inactive + client_focused2 match - (client\.focused\_inactive)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) + (client\.focused)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*) captures 1 @@ -434,28 +458,96 @@ 2 name - constant.string.i3wm_config + variable.other.i3wm_config 3 name - constant.string.i3wm_config + variable.other.i3wm_config 4 name - constant.string.i3wm_config + variable.other.i3wm_config 5 name - constant.string.i3wm_config + variable.other.i3wm_config + + + + + name + client_focused_inactive1 + match + (client\.focused_inactive)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) + captures + + 1 + + name + keyword.control.i3wm_config + + 2 + + name + constant.other.i3wm_config + + 3 + + name + constant.other.i3wm_config + + 4 + + name + constant.other.i3wm_config + + 5 + + name + constant.other.i3wm_config + + + + + name + client_focused_inactive2 + match + (client\.focused_inactive)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*) + captures + + 1 + + name + keyword.control.i3wm_config + + 2 + + name + variable.other.i3wm_config + + 3 + + name + variable.other.i3wm_config + + 4 + + name + variable.other.i3wm_config + + 5 + + name + variable.other.i3wm_config name - client_unfocused + client_unfocused1 match (client\.unfocused)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) captures @@ -468,28 +560,62 @@ 2 name - constant.string.i3wm_config + constant.other.i3wm_config 3 name - constant.string.i3wm_config + constant.other.i3wm_config 4 name - constant.string.i3wm_config + constant.other.i3wm_config 5 name - constant.string.i3wm_config + constant.other.i3wm_config + + + + + name + client_unfocused2 + match + (client\.unfocused)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*) + captures + + 1 + + name + keyword.control.i3wm_config + + 2 + + name + variable.other.i3wm_config + + 3 + + name + variable.other.i3wm_config + + 4 + + name + variable.other.i3wm_config + + 5 + + name + variable.other.i3wm_config name - client_urgent + client_urgent1 match (client\.urgent)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) captures @@ -502,22 +628,56 @@ 2 name - constant.string.i3wm_config + constant.other.i3wm_config 3 name - constant.string.i3wm_config + constant.other.i3wm_config 4 name - constant.string.i3wm_config + constant.other.i3wm_config 5 name - constant.string.i3wm_config + constant.other.i3wm_config + + + + + name + client_urgent2 + match + (client\.urgent)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*) + captures + + 1 + + name + keyword.control.i3wm_config + + 2 + + name + variable.other.i3wm_config + + 3 + + name + variable.other.i3wm_config + + 4 + + name + variable.other.i3wm_config + + 5 + + name + variable.other.i3wm_config @@ -900,7 +1060,7 @@ name background match - (background)\s*(#\w{6}) + (background)\s*([#$\w]*) captures 1 @@ -917,7 +1077,7 @@ name - statusline + statusline1 match (statusline)\s*(#\w{6}) captures @@ -934,11 +1094,30 @@ + + name + statusline2 + match + (statusline)\s*(\$\w*) + captures + + 1 + + name + keyword.control.i3wm_config + + 2 + + name + variable.other.i3wm_config + + + name separator match - (separator)\s*(#\w{6}) + (separator)\s*([#$\w]*) captures 1 @@ -955,7 +1134,7 @@ name - focused_workspace + focused_workspace1 match (focused_workspace)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) captures @@ -989,7 +1168,41 @@ name - active_workspace + focused_workspace2 + match + (focused_workspace)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*) + captures + + 1 + + name + keyword.control.i3wm_config + + 2 + + name + variable.other.i3wm_config + + 3 + + name + variable.other.i3wm_config + + 4 + + name + variable.other.i3wm_config + + 5 + + name + variable.other.i3wm_config + + + + + name + active_workspace1 match (active_workspace)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) captures @@ -1023,9 +1236,43 @@ name - inactive_workspace + active_workspace2 + match + (active_workspace)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*) + captures + + 1 + + name + keyword.control.i3wm_config + + 2 + + name + variable.other.i3wm_config + + 3 + + name + variable.other.i3wm_config + + 4 + + name + variable.other.i3wm_config + + 5 + + name + variable.other.i3wm_config + + + + + name + inactive_workspace1 match - (inactive_workspace)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) + (inactive_workspace)\s*([#\$\w]*)\s*([#\$\w]*)\s*([#\$\w]*) captures 1 @@ -1057,7 +1304,41 @@ name - urgent_workspace + inactive_workspace2 + match + (inactive_workspace)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*) + captures + + 1 + + name + keyword.control.i3wm_config + + 2 + + name + variable.other.i3wm_config + + 3 + + name + variable.other.i3wm_config + + 4 + + name + variable.other.i3wm_config + + 5 + + name + variable.other.i3wm_config + + + + + name + urgent_workspace1 match (urgent_workspace)\s*(#\w{6})\s*(#\w{6})\s*(#\w{6}) captures @@ -1089,6 +1370,40 @@ + + name + urgent_workspace2 + match + (urgent_workspace)\s*(\$\w*)\s*(\$\w*)\s*(\$\w*) + captures + + 1 + + name + keyword.control.i3wm_config + + 2 + + name + variable.other.i3wm_config + + 3 + + name + variable.other.i3wm_config + + 4 + + name + variable.other.i3wm_config + + 5 + + name + variable.other.i3wm_config + + + name bindcode @@ -1450,7 +1765,7 @@ name move_workspace match - (move)\s*(workspace)\s*(next|prev|next_on_output|prev_on_output|back_and_forth|(?:\w)*|(?:\d*\s*\w*)) + (move)\s*(workspace)\s*(next|prev|next_on_output|prev_on_output|back_and_forth|(?:\w)*|(?:\d*\s*\w*))(\$\w*){0,1} captures 1 @@ -1468,13 +1783,91 @@ name constant.language.i3wm_config + 4 + + name + variable.other.i3wm_config + + + + + name + move__window_or_container1 + match + (move)\s*(window|container)\s*(to)?\s*(workspace)?\s*(\$\w*) + captures + + 1 + + name + keyword.control.i3wm_config + + 2 + + name + keyword.control.i3wm_config + + 3 + + name + keyword.control.i3wm_config + + 4 + + name + keyword.control.i3wm_config + + 5 + + name + variable.other.i3wm_config + + + + + name + move__window_or_container2 + match + (move)\s*(window|container)\s*(to)?\s*(workspace)?\s*(\d*)\s*(\$?\w*)? + captures + + 1 + + name + keyword.control.i3wm_config + + 2 + + name + keyword.control.i3wm_config + + 3 + + name + keyword.control.i3wm_config + + 4 + + name + variable.other.i3wm_config + + 5 + + name + constant.numeric.i3wm_config + + 6 + + name + variable.other.i3wm_config + name - move__window_or_container + move__window_or_container3 match - (move)\s*(window|container)\s*(to)? + (move)\s*(window|container)\s*(to)?\s*(workspace)\s*(prev|next|current) captures 1 @@ -1492,6 +1885,11 @@ name keyword.control.i3wm_config + 4 + + name + constant.language.i3wm_config +