[Mlir-commits] [mlir] [vim] Improve `iskeyword` for MLIR (PR #121750)

Jack Frankland llvmlistbot at llvm.org
Mon Jan 6 02:49:01 PST 2025


https://github.com/FranklandJack created https://github.com/llvm/llvm-project/pull/121750

Define keywords for the MLIR syntax. This allows better recognition of semantic constructs such as SSA value identification e.g. `%foo` which gives improved motion handling when using 'word based' such as `w, e`.

This is based on the work done for the LLVM IR in
8c46413f343d0a5b8db48d958890b9038f03b70d.

>From dc6043a817558ed20cc60ad6345f95fc9c3096e1 Mon Sep 17 00:00:00 2001
From: Jack Frankland <jack.frankland at arm.com>
Date: Thu, 2 Jan 2025 10:54:05 +0000
Subject: [PATCH] [vim] Improve `iskeyword` for MLIR

Define keywords for the MLIR syntax. This allows better recognition of
semantic constructs such as SSA value identification e.g. `%foo` which
gives improved motion handling when using 'word based' such as `w, e`.

This is based on the work done for the LLVM IR in
8c46413f343d0a5b8db48d958890b9038f03b70d.

Signed-off-by: Jack Frankland <jack.frankland at arm.com>
---
 mlir/utils/vim/ftplugin/mlir.vim | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/mlir/utils/vim/ftplugin/mlir.vim b/mlir/utils/vim/ftplugin/mlir.vim
index 83b07f51001c02..2e3845cdddc327 100644
--- a/mlir/utils/vim/ftplugin/mlir.vim
+++ b/mlir/utils/vim/ftplugin/mlir.vim
@@ -10,3 +10,12 @@ let b:did_ftplugin = 1
 setlocal softtabstop=2 shiftwidth=2
 setlocal expandtab
 setlocal comments+=://
+setlocal commentstring=//\ %s
+" We treat sequences of the following characters as forming 'keywords', with
+" the aim of easing movement around MLIR identifiers:
+" * identifier prefixes: '%' and '@' (@-@)
+" * all characters where isalpha() returns TRUE (@)
+" * the digits 0-9 (48-57)
+" * other characters that may form identifiers: '_', '.', '-', '$'
+" Comment this out to restore the default behaviour
+setlocal iskeyword=%, at -@,@,48-57,_,.,-,$



More information about the Mlir-commits mailing list