Bram Moolenaar | 0e6adf8 | 2021-12-16 14:41:10 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: i3 config file |
Bram Moolenaar | 2f0936c | 2022-01-08 21:51:59 +0000 | [diff] [blame] | 3 | " Original Author: Mohamed Boughaba <mohamed dot bgb at gmail dot com> |
| 4 | " Maintainer: Quentin Hibon (github user hiqua) |
Bram Moolenaar | 0e6adf8 | 2021-12-16 14:41:10 +0000 | [diff] [blame] | 5 | " Version: 0.4 |
Bram Moolenaar | 016188f | 2022-06-06 20:52:59 +0100 | [diff] [blame] | 6 | " Last Change: 2022 Jun 05 |
Bram Moolenaar | 0e6adf8 | 2021-12-16 14:41:10 +0000 | [diff] [blame] | 7 | |
| 8 | " References: |
| 9 | " http://i3wm.org/docs/userguide.html#configuring |
| 10 | " http://vimdoc.sourceforge.net/htmldoc/syntax.html |
| 11 | " |
| 12 | " |
| 13 | " Quit when a syntax file was already loaded |
| 14 | if exists("b:current_syntax") |
| 15 | finish |
| 16 | endif |
| 17 | |
| 18 | scriptencoding utf-8 |
| 19 | |
Bram Moolenaar | 0e6adf8 | 2021-12-16 14:41:10 +0000 | [diff] [blame] | 20 | " Todo |
| 21 | syn keyword i3ConfigTodo TODO FIXME XXX contained |
| 22 | |
| 23 | " Comment |
| 24 | " Comments are started with a # and can only be used at the beginning of a line |
| 25 | syn match i3ConfigComment /^\s*#.*$/ contains=i3ConfigTodo |
| 26 | |
| 27 | " Font |
| 28 | " A FreeType font description is composed by: |
| 29 | " a font family, a style, a weight, a variant, a stretch and a size. |
| 30 | syn match i3ConfigFontSeparator /,/ contained |
| 31 | syn match i3ConfigFontSeparator /:/ contained |
| 32 | syn keyword i3ConfigFontKeyword font contained |
| 33 | syn match i3ConfigFontNamespace /\w\+:/ contained contains=i3ConfigFontSeparator |
| 34 | syn match i3ConfigFontContent /-\?\w\+\(-\+\|\s\+\|,\)/ contained contains=i3ConfigFontNamespace,i3ConfigFontSeparator,i3ConfigFontKeyword |
| 35 | syn match i3ConfigFontSize /\s\=\d\+\(px\)\?\s\?$/ contained |
| 36 | syn match i3ConfigFont /^\s*font\s\+.*$/ contains=i3ConfigFontContent,i3ConfigFontSeparator,i3ConfigFontSize,i3ConfigFontNamespace |
| 37 | syn match i3ConfigFont /^\s*font\s\+.*\(\\\_.*\)\?$/ contains=i3ConfigFontContent,i3ConfigFontSeparator,i3ConfigFontSize,i3ConfigFontNamespace |
| 38 | syn match i3ConfigFont /^\s*font\s\+.*\(\\\_.*\)\?[^\\]\+$/ contains=i3ConfigFontContent,i3ConfigFontSeparator,i3ConfigFontSize,i3ConfigFontNamespace |
| 39 | syn match i3ConfigFont /^\s*font\s\+\(\(.*\\\_.*\)\|\(.*[^\\]\+$\)\)/ contains=i3ConfigFontContent,i3ConfigFontSeparator,i3ConfigFontSize,i3ConfigFontNamespace |
| 40 | |
| 41 | " variables |
| 42 | syn match i3ConfigString /\(['"]\)\(.\{-}\)\1/ contained |
| 43 | syn match i3ConfigColor /#\w\{6}/ contained |
| 44 | syn match i3ConfigVariableModifier /+/ contained |
| 45 | syn match i3ConfigVariableAndModifier /+\w\+/ contained contains=i3ConfigVariableModifier |
| 46 | syn match i3ConfigVariable /\$\w\+\(\(-\w\+\)\+\)\?\(\s\|+\)\?/ contains=i3ConfigVariableModifier,i3ConfigVariableAndModifier |
| 47 | syn keyword i3ConfigInitializeKeyword set contained |
| 48 | syn match i3ConfigInitialize /^\s*set\s\+.*$/ contains=i3ConfigVariable,i3ConfigInitializeKeyword,i3ConfigColor,i3ConfigString |
| 49 | |
Bram Moolenaar | d899e51 | 2022-05-07 21:54:03 +0100 | [diff] [blame] | 50 | " Include |
| 51 | syn keyword i3ConfigIncludeKeyword include contained |
| 52 | syn match i3ConfigInclude /^\s*include\s\+.*$/ contains=i3ConfigIncludeKeyword,i3ConfigString,i3ConfigVariable |
| 53 | |
Bram Moolenaar | 0e6adf8 | 2021-12-16 14:41:10 +0000 | [diff] [blame] | 54 | " Gaps |
| 55 | syn keyword i3ConfigGapStyleKeyword inner outer horizontal vertical top right bottom left current all set plus minus toggle up down contained |
| 56 | syn match i3ConfigGapStyle /^\s*\(gaps\)\s\+\(inner\|outer\|horizontal\|vertical\|left\|top\|right\|bottom\)\(\s\+\(current\|all\)\)\?\(\s\+\(set\|plus\|minus\|toggle\)\)\?\(\s\+\(-\?\d\+\|\$.*\)\)$/ contains=i3ConfigGapStyleKeyword,i3ConfigNumber,i3ConfigVariable |
| 57 | syn keyword i3ConfigSmartGapKeyword on inverse_outer contained |
| 58 | syn match i3ConfigSmartGap /^\s*smart_gaps\s\+\(on\|inverse_outer\)\s\?$/ contains=i3ConfigSmartGapKeyword |
| 59 | syn keyword i3ConfigSmartBorderKeyword on no_gaps contained |
| 60 | syn match i3ConfigSmartBorder /^\s*smart_borders\s\+\(on\|no_gaps\)\s\?$/ contains=i3ConfigSmartBorderKeyword |
| 61 | |
| 62 | " Keyboard bindings |
| 63 | syn keyword i3ConfigAction toggle fullscreen restart key import kill shrink grow contained |
| 64 | syn keyword i3ConfigAction focus move grow height width split layout resize restore reload mute unmute exit mode workspace container to contained |
| 65 | syn match i3ConfigModifier /\w\++\w\+\(\(+\w\+\)\+\)\?/ contained contains=i3ConfigVariableModifier |
| 66 | syn match i3ConfigNumber /\s\d\+/ contained |
| 67 | syn match i3ConfigUnit /\sp\(pt\|x\)/ contained |
| 68 | syn match i3ConfigUnitOr /\sor/ contained |
| 69 | syn keyword i3ConfigBindKeyword bindsym bindcode exec gaps border contained |
| 70 | syn match i3ConfigBindArgument /--\w\+\(\(-\w\+\)\+\)\?\s/ contained |
| 71 | syn match i3ConfigBind /^\s*\(bindsym\|bindcode\)\s\+.*$/ contains=i3ConfigVariable,i3ConfigBindKeyword,i3ConfigVariableAndModifier,i3ConfigNumber,i3ConfigUnit,i3ConfigUnitOr,i3ConfigBindArgument,i3ConfigModifier,i3ConfigAction,i3ConfigString,i3ConfigGapStyleKeyword,i3ConfigBorderStyleKeyword |
| 72 | |
| 73 | " Floating |
| 74 | syn keyword i3ConfigSizeSpecial x contained |
| 75 | syn match i3ConfigNegativeSize /-/ contained |
| 76 | syn match i3ConfigSize /-\?\d\+\s\?x\s\?-\?\d\+/ contained contains=i3ConfigSizeSpecial,i3ConfigNumber,i3ConfigNegativeSize |
| 77 | syn match i3ConfigFloating /^\s*floating_modifier\s\+\$\w\+\d\?/ contains=i3ConfigVariable |
| 78 | syn match i3ConfigFloating /^\s*floating_\(maximum\|minimum\)_size\s\+-\?\d\+\s\?x\s\?-\?\d\+/ contains=i3ConfigSize |
| 79 | |
| 80 | " Orientation |
| 81 | syn keyword i3ConfigOrientationKeyword vertical horizontal auto contained |
| 82 | syn match i3ConfigOrientation /^\s*default_orientation\s\+\(vertical\|horizontal\|auto\)\s\?$/ contains=i3ConfigOrientationKeyword |
| 83 | |
| 84 | " Layout |
| 85 | syn keyword i3ConfigLayoutKeyword default stacking tabbed contained |
| 86 | syn match i3ConfigLayout /^\s*workspace_layout\s\+\(default\|stacking\|tabbed\)\s\?$/ contains=i3ConfigLayoutKeyword |
| 87 | |
| 88 | " Border style |
| 89 | syn keyword i3ConfigBorderStyleKeyword none normal pixel contained |
| 90 | syn match i3ConfigBorderStyle /^\s*\(new_window\|new_float\|default_border\|default_floating_border\)\s\+\(none\|\(normal\|pixel\)\(\s\+\d\+\)\?\(\s\+\$\w\+\(\(-\w\+\)\+\)\?\(\s\|+\)\?\)\?\)\s\?$/ contains=i3ConfigBorderStyleKeyword,i3ConfigNumber,i3ConfigVariable |
| 91 | |
| 92 | " Hide borders and edges |
| 93 | syn keyword i3ConfigEdgeKeyword none vertical horizontal both smart smart_no_gaps contained |
| 94 | syn match i3ConfigEdge /^\s*hide_edge_borders\s\+\(none\|vertical\|horizontal\|both\|smart\|smart_no_gaps\)\s\?$/ contains=i3ConfigEdgeKeyword |
| 95 | |
| 96 | " Arbitrary commands for specific windows (for_window) |
| 97 | syn keyword i3ConfigCommandKeyword for_window contained |
| 98 | syn region i3ConfigWindowStringSpecial start=+"+ skip=+\\"+ end=+"+ contained contains=i3ConfigString |
| 99 | syn region i3ConfigWindowCommandSpecial start="\[" end="\]" contained contains=i3ConfigWindowStringSpacial,i3ConfigString |
| 100 | syn match i3ConfigArbitraryCommand /^\s*for_window\s\+.*$/ contains=i3ConfigWindowCommandSpecial,i3ConfigCommandKeyword,i3ConfigBorderStyleKeyword,i3ConfigLayoutKeyword,i3ConfigOrientationKeyword,Size,i3ConfigNumber |
| 101 | |
| 102 | " Disable focus open opening |
| 103 | syn keyword i3ConfigNoFocusKeyword no_focus contained |
| 104 | syn match i3ConfigDisableFocus /^\s*no_focus\s\+.*$/ contains=i3ConfigWindowCommandSpecial,i3ConfigNoFocusKeyword |
| 105 | |
| 106 | " Move client to specific workspace automatically |
| 107 | syn keyword i3ConfigAssignKeyword assign contained |
| 108 | syn match i3ConfigAssignSpecial /→/ contained |
| 109 | syn match i3ConfigAssign /^\s*assign\s\+.*$/ contains=i3ConfigAssignKeyword,i3ConfigWindowCommandSpecial,i3ConfigAssignSpecial |
| 110 | |
| 111 | " X resources |
| 112 | syn keyword i3ConfigResourceKeyword set_from_resource contained |
| 113 | syn match i3ConfigResource /^\s*set_from_resource\s\+.*$/ contains=i3ConfigResourceKeyword,i3ConfigWindowCommandSpecial,i3ConfigColor,i3ConfigVariable |
| 114 | |
| 115 | " Auto start applications |
| 116 | syn keyword i3ConfigExecKeyword exec exec_always contained |
| 117 | syn match i3ConfigNoStartupId /--no-startup-id/ contained " We are not using i3ConfigBindArgument as only no-startup-id is supported here |
| 118 | syn match i3ConfigExec /^\s*exec\(_always\)\?\s\+.*$/ contains=i3ConfigExecKeyword,i3ConfigNoStartupId,i3ConfigString |
| 119 | |
| 120 | " Automatically putting workspaces on specific screens |
| 121 | syn keyword i3ConfigWorkspaceKeyword workspace contained |
| 122 | syn keyword i3ConfigOutput output contained |
| 123 | syn match i3ConfigWorkspace /^\s*workspace\s\+.*$/ contains=i3ConfigWorkspaceKeyword,i3ConfigNumber,i3ConfigString,i3ConfigOutput |
| 124 | |
| 125 | " Changing colors |
| 126 | syn keyword i3ConfigClientColorKeyword client focused focused_inactive unfocused urgent placeholder background contained |
| 127 | syn match i3ConfigClientColor /^\s*client.\w\+\s\+.*$/ contains=i3ConfigClientColorKeyword,i3ConfigColor,i3ConfigVariable |
| 128 | |
| 129 | syn keyword i3ConfigTitleAlignKeyword left center right contained |
| 130 | syn match i3ConfigTitleAlign /^\s*title_align\s\+.*$/ contains=i3ConfigTitleAlignKeyword |
| 131 | |
| 132 | " Interprocess communication |
| 133 | syn match i3ConfigInterprocessKeyword /ipc-socket/ contained |
| 134 | syn match i3ConfigInterprocess /^\s*ipc-socket\s\+.*$/ contains=i3ConfigInterprocessKeyword |
| 135 | |
| 136 | " Mouse warping |
| 137 | syn keyword i3ConfigMouseWarpingKeyword mouse_warping contained |
| 138 | syn keyword i3ConfigMouseWarpingType output none contained |
| 139 | syn match i3ConfigMouseWarping /^\s*mouse_warping\s\+\(output\|none\)\s\?$/ contains=i3ConfigMouseWarpingKeyword,i3ConfigMouseWarpingType |
| 140 | |
| 141 | " Focus follows mouse |
| 142 | syn keyword i3ConfigFocusFollowsMouseKeyword focus_follows_mouse contained |
| 143 | syn keyword i3ConfigFocusFollowsMouseType yes no contained |
| 144 | syn match i3ConfigFocusFollowsMouse /^\s*focus_follows_mouse\s\+\(yes\|no\)\s\?$/ contains=i3ConfigFocusFollowsMouseKeyword,i3ConfigFocusFollowsMouseType |
| 145 | |
| 146 | " Popups during fullscreen mode |
| 147 | syn keyword i3ConfigPopupOnFullscreenKeyword popup_during_fullscreen contained |
| 148 | syn keyword i3ConfigPopuponFullscreenType smart ignore leave_fullscreen contained |
| 149 | syn match i3ConfigPopupOnFullscreen /^\s*popup_during_fullscreen\s\+\w\+\s\?$/ contains=i3ConfigPopupOnFullscreenKeyword,i3ConfigPopupOnFullscreenType |
| 150 | |
| 151 | " Focus wrapping |
| 152 | syn keyword i3ConfigFocusWrappingKeyword force_focus_wrapping focus_wrapping contained |
| 153 | syn keyword i3ConfigFocusWrappingType yes no contained |
| 154 | syn match i3ConfigFocusWrapping /^\s*\(force_\)\?focus_wrapping\s\+\(yes\|no\)\s\?$/ contains=i3ConfigFocusWrappingType,i3ConfigFocusWrappingKeyword |
| 155 | |
| 156 | " Forcing Xinerama |
| 157 | syn keyword i3ConfigForceXineramaKeyword force_xinerama contained |
| 158 | syn match i3ConfigForceXinerama /^\s*force_xinerama\s\+\(yes\|no\)\s\?$/ contains=i3ConfigFocusWrappingType,i3ConfigForceXineramaKeyword |
| 159 | |
| 160 | " Automatic back-and-forth when switching to the current workspace |
| 161 | syn keyword i3ConfigAutomaticSwitchKeyword workspace_auto_back_and_forth contained |
| 162 | syn match i3ConfigAutomaticSwitch /^\s*workspace_auto_back_and_forth\s\+\(yes\|no\)\s\?$/ contains=i3ConfigFocusWrappingType,i3ConfigAutomaticSwitchKeyword |
| 163 | |
| 164 | " Delay urgency hint |
| 165 | syn keyword i3ConfigTimeUnit ms contained |
| 166 | syn keyword i3ConfigDelayUrgencyKeyword force_display_urgency_hint contained |
| 167 | syn match i3ConfigDelayUrgency /^\s*force_display_urgency_hint\s\+\d\+\s\+ms\s\?$/ contains=i3ConfigFocusWrappingType,i3ConfigDelayUrgencyKeyword,i3ConfigNumber,i3ConfigTimeUnit |
| 168 | |
| 169 | " Focus on window activation |
| 170 | syn keyword i3ConfigFocusOnActivationKeyword focus_on_window_activation contained |
| 171 | syn keyword i3ConfigFocusOnActivationType smart urgent focus none contained |
| 172 | syn match i3ConfigFocusOnActivation /^\s*focus_on_window_activation\s\+\(smart\|urgent\|focus\|none\)\s\?$/ contains=i3ConfigFocusOnActivationKeyword,i3ConfigFocusOnActivationType |
| 173 | |
| 174 | " Automatic back-and-forth when switching to the current workspace |
| 175 | syn keyword i3ConfigDrawingMarksKeyword show_marks contained |
| 176 | syn match i3ConfigDrawingMarks /^\s*show_marks\s\+\(yes\|no\)\s\?$/ contains=i3ConfigFocusWrappingType,i3ConfigDrawingMarksKeyword |
| 177 | |
| 178 | " Group mode/bar |
Bram Moolenaar | fd31be2 | 2022-01-16 14:46:06 +0000 | [diff] [blame] | 179 | syn keyword i3ConfigBlockKeyword mode bar colors i3bar_command status_command position exec mode hidden_state modifier id position output background statusline tray_output tray_padding separator separator_symbol workspace_min_width workspace_buttons strip_workspace_numbers binding_mode_indicator focused_workspace active_workspace inactive_workspace urgent_workspace binding_mode contained |
Bram Moolenaar | 016188f | 2022-06-06 20:52:59 +0100 | [diff] [blame] | 180 | syn region i3ConfigBlock start=+^\s*[^#]*s\?{$+ end=+^\s*[^#]*}$+ contains=i3ConfigBlockKeyword,i3ConfigString,i3ConfigBind,i3ConfigComment,i3ConfigFont,i3ConfigFocusWrappingType,i3ConfigColor,i3ConfigVariable transparent keepend extend |
Bram Moolenaar | 0e6adf8 | 2021-12-16 14:41:10 +0000 | [diff] [blame] | 181 | |
| 182 | " Line continuation |
| 183 | syn region i3ConfigLineCont start=/^.*\\$/ end=/^.*$/ contains=i3ConfigBlockKeyword,i3ConfigString,i3ConfigBind,i3ConfigComment,i3ConfigFont,i3ConfigFocusWrappingType,i3ConfigColor,i3ConfigVariable transparent keepend extend |
| 184 | |
| 185 | " Define the highlighting. |
Bram Moolenaar | 0e6adf8 | 2021-12-16 14:41:10 +0000 | [diff] [blame] | 186 | hi def link i3ConfigTodo Todo |
| 187 | hi def link i3ConfigComment Comment |
| 188 | hi def link i3ConfigFontContent Type |
| 189 | hi def link i3ConfigFocusOnActivationType Type |
| 190 | hi def link i3ConfigPopupOnFullscreenType Type |
| 191 | hi def link i3ConfigOrientationKeyword Type |
| 192 | hi def link i3ConfigMouseWarpingType Type |
| 193 | hi def link i3ConfigFocusFollowsMouseType Type |
| 194 | hi def link i3ConfigGapStyleKeyword Type |
| 195 | hi def link i3ConfigTitleAlignKeyword Type |
| 196 | hi def link i3ConfigSmartGapKeyword Type |
| 197 | hi def link i3ConfigSmartBorderKeyword Type |
| 198 | hi def link i3ConfigLayoutKeyword Type |
| 199 | hi def link i3ConfigBorderStyleKeyword Type |
| 200 | hi def link i3ConfigEdgeKeyword Type |
| 201 | hi def link i3ConfigAction Type |
| 202 | hi def link i3ConfigCommand Type |
| 203 | hi def link i3ConfigOutput Type |
| 204 | hi def link i3ConfigWindowCommandSpecial Type |
| 205 | hi def link i3ConfigFocusWrappingType Type |
| 206 | hi def link i3ConfigUnitOr Type |
| 207 | hi def link i3ConfigFontSize Constant |
| 208 | hi def link i3ConfigColor Constant |
| 209 | hi def link i3ConfigNumber Constant |
| 210 | hi def link i3ConfigUnit Constant |
| 211 | hi def link i3ConfigVariableAndModifier Constant |
| 212 | hi def link i3ConfigTimeUnit Constant |
| 213 | hi def link i3ConfigModifier Constant |
| 214 | hi def link i3ConfigString Constant |
| 215 | hi def link i3ConfigNegativeSize Constant |
| 216 | hi def link i3ConfigFontSeparator Special |
| 217 | hi def link i3ConfigVariableModifier Special |
| 218 | hi def link i3ConfigSizeSpecial Special |
| 219 | hi def link i3ConfigWindowSpecial Special |
| 220 | hi def link i3ConfigAssignSpecial Special |
| 221 | hi def link i3ConfigFontNamespace PreProc |
| 222 | hi def link i3ConfigBindArgument PreProc |
| 223 | hi def link i3ConfigNoStartupId PreProc |
Bram Moolenaar | d899e51 | 2022-05-07 21:54:03 +0100 | [diff] [blame] | 224 | hi def link i3ConfigIncludeKeyword Identifier |
Bram Moolenaar | 0e6adf8 | 2021-12-16 14:41:10 +0000 | [diff] [blame] | 225 | hi def link i3ConfigFontKeyword Identifier |
| 226 | hi def link i3ConfigBindKeyword Identifier |
| 227 | hi def link i3ConfigOrientation Identifier |
| 228 | hi def link i3ConfigGapStyle Identifier |
| 229 | hi def link i3ConfigTitleAlign Identifier |
| 230 | hi def link i3ConfigSmartGap Identifier |
| 231 | hi def link i3ConfigSmartBorder Identifier |
| 232 | hi def link i3ConfigLayout Identifier |
| 233 | hi def link i3ConfigBorderStyle Identifier |
| 234 | hi def link i3ConfigEdge Identifier |
| 235 | hi def link i3ConfigFloating Identifier |
| 236 | hi def link i3ConfigCommandKeyword Identifier |
| 237 | hi def link i3ConfigNoFocusKeyword Identifier |
| 238 | hi def link i3ConfigInitializeKeyword Identifier |
| 239 | hi def link i3ConfigAssignKeyword Identifier |
| 240 | hi def link i3ConfigResourceKeyword Identifier |
| 241 | hi def link i3ConfigExecKeyword Identifier |
| 242 | hi def link i3ConfigWorkspaceKeyword Identifier |
| 243 | hi def link i3ConfigClientColorKeyword Identifier |
| 244 | hi def link i3ConfigInterprocessKeyword Identifier |
| 245 | hi def link i3ConfigMouseWarpingKeyword Identifier |
| 246 | hi def link i3ConfigFocusFollowsMouseKeyword Identifier |
| 247 | hi def link i3ConfigPopupOnFullscreenKeyword Identifier |
| 248 | hi def link i3ConfigFocusWrappingKeyword Identifier |
| 249 | hi def link i3ConfigForceXineramaKeyword Identifier |
| 250 | hi def link i3ConfigAutomaticSwitchKeyword Identifier |
| 251 | hi def link i3ConfigDelayUrgencyKeyword Identifier |
| 252 | hi def link i3ConfigFocusOnActivationKeyword Identifier |
| 253 | hi def link i3ConfigDrawingMarksKeyword Identifier |
| 254 | hi def link i3ConfigBlockKeyword Identifier |
| 255 | hi def link i3ConfigVariable Statement |
| 256 | hi def link i3ConfigArbitraryCommand Type |
| 257 | |
| 258 | let b:current_syntax = "i3config" |