neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit fbbb9d6f7bc8fd3ed309d195d723894572549cf8
parent 6e4df18b457e9743c34068fd6e0a89fd04d3526c
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Sat, 16 Nov 2024 08:42:12 +0800

vim-patch:9.1.0866: filetype: LLVM IR files are not recognized (#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

https://github.com/vim/vim/commit/bc32bbddcfc2671158a4780838766ed2d1e14fa6

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

Co-authored-by: Wu, Zhenyu <wuzhenyu@ustc.edu>
Diffstat:
Aruntime/ftplugin/llvm.vim | 12++++++++++++
Mruntime/lua/vim/filetype.lua | 2+-
Mruntime/lua/vim/filetype/detect.lua | 10++++++++++
Mtest/old/testdir/test_filetype.vim | 18++++++++++++++++++
4 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/runtime/ftplugin/llvm.vim 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<" diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua @@ -682,7 +682,6 @@ local extension = { l = 'lex', lhs = 'lhaskell', lidr = 'lidris2', - ll = 'lifelines', ly = 'lilypond', ily = 'lilypond', liquid = 'liquid', @@ -697,6 +696,7 @@ local extension = { lt = 'lite', lite = 'lite', livemd = 'livebook', + ll = detect.ll, log = detect.log, Log = detect.log, LOG = detect.log, diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua @@ -869,6 +869,16 @@ function M.log(path, _) 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 for _, line in ipairs(getlines(bufnr, 1, 12)) do diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim @@ -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