浏览代码

Merge pull request #13604 from tianon/vim-embedded-shell

Add embedded shell script highlight to vim syntax
Jessie Frazelle 10 年之前
父节点
当前提交
4d9191e15d
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      contrib/syntax/vim/syntax/dockerfile.vim

+ 8 - 0
contrib/syntax/vim/syntax/dockerfile.vim

@@ -21,3 +21,11 @@ syntax match dockerfileComment "\v^\s*#.*$"
 highlight link dockerfileComment Comment
 highlight link dockerfileComment Comment
 
 
 set commentstring=#\ %s
 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)