]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0866: filetype: LLVM IR files are not recognized v9.1.0866
authorWu, Zhenyu <wuzhenyu@ustc.edu>
Thu, 14 Nov 2024 21:55:36 +0000 (22:55 +0100)
committerChristian Brabandt <cb@256bit.org>
Thu, 14 Nov 2024 21:55:36 +0000 (22:55 +0100)
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>
runtime/autoload/dist/ft.vim
runtime/filetype.vim
runtime/ftplugin/llvm.vim [new file with mode: 0644]
src/testdir/test_filetype.vim
src/version.c

index c8942eb3d114a589cfb8815d366b3b529c8c8e38..214cf6e3ec47e97a015badb7d65a20243732b57b 100644 (file)
@@ -169,6 +169,14 @@ export def FTcls()
   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
index 897f356bbc7b15104481d1806ed7cc75f7d0e614..085e4bd1ed70fcce0946bdbec3571092f9e1414f 100644 (file)
@@ -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 (file)
index 0000000..148b12f
--- /dev/null
@@ -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<"
index 8a89905e5ed02ad8ac63b5b9cb8a13d0a7707708..215d750ce110bd4af5b0d9bc0b131ea1ef9a42e7 100644 (file)
@@ -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
 
index 79b3099a5cd820abed778dd3f14012139417af61..7ba9d877e56ba7952901df6c982046a8a94e9128 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    866,
 /**/
     865,
 /**/