vim-polyglot/syntax/dockerfile.vim

69 lines
2.2 KiB
VimL
Raw Permalink Normal View History

if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'dockerfile') == -1
2018-12-26 14:22:36 -05:00
" Vim syntax file
" Language: Dockerfile
" Maintainer: Eugene Kalinin
" Latest Revision: 11 September 2013
" Source: http://docs.docker.io/en/latest/use/builder/
2013-09-26 06:48:01 -04:00
if exists("b:current_syntax")
2018-12-26 14:22:36 -05:00
finish
2013-09-26 06:48:01 -04:00
endif
2018-12-26 14:22:36 -05:00
" 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
2018-12-26 14:22:36 -05:00
" Strings
syn region dockerfileString start=/"/ skip=/\\"|\\\\/ end=/"/
syn region dockerfileString1 start=/'/ skip=/\\'|\\\\/ end=/'/
2013-09-26 06:48:01 -04:00
2018-12-26 14:22:36 -05:00
" Emails
syn region dockerfileEmail start=/</ end=/>/ contains=@ oneline
2013-09-26 06:48:01 -04:00
2018-12-26 14:22:36 -05:00
" Urls
syn match dockerfileUrl /\(http\|https\|ssh\|hg\|git\)\:\/\/[a-zA-Z0-9\/\-\.]\+/
2013-09-26 06:48:01 -04:00
2018-12-26 14:22:36 -05:00
" 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"
2014-11-10 20:37:21 -05:00
set commentstring=#\ %s
2014-11-10 20:37:21 -05:00
2018-12-26 14:22:36 -05:00
" Enable automatic comment insertion
setlocal fo+=cro
endif