2015-07-18 17:05:45 -04:00
if ! exists ( 'g:polyglot_disabled' ) | | index ( g :polyglot_disabled , 'dockerfile' ) = = -1
2013-09-26 06:48:01 -04:00
" dockerfile.vim - Syntax highlighting for Dockerfiles
2017-03-23 06:30:58 -04:00
" Maintainer: Honza Pokorny <https://honza.ca>
2013-09-26 06:48:01 -04:00
" Version: 0.5
if exists ( "b:current_syntax" )
finish
endif
2017-03-23 06:30:58 -04:00
let b :current_syntax = "dockerfile"
2013-09-26 06:48:01 -04:00
syntax case ignore
2017-03-23 06:30:58 -04:00
syntax match dockerfileKeyword /\v^\s*(ONBUILD\s+)?(ADD|ARG|CMD|COPY|ENTRYPOINT|ENV|EXPOSE|FROM|HEALTHCHECK|LABEL|MAINTAINER|RUN|SHELL|STOPSIGNAL|USER|VOLUME|WORKDIR)\s/
2013-09-26 06:48:01 -04:00
highlight link dockerfileKeyword Keyword
syntax region dockerfileString start = /\v"/ skip = /\v\\./ end = /\v"/
highlight link dockerfileString String
syntax match dockerfileComment "\v^\s*#.*$"
highlight link dockerfileComment Comment
2014-11-10 20:37:21 -05:00
2017-03-23 06:30:58 -04:00
set commentstring = #\ %s
2014-11-10 20:37:21 -05:00
2017-03-23 06:30:58 -04:00
" 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)
2015-07-18 17:05:45 -04:00
endif