diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2021-03-10 17:22:05 +0100 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2021-03-10 17:22:05 +0100 |
commit | eda351ca897ca0270ed8b01798af3679914683a1 (patch) | |
tree | 5340822acd25ecd12063f08b1e6d0bed4a891a82 /syntax/gomod.vim | |
parent | cc63193ce82c1e7b9ee2ad7d0ddd14e8394211ef (diff) | |
download | vim-polyglot-eda351ca897ca0270ed8b01798af3679914683a1.tar.gz vim-polyglot-eda351ca897ca0270ed8b01798af3679914683a1.zip |
Update
Diffstat (limited to 'syntax/gomod.vim')
-rw-r--r-- | syntax/gomod.vim | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/syntax/gomod.vim b/syntax/gomod.vim index 0de3d9d9..4f120ffd 100644 --- a/syntax/gomod.vim +++ b/syntax/gomod.vim @@ -11,17 +11,22 @@ endif syntax case match +" Reference documentation: +" https://golang.org/ref/mod#go-mod-file-grammar + " match keywords syntax keyword gomodModule module syntax keyword gomodGo go contained syntax keyword gomodRequire require syntax keyword gomodExclude exclude syntax keyword gomodReplace replace +syntax keyword gomodRetract retract " require, exclude, replace, and go can be also grouped into block syntax region gomodRequire start='require (' end=')' transparent contains=gomodRequire,gomodVersion syntax region gomodExclude start='exclude (' end=')' transparent contains=gomodExclude,gomodVersion syntax region gomodReplace start='replace (' end=')' transparent contains=gomodReplace,gomodVersion +syntax region gomodRetract start='retract (' end=')' transparent contains=gomodVersionRange,gomodVersion syntax match gomodGo '^go .*$' transparent contains=gomodGo,gomodGoVersion " set highlights @@ -30,6 +35,7 @@ highlight default link gomodGo Keyword highlight default link gomodRequire Keyword highlight default link gomodExclude Keyword highlight default link gomodReplace Keyword +highlight default link gomodRetract Keyword " comments are always in form of // ... syntax region gomodComment start="//" end="$" contains=@Spell @@ -47,7 +53,6 @@ highlight default link gomodReplaceOperator Operator syntax match gomodGoVersion "1\.\d\+" contained highlight default link gomodGoVersion Identifier - " highlight versions: " * vX.Y.Z-pre " * vX.Y.Z @@ -93,4 +98,15 @@ syntax match gomodVersion "v[2-9]\{1}\d*\.\d\+\.\d\+\%(+\%([0-9A-Za-z-]\+\)\%(\. " ^------- version -------^^---------------- metadata ---------------------^ highlight default link gomodVersion Identifier +" match go version ranges in retract directive +" https://golang.org/ref/mod#go-mod-file-retract +syntax region gomodVersionRange start="\[" end="\]" transparent matchgroup=gomodVersionRangeBracket contains=gomodVersion,gomodVersionRangeSeparator +highlight default link gomodVersionRange Operator +syntax match gomodVersionRangeBracket "\[" contained +syntax match gomodVersionRangeBracket "\]" contained +highlight default link gomodVersionRangeBracket Operator +syntax match gomodVersionRangeSeparator "," contained +highlight default link gomodVersionRangeSeparator Operator + + let b:current_syntax = "gomod" |