1
0
Fork 0
mirror of https://github.com/vim/vim synced 2025-03-22 17:55:10 +01:00
vim/runtime/syntax/dockerfile.vim

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

45 lines
2.4 KiB
VimL
Raw Normal View History

2014-08-29 15:12:19 +02:00
" dockerfile.vim - Syntax highlighting for Dockerfiles
2016-08-12 22:54:35 +02:00
" Maintainer: Honza Pokorny <https://honza.ca>
" Last Change: 2024 Dec 20
2014-08-29 15:12:19 +02:00
" License: BSD
2020-02-04 22:53:05 +01:00
" https://docs.docker.com/engine/reference/builder/
2014-08-29 15:12:19 +02:00
if exists("b:current_syntax")
finish
endif
2020-02-04 22:53:05 +01:00
syntax include @JSON syntax/json.vim
unlet b:current_syntax
syntax include @Shell syntax/sh.vim
unlet b:current_syntax
2014-08-29 15:12:19 +02:00
syntax case ignore
2020-02-04 22:53:05 +01:00
syntax match dockerfileLinePrefix /\v^\s*(ONBUILD\s+)?\ze\S/ contains=dockerfileKeyword nextgroup=dockerfileInstruction skipwhite
syntax region dockerfileFrom matchgroup=dockerfileKeyword start=/\v^\s*(FROM)\ze(\s|$)/ skip=/\v\\\_./ end=/\v((^|\s)AS(\s|$)|$)/ contains=dockerfileOption
2014-08-29 15:12:19 +02:00
2020-02-04 22:53:05 +01:00
syntax keyword dockerfileKeyword contained ADD ARG CMD COPY ENTRYPOINT ENV EXPOSE HEALTHCHECK LABEL MAINTAINER ONBUILD RUN SHELL STOPSIGNAL USER VOLUME WORKDIR
syntax match dockerfileOption contained /\v(^|\s)\zs--\S+/
2014-08-29 15:12:19 +02:00
2020-02-15 21:41:42 +01:00
syntax match dockerfileInstruction contained /\v<(\S+)>(\s+--\S+)*/ contains=dockerfileKeyword,dockerfileOption skipwhite nextgroup=dockerfileValue
syntax match dockerfileInstruction contained /\v<(ADD|COPY)>(\s+--\S+)*/ contains=dockerfileKeyword,dockerfileOption skipwhite nextgroup=dockerfileJSON
syntax match dockerfileInstruction contained /\v<(HEALTHCHECK)>(\s+--\S+)*/ contains=dockerfileKeyword,dockerfileOption skipwhite nextgroup=dockerfileInstruction
syntax match dockerfileInstruction contained /\v<(CMD|ENTRYPOINT|RUN)>/ contains=dockerfileKeyword skipwhite nextgroup=dockerfileShell
syntax match dockerfileInstruction contained /\v<(CMD|ENTRYPOINT|RUN)>\ze\s+\[/ contains=dockerfileKeyword skipwhite nextgroup=dockerfileJSON
syntax match dockerfileInstruction contained /\v<(SHELL|VOLUME)>/ contains=dockerfileKeyword skipwhite nextgroup=dockerfileJSON
2019-08-17 20:09:31 +02:00
2020-02-04 22:53:05 +01:00
syntax region dockerfileString contained start=/\v"/ skip=/\v\\./ end=/\v"/
syntax region dockerfileJSON contained keepend start=/\v\[/ skip=/\v\\\_./ end=/\v$/ contains=@JSON
syntax region dockerfileShell contained keepend start=/\v/ skip=/\v\\\_./ end=/\v$/ contains=@Shell
syntax region dockerfileValue contained keepend start=/\v/ skip=/\v\\\_./ end=/\v$/ contains=dockerfileString
2014-08-29 15:12:19 +02:00
syntax region dockerfileComment start=/\v^\s*#/ end=/\v$/ contains=@Spell
2014-08-29 15:12:19 +02:00
hi def link dockerfileString String
hi def link dockerfileKeyword Keyword
hi def link dockerfileComment Comment
2020-02-04 22:53:05 +01:00
hi def link dockerfileOption Special
let b:current_syntax = "dockerfile"