mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
vim-patch:9.1.1466: filetype: not all lex files are recognized
Problem: filetype: not all lex files are recognized
Solution: detect *.ll as lex, llvm or lifelines filetype, depending on
the content (Eisuke Kawashima)
closes: vim/vim#17560
48295111e5
Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
This commit is contained in:
committed by
Christian Clason
parent
32f30c4874
commit
5cf135f9a0
@ -908,9 +908,13 @@ function M.ll(_, bufnr)
|
||||
local first_line = getline(bufnr, 1)
|
||||
if matchregex(first_line, [[;\|\<source_filename\>\|\<target\>]]) then
|
||||
return 'llvm'
|
||||
else
|
||||
return 'lifelines'
|
||||
end
|
||||
for _, line in ipairs(getlines(bufnr, 1, 100)) do
|
||||
if line:find('^%s*%%') then
|
||||
return 'lex'
|
||||
end
|
||||
end
|
||||
return 'lifelines'
|
||||
end
|
||||
|
||||
--- @type vim.filetype.mapfn
|
||||
|
@ -2600,6 +2600,12 @@ func Test_ll_file()
|
||||
call assert_equal('llvm', &filetype)
|
||||
bwipe!
|
||||
|
||||
" lex (C++)
|
||||
call writefile(['%{', '#include <iostream>', '%}'], 'Xfile.ll', 'D')
|
||||
split Xfile.ll
|
||||
call assert_equal('lex', &filetype)
|
||||
bwipe!
|
||||
|
||||
" lifelines
|
||||
call writefile(['proc main() {}'], 'Xfile.ll', 'D')
|
||||
split Xfile.ll
|
||||
|
Reference in New Issue
Block a user