Skip to content

Commit

Permalink
vim-patch:9.1.0866: filetype: LLVM IR files are not recognized (neovi…
Browse files Browse the repository at this point in the history
…m#31228)

Problem:  filetype: LLVM IR files are not recognized
Solution: detect '*.ll' files either as lifelines or llvm filetype
          (Wu, Zhenyu)

closes: vim/vim#15824

vim/vim@bc32bbd

N/A patch:
vim-patch:7e4b861: runtime(filetype): remove duplicated *.org file pattern

Co-authored-by: Wu, Zhenyu <[email protected]>
  • Loading branch information
zeertzjq and Freed-Wu authored Nov 16, 2024
1 parent 6e4df18 commit fbbb9d6
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
12 changes: 12 additions & 0 deletions runtime/ftplugin/llvm.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
" Vim filetype plugin file
" Language: LLVM IR
" Last Change: 2024 Oct 22
" Maintainer: Wu, Zhenyu <[email protected]>

if exists("b:did_ftplugin") | finish | endif
let b:did_ftplugin = 1

setl comments=:;
setl commentstring=;\ %s

let b:undo_ftplugin = "setl commentstring< comments<"
2 changes: 1 addition & 1 deletion runtime/lua/vim/filetype.lua
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,6 @@ local extension = {
l = 'lex',
lhs = 'lhaskell',
lidr = 'lidris2',
ll = 'lifelines',
ly = 'lilypond',
ily = 'lilypond',
liquid = 'liquid',
Expand All @@ -697,6 +696,7 @@ local extension = {
lt = 'lite',
lite = 'lite',
livemd = 'livebook',
ll = detect.ll,
log = detect.log,
Log = detect.log,
LOG = detect.log,
Expand Down
10 changes: 10 additions & 0 deletions runtime/lua/vim/filetype/detect.lua
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,16 @@ function M.log(path, _)
end
end

--- @type vim.filetype.mapfn
function M.ll(_, bufnr)
local first_line = getline(bufnr, 1)
if matchregex(first_line, [[;\|\<source_filename\>\|\<target\>]]) then
return 'llvm'
else
return 'lifelines'
end
end

--- @type vim.filetype.mapfn
function M.lpc(_, bufnr)
if vim.g.lpc_syntax_for_c then
Expand Down
18 changes: 18 additions & 0 deletions test/old/testdir/test_filetype.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2440,6 +2440,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

Expand Down

0 comments on commit fbbb9d6

Please sign in to comment.