[Mlir-commits] [mlir] b08ede4 - [MLIR] Fix MLIR vim syntax file

Sergei Grechanik llvmlistbot at llvm.org
Mon Apr 4 09:23:04 PDT 2022


Author: Sergei Grechanik
Date: 2022-04-04T09:02:32-07:00
New Revision: b08ede4374dbb6587dc5264a3352cb8463f4691c

URL: https://github.com/llvm/llvm-project/commit/b08ede4374dbb6587dc5264a3352cb8463f4691c
DIFF: https://github.com/llvm/llvm-project/commit/b08ede4374dbb6587dc5264a3352cb8463f4691c.diff

LOG: [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

Added: 
    

Modified: 
    mlir/utils/vim/syntax/mlir.vim

Removed: 
    


################################################################################
diff  --git a/mlir/utils/vim/syntax/mlir.vim b/mlir/utils/vim/syntax/mlir.vim
index 5246aa04510e7..d874149379bc7 100644
--- a/mlir/utils/vim/syntax/mlir.vim
+++ b/mlir/utils/vim/syntax/mlir.vim
@@ -84,12 +84,22 @@ syn match   mlirNumber /x\s*\zs-\?\d\+\ze\s*x/
 syn match   mlirFloat  /-\?\<\d\+\.\d*\(e[+-]\d\+\)\?\>/
 syn match   mlirFloat  /\<0x\x\+\>/
 syn keyword mlirBoolean true false
-syn match   mlirComment /\/\/.*$/
+" Spell checking is enabled only in comments by default.
+syn match   mlirComment /\/\/.*$/ contains=@Spell
 syn region  mlirString start=/"/ skip=/\\"/ end=/"/
 syn match   mlirLabel /[-a-zA-Z$._][-a-zA-Z$._0-9]*:/
+" Prefixed identifiers usually used for ssa values and symbols.
 syn match   mlirIdentifier /[%@][a-zA-Z$._-][a-zA-Z0-9$._-]*/
-syn match   mlirIdentifier /[%@!]\d\+\>/
-syn match mlirMapSetOutline "#.*$"
+syn match   mlirIdentifier /[%@]\d\+\>/
+" Prefixed identifiers usually used for blocks.
+syn match   mlirBlockIdentifier /\^[a-zA-Z$._-][a-zA-Z0-9$._-]*/
+syn match   mlirBlockIdentifier /\^\d\+\>/
+" Prefixed identifiers usually used for types.
+syn match   mlirTypeIdentifier /![a-zA-Z$._-][a-zA-Z0-9$._-]*/
+syn match   mlirTypeIdentifier /!\d\+\>/
+" Prefixed identifiers usually used for attribute aliases and result numbers.
+syn match   mlirAttrIdentifier /#[a-zA-Z$._-][a-zA-Z0-9$._-]*/
+syn match   mlirAttrIdentifier /#\d\+\>/
 
 " Syntax-highlight lit test commands and bug numbers.
 syn match  mlirSpecialComment /\/\/\s*RUN:.*$/
@@ -111,7 +121,6 @@ if version >= 508 || !exists("did_c_syn_inits")
 
   HiLink mlirType Type
   HiLink mlirOps Statement
-  HiLink mlirMapSetOutline PreProc
   HiLink mlirNumber Number
   HiLink mlirComment Comment
   HiLink mlirString String
@@ -122,6 +131,9 @@ if version >= 508 || !exists("did_c_syn_inits")
   HiLink mlirConstant Constant
   HiLink mlirSpecialComment SpecialComment
   HiLink mlirIdentifier Identifier
+  HiLink mlirBlockIdentifier Label
+  HiLink mlirTypeIdentifier Type
+  HiLink mlirAttrIdentifier PreProc
 
   delcommand HiLink
 endif


        


More information about the Mlir-commits mailing list