2015-09-21 14:37:45 +02:00
|
|
|
# Detection
|
|
|
|
# ‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
hook global BufSetOption mimetype=text/x-makefile %{
|
|
|
|
set buffer filetype makefile
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
addhl -group / regions -default content makefile \
|
|
|
|
comment '#' '$' '' \
|
|
|
|
eval '\$\(' '\)' '\('
|
|
|
|
|
|
|
|
addhl -group /makefile/comment fill comment
|
|
|
|
addhl -group /makefile/eval fill value
|
|
|
|
|
|
|
|
addhl -group /makefile/content regex ^[\w.%]+\h*:\s 0:identifier
|
|
|
|
addhl -group /makefile/content regex [+?:]= 0:operator
|
|
|
|
|
2016-03-14 13:08:51 +01:00
|
|
|
%sh{
|
|
|
|
# Grammar
|
2016-03-14 17:29:11 +01:00
|
|
|
keywords="ifeq|ifneq|else|endif"
|
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
|
2016-03-17 14:30:14 +01:00
|
|
|
printf %s "addhl -group /makefile/content regex \<(${keywords})\> 0:keyword"
|
2016-03-14 13:08:51 +01:00
|
|
|
}
|
|
|
|
|
2016-02-24 23:26:54 +01:00
|
|
|
# Commands
|
|
|
|
# ‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
def -hidden _makefile-indent-on-new-line %{
|
|
|
|
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 }
|
|
|
|
# indent after ifeq, ifneq, else
|
|
|
|
try %{ exec -draft Z k<a-x> <a-k> ^\h*(ifeq|ifneq|else)\b<ret> z <a-gt> }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-21 14:37:45 +02:00
|
|
|
# Initialization
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
2015-10-25 13:17:36 +01:00
|
|
|
hook global WinSetOption filetype=makefile %{
|
|
|
|
addhl ref makefile
|
|
|
|
|
2016-02-24 23:26:54 +01:00
|
|
|
hook window InsertChar \n -group makefile-indent _makefile-indent-on-new-line
|
|
|
|
|
2015-10-25 13:17:36 +01:00
|
|
|
set window comment_selection_chars ""
|
|
|
|
set window comment_line_chars "#"
|
|
|
|
}
|
2016-02-24 23:26:54 +01:00
|
|
|
|
|
|
|
hook global WinSetOption filetype=(?!makefile).* %{
|
|
|
|
rmhl makefile
|
|
|
|
rmhooks window makefile-indent
|
|
|
|
}
|