File tree 2 files changed +17
-11
lines changed
2 files changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -680,11 +680,14 @@ function! Test_gomodToolchainVersion_highlight() abort
680
680
let l: dir = gotest#write_file (' gomodtest/go.mod' , [
681
681
\ ' module github.com/fatih/vim-go' ,
682
682
\ ' ' ,
683
+ \ ' toolchain default' ,
684
+ \ ' toolchain go1' ,
685
+ \ ' toolchain go1' ,
683
686
\ ' toolchain go1.21' ,
684
687
\ ' toolchain go1.21rc3' ,
685
688
\ ' toolchain go1.21' ,
686
689
\ ' toolchain go1.21.3-somesuffix' ,
687
- \ ' toolchain go1.21rc4 -somesuffix more suffix ' ,
690
+ \ ' toolchain go1.21rc2 -somesuffix' ,
688
691
\ ' ' ])
689
692
690
693
let l: lineno = 3
@@ -734,11 +737,12 @@ function! Test_gomodToolchainVersion_invalid_highlight() abort
734
737
let l: dir = gotest#write_file (' gomodtest/go.mod' , [
735
738
\ ' module github.com/fatih/vim-go' ,
736
739
\ ' ' ,
737
- \ ' toolchain go1.21.1rc2' ,
738
- \ ' toolchain go1.21abc' ,
740
+ \ ' toolchain go2' ,
741
+ \ ' toolchain go1.21.1.4' ,
742
+ \ ' toolchain go1.21.1blah' ,
739
743
\ ' toolchain go1.21!some-suffix' ,
740
- \ ' toolchain 1.21rc2 ' ,
741
- \ ' toolchain 1.21.3 ' ,
744
+ \ ' toolchain go1.21 some-suffix ' ,
745
+ \ ' toolchain something-else ' ,
742
746
\ ' ' ])
743
747
744
748
let l: lineno = 3
Original file line number Diff line number Diff line change @@ -41,21 +41,23 @@ syntax region gomodComment start="//" end="$" contains=@Spell
41
41
highlight default link gomodComment Comment
42
42
43
43
" make sure quoted import paths are higlighted
44
- syntax region gomodString start =+ "+ skip =+ \\\\\|\\ "+ end =+ "+
45
- highlight default link gomodString String
44
+ syntax region gomodString start =+ "+ skip =+ \\\\\|\\ "+ end =+ "+
45
+ highlight default link gomodString String
46
46
47
47
" replace operator is in the form of '=>'
48
48
syntax match gomodReplaceOperator " \v\=\> "
49
49
highlight default link gomodReplaceOperator Operator
50
50
51
- " match toolchain versions, per https://go.dev/doc/toolchain#version, e.g.
52
- "
51
+ " match toolchain versions, based on https://go.dev/doc/toolchain#version,
52
+ " and https://pkg.go.dev/golang.org/x/[email protected] /modfile#ToolchainRE
53
+ syntax match gomodToolchainVersion " default$" contained
54
+ syntax match gomodToolchainVersion " go1$" contained
53
55
" * go1.X.Y
54
56
" * go1.X
55
57
" * go1.XrcN
58
+ " * go1.XrcN-somesuffix
56
59
" * go1.X.Y-somesuffix
57
- " * go1.XrcN-somesuffix more stuff
58
- syntax match gomodToolchainVersion " go1\.\d\+\(\( .\d\+\)\|\( rc\d\+\)\)\?\( [ \t -].*\)\? " contained
60
+ syntax match gomodToolchainVersion " go1\(\.\d\+\)\{ ,2\}\( rc\d\+\)\?\( -\( [a-zA-Z0-9]\+\)\)\? " contained
59
61
highlight default link gomodToolchainVersion Identifier
60
62
61
63
" match go versions
You can’t perform that action at this time.
0 commit comments