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