2015-09-21 15:37:45 +03:00
|
|
|
# Detection
|
|
|
|
# ‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2016-02-25 01:26:54 +03:00
|
|
|
hook global BufCreate .*/?[mM]akefile %{
|
2017-11-03 10:34:41 +03:00
|
|
|
set-option buffer filetype makefile
|
2015-09-21 15:37:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
# Highlighters
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2017-10-28 06:00:51 +03:00
|
|
|
add-highlighter shared/ regions -default content makefile \
|
2015-09-21 15:37:45 +03:00
|
|
|
comment '#' '$' '' \
|
2017-11-03 11:09:45 +03:00
|
|
|
evaluate-commands '\$\(' '\)' '\('
|
2015-09-21 15:37:45 +03:00
|
|
|
|
2017-10-28 06:00:51 +03:00
|
|
|
add-highlighter shared/makefile/comment fill comment
|
2017-11-03 11:09:45 +03:00
|
|
|
add-highlighter shared/makefile/evaluate-commands fill value
|
2015-09-21 15:37:45 +03:00
|
|
|
|
2017-10-28 06:00:51 +03:00
|
|
|
add-highlighter shared/makefile/content regex ^[\w.%-]+\h*:\s 0:variable
|
|
|
|
add-highlighter shared/makefile/content regex [+?:]= 0:operator
|
2015-09-21 15:37:45 +03:00
|
|
|
|
2016-03-14 15:08:51 +03:00
|
|
|
%sh{
|
|
|
|
# Grammar
|
2016-09-24 11:09:42 +03:00
|
|
|
keywords="ifeq|ifneq|ifdef|ifndef|else|endif|define|endef"
|
2016-03-14 15:08:51 +03:00
|
|
|
|
|
|
|
# Add the language's grammar to the static completion list
|
2016-03-25 22:31:01 +03:00
|
|
|
printf %s\\n "hook global WinSetOption filetype=makefile %{
|
2017-11-03 10:34:41 +03:00
|
|
|
set-option window static_words '${keywords}'
|
2016-03-17 16:30:14 +03:00
|
|
|
}" | sed 's,|,:,g'
|
2016-03-14 15:08:51 +03:00
|
|
|
|
|
|
|
# Highlight keywords
|
2017-10-28 06:00:51 +03:00
|
|
|
printf %s "add-highlighter shared/makefile/content regex \b(${keywords})\b 0:keyword"
|
2016-03-14 15:08:51 +03:00
|
|
|
}
|
|
|
|
|
2016-02-25 01:26:54 +03:00
|
|
|
# Commands
|
|
|
|
# ‾‾‾‾‾‾‾‾
|
|
|
|
|
2017-11-03 10:34:41 +03:00
|
|
|
define-command -hidden makefile-indent-on-new-line %{
|
2017-11-03 11:09:45 +03:00
|
|
|
evaluate-commands -draft -itersel %{
|
2016-02-25 01:26:54 +03:00
|
|
|
# preserve previous line indent
|
2017-11-03 11:09:45 +03:00
|
|
|
try %{ execute-keys -draft \;K<a-&> }
|
2016-02-25 01:26:54 +03:00
|
|
|
## If the line above is a target indent with a tab
|
2017-11-03 11:09:45 +03:00
|
|
|
try %{ execute-keys -draft Z k<a-x> <a-k>^[^:]+:\s<ret> z i<tab> }
|
2016-02-25 01:26:54 +03:00
|
|
|
# cleanup trailing white space son previous line
|
2017-11-03 11:09:45 +03:00
|
|
|
try %{ execute-keys -draft k<a-x> s \h+$ <ret>d }
|
2016-09-25 09:19:04 +03:00
|
|
|
# indent after some keywords
|
2017-11-03 11:09:45 +03:00
|
|
|
try %{ execute-keys -draft Z k<a-x> <a-k> ^\h*(ifeq|ifneq|ifdef|ifndef|else|define)\b<ret> z <a-gt> }
|
2016-02-25 01:26:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-21 15:37:45 +03:00
|
|
|
# Initialization
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2017-10-28 06:00:51 +03:00
|
|
|
hook -group makefile-highlight global WinSetOption filetype=makefile %{ add-highlighter window ref makefile }
|
2015-10-25 15:17:36 +03:00
|
|
|
|
2016-09-25 16:15:07 +03:00
|
|
|
hook global WinSetOption filetype=makefile %{
|
2017-01-13 03:56:30 +03:00
|
|
|
hook window InsertChar \n -group makefile-indent makefile-indent-on-new-line
|
2015-10-25 15:17:36 +03:00
|
|
|
}
|
2016-02-25 01:26:54 +03:00
|
|
|
|
2017-10-28 06:00:51 +03:00
|
|
|
hook -group makefile-highlight global WinSetOption filetype=(?!makefile).* %{ remove-highlighter window/makefile }
|
2016-09-28 09:45:01 +03:00
|
|
|
|
2016-02-25 01:26:54 +03:00
|
|
|
hook global WinSetOption filetype=(?!makefile).* %{
|
2017-01-04 03:07:45 +03:00
|
|
|
remove-hooks window makefile-indent
|
2016-02-25 01:26:54 +03:00
|
|
|
}
|