From b1d24ca760ba16e73a504bebd704cec4c77291c5 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 12 Sep 2023 22:29:37 +0200 Subject: [PATCH] vim-patch:f5356bf6751f MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit runtime(i3config): syntax structure cleanup (vim/vim#13080) * syntax(i3config): improved i3config highlighting * syntax(i3config): refactor structure https://github.com/vim/vim/commit/f5356bf6751fc1af77c8d27c7286639527fde3f2 Co-authored-by: Josef Litoš <54900518+JosefLitos@users.noreply.github.com> --- runtime/syntax/i3config.vim | 460 ++++++++++++++++++++---------------- 1 file changed, 250 insertions(+), 210 deletions(-) diff --git a/runtime/syntax/i3config.vim b/runtime/syntax/i3config.vim index 1eddd60f7c..8bc2a6e03c 100644 --- a/runtime/syntax/i3config.vim +++ b/runtime/syntax/i3config.vim @@ -4,7 +4,7 @@ " Maintainer: Quentin Hibon (github user hiqua) " Version: 0.4.22 " Reference version (JosefLitos/i3config.vim): 4.22 -" Last Change: 2023-09-09 +" Last Change: 2023-09-12 " References: " http://i3wm.org/docs/userguide.html#configuring @@ -24,284 +24,324 @@ syn match i3ConfigError /.\+/ " Todo syn keyword i3ConfigTodo TODO FIXME XXX contained -" Comment -" Comments are started with a # and can only be used at the beginning of a line +" Helper type definitions +syn match i3ConfigSeparator /[,;]/ contained +syn match i3ConfigParen /[{}]/ contained +syn keyword i3ConfigBoolean yes no enabled disabled on off true false contained +syn region i3ConfigString start=/\W\@<="/ skip=/\\"/ end=/"/ contained contains=i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigNumber,i3ConfigVariable,i3ConfigExecAction keepend extend +syn region i3ConfigString start=/\W\@<='/ end=/'/ contained contains=i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigNumber,i3ConfigVariable,i3ConfigExecAction keepend extend +syn match i3ConfigColor /#\w\{3,8}/ contained +syn match i3ConfigNumber /[a-zA-Z_$-]\@&|+=~^*!.?]\+/ contained syn match i3ConfigShParam /\<-[a-zA-Z0-9_-]\+\>/ contained containedin=i3ConfigVar -syn region i3ConfigExec start=/exec\(_always\)\?\( --no-startup-id\)\? [^{]/ skip=/\\$/ end=/\([,;]\|$\)/ contains=i3ConfigExecKeyword,i3ConfigExecAlwaysKeyword,i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigNumber,i3ConfigString,i3ConfigVariable,i3ConfigOperator keepend extend +syn region i3ConfigExec start=/^\s*exec\(_always\)\?\( --no-startup-id\)\? [^{]/ skip=/\\$/ end=/$/ contains=i3ConfigExecKeyword,i3ConfigExecAlwaysKeyword,i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigNumber,i3ConfigString,i3ConfigVariable,i3ConfigExecAction keepend -" Automatically putting workspaces on specific screens +" 4.21 Workspaces per output syn keyword i3ConfigWorkspaceKeyword workspace contained -syn keyword i3ConfigOutput output contained -syn match i3ConfigWorkspace /^\s*workspace\s\+.*$/ contains=i3ConfigWorkspaceKeyword,i3ConfigNumber,i3ConfigString,i3ConfigOutput,i3ConfigVariable,i3ConfigBoolean +syn keyword i3ConfigWorkspaceOutput output contained +syn keyword i3ConfigWorkspaceDir prev next back_and_forth contained +syn region i3ConfigWorkspaceLine start=/^workspace / skip=/\\$/ end=/$/ contains=i3ConfigWorkspaceKeyword,i3ConfigNumber,i3ConfigString,i3ConfigGaps,i3ConfigWorkspaceOutput,i3ConfigVariable,i3ConfigBoolean,i3ConfigSeparator keepend -" Changing colors -syn keyword i3ConfigClientColorKeyword client focused focused_inactive unfocused urgent placeholder background contained -syn match i3ConfigClientColor /^\s*client.\w\+\s\+.*$/ contains=i3ConfigClientColorKeyword,i3ConfigColor,i3ConfigVariable +" 4.22 Changing colors +syn match i3ConfigDotOperator /\./ contained +syn keyword i3ConfigClientOpts focused focused_inactive unfocused urgent placeholder background contained +syn match i3ConfigKeyword /^client\..*$/ contains=i3ConfigDotOperator,i3ConfigClientOpts,i3ConfigColor,i3ConfigVariable -syn keyword i3ConfigTitleAlignKeyword left center right contained -syn match i3ConfigTitleAlign /^title_align .*$/ contains=i3ConfigTitleAlignKeyword +" 4.23 Interprocess communication +syn match i3ConfigIpcKeyword /ipc-socket/ contained +syn match i3ConfigIpc /^ipc-socket .*$/ contains=i3ConfigIpcKeyword -" Interprocess communication -syn match i3ConfigInterprocessKeyword /ipc-socket/ contained -syn match i3ConfigInterprocess /^ipc-socket .*$/ contains=i3ConfigInterprocessKeyword +" 4.24 Focus follows mouse +syn keyword i3ConfigFocusFollowsMouseOpts always contained +syn match i3ConfigFocusFollowsMouse /^focus_follows_mouse \(yes\|no\|always\)$/ contains=i3ConfigBoolean,i3ConfigFocusFollowsMouseOpts -" Mouse warping -syn keyword i3ConfigMouseWarpingKeyword mouse_warping contained -syn keyword i3ConfigMouseWarpingType output container none contained -syn match i3ConfigMouseWarping /^mouse_warping \(output\|container\|none\)$/ contains=i3ConfigMouseWarpingKeyword,i3ConfigMouseWarpingType +" 4.25 Mouse warping +syn keyword i3ConfigMouseWarpingOpts output container none contained +syn match i3ConfigMouseWarping /^mouse_warping \w*$/ contains=i3ConfigMouseWarpingOpts -" Focus follows mouse -syn keyword i3ConfigFocusFollowsMouseKeyword focus_follows_mouse contained -syn keyword i3ConfigFocusFollowsMouseType always contained -syn match i3ConfigFocusFollowsMouse /^focus_follows_mouse \(yes\|no\|always\)$/ contains=i3ConfigFocusFollowsMouseKeyword,i3ConfigBoolean,i3ConfigFocusFollowsMouseType +" 4.26 Popups while fullscreen +syn keyword i3ConfigPopupFullscreenOpts smart ignore leave_fullscreen contained +syn match i3ConfigPopupFullscreen /^popup_during_fullscreen \w*$/ contains=i3ConfigPopupFullscreenOpts -" Focus wrapping -syn keyword i3ConfigFocusWrappingKeyword force_focus_wrapping focus_wrapping contained -syn keyword i3ConfigFocusWrappingType force workspace contained -syn match i3ConfigFocusWrapping /^focus_wrapping \(yes\|no\|force\|workspace\)$/ contains=i3ConfigBoolean,i3ConfigFocusWrappingKeyword,i3ConfigFocusWrappingType +" 4.27 Focus wrapping +syn keyword i3ConfigFocusWrappingOpts force workspace contained +syn match i3ConfigFocusWrapping /^focus_wrapping \(yes\|no\|force\|workspace\)$/ contains=i3ConfigBoolean,i3ConfigFocusWrappingOpts -" Popups during fullscreen mode -syn keyword i3ConfigPopupOnFullscreenKeyword popup_during_fullscreen contained -syn keyword i3ConfigPopupOnFullscreenType smart ignore leave_fullscreen contained -syn match i3ConfigPopupOnFullscreen /^popup_during_fullscreen \w\+$/ contains=i3ConfigPopupOnFullscreenKeyword,i3ConfigPopupOnFullscreenType +" 4.28 Forcing Xinerama +syn match i3ConfigForceXinerama /^force_xinerama \(yes\|no\)$/ contains=i3ConfigBoolean -" Forcing Xinerama -syn keyword i3ConfigForceXineramaKeyword force_xinerama contained -syn match i3ConfigForceXinerama /^force_xinerama \(yes\|no\)$/ contains=i3ConfigBoolean,i3ConfigForceXineramaKeyword +" 4.29 Automatic workspace back-and-forth +syn match i3ConfigAutomaticSwitch /^workspace_auto_back_and_forth \(yes\|no\)$/ contains=i3ConfigBoolean -" Automatic back-and-forth when switching to the current workspace -syn keyword i3ConfigAutomaticSwitchKeyword workspace_auto_back_and_forth contained -syn match i3ConfigAutomaticSwitch /^workspace_auto_back_and_forth \(yes\|no\)$/ contains=i3ConfigBoolean,i3ConfigAutomaticSwitchKeyword - -" Delay urgency hint +" 4.30 Delay urgency hint syn keyword i3ConfigTimeUnit ms contained -syn keyword i3ConfigDelayUrgencyKeyword force_display_urgency_hint contained -syn match i3ConfigDelayUrgency /^force_display_urgency_hint \d\+ ms$/ contains=i3ConfigBoolean,i3ConfigDelayUrgencyKeyword,i3ConfigNumber,i3ConfigTimeUnit +syn match i3ConfigDelayUrgency /^force_display_urgency_hint \d\+ ms$/ contains=i3ConfigBoolean,i3ConfigNumber,i3ConfigTimeUnit -" Focus on window activation -syn keyword i3ConfigFocusOnActivationKeyword focus_on_window_activation contained -syn keyword i3ConfigFocusOnActivationType smart urgent focus none contained -syn match i3ConfigFocusOnActivation /^focus_on_window_activation \(smart\|urgent\|focus\|none\)$/ contains=i3ConfigFocusOnActivationKeyword,i3ConfigFocusOnActivationType +" 4.31 Focus on window activation +syn keyword i3ConfigFocusOnActivationOpts smart urgent focus none contained +syn match i3ConfigFocusOnActivation /^focus_on_window_activation .*$/ contains=i3ConfigFocusOnActivationKeyword -" Show window marks in their window title -syn keyword i3ConfigShowMarksKeyword show_marks contained -syn match i3ConfigShowMarks /^show_marks \(yes\|no\)$/ contains=i3ConfigBoolean,i3ConfigShowMarksKeyword +" 4.32 Show marks in title +syn match i3ConfigShowMarks /^show_marks \(yes\|no\)$/ contains=i3ConfigBoolean -" Mode block -syn match i3ConfigModeKeyword /^mode/ contained -syn region i3ConfigModeBlock start=/^mode\( --pango_markup\)\? \([^'" {]\+\|'[^']\+'\|".\+"\)\s\+{$/ end=/^\s*}$/ contains=i3ConfigModeKeyword,i3ConfigString,i3ConfigBind,i3ConfigComment,i3ConfigNumber,i3ConfigParen,i3ConfigVariable fold keepend extend +" 4.34 Tiling drag +syn keyword i3ConfigTilingDragOpts modifier titlebar contained +syn match i3ConfigTilingDrag /^tiling_drag\( off\|\( modifier\| titlebar\)\{1,2\}\)$/ contains=i3ConfigTilingOpts,i3ConfigBoolean -" Color block -syn keyword i3ConfigColorsKeyword colors contained -syn match i3ConfigColorsCategory /\(focused_\)\?\(background\|statusline\|separator\)\|\(focused\|active\|inactive\|urgent\)_workspace\|binding_mode/ contained -syn region i3ConfigColorsBlock start=/^\s\+colors {$/ end=/^\s\+}$/ contained contains=i3ConfigColorsKeyword,i3ConfigColorsCategory,i3ConfigColor,i3ConfigVariable,i3ConfigComment,i3ConfigParen fold keepend extend +" 4.35 Gaps +syn keyword i3ConfigGapsOpts inner outer horizontal vertical left right top bottom current all set plus minus toggle contained +syn region i3ConfigGaps start=/gaps/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigGapsOpts,i3ConfigNumber,i3ConfigVariable,i3ConfigSeparator keepend +syn match i3ConfigGapStyleLine /^gaps .*$/ contains=i3ConfigGaps +syn keyword i3ConfigSmartGapOpts inverse_outer contained +syn match i3ConfigSmartGap /^smart_gaps \(on\|off\|inverse_outer\)$/ contains=i3ConfigSmartGapOpts,i3ConfigBoolean -" Bar block -syn keyword i3ConfigBarBlockKeyword bar i3bar_command status_command mode hidden_state id position output tray_output tray_padding font separator_symbol workspace_buttons workspace_min_width strip_workspace_numbers strip_workspace_name binding_mode_indicator padding contained -syn keyword i3ConfigBarModifierKeyword modifier contained -syn match i3ConfigBarModifierLine /^\s\+modifier [^ ]\+$/ contained contains=i3ConfigBarModifierKeyword,i3ConfigBindModifier,i3ConfigVariable,i3ConfigBindModkey -syn region i3ConfigBarBlock start=/^bar {$/ end=/^}$/ contains=i3ConfigBarBlockKeyword,i3ConfigBarModifierLine,i3ConfigBind,i3ConfigString,i3ConfigComment,i3ConfigFont,i3ConfigBoolean,i3ConfigNumber,i3ConfigOperator,i3ConfigParen,i3ConfigColor,i3ConfigVariable,i3ConfigColorsBlock fold keepend extend +" 5 Configuring bar +syn match i3ConfigBarModifier /^\s\+modifier [^ ]\+$/ contained contains=i3ConfigBindModifier,i3ConfigVariable,i3ConfigBindModkey +syn keyword i3ConfigBarOpts bar i3bar_command status_command mode hidden_state id position output tray_output tray_padding font separator_symbol workspace_buttons workspace_min_width strip_workspace_numbers strip_workspace_name binding_mode_indicator padding contained +syn region i3ConfigBarBlock start=/^bar {$/ end=/^}$/ contains=i3ConfigBarOpts,i3ConfigBarModifier,i3ConfigBind,i3ConfigString,i3ConfigComment,i3ConfigFont,i3ConfigBoolean,i3ConfigNumber,i3ConfigParen,i3ConfigColor,i3ConfigVariable,i3ConfigColorsBlock fold keepend extend + +" 5.16 Color block +syn match i3ConfigColorsOpts /\(focused_\)\?\(background\|statusline\|separator\)\|\(focused\|active\|inactive\|urgent\)_workspace\|binding_mode/ contained +syn region i3ConfigColorsBlock start=/^\s\+colors {$/ end=/^\s\+}$/ contained contains=i3ConfigColorsOpts,i3ConfigColor,i3ConfigVariable,i3ConfigComment,i3ConfigParen fold keepend extend + +" 6.0 Criteria-based commands +syn match i3ConfigConditionProp /\w\+\(-\w\+\)*/ contained +syn match i3ConfigConditionText /[^[ ]\+=/ contained contains=i3ConfigConditionProp,i3ConfigShOper +syn keyword i3ConfigConditionFocused __focused__ contained +syn region i3ConfigCondition start=/\[/ end=/\]/ contained contains=i3ConfigConditionText,i3ConfigShDelim,i3ConfigNumber,i3ConfigString,i3ConfigConditionFocused keepend extend +syn region i3ConfigCriteria start=/\[/ skip=/\\$/ end=/\(;\|$\)/ contained contains=i3ConfigCondition,i3ConfigAction,i3ConfigActionKeyword,i3ConfigOption,i3ConfigBoolean,i3ConfigNumber,i3ConfigVariable,i3ConfigSeparator keepend + +" 6.1 Actions through shell +syn match i3ConfigExecActionKeyword /i3-msg/ contained +syn region i3ConfigExecAction start=/[a-z3-]\+msg '/ skip=/\\$\| '/ end=/'/ contained contains=i3ConfigExecActionKeyword,i3ConfigShCommand,i3ConfigNumber,i3ConfigShOper,i3ConfigCriteria,i3ConfigAction,i3ConfigActionKeyword,i3ConfigOption,i3ConfigVariable keepend extend +syn region i3ConfigExecAction start=/[a-z3-]\+msg "/ skip=/\\$\| "/ end=/"/ contained contains=i3ConfigExecActionKeyword,i3ConfigShCommand,i3ConfigNumber,i3ConfigShOper,i3ConfigCriteria,i3ConfigAction,i3ConfigActionKeyword,i3ConfigOption,i3ConfigVariable keepend extend +syn region i3ConfigExecAction start=/[a-z3-]\+msg\( ['"-]\)\@!/ skip=/\\$/ end=/\([&|;})'"]\|$\)/ contained contains=i3ConfigExecActionKeyword,i3ConfigShCommand,i3ConfigNumber,i3ConfigShOper,i3ConfigCriteria,i3ConfigAction,i3ConfigActionKeyword,i3ConfigOption,i3ConfigVariable keepend +" 6.1 Executing applications (4.20) +syn region i3ConfigAction start=/exec/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigExecKeyword,i3ConfigShCommand,i3ConfigShDelim,i3ConfigShOper,i3ConfigShParam,i3ConfigNumber,i3ConfigString,i3ConfigVariable,i3ConfigSeparator keepend + +" 6.3 Manipulating layout +syn keyword i3ConfigLayoutKeyword layout contained +syn keyword i3ConfigLayoutOpts default tabbed stacking splitv splith toggle split all contained +syn region i3ConfigAction start=/layout/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigLayoutKeyword,i3ConfigLayoutOpts,i3ConfigSeparator keepend + +" 6.4 Focusing containers +syn keyword i3ConfigFocusKeyword focus contained +syn keyword i3ConfigFocusOpts left right up down parent child next prev sibling floating tiling mode_toggle contained +syn keyword i3ConfigFocusOutputOpts left right down up current primary nonprimary next prev contained +syn region i3ConfigFocusOutput start=/ output / skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigMoveType,i3ConfigWorkspaceOutput,i3ConfigFocusOutputOpts,i3ConfigString,i3ConfigNumber,i3ConfigSeparator keepend +syn match i3ConfigFocusOutputLine /^focus output .*$/ contains=i3ConfigFocusKeyword,i3ConfigFocusOutput +syn region i3ConfigAction start=/focus/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigFocusKeyword,i3ConfigFocusOpts,i3ConfigFocusOutput,i3ConfigString,i3ConfigSeparator keepend + +" 6.8 Focusing workspaces (4.21) +syn region i3ConfigAction start=/workspace / skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigWorkspaceKeyword,i3ConfigWorkspaceDir,i3ConfigNumber,i3ConfigString,i3ConfigGaps,i3ConfigWorkspaceOutput,i3ConfigVariable,i3ConfigBoolean,i3ConfigSeparator keepend + +" 6.9-6.11 Moving containers +syn keyword i3ConfigMoveKeyword move contained +syn keyword i3ConfigMoveDir left right down up position absolute center to contained +syn keyword i3ConfigMoveType window container workspace output mark mouse scratchpad contained +syn match i3ConfigUnit / px\| ppt/ contained +syn region i3ConfigAction start=/move/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigMoveKeyword,i3ConfigMoveDir,i3ConfigMoveType,i3ConfigWorkspaceDir,i3ConfigUnit,i3ConfigNumber,i3ConfigVariable,i3ConfigSeparator keepend + +" 6.12 Resizing containers/windows +syn keyword i3ConfigResizeKeyword resize contained +syn keyword i3ConfigResizeOpts grow shrink up down left right set width height or contained +syn region i3ConfigAction start=/resize/ skip=/\\$/ end=/\([,;]\|$\)/ contained contains=i3ConfigResizeKeyword,i3ConfigResizeOpts,i3ConfigNumber,i3ConfigUnit,i3ConfigSeparator keepend + +" 6.14 VIM-like marks +syn keyword i3ConfigMarkKeyword mark contained +syn match i3ConfigMark /mark\( --\(add\|replace\)\( --toggle\)\?\)\?/ contained contains=i3ConfigMarkKeyword +syn region i3ConfigAction start=/\