# Detection hook global BufCreate .*\.fidl %{ set-option buffer filetype fidl } hook global WinSetOption filetype=fidl %< require-module fidl hook window ModeChange pop:insert:.* -group fidl-trim-indent fidl-trim-indent hook window InsertChar \n -group fidl-indent fidl-indent-on-new-line hook window InsertChar [)}] -group fidl-indent fidl-indent-on-closing hook -once -always window WinSetOption filetype=.* %{ remove-hooks window fidl-.+ } > hook -group fidl-highlight global WinSetOption filetype=fidl %{ add-highlighter window/fidl ref fidl hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/fidl } } provide-module fidl %§ # Highlighters add-highlighter shared/fidl regions add-highlighter shared/fidl/code default-region group add-highlighter shared/fidl/string region \" (? s \h+$ d } } define-command -hidden fidl-indent-on-new-line %~ evaluate-commands -draft -itersel %@ try %{ # line comment # copy the commenting prefix execute-keys -draft k s ^\h*/{2,}\h* yjghP } catch %` # preserve previous line indent try %{ execute-keys -draft K } # align to opening ( or { if possible try %+ execute-keys -draft [)}] m 1 + catch %+ # indent after lines ending with ( or { try %! execute-keys -draft k [({]$ j ! + ` # remove trailing white spaces try %{ execute-keys -draft k : fidl-trim-indent } @ ~ define-command -hidden fidl-indent-on-closing %~ evaluate-commands -draft -itersel %@ # align to opening ( or { when alone on a line try %< execute-keys -draft ^\h*[)}]$ m 1 > @ ~ §