From bc32bbddcfc2671158a4780838766ed2d1e14fa6 Mon Sep 17 00:00:00 2001 From: "Wu, Zhenyu" Date: Thu, 14 Nov 2024 22:55:36 +0100 Subject: [PATCH] patch 9.1.0866: filetype: LLVM IR files are not recognized Problem: filetype: LLVM IR files are not recognized Solution: detect '*.ll' files either as lifelines or llvm filetype (Wu, Zhenyu) closes: #15824 Signed-off-by: Wu, Zhenyu Signed-off-by: Christian Brabandt --- runtime/autoload/dist/ft.vim | 8 ++++++++ runtime/filetype.vim | 2 +- runtime/ftplugin/llvm.vim | 12 ++++++++++++ src/testdir/test_filetype.vim | 18 ++++++++++++++++++ src/version.c | 2 ++ 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 runtime/ftplugin/llvm.vim diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index c8942eb3d1..214cf6e3ec 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -169,6 +169,14 @@ export def FTcls() endif enddef +export def FTll() + if getline(1) =~ ';\|\\|\' + setf llvm + else + setf lifelines + endif +enddef + export def FTlpc() if exists("g:lpc_syntax_for_c") var lnum = 1 diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 897f356bbc..085e4bd1ed 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1351,7 +1351,7 @@ au BufNewFile,BufRead */etc/sensors.conf,*/etc/sensors3.conf setf sensors au BufNewFile,BufRead lftp.conf,.lftprc,*lftp/rc setf lftp " Lifelines (or Lex for C++!) -au BufNewFile,BufRead *.ll setf lifelines +au BufNewFile,BufRead *.ll call dist#ft#FTll() " Lilo: Linux loader au BufNewFile,BufRead lilo.conf setf lilo diff --git a/runtime/ftplugin/llvm.vim b/runtime/ftplugin/llvm.vim new file mode 100644 index 0000000000..148b12f102 --- /dev/null +++ b/runtime/ftplugin/llvm.vim @@ -0,0 +1,12 @@ +" Vim filetype plugin file +" Language: LLVM IR +" Last Change: 2024 Oct 22 +" Maintainer: Wu, Zhenyu + +if exists("b:did_ftplugin") | finish | endif +let b:did_ftplugin = 1 + +setl comments=:; +setl commentstring=;\ %s + +let b:undo_ftplugin = "setl commentstring< comments<" diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim index 8a89905e5e..215d750ce1 100644 --- a/src/testdir/test_filetype.vim +++ b/src/testdir/test_filetype.vim @@ -2446,6 +2446,24 @@ func Test_inc_file() filetype off endfunc +func Test_ll_file() + filetype on + + " LLVM IR + call writefile(['target triple = "nvptx64-nvidia-cuda"'], 'Xfile.ll', 'D') + split Xfile.ll + call assert_equal('llvm', &filetype) + bwipe! + + " lifelines + call writefile(['proc main() {}'], 'Xfile.ll', 'D') + split Xfile.ll + call assert_equal('lifelines', &filetype) + bwipe! + + filetype off +endfunc + func Test_lsl_file() filetype on diff --git a/src/version.c b/src/version.c index 79b3099a5c..7ba9d877e5 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 866, /**/ 865, /**/