Skip to content

Commit bc32bbd

Browse files
Freed-Wuchrisbra
authored andcommitted
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>
1 parent 0684800 commit bc32bbd

5 files changed

Lines changed: 41 additions & 1 deletion

File tree

runtime/autoload/dist/ft.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ export def FTcls()
169169
endif
170170
enddef
171171

172+
export def FTll()
173+
if getline(1) =~ ';\|\<source_filename\>\|\<target\>'
174+
setf llvm
175+
else
176+
setf lifelines
177+
endif
178+
enddef
179+
172180
export def FTlpc()
173181
if exists("g:lpc_syntax_for_c")
174182
var lnum = 1

runtime/filetype.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ au BufNewFile,BufRead */etc/sensors.conf,*/etc/sensors3.conf setf sensors
13511351
au BufNewFile,BufRead lftp.conf,.lftprc,*lftp/rc setf lftp
13521352

13531353
" Lifelines (or Lex for C++!)
1354-
au BufNewFile,BufRead *.ll setf lifelines
1354+
au BufNewFile,BufRead *.ll call dist#ft#FTll()
13551355

13561356
" Lilo: Linux loader
13571357
au BufNewFile,BufRead lilo.conf setf lilo

runtime/ftplugin/llvm.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
" Vim filetype plugin file
2+
" Language: LLVM IR
3+
" Last Change: 2024 Oct 22
4+
" Maintainer: Wu, Zhenyu <wuzhenyu@ustc.edu>
5+
6+
if exists("b:did_ftplugin") | finish | endif
7+
let b:did_ftplugin = 1
8+
9+
setl comments=:;
10+
setl commentstring=;\ %s
11+
12+
let b:undo_ftplugin = "setl commentstring< comments<"

src/testdir/test_filetype.vim

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2446,6 +2446,24 @@ func Test_inc_file()
24462446
filetype off
24472447
endfunc
24482448

2449+
func Test_ll_file()
2450+
filetype on
2451+
2452+
" LLVM IR
2453+
call writefile(['target triple = "nvptx64-nvidia-cuda"'], 'Xfile.ll', 'D')
2454+
split Xfile.ll
2455+
call assert_equal('llvm', &filetype)
2456+
bwipe!
2457+
2458+
" lifelines
2459+
call writefile(['proc main() {}'], 'Xfile.ll', 'D')
2460+
split Xfile.ll
2461+
call assert_equal('lifelines', &filetype)
2462+
bwipe!
2463+
2464+
filetype off
2465+
endfunc
2466+
24492467
func Test_lsl_file()
24502468
filetype on
24512469

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
866,
707709
/**/
708710
865,
709711
/**/

0 commit comments

Comments
 (0)