Skip to content

Commit

Permalink
0.5 -> 0.6
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Bentley <mbentley@mbentley.net>
  • Loading branch information
mbentley committed Feb 2, 2020
1 parent 6c5e9aa commit c090dc0
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions syntax/dockerfile.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
" dockerfile.vim - Syntax highlighting for Dockerfiles
" Maintainer: Honza Pokorny <https://honza.ca>
" Version: 0.5
" Version: 0.6
" Last Change: 2019 Aug 16
" License: BSD


if exists("b:current_syntax")
Expand All @@ -12,20 +14,13 @@ let b:current_syntax = "dockerfile"
syntax case ignore

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/
highlight link dockerfileKeyword Keyword

syntax match dockerfileKeyword /\v(AS)/

syntax region dockerfileString start=/\v"/ skip=/\v\\./ end=/\v"/
highlight link dockerfileString String

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)
hi def link dockerfileString String
hi def link dockerfileKeyword Keyword
hi def link dockerfileComment Comment

0 comments on commit c090dc0

Please sign in to comment.