rc: Simplify Dockerfile support, highlight values and additional keywords

This commit is contained in:
Frank LENORMAND 2017-11-04 10:45:58 +03:00
parent 9b216e0e79
commit ff557a0cf0

View File

@ -6,33 +6,40 @@
# Detection # Detection
# ‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*Dockerfile %{ hook global BufCreate .*/?Dockerfile(\.\w+)?$ %{
set-option buffer filetype dockerfile set-option buffer filetype dockerfile
} }
# Highlighters # Highlighters
# ‾‾‾‾‾‾‾‾‾‾‾‾ # ‾‾‾‾‾‾‾‾‾‾‾‾
add-highlighter shared/ regions dockerfile \ add-highlighter shared/ regions -default code dockerfile \
instruction '^(?i)(ONBUILD\h+)?(FROM|MAINTAINER|RUN|CMD|LABEL|EXPOSE|ENV|ADD|COPY|ENTRYPOINT|VOLUME|USER|WORKDIR)' '$' '' \
comment '#' '$' ''
add-highlighter shared/dockerfile/instruction regex '^(?i)(ONBUILD\h+)?(FROM|MAINTAINER|RUN|CMD|LABEL|EXPOSE|ENV|ADD|COPY|ENTRYPOINT|VOLUME|USER|WORKDIR)' 0:keyword
add-highlighter shared/dockerfile/instruction regions regions \
plain '^(?i)(ONBUILD\h+)?(LABEL|ENV)' '$' '' \
json '^(?i)(ONBUILD\h+)?(RUN|CMD|ADD|COPY|ENTRYPOINT|VOLUME)\h+\[' \] \[ \
sh '^(?i)(ONBUILD\h+)?(RUN|CMD|ENTRYPOINT)\h+([A-Z/a-z])+' '$' ''
add-highlighter shared/dockerfile/instruction/regions/plain regions regions \
string '"' '(?<!\\)(\\\\)*"' '' \ string '"' '(?<!\\)(\\\\)*"' '' \
string "'" "'" '' string "'" "'" '' \
comment '#' $ ''
add-highlighter shared/dockerfile/instruction/regions/plain/regions/string fill string %sh{
set -x
# Grammar
keywords="ADD|ARG|CMD|COPY|ENTRYPOINT|ENV|EXPOSE|FROM|HEALTHCHECK|LABEL"
keywords="${keywords}|MAINTAINER|RUN|SHELL|STOPSIGNAL|USER|VOLUME|WORKDIR"
add-highlighter shared/dockerfile/instruction/regions/json ref json # Add the language's grammar to the static completion list
add-highlighter shared/dockerfile/instruction/regions/sh ref sh printf %s\\n "hook global WinSetOption filetype=dockerfile %{
set window static_words 'ONBUILD|${keywords}'
}" | sed 's,|,:,g'
# Highlight keywords
printf %s "
add-highlighter shared/dockerfile/code regex '^(?i)(ONBUILD\h+)?(${keywords})\b' 2:keyword
add-highlighter shared/dockerfile/code regex '^(?i)(ONBUILD)\h+' 1:keyword
"
}
add-highlighter shared/dockerfile/code regex '\$\{[\w_]+\}' 0:value
add-highlighter shared/dockerfile/code regex '\$[\w_]+' 0:value
add-highlighter shared/dockerfile/string fill string
add-highlighter shared/dockerfile/comment fill comment add-highlighter shared/dockerfile/comment fill comment
# Initialization # Initialization