Skip to content

Commit b08ede4

Browse files
[MLIR] Fix MLIR vim syntax file
This commit fixes several things in the MLIR vim syntax file: - Spell checking is now on by default only in comments. - '#' now starts an identifier instead of starting an outline attribute declaration, which fixes coloring the rest of the line as a preprocessor directive when there is a '#' in the middle. - '!' and '^' -prefixed identifiers are now colored as types and labels. Reviewed By: bondhugula Differential Revision: https://reviews.llvm.org/D122626
1 parent 920de9c commit b08ede4

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

mlir/utils/vim/syntax/mlir.vim

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,22 @@ syn match mlirNumber /x\s*\zs-\?\d\+\ze\s*x/
8484
syn match mlirFloat /-\?\<\d\+\.\d*\(e[+-]\d\+\)\?\>/
8585
syn match mlirFloat /\<0x\x\+\>/
8686
syn keyword mlirBoolean true false
87-
syn match mlirComment /\/\/.*$/
87+
" Spell checking is enabled only in comments by default.
88+
syn match mlirComment /\/\/.*$/ contains=@Spell
8889
syn region mlirString start=/"/ skip=/\\"/ end=/"/
8990
syn match mlirLabel /[-a-zA-Z$._][-a-zA-Z$._0-9]*:/
91+
" Prefixed identifiers usually used for ssa values and symbols.
9092
syn match mlirIdentifier /[%@][a-zA-Z$._-][a-zA-Z0-9$._-]*/
91-
syn match mlirIdentifier /[%@!]\d\+\>/
92-
syn match mlirMapSetOutline "#.*$"
93+
syn match mlirIdentifier /[%@]\d\+\>/
94+
" Prefixed identifiers usually used for blocks.
95+
syn match mlirBlockIdentifier /\^[a-zA-Z$._-][a-zA-Z0-9$._-]*/
96+
syn match mlirBlockIdentifier /\^\d\+\>/
97+
" Prefixed identifiers usually used for types.
98+
syn match mlirTypeIdentifier /![a-zA-Z$._-][a-zA-Z0-9$._-]*/
99+
syn match mlirTypeIdentifier /!\d\+\>/
100+
" Prefixed identifiers usually used for attribute aliases and result numbers.
101+
syn match mlirAttrIdentifier /#[a-zA-Z$._-][a-zA-Z0-9$._-]*/
102+
syn match mlirAttrIdentifier /#\d\+\>/
93103

94104
" Syntax-highlight lit test commands and bug numbers.
95105
syn match mlirSpecialComment /\/\/\s*RUN:.*$/
@@ -111,7 +121,6 @@ if version >= 508 || !exists("did_c_syn_inits")
111121

112122
HiLink mlirType Type
113123
HiLink mlirOps Statement
114-
HiLink mlirMapSetOutline PreProc
115124
HiLink mlirNumber Number
116125
HiLink mlirComment Comment
117126
HiLink mlirString String
@@ -122,6 +131,9 @@ if version >= 508 || !exists("did_c_syn_inits")
122131
HiLink mlirConstant Constant
123132
HiLink mlirSpecialComment SpecialComment
124133
HiLink mlirIdentifier Identifier
134+
HiLink mlirBlockIdentifier Label
135+
HiLink mlirTypeIdentifier Type
136+
HiLink mlirAttrIdentifier PreProc
125137

126138
delcommand HiLink
127139
endif

0 commit comments

Comments
 (0)