summaryrefslogtreecommitdiffstats
path: root/bitbake/contrib/vim/ftdetect/bitbake.vim
blob: 427ab5b987c3740f2532ba4464f2cd549d7b1957 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
" Vim filetype detection file
" Language:     BitBake
" Author:       Ricardo Salveti <rsalveti@rsalveti.net>
" Copyright:    Copyright (C) 2008  Ricardo Salveti <rsalveti@rsalveti.net>
" Licence:      You may redistribute this under the same terms as Vim itself
"
" This sets up the syntax highlighting for BitBake files, like .bb, .bbclass and .inc

if &compatible || version < 600 || exists("b:loaded_bitbake_plugin")
    finish
endif

" .bb, .bbappend and .bbclass
au BufNewFile,BufRead *.{bb,bbappend,bbclass}  setfiletype bitbake

" .inc -- meanwhile included upstream
if !has("patch-9.0.0055")
    au BufNewFile,BufRead *.inc                call s:BBIncDetect()
    def s:BBIncDetect()
        l:lines = getline(1) .. getline(2) .. getline(3)
        if l:lines =~# '\<\%(require\|inherit\)\>' || lines =~# '[A-Z][A-Za-z0-9_:${}]*\s\+\%(??\|[?:+]\)\?= '
            set filetype bitbake
        endif
    enddef
endif

" .conf
au BufNewFile,BufRead *.conf
    \ if (match(expand("%:p:h"), "conf") > 0) |
    \     set filetype=bitbake |
    \ endif