summaryrefslogtreecommitdiffstats
path: root/syntax/dockerfile.vim
diff options
context:
space:
mode:
Diffstat (limited to 'syntax/dockerfile.vim')
-rw-r--r--syntax/dockerfile.vim73
1 files changed, 53 insertions, 20 deletions
diff --git a/syntax/dockerfile.vim b/syntax/dockerfile.vim
index 1c768de7..726240fa 100644
--- a/syntax/dockerfile.vim
+++ b/syntax/dockerfile.vim
@@ -1,35 +1,68 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'dockerfile') == -1
-" dockerfile.vim - Syntax highlighting for Dockerfiles
-" Maintainer: Honza Pokorny <https://honza.ca>
-" Version: 0.5
-
+" Vim syntax file
+" Language: Dockerfile
+" Maintainer: Eugene Kalinin
+" Latest Revision: 11 September 2013
+" Source: http://docs.docker.io/en/latest/use/builder/
if exists("b:current_syntax")
- finish
+ finish
endif
-let b:current_syntax = "dockerfile"
+" case sensitivity (fix #17)
+" syn case ignore
+
+" Keywords
+syn keyword dockerfileKeywords FROM AS MAINTAINER RUN CMD COPY
+syn keyword dockerfileKeywords EXPOSE ADD ENTRYPOINT
+syn keyword dockerfileKeywords VOLUME USER WORKDIR ONBUILD
+syn keyword dockerfileKeywords LABEL ARG HEALTHCHECK SHELL
+
+" Bash statements
+setlocal iskeyword+=-
+syn keyword bashStatement add-apt-repository adduser apk apt-get aptitude apt-key autoconf bundle
+syn keyword bashStatement cd chgrp chmod chown clear complete composer cp curl du echo egrep
+syn keyword bashStatement expr fgrep find gem gnufind gnugrep gpg grep groupadd head less ln
+syn keyword bashStatement ls make mkdir mv node npm pacman pip pip3 php python rails rm rmdir rpm ruby
+syn keyword bashStatement sed sleep sort strip tar tail tailf touch useradd virtualenv yum
+syn keyword bashStatement usermod bash cat a2ensite a2dissite a2enmod a2dismod apache2ctl
+syn keyword bashStatement wget gzip
-syntax case ignore
+" Strings
+syn region dockerfileString start=/"/ skip=/\\"|\\\\/ end=/"/
+syn region dockerfileString1 start=/'/ skip=/\\'|\\\\/ end=/'/
-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
+" Emails
+syn region dockerfileEmail start=/</ end=/>/ contains=@ oneline
-syntax region dockerfileString start=/\v"/ skip=/\v\\./ end=/\v"/
-highlight link dockerfileString String
+" Urls
+syn match dockerfileUrl /\(http\|https\|ssh\|hg\|git\)\:\/\/[a-zA-Z0-9\/\-\.]\+/
-syntax match dockerfileComment "\v^\s*#.*$"
-highlight link dockerfileComment Comment
+" Task tags
+syn keyword dockerfileTodo contained TODO FIXME XXX
+
+" Comments
+syn region dockerfileComment start="#" end="\n" contains=dockerfileTodo
+syn region dockerfileEnvWithComment start="^\s*ENV\>" end="\n" contains=dockerfileEnv
+syn match dockerfileEnv contained /\<ENV\>/
+
+" Highlighting
+hi link dockerfileKeywords Keyword
+hi link dockerfileEnv Keyword
+hi link dockerfileString String
+hi link dockerfileString1 String
+hi link dockerfileComment Comment
+hi link dockerfileEmail Identifier
+hi link dockerfileUrl Identifier
+hi link dockerfileTodo Todo
+hi link bashStatement Function
+
+let b:current_syntax = "dockerfile"
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)
+" Enable automatic comment insertion
+setlocal fo+=cro
endif