summaryrefslogtreecommitdiff
path: root/contrib/syntax
diff options
context:
space:
mode:
authorTianon Gravi <admwiggin@gmail.com>2015-05-29 13:39:37 -0700
committerTianon Gravi <admwiggin@gmail.com>2015-05-29 13:39:37 -0700
commit62d3b1bf2e830b6cdf7c4df86d356d48b58b1ab0 (patch)
treea5791aa4c4e902cdaca86c51d1565310edc092ed /contrib/syntax
parent4c9fd72a91543bff32241198704f77fa38eaf5c8 (diff)
downloaddocker-62d3b1bf2e830b6cdf7c4df86d356d48b58b1ab0.tar.gz
Add embedded shell script highlight to vim syntax
This highlights `RUN`, `CMD`, and `ENTRYPOINT` lines using shell highlighting. It doesn't bother detecting the JSON forms, but that's OK because JSON arrays highlight pretty reasonably with shell highlights. :) Signed-off-by: Andrew "Tianon" Page <admwiggin@gmail.com>
Diffstat (limited to 'contrib/syntax')
-rw-r--r--contrib/syntax/vim/syntax/dockerfile.vim8
1 files changed, 8 insertions, 0 deletions
diff --git a/contrib/syntax/vim/syntax/dockerfile.vim b/contrib/syntax/vim/syntax/dockerfile.vim
index bd09268664..220a4db3a2 100644
--- a/contrib/syntax/vim/syntax/dockerfile.vim
+++ b/contrib/syntax/vim/syntax/dockerfile.vim
@@ -21,3 +21,11 @@ syntax match dockerfileComment "\v^\s*#.*$"
highlight link dockerfileComment Comment
set commentstring=#\ %s
+
+" match "RUN", "CMD", and "ENTRYPOINT" lines, and parse them as shell
+let s:current_syntax = b:current_syntax
+unlet b:current_syntax
+syntax include @SH syntax/sh.vim
+let b:current_syntax = s:current_syntax
+syntax region shLine matchgroup=dockerfileKeyword start=/\v^\s*(RUN|CMD|ENTRYPOINT)\s/ end=/\v$/ contains=@SH
+" since @SH will handle "\" as part of the same line automatically, this "just works" for line continuation too, but with the caveat that it will highlight "RUN echo '" followed by a newline as if it were a block because the "'" is shell line continuation... not sure how to fix that just yet (TODO)