私はLLVM-IRコードで作業しており、によって生成されclang -emit-llvm
、コードの折りたたみを機能させたいと考えています。
これまでのところ、私は と を使用foldmethod=expr
してfoldexpr=LLVMFold()
います。foldmethod=syntax
llvm リポジトリの構文ファイルを使用して、構文ベースの折りたたみ (つまり) を使用したいと考えています。こちらから入手できます。
最初の正規表現は、ラベルの構文ファイルからのものであることに注意してください。
function! LLVMFolds()
let thisline = getline(v:lnum)
if match(thisline, '^[-a-zA-Z$._][-a-zA-Z$._0-9]*:') >= 0
return ">2"
elseif match(thisline, '^\}$') >= 0
return "<1"
elseif match(thisline, '{$') >= 0
return ">1"
else
return "="
endif
endfunction
Which gobbles the closing braces into the level 2 folds.
Also tried have been foldmethod=indent
which didn't fold enough and foldmethod=marker
with foldmark="{,}"
Ideally for this sample incomplete LLVM-IR code:
define i32 @main() nounwind {
entry:
%retval = alloca i32, align 4
for.cond: ; preds = %entry
%4 = load i32* %i, align 4
%cmp1 = icmp slt i32 %4, 10
br i1 %cmp1, label %for.body, label %for.end
}
I would like folds to be from the {
of the define
to the }
and in each labelled section, i.e. from the entry:
to the clear line.