[llvm] [vim] Improve iskeyword for LLVM IR (PR #117905)
Fraser Cormack via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 3 05:13:10 PST 2024
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/117905
>From 6bcb6066e917758544951b0dfbf91311d74dbeb7 Mon Sep 17 00:00:00 2001
From: Fraser Cormack <fraser at codeplay.com>
Date: Wed, 27 Nov 2024 16:49:29 +0000
Subject: [PATCH 1/2] [vim] Improve iskeyword for LLVM IR
This patch sets the 'iskeyword' variable to characters found in LLVM IR
identifiers. Keywords are used in many places in vim, most notably being
treated as word boundaries for commands like 'w' and '*'. The aim with
this is to improve the navigability and editability of LLVM IR files as
now one is able to: skip over entire identifiers with motions (e.g.,
w/e/b); yank/delete whole identifiers (e.g., diw); highlight/search for
the identifier under the cursor (*), etc.
More complicated LLVM identifiers including quotation marks are not
supported. The 'iskeyword' variable is just a list of characters, not a
regex, and including quotation marks and all the characters permitted in
quoted identifiers would expand the scope to almost everything and
become less usable. These types of identifiers are rare by comparison.
Note that this does change how words are considered across the entire
LLVM IR file, so including strings, comments, names, etc. Given that the
majority of editing/navigating LLVM IR is working with and across
values, this is arguably a worthwhile trade-off.
---
llvm/utils/vim/ftplugin/llvm.vim | 1 +
1 file changed, 1 insertion(+)
diff --git a/llvm/utils/vim/ftplugin/llvm.vim b/llvm/utils/vim/ftplugin/llvm.vim
index 55315159c18bce..c7f587956e76f4 100644
--- a/llvm/utils/vim/ftplugin/llvm.vim
+++ b/llvm/utils/vim/ftplugin/llvm.vim
@@ -11,3 +11,4 @@ setlocal softtabstop=2 shiftwidth=2
setlocal expandtab
setlocal comments+=:;
setlocal commentstring=;\ %s
+setlocal iskeyword=%, at -@,$,a-z,A-Z,48-57,_,.,-
>From 83cb340b3eec380854e997993261e97afc9e10a5 Mon Sep 17 00:00:00 2001
From: Fraser Cormack <fraser at codeplay.com>
Date: Tue, 3 Dec 2024 13:12:56 +0000
Subject: [PATCH 2/2] add a comment; restore @ for more isalpha chars
---
llvm/utils/vim/ftplugin/llvm.vim | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/llvm/utils/vim/ftplugin/llvm.vim b/llvm/utils/vim/ftplugin/llvm.vim
index c7f587956e76f4..4f38c47552d55b 100644
--- a/llvm/utils/vim/ftplugin/llvm.vim
+++ b/llvm/utils/vim/ftplugin/llvm.vim
@@ -11,4 +11,11 @@ setlocal softtabstop=2 shiftwidth=2
setlocal expandtab
setlocal comments+=:;
setlocal commentstring=;\ %s
-setlocal iskeyword=%, at -@,$,a-z,A-Z,48-57,_,.,-
+" We treat sequences of the following characters as forming 'keywords', with
+" the aim of easing movement around LLVM 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 llvm-commits
mailing list