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 <wuzhenyu@ustc.edu>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index c8942eb..214cf6e 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -169,6 +169,14 @@
endif
enddef
+export def FTll()
+ if getline(1) =~ ';\|\<source_filename\>\|\<target\>'
+ 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 897f356..085e4bd 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1351,7 +1351,7 @@
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 0000000..148b12f
--- /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 <wuzhenyu@ustc.edu>
+
+if exists("b:did_ftplugin") | finish | endif
+let b:did_ftplugin = 1
+
+setl comments=:;
+setl commentstring=;\ %s
+
+let b:undo_ftplugin = "setl commentstring< comments<"