# Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*(/?[mM]akefile|\.mk|\.make) %{ set-option buffer filetype makefile } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=makefile %{ require-module makefile set-option window static_words %opt{makefile_static_words} hook window ModeChange pop:insert:.* -group makefile-trim-indent makefile-trim-indent hook window InsertChar \n -group makefile-indent makefile-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window makefile-.+ } } hook -group makefile-highlight global WinSetOption filetype=makefile %{ add-highlighter window/makefile ref makefile hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/makefile } } provide-module makefile %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/makefile regions add-highlighter shared/makefile/content default-region group add-highlighter shared/makefile/comment region (? # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } } define-command -hidden makefile-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve previous line indent try %{ execute-keys -draft K } ## If the line above is a target indent with a tab try %{ execute-keys -draft Z k ^\S.*?(::|:|!)\s z i } # cleanup trailing white space son previous line try %{ execute-keys -draft k s \h+$ d } # indent after some keywords try %{ execute-keys -draft Z k ^\h*(ifeq|ifneq|ifdef|ifndef|else|define)\b z } } } }