codekingpro/portable-devtools
115k
1" dockerfile.vim - Syntax highlighting for Dockerfiles2" Maintainer: Honza Pokorny <https://honza.ca>3" Last Change: 2024 Dec 204" License: BSD5 6" https://docs.docker.com/engine/reference/builder/7 8if exists("b:current_syntax")9 finish10endif11 12syntax include @JSON syntax/json.vim13unlet b:current_syntax14 15syntax include @Shell syntax/sh.vim16unlet b:current_syntax17 18syntax case ignore19syntax match dockerfileLinePrefix /\v^\s*(ONBUILD\s+)?\ze\S/ contains=dockerfileKeyword nextgroup=dockerfileInstruction skipwhite20syntax region dockerfileFrom matchgroup=dockerfileKeyword start=/\v^\s*(FROM)\ze(\s|$)/ skip=/\v\\\_./ end=/\v((^|\s)AS(\s|$)|$)/ contains=dockerfileOption21 22syntax keyword dockerfileKeyword contained ADD ARG CMD COPY ENTRYPOINT ENV EXPOSE HEALTHCHECK LABEL MAINTAINER ONBUILD RUN SHELL STOPSIGNAL USER VOLUME WORKDIR23syntax match dockerfileOption contained /\v(^|\s)\zs--\S+/24 25syntax match dockerfileInstruction contained /\v<(\S+)>(\s+--\S+)*/ contains=dockerfileKeyword,dockerfileOption skipwhite nextgroup=dockerfileValue26syntax match dockerfileInstruction contained /\v<(ADD|COPY)>(\s+--\S+)*/ contains=dockerfileKeyword,dockerfileOption skipwhite nextgroup=dockerfileJSON27syntax match dockerfileInstruction contained /\v<(HEALTHCHECK)>(\s+--\S+)*/ contains=dockerfileKeyword,dockerfileOption skipwhite nextgroup=dockerfileInstruction28syntax match dockerfileInstruction contained /\v<(CMD|ENTRYPOINT|RUN)>/ contains=dockerfileKeyword skipwhite nextgroup=dockerfileShell29syntax match dockerfileInstruction contained /\v<(CMD|ENTRYPOINT|RUN)>\ze\s+\[/ contains=dockerfileKeyword skipwhite nextgroup=dockerfileJSON30syntax match dockerfileInstruction contained /\v<(SHELL|VOLUME)>/ contains=dockerfileKeyword skipwhite nextgroup=dockerfileJSON31 32syntax region dockerfileString contained start=/\v"/ skip=/\v\\./ end=/\v"/33syntax region dockerfileJSON contained keepend start=/\v\[/ skip=/\v\\\_./ end=/\v$/ contains=@JSON34syntax region dockerfileShell contained keepend start=/\v/ skip=/\v\\\_./ end=/\v$/ contains=@Shell35syntax region dockerfileValue contained keepend start=/\v/ skip=/\v\\\_./ end=/\v$/ contains=dockerfileString36 37syntax region dockerfileComment start=/\v^\s*#/ end=/\v$/ contains=@Spell38 39hi def link dockerfileString String40hi def link dockerfileKeyword Keyword41hi def link dockerfileComment Comment42hi def link dockerfileOption Special43 44let b:current_syntax = "dockerfile"45 