neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

swayconfig.vim (14931B)


      1 " Vim syntax file
      2 " Language: sway config file
      3 " Original Author: Josef Litos (litoj/i3config.vim)
      4 " Maintainer: James Eapen <james.eapen@vai.org>
      5 " Version: 1.2.7
      6 " Last Change: 2025-12-02
      7 
      8 " References:
      9 " http://i3wm.org/docs/userguide.html#configuring
     10 " https://github.com/swaywm/sway/blob/b69d637f7a34e239e48a4267ae94a5e7087b5834/sway/sway.5.scd
     11 " http://vimdoc.sourceforge.net/htmldoc/syntax.html
     12 "
     13 "
     14 " Quit when a syntax file was already loaded
     15 if exists("b:current_syntax")
     16  finish
     17 endif
     18 
     19 " before i3 load to give i3ConfigKeyword lower priority
     20 syn cluster i3ConfigCommand contains=i3ConfigCommand,i3ConfigAction,i3ConfigActionKeyword,@i3ConfigValue,i3ConfigColor,i3ConfigKeyword
     21 
     22 runtime! syntax/i3config.vim
     23 
     24 " In sway, popup_during_fullscreen does not have options like all option.
     25 syn cluster i3ConfigPopupFullscreenOpts remove=i3ConfigPopupFullscreenOptsExtra
     26 
     27 " Sway extensions to i3
     28 syn keyword i3ConfigActionKeyword opacity urgent shortcuts_inhibitor splitv splith splitt contained contained skipwhite nextgroup=i3ConfigOption
     29 syn keyword i3ConfigOption set plus minus allow deny csd v h t contained contained skipwhite nextgroup=i3ConfigOption,@i3ConfigValue
     30 
     31 syn keyword i3ConfigConditionProp app_id pid shell contained
     32 
     33 syn keyword i3ConfigWorkspaceDir prev_on_output next_on_output contained
     34 
     35 syn match i3ConfigBindArgument /--\(locked\|to-code\|no-repeat\|input-device=[^ '"]*\|no-warn\|inhibited\) / contained contains=i3ConfigShOper,@i3ConfigStrVar nextgroup=i3ConfigBindArgument,i3ConfigBindCombo
     36 syn region i3ConfigBindArgument start=/--input-device=['"]/ end=/\s/ contained contains=@i3ConfigIdent,i3ConfigShOper,i3ConfigString nextgroup=i3ConfigBindArgument,i3ConfigBindCombo
     37 
     38 syn region i3ConfigBindCombo matchgroup=i3ConfigParen start=/{$/ end=/^\s*}$/ contained contains=i3ConfigBindArgument,i3ConfigBindCombo,i3ConfigComment fold keepend extend
     39 " hack for blocks with start outside parsing range
     40 syn region swayConfigBlockOrphan start=/^\s\+\(--[a-z-]\+ \)*\([$A-Z][$0-9A-Za-z_+]\+\|[a-z]\) [a-z[]/ skip=/\\$\|$\n^\s*}$/ end=/$/ contains=i3ConfigBindArgument,i3ConfigBindCombo,i3ConfigParen keepend extend
     41 
     42 " Note: braces highlighted by @i3ConfigSh already
     43 syn region i3ConfigExec start=/ {$/ end=/^\s*}$/ contained contains=i3ConfigExecAction,@i3ConfigSh,i3ConfigComment fold keepend extend
     44 
     45 syn keyword swayConfigFloatingModifierOpts normal inverse none contained
     46 syn match i3ConfigKeyword /floating_modifier \(none\|[$A-Z][0-9A-Za-z]\+ \(normal\|inverse\)\)$/ contained contains=i3ConfigVariable,i3ConfigBindModkey,swayConfigFloatingModifierOpts
     47 
     48 syn match swayConfigI3Param /--i3/ contains=i3ConfigShParam skipwhite nextgroup=i3ConfigEdgeOpts
     49 syn keyword i3ConfigKeyword hide_edge_borders contained skipwhite nextgroup=swayConfigI3Param,i3ConfigEdgeOpts
     50 
     51 " accept bar ids in the form: bar <id> { ... }
     52 syn match swayConfigBarIdent /[^{ ,;]\+/ contained contains=@i3ConfigStrVar skipwhite nextgroup=i3ConfigBarBlock
     53 syn keyword i3ConfigKeyword bar contained skipwhite nextgroup=swayConfigBarIdent,i3ConfigBarBlock
     54 
     55 syn keyword i3ConfigBarOpts swaybar_command contained skipwhite nextgroup=@i3ConfigSh
     56 syn region i3ConfigBarOpts matchgroup=i3ConfigBarOpts start=/gaps/ end=/$/ contained contains=@i3ConfigNumVar
     57 syn keyword i3ConfigBarOpts height pango_markup status_edge_padding status_padding wrap_scroll tray_bindcode tray_bindsym icon_theme contained skipwhite nextgroup=i3ConfigBarOptVals,@i3ConfigValue,i3ConfigShOper
     58 syn keyword i3ConfigBarOptVals overlay contained
     59 
     60 syn keyword i3ConfigExecActionKeyword swaymsg contained
     61 
     62 " Sway-only options
     63 " Xwayland
     64 syn keyword swayConfigXOpt enable disable force contained
     65 syn keyword i3ConfigKeyword xwayland contained skipwhite nextgroup=swayConfigXOpt
     66 
     67 " Inhibit idle
     68 syn keyword swayConfigInhibitOpts focus fullscreen open none visible contained
     69 syn keyword i3ConfigActionKeyword inhibit_idle contained skipwhite nextgroup=swayConfigInhibitOpts
     70 
     71 " Primary selection
     72 syn keyword i3ConfigKeyword primary_selection contained skipwhite nextgroup=i3ConfigBoolean
     73 
     74 " Swaybg command
     75 " Swaynag command
     76 syn keyword i3ConfigKeyword swaybg_command swaynag_command contained nextgroup=i3ConfigExec
     77 
     78 " Bindswitch
     79 syn match swayConfigBindswitchArgument /--\(locked\|no-warn\|reload\) / contained nextgroup=swayConfigBindswitchArgument,swayConfigBindswitchType
     80 syn keyword swayConfigBindswitchType lid tablet contained nextgroup=swayConfigBindswitchCombo
     81 syn keyword swayConfigBindswitchState toggle contained
     82 syn match swayConfigBindswitchCombo /:\(on\|off\|toggle\) / contained contains=i3ConfigColonOperator,swayConfigBindswitchState,i3ConfigBoolean nextgroup=i3ConfigBind
     83 syn region swayConfigBindswitchType matchgroup=i3ConfigParen start=/{$/ end=/^\s*}$/ contained contains=swayConfigBindswitchArgument,swayConfigBindswitchType,i3ConfigComment fold keepend extend
     84 syn keyword i3ConfigBindKeyword bindswitch contained skipwhite nextgroup=swayConfigBindswitchArgument,swayConfigBindswitchType
     85 " hack for blocks with start outside parsing range
     86 syn region swayConfigBlockOrphan start=/^\s\+\(lid\|tablet\):/ skip=/\\$\|$\n^\s*}$/ end=/$/ contains=swayConfigBindswitchArgument,swayConfigBindswitchType,i3ConfigParen keepend extend
     87 
     88 " Bindgesture
     89 syn match swayConfigBindgestureArgument /--\(exact\|input-device=[:0-9A-Za-z_/-]\+\|no-warn\) / contained nextgroup=swayConfigBindgestureArgument,swayConfigBindgestureCombo
     90 syn keyword swayConfigBindgestureType hold swipe pinch contained
     91 syn keyword swayConfigBindgestureDir up down left right inward outward clockwise counterclockwise contained
     92 syn match swayConfigBindgestureCombo /\(hold\(:[1-5]\)\?\|swipe\(:[3-5]\)\?\(:up\|:down\|:left\|:right\)\?\|pinch\(:[2-5]\)\?:\(+\?\(inward\|outward\|clockwise\|counterclockwise\|up\|down\|left\|right\)\)\+\) / contained contains=i3ConfigNumber,swayConfigBindgestureType,i3ConfigColonOperator,swayConfigBindgestureDir,i3ConfigBindModifier nextgroup=swayConfigBindgestureCombo,i3ConfigBind
     93 syn region swayConfigBindgestureCombo matchgroup=i3ConfigParen start=/{$/ end=/^\s*}$/ contained contains=swayConfigBindgestureArgument,swayConfigBindgestureCombo,i3ConfigComment fold keepend extend
     94 syn keyword i3ConfigBindKeyword bindgesture contained skipwhite nextgroup=swayConfigBindgestureArgument,swayConfigBindgestureCombo
     95 " hack for blocks with start outside parsing range
     96 syn region swayConfigBlockOrphan start=/^\s\+\(--[a-z-]\+ \)*\(hold\|swipe\|pinch\):/ skip=/\\$\|$\n^\s*}$/ end=/$/ contains=swayConfigBindgestureArgument,swayConfigBindgestureCombo,i3ConfigParen keepend extend
     97 
     98 " Tiling drag threshold
     99 " Titlebar commands
    100 syn keyword i3ConfigKeyword tiling_drag_threshold titlebar_border_thickness contained skipwhite nextgroup=@i3ConfigNumVar
    101 syn match i3ConfigKeyword /titlebar_padding \(\d\+\|\$\S\+\)\( \d\+\)\?$/ contained contains=@i3ConfigNumVar
    102 
    103 syn match swayConfigDeviceOper /[*:;!]/ contained
    104 
    105 " Input devices
    106 syn keyword swayConfigInputOpts xkb_variant xkb_rules xkb_switch_layout xkb_numlock xkb_file xkb_capslock xkb_model repeat_delay repeat_rate map_to_output map_to_region map_from_region tool_mode accel_profile dwt dwtp drag_lock drag click_method clickfinger_button_map middle_emulation tap events calibration_matrix natural_scroll left_handed pointer_accel scroll_button scroll_button_lock scroll_factor scroll_method tap_button_map contained skipwhite nextgroup=swayConfigInputOptVals,@i3ConfigValue
    107 syn keyword swayConfigInputOptVals absolute relative adaptive flat none button_areas clickfinger toggle two_finger edge on_button_down lrm lmr next prev pen eraser brush pencil airbrush disabled_on_external_mouse disable enable contained skipwhite nextgroup=swayConfigInputOpts,@i3ConfigValue,swayConfigDeviceOper
    108 syn match swayConfigDeviceOper /,/ contained nextgroup=swayConfigXkbOptsPair,swayConfigXkbLayout
    109 syn match swayConfigXkbLayout /[a-z]\+/ contained nextgroup=swayConfigDeviceOper
    110 syn keyword swayConfigInputOpts xkb_layout contained skipwhite nextgroup=swayConfigXkbLayout
    111 syn match swayConfigXkbOptsPairVal /[0-9a-z_-]\+/ contained contains=i3ConfigNumber skipwhite nextgroup=swayConfigDeviceOper,swayConfigInputOpts
    112 syn match swayConfigXkbOptsPair /[a-z]\+:/ contained contains=i3ConfigColonOperator nextgroup=swayConfigXkbOptsPairVal
    113 syn keyword swayConfigInputOpts xkb_options contained skipwhite nextgroup=swayConfigXkbOptsPair
    114 syn match swayConfigInputAngle /\(3[0-5][0-9]\|[1-2]\?[0-9]\{1,2\}\)\(\.[0-9]\+\)\?/ skipwhite nextgroup=swayConfigInputOpts
    115 syn keyword swayConfigInputOpts rotation_angle contained skipwhite nextgroup=swayConfigInputAngle
    116 
    117 syn region swayConfigInput start=/\s/ skip=/\\$/ end=/\ze[,;]\|$/ contained contains=swayConfigInputOpts,@i3ConfigValue keepend
    118 syn region swayConfigInput matchgroup=i3ConfigParen start=/ {$/ end=/^\s*}$/ contained contains=swayConfigInputOpts,@i3ConfigValue,i3ConfigComment keepend
    119 syn keyword swayConfigInputType touchpad pointer keyboard touch tablet_tool tablet_pad switch contained skipwhite nextgroup=swayConfigInput
    120 syn match swayConfigInputTypeIdent /type:!\?/ contained contains=swayConfigDeviceOper skipwhite nextgroup=swayConfigInputType
    121 syn match swayConfigInputIdent /[^t ,;][^ ,;]*/ contained contains=@i3ConfigStrVar skipwhite nextgroup=swayConfigInput extend
    122 syn keyword i3ConfigKeyword input contained skipwhite nextgroup=swayConfigInputTypeIdent,swayConfigInputIdent
    123 
    124 " Seat
    125 syn keyword swayConfigSeatOpts cursor fallback hide_cursor keyboard_grouping shortcuts_inhibitor pointer_constraint xcursor_theme contained skipwhite nextgroup=swayConfigSeatOptVals,@i3ConfigValue
    126 syn match swayConfigInputTypeSeq / \w\+/ contained contains=swayConfigInputType skipwhite nextgroup=swayConfigInputTypeSeq,swayConfigSeatOpts
    127 syn keyword swayConfigSeatOpts idle_inhibit idle_wake contained nextgroup=swayConfigInputTypeSeq
    128 syn keyword swayConfigSeatOpts attach contained skipwhite nextgroup=swayConfigSeatIdent
    129 syn match swayConfigSeatOptVals /when-typing/ contained skipwhite nextgroup=swayConfigSeatOptVals
    130 syn keyword swayConfigSeatOptVals move set press release none smart activate deactivate toggle escape enable disable contained skipwhite nextgroup=swayConfigSeatOpts
    131 syn region swayConfigSeat start=/\s/ skip=/\\$/ end=/\ze[,;]\|$/ contained contains=swayConfigSeatOpts,@i3ConfigValue keepend
    132 syn region swayConfigSeat matchgroup=i3ConfigParen start=/ {$/ end=/^\s*}$/ contained contains=swayConfigSeatOpts,@i3ConfigValue,i3ConfigComment keepend
    133 syn match swayConfigSeatIdent /[^ ,;]\+/ contained contains=@i3ConfigStrVar nextgroup=swayConfigSeat extend
    134 syn keyword i3ConfigKeyword seat contained skipwhite nextgroup=swayConfigSeatIdent
    135 
    136 " Output monitors
    137 syn keyword swayConfigOutputOpts mode resolution res modeline position pos scale scale_filter subpixel transform disable enable toggle power dpms max_render_time adaptive_sync render_bit_depth color_profile allow_tearing contained skipwhite nextgroup=swayConfigOutputOptVals,@i3ConfigValue,swayConfigOutputMode
    138 syn keyword swayConfigOutputOptVals linear nearest smart rgb bgr vrgb vbgr none toggle srgb contained skipwhite nextgroup=swayConfigOutputOptVals,@i3ConfigValue
    139 syn keyword swayConfigOutputBgVals solid_color fill stretch fit center tile contained skipwhite nextgroup=@i3ConfigColVar
    140 syn match swayConfigOutputBg /[#$]\S\+ solid_color/ contained contains=@i3ConfigColVar,swayConfigOutputBgVals skipwhite nextgroup=swayConfigOutputOpts
    141 syn match swayConfigOutputBg /[^b# ,;][^ ,;]*/ contained contains=@i3ConfigStrVar skipwhite nextgroup=swayConfigOutputBgVals extend
    142 syn keyword swayConfigOutputOpts bg background contained skipwhite nextgroup=swayConfigOutputBg
    143 syn match swayConfigOutputFPS /@[0-9.]\+Hz/ contained skipwhite nextgroup=swayConfigOutputOpts
    144 syn match swayConfigOutputMode /\(--custom \)\?[0-9]\+x[0-9]\+/ contained contains=i3ConfigShParam skipwhite nextgroup=swayConfigOutputFPS,swayConfigOutputOpts
    145 " clockwise and anticlockwise are relative -> only as bindings / user actions - not in config setup
    146 syn match swayConfigOutputOptVals /\(\(flipped-\)\?\(90\|180\|270\)\|flipped\|normal\)\( \(anti\)\?clockwise\)\?/ contained contains=i3ConfigNumber skipwhite nextgroup=swayConfigOutputOpts
    147 syn match swayConfigOutputICCPath /\S\+/ contained contains=@i3ConfigStrVar skipwhite nextgroup=swayConfigOutputOpts extend
    148 syn keyword swayConfigOutputOptVals icc contained skipwhite nextgroup=swayConfigOutputICCPath
    149 syn region swayConfigOutput start=/\s/ skip=/\\$/ end=/\ze[,;]\|$/ contained contains=swayConfigOutputOpts,@i3ConfigValue keepend
    150 syn region swayConfigOutput matchgroup=i3ConfigParen start=/ {$/ end=/^\s*}$/ contained contains=swayConfigOutputOpts,@i3ConfigValue,i3ConfigComment keepend
    151 syn match swayConfigOutputIdent /[^ ,;]\+/ contained contains=@i3ConfigIdent skipwhite nextgroup=swayConfigOutput extend
    152 syn keyword i3ConfigKeyword output contained skipwhite nextgroup=swayConfigOutputIdent
    153 syn keyword i3ConfigActionKeyword output contained skipwhite nextgroup=swayConfigOutputIdent
    154 
    155 " Define the highlighting.
    156 hi def link swayConfigFloatingModifierOpts   i3ConfigOption
    157 hi def link swayConfigBarIdent               i3ConfigIdent
    158 hi def link swayConfigXOpt                   i3ConfigOption
    159 hi def link swayConfigInhibitOpts            i3ConfigOption
    160 hi def link swayConfigBindswitchArgument     i3ConfigBindArgument
    161 hi def link swayConfigBindswitchType         i3ConfigMoveType
    162 hi def link swayConfigBindswitchState        i3ConfigMoveDir
    163 hi def link swayConfigBindgestureArgument    i3ConfigBindArgument
    164 hi def link swayConfigBindgestureType        i3ConfigMoveType
    165 hi def link swayConfigBindgestureDir         i3ConfigMoveDir
    166 hi def link swayConfigDeviceOper             i3ConfigOperator
    167 hi def link swayConfigInputType              i3ConfigMoveType
    168 hi def link swayConfigInputTypeIdent         i3ConfigMoveDir
    169 hi def link swayConfigInputIdent             i3ConfigIdent
    170 hi def link swayConfigInputOptVals           i3ConfigShParam
    171 hi def link swayConfigInputOpts              i3ConfigOption
    172 hi def link swayConfigInputAngle             i3ConfigNumber
    173 hi def link swayConfigXkbOptsPairVal         i3ConfigParamLine
    174 hi def link swayConfigXkbOptsPair            i3ConfigShParam
    175 hi def link swayConfigXkbLayout              i3ConfigParamLine
    176 hi def link swayConfigSeatOptVals            swayConfigInputOptVals
    177 hi def link swayConfigSeatOpts               swayConfigInputOpts
    178 hi def link swayConfigSeatIdent              i3ConfigIdent
    179 hi def link swayConfigOutputOptVals          swayConfigInputOptVals
    180 hi def link swayConfigOutputBgVals           swayConfigInputOptVals
    181 hi def link swayConfigOutputBg               i3ConfigString
    182 hi def link swayConfigOutputICCPath          i3ConfigString
    183 hi def link swayConfigOutputOpts             swayConfigInputOpts
    184 hi def link swayConfigOutputFPS              Constant
    185 hi def link swayConfigOutputMode             i3ConfigNumber
    186 hi def link swayConfigOutputIdent            i3ConfigIdent
    187 
    188 let b:current_syntax = "swayconfig"