mirror of
https://github.com/neovim/neovim.git
synced 2025-12-16 11:25:33 +00:00
vim-patch:9.0.0055 (#19392)
vim-patch:9.0.0055: bitbake files are not detected
Problem: Bitbake files are not detected.
Solution: Add bitbake filetype detection by file name and contents. (Gregory
Anders, closes vim/vim#10697)
fa49eb4827
This commit is contained in:
6
runtime/autoload/dist/ft.vim
vendored
6
runtime/autoload/dist/ft.vim
vendored
@@ -519,12 +519,14 @@ func dist#ft#FTinc()
|
|||||||
" headers so assume POV-Ray
|
" headers so assume POV-Ray
|
||||||
elseif lines =~ '^\s*\%({\|(\*\)' || lines =~? s:ft_pascal_keywords
|
elseif lines =~ '^\s*\%({\|(\*\)' || lines =~? s:ft_pascal_keywords
|
||||||
setf pascal
|
setf pascal
|
||||||
|
elseif lines =~# '\<\%(require\|inherit\)\>' || lines =~# '\w\+ = '
|
||||||
|
setf bitbake
|
||||||
else
|
else
|
||||||
call dist#ft#FTasmsyntax()
|
call dist#ft#FTasmsyntax()
|
||||||
if exists("b:asmsyntax")
|
if exists("b:asmsyntax")
|
||||||
exe "setf " . fnameescape(b:asmsyntax)
|
exe "setf " . fnameescape(b:asmsyntax)
|
||||||
else
|
else
|
||||||
setf pov
|
setf pov
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -253,6 +253,9 @@ au BufNewFile,BufRead *.db call dist#ft#BindzoneCheck('')
|
|||||||
" Blank
|
" Blank
|
||||||
au BufNewFile,BufRead *.bl setf blank
|
au BufNewFile,BufRead *.bl setf blank
|
||||||
|
|
||||||
|
" Bitbake
|
||||||
|
au BufNewFile,BufRead *.bb,*.bbappend,*.bbclass,*/build/conf/*.conf,*/meta{-*,}/conf/*.conf setf bitbake
|
||||||
|
|
||||||
" Blkid cache file
|
" Blkid cache file
|
||||||
au BufNewFile,BufRead */etc/blkid.tab,*/etc/blkid.tab.old setf xml
|
au BufNewFile,BufRead */etc/blkid.tab,*/etc/blkid.tab.old setf xml
|
||||||
|
|
||||||
|
|||||||
@@ -172,6 +172,9 @@ local extension = {
|
|||||||
return require('vim.filetype.detect').bindzone(bufnr, '')
|
return require('vim.filetype.detect').bindzone(bufnr, '')
|
||||||
end,
|
end,
|
||||||
bicep = 'bicep',
|
bicep = 'bicep',
|
||||||
|
bb = 'bitbake',
|
||||||
|
bbappend = 'bitbake',
|
||||||
|
bbclass = 'bitbake',
|
||||||
bl = 'blank',
|
bl = 'blank',
|
||||||
bsdl = 'bsdl',
|
bsdl = 'bsdl',
|
||||||
bst = 'bst',
|
bst = 'bst',
|
||||||
@@ -1662,6 +1665,9 @@ local pattern = {
|
|||||||
['[mM]akefile%.am'] = 'automake',
|
['[mM]akefile%.am'] = 'automake',
|
||||||
['.*/bind/db%..*'] = starsetf('bindzone'),
|
['.*/bind/db%..*'] = starsetf('bindzone'),
|
||||||
['.*/named/db%..*'] = starsetf('bindzone'),
|
['.*/named/db%..*'] = starsetf('bindzone'),
|
||||||
|
['.*/build/conf/.*%.conf'] = 'bitbake',
|
||||||
|
['.*/meta/conf/.*%.conf'] = 'bitbake',
|
||||||
|
['.*/meta%-.*/conf/.*%.conf'] = 'bitbake',
|
||||||
['.*bsd'] = 'bsdl',
|
['.*bsd'] = 'bsdl',
|
||||||
['bzr_log%..*'] = 'bzr',
|
['bzr_log%..*'] = 'bzr',
|
||||||
['.*enlightenment/.*%.cfg'] = 'c',
|
['.*enlightenment/.*%.cfg'] = 'c',
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ end
|
|||||||
-- Checks the first 5 lines for a asmsyntax=foo override.
|
-- Checks the first 5 lines for a asmsyntax=foo override.
|
||||||
-- Only whitespace characters can be present immediately before or after this statement.
|
-- Only whitespace characters can be present immediately before or after this statement.
|
||||||
function M.asm_syntax(bufnr)
|
function M.asm_syntax(bufnr)
|
||||||
local lines = table.concat(getlines(bufnr, 1, 5), ' '):lower()
|
local lines = ' ' .. table.concat(getlines(bufnr, 1, 5), ' '):lower() .. ' '
|
||||||
local match = lines:match('%sasmsyntax=([a-zA-Z0-9]+)%s')
|
local match = lines:match('%sasmsyntax=([a-zA-Z0-9]+)%s')
|
||||||
if match then
|
if match then
|
||||||
return match
|
return match
|
||||||
@@ -554,6 +554,8 @@ function M.inc(bufnr)
|
|||||||
-- headers so assume POV-Ray
|
-- headers so assume POV-Ray
|
||||||
elseif findany(lines, { '^%s{', '^%s%(%*' }) or matchregex(lines, pascal_keywords) then
|
elseif findany(lines, { '^%s{', '^%s%(%*' }) or matchregex(lines, pascal_keywords) then
|
||||||
return 'pascal'
|
return 'pascal'
|
||||||
|
elseif findany(lines, { '^%s*inherit ', '^%s*require ', '^%s*%w+%s+= ' }) then
|
||||||
|
return 'bitbake'
|
||||||
else
|
else
|
||||||
local syntax = M.asm_syntax(bufnr)
|
local syntax = M.asm_syntax(bufnr)
|
||||||
if not syntax or syntax == '' then
|
if not syntax or syntax == '' then
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ let s:filename_checks = {
|
|||||||
\ 'bib': ['file.bib'],
|
\ 'bib': ['file.bib'],
|
||||||
\ 'bicep': ['file.bicep'],
|
\ 'bicep': ['file.bicep'],
|
||||||
\ 'bindzone': ['named.root', '/bind/db.file', '/named/db.file', 'any/bind/db.file', 'any/named/db.file'],
|
\ 'bindzone': ['named.root', '/bind/db.file', '/named/db.file', 'any/bind/db.file', 'any/named/db.file'],
|
||||||
|
\ 'bitbake': ['file.bb', 'file.bbappend', 'file.bbclass', 'build/conf/local.conf', 'meta/conf/layer.conf', 'build/conf/bbappend.conf', 'meta-layer/conf/distro/foo.conf'],
|
||||||
\ 'blank': ['file.bl'],
|
\ 'blank': ['file.bl'],
|
||||||
\ 'bsdl': ['file.bsd', 'file.bsdl', 'bsd', 'some-bsd'],
|
\ 'bsdl': ['file.bsd', 'file.bsdl', 'bsd', 'some-bsd'],
|
||||||
\ 'bst': ['file.bst'],
|
\ 'bst': ['file.bst'],
|
||||||
@@ -1813,5 +1814,58 @@ func Test_sig_file()
|
|||||||
filetype off
|
filetype off
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_inc_file()
|
||||||
|
filetype on
|
||||||
|
|
||||||
|
call writefile(['this is the fallback'], 'Xfile.inc')
|
||||||
|
split Xfile.inc
|
||||||
|
call assert_equal('pov', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
let g:filetype_inc = 'foo'
|
||||||
|
split Xfile.inc
|
||||||
|
call assert_equal('foo', &filetype)
|
||||||
|
bwipe!
|
||||||
|
unlet g:filetype_inc
|
||||||
|
|
||||||
|
" aspperl
|
||||||
|
call writefile(['perlscript'], 'Xfile.inc')
|
||||||
|
split Xfile.inc
|
||||||
|
call assert_equal('aspperl', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
" aspvbs
|
||||||
|
call writefile(['<% something'], 'Xfile.inc')
|
||||||
|
split Xfile.inc
|
||||||
|
call assert_equal('aspvbs', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
" php
|
||||||
|
call writefile(['<?php'], 'Xfile.inc')
|
||||||
|
split Xfile.inc
|
||||||
|
call assert_equal('php', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
" pascal
|
||||||
|
call writefile(['program'], 'Xfile.inc')
|
||||||
|
split Xfile.inc
|
||||||
|
call assert_equal('pascal', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
" bitbake
|
||||||
|
call writefile(['require foo'], 'Xfile.inc')
|
||||||
|
split Xfile.inc
|
||||||
|
call assert_equal('bitbake', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
" asm
|
||||||
|
call writefile(['asmsyntax=bar'], 'Xfile.inc')
|
||||||
|
split Xfile.inc
|
||||||
|
call assert_equal('bar', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
call delete('Xfile.inc')
|
||||||
|
filetype off
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
|||||||
Reference in New Issue
Block a user