diff options
| -rw-r--r-- | bitbake/contrib/vim/ftdetect/bitbake.vim | 28 | ||||
| -rwxr-xr-x | bitbake/contrib/vim/plugin/newbb.vim | 85 | ||||
| -rw-r--r-- | bitbake/contrib/vim/syntax/bitbake.vim | 195 |
3 files changed, 204 insertions, 104 deletions
diff --git a/bitbake/contrib/vim/ftdetect/bitbake.vim b/bitbake/contrib/vim/ftdetect/bitbake.vim index 3882a9a08d..179e4d9888 100644 --- a/bitbake/contrib/vim/ftdetect/bitbake.vim +++ b/bitbake/contrib/vim/ftdetect/bitbake.vim | |||
| @@ -1,4 +1,24 @@ | |||
| 1 | au BufNewFile,BufRead *.bb setfiletype bitbake | 1 | " Vim filetype detection file |
| 2 | au BufNewFile,BufRead *.bbclass setfiletype bitbake | 2 | " Language: BitBake |
| 3 | au BufNewFile,BufRead *.inc setfiletype bitbake | 3 | " Author: Ricardo Salveti <rsalveti@rsalveti.net> |
| 4 | " au BufNewFile,BufRead *.conf setfiletype bitbake | 4 | " Copyright: Copyright (C) 2008 Ricardo Salveti <rsalveti@rsalveti.net> |
| 5 | " Licence: You may redistribute this under the same terms as Vim itself | ||
| 6 | " | ||
| 7 | " This sets up the syntax highlighting for BitBake files, like .bb, .bbclass and .inc | ||
| 8 | |||
| 9 | if &compatible || version < 600 | ||
| 10 | finish | ||
| 11 | endif | ||
| 12 | |||
| 13 | " .bb and .bbclass | ||
| 14 | au BufNewFile,BufRead *.b{b,bclass} set filetype=bitbake | ||
| 15 | |||
| 16 | " .inc | ||
| 17 | au BufNewFile,BufRead *.inc set filetype=bitbake | ||
| 18 | |||
| 19 | " .conf | ||
| 20 | au BufNewFile,BufRead *.conf | ||
| 21 | \ if (match(expand("%:p:h"), "conf") > 0) | | ||
| 22 | \ set filetype=bitbake | | ||
| 23 | \ endif | ||
| 24 | |||
diff --git a/bitbake/contrib/vim/plugin/newbb.vim b/bitbake/contrib/vim/plugin/newbb.vim new file mode 100755 index 0000000000..afba1d9aa4 --- /dev/null +++ b/bitbake/contrib/vim/plugin/newbb.vim | |||
| @@ -0,0 +1,85 @@ | |||
| 1 | " Vim plugin file | ||
| 2 | " Purpose: Create a template for new bb files | ||
| 3 | " Author: Ricardo Salveti <rsalveti@gmail.com> | ||
| 4 | " Copyright: Copyright (C) 2008 Ricardo Salveti <rsalveti@gmail.com> | ||
| 5 | " | ||
| 6 | " This file is licensed under the MIT license, see COPYING.MIT in | ||
| 7 | " this source distribution for the terms. | ||
| 8 | " | ||
| 9 | " Based on the gentoo-syntax package | ||
| 10 | " | ||
| 11 | " Will try to use git to find the user name and email | ||
| 12 | |||
| 13 | if &compatible || v:version < 600 | ||
| 14 | finish | ||
| 15 | endif | ||
| 16 | |||
| 17 | fun! <SID>GetUserName() | ||
| 18 | let l:user_name = system("git-config --get user.name") | ||
| 19 | if v:shell_error | ||
| 20 | return "Unknow User" | ||
| 21 | else | ||
| 22 | return substitute(l:user_name, "\n", "", "") | ||
| 23 | endfun | ||
| 24 | |||
| 25 | fun! <SID>GetUserEmail() | ||
| 26 | let l:user_email = system("git-config --get user.email") | ||
| 27 | if v:shell_error | ||
| 28 | return "unknow@user.org" | ||
| 29 | else | ||
| 30 | return substitute(l:user_email, "\n", "", "") | ||
| 31 | endfun | ||
| 32 | |||
| 33 | fun! BBHeader() | ||
| 34 | let l:current_year = strftime("%Y") | ||
| 35 | let l:user_name = <SID>GetUserName() | ||
| 36 | let l:user_email = <SID>GetUserEmail() | ||
| 37 | 0 put ='# Copyright (C) ' . l:current_year . | ||
| 38 | \ ' ' . l:user_name . ' <' . l:user_email . '>' | ||
| 39 | put ='# Released under the MIT license (see COPYING.MIT for the terms)' | ||
| 40 | $ | ||
| 41 | endfun | ||
| 42 | |||
| 43 | fun! NewBBTemplate() | ||
| 44 | let l:paste = &paste | ||
| 45 | set nopaste | ||
| 46 | |||
| 47 | " Get the header | ||
| 48 | call BBHeader() | ||
| 49 | |||
| 50 | " New the bb template | ||
| 51 | put ='DESCRIPTION = \"\"' | ||
| 52 | put ='HOMEPAGE = \"\"' | ||
| 53 | put ='LICENSE = \"\"' | ||
| 54 | put ='SECTION = \"\"' | ||
| 55 | put ='DEPENDS = \"\"' | ||
| 56 | put ='PR = \"r0\"' | ||
| 57 | put ='' | ||
| 58 | put ='SRC_URI = \"\"' | ||
| 59 | |||
| 60 | " Go to the first place to edit | ||
| 61 | 0 | ||
| 62 | /^DESCRIPTION =/ | ||
| 63 | exec "normal 2f\"" | ||
| 64 | |||
| 65 | if paste == 1 | ||
| 66 | set paste | ||
| 67 | endif | ||
| 68 | endfun | ||
| 69 | |||
| 70 | if !exists("g:bb_create_on_empty") | ||
| 71 | let g:bb_create_on_empty = 1 | ||
| 72 | endif | ||
| 73 | |||
| 74 | " disable in case of vimdiff | ||
| 75 | if v:progname =~ "vimdiff" | ||
| 76 | let g:bb_create_on_empty = 0 | ||
| 77 | endif | ||
| 78 | |||
| 79 | augroup NewBB | ||
| 80 | au BufNewFile *.bb | ||
| 81 | \ if g:bb_create_on_empty | | ||
| 82 | \ call NewBBTemplate() | | ||
| 83 | \ endif | ||
| 84 | augroup END | ||
| 85 | |||
diff --git a/bitbake/contrib/vim/syntax/bitbake.vim b/bitbake/contrib/vim/syntax/bitbake.vim index be55980b3a..b46436a567 100644 --- a/bitbake/contrib/vim/syntax/bitbake.vim +++ b/bitbake/contrib/vim/syntax/bitbake.vim | |||
| @@ -1,127 +1,122 @@ | |||
| 1 | " Vim syntax file | 1 | " Vim syntax file |
| 2 | " Language: BitBake bb/bbclasses/inc | ||
| 3 | " Author: Chris Larson <kergoth@handhelds.org> | ||
| 4 | " Ricardo Salveti <rsalveti@rsalveti.net> | ||
| 5 | " Copyright: Copyright (C) 2004 Chris Larson <kergoth@handhelds.org> | ||
| 6 | " Copyright (C) 2008 Ricardo Salveti <rsalveti@rsalveti.net> | ||
| 2 | " | 7 | " |
| 3 | " Copyright (C) 2004 Chris Larson <kergoth@handhelds.org> | ||
| 4 | " This file is licensed under the MIT license, see COPYING.MIT in | 8 | " This file is licensed under the MIT license, see COPYING.MIT in |
| 5 | " this source distribution for the terms. | 9 | " this source distribution for the terms. |
| 6 | " | 10 | " |
| 7 | " Language: BitBake | 11 | " Syntax highlighting for bb, bbclasses and inc files. |
| 8 | " Maintainer: Chris Larson <kergoth@handhelds.org> | ||
| 9 | " Filenames: *.bb, *.bbclass | ||
| 10 | |||
| 11 | if version < 600 | ||
| 12 | syntax clear | ||
| 13 | elseif exists("b:current_syntax") | ||
| 14 | finish | ||
| 15 | endif | ||
| 16 | |||
| 17 | syn case match | ||
| 18 | |||
| 19 | " Catch incorrect syntax (only matches if nothing else does) | ||
| 20 | " | 12 | " |
| 21 | syn match bbUnmatched "." | 13 | " It's an entirely new type, just has specific syntax in shell and python code |
| 22 | |||
| 23 | 14 | ||
| 24 | syn include @python syntax/python.vim | 15 | if &compatible || v:version < 600 |
| 16 | finish | ||
| 17 | endif | ||
| 25 | if exists("b:current_syntax") | 18 | if exists("b:current_syntax") |
| 26 | unlet b:current_syntax | 19 | finish |
| 27 | endif | 20 | endif |
| 28 | 21 | ||
| 22 | " BitBake syntax | ||
| 29 | 23 | ||
| 30 | " Other | 24 | " Matching case |
| 31 | 25 | syn case match | |
| 32 | syn match bbComment "^#.*$" display contains=bbTodo | ||
| 33 | syn keyword bbTodo TODO FIXME XXX contained | ||
| 34 | syn match bbDelimiter "[(){}=]" contained | ||
| 35 | syn match bbQuote /['"]/ contained | ||
| 36 | syn match bbArrayBrackets "[\[\]]" contained | ||
| 37 | |||
| 38 | |||
| 39 | " BitBake strings | ||
| 40 | |||
| 41 | syn match bbContinue "\\$" | ||
| 42 | syn region bbString matchgroup=bbQuote start=/"/ skip=/\\$/ excludenl end=/"/ contained keepend contains=bbTodo,bbContinue,bbVarInlinePy,bbVarDeref | ||
| 43 | syn region bbString matchgroup=bbQuote start=/'/ skip=/\\$/ excludenl end=/'/ contained keepend contains=bbTodo,bbContinue,bbVarInlinePy,bbVarDeref | ||
| 44 | |||
| 45 | " BitBake variable metadata | ||
| 46 | |||
| 47 | syn match bbVarBraces "[\${}]" | ||
| 48 | syn region bbVarDeref matchgroup=bbVarBraces start="${" end="}" contained | ||
| 49 | " syn region bbVarDeref start="${" end="}" contained | ||
| 50 | " syn region bbVarInlinePy start="${@" end="}" contained contains=@python | ||
| 51 | syn region bbVarInlinePy matchgroup=bbVarBraces start="${@" end="}" contained contains=@python | ||
| 52 | |||
| 53 | syn keyword bbExportFlag export contained nextgroup=bbIdentifier skipwhite | ||
| 54 | " syn match bbVarDeref "${[a-zA-Z0-9\-_\.]\+}" contained | ||
| 55 | syn match bbVarDef "^\(export\s*\)\?\([a-zA-Z0-9\-_\.]\+\(_[${}a-zA/-Z0-9\-_\.]\+\)\?\)\s*\(:=\|+=\|=+\|\.=\|=\.\|?=\|=\)\@=" contains=bbExportFlag,bbIdentifier,bbVarDeref nextgroup=bbVarEq | ||
| 56 | |||
| 57 | syn match bbIdentifier "[a-zA-Z0-9\-_\./]\+" display contained | ||
| 58 | "syn keyword bbVarEq = display contained nextgroup=bbVarValue | ||
| 59 | syn match bbVarEq "\(:=\|+=\|=+\|\.=\|=\.\|?=\|=\)" contained nextgroup=bbVarValue | ||
| 60 | syn match bbVarValue ".*$" contained contains=bbString | ||
| 61 | |||
| 62 | " BitBake variable metadata flags | ||
| 63 | syn match bbVarFlagDef "^\([a-zA-Z0-9\-_\.]\+\)\(\[[a-zA-Z0-9\-_\.]\+\]\)\@=" contains=bbIdentifier nextgroup=bbVarFlagFlag | ||
| 64 | syn region bbVarFlagFlag matchgroup=bbArrayBrackets start="\[" end="\]\s*\(=\)\@=" keepend excludenl contained contains=bbIdentifier nextgroup=bbVarEq | ||
| 65 | "syn match bbVarFlagFlag "\[\([a-zA-Z0-9\-_\.]\+\)\]\s*\(=\)\@=" contains=bbIdentifier nextgroup=bbVarEq | ||
| 66 | |||
| 67 | |||
| 68 | " Functions! | ||
| 69 | syn match bbFunction "\h\w*" display contained | ||
| 70 | 26 | ||
| 27 | " Indicates the error when nothing is matched | ||
| 28 | syn match bbUnmatched "." | ||
| 71 | 29 | ||
| 72 | " BitBake python metadata | 30 | " Comments |
| 31 | syn cluster bbCommentGroup contains=bbTodo,@Spell | ||
| 32 | syn keyword bbTodo COMBAK FIXME TODO XXX contained | ||
| 33 | syn match bbComment "#.*$" contains=@bbCommentGroup | ||
| 73 | 34 | ||
| 74 | syn keyword bbPythonFlag python contained nextgroup=bbFunction | 35 | " String helpers |
| 75 | syn match bbPythonFuncDef "^\(python\s\+\)\(\w\+\)\?\(\s*()\s*\)\({\)\@=" contains=bbPythonFlag,bbFunction,bbDelimiter nextgroup=bbPythonFuncRegion skipwhite | 36 | syn match bbQuote +['"]+ contained |
| 76 | syn region bbPythonFuncRegion matchgroup=bbDelimiter start="{\s*$" end="^}\s*$" keepend contained contains=@python | 37 | syn match bbDelimiter "[(){}=]" contained |
| 77 | "hi def link bbPythonFuncRegion Comment | 38 | syn match bbArrayBrackets "[\[\]]" contained |
| 78 | 39 | ||
| 40 | " BitBake strings | ||
| 41 | syn match bbContinue "\\$" | ||
| 42 | syn region bbString matchgroup=bbQuote start=+"+ skip=+\\$+ excludenl end=+"+ contained keepend contains=bbTodo,bbContinue,bbVarDeref,@Spell | ||
| 43 | syn region bbString matchgroup=bbQuote start=+'+ skip=+\\$+ excludenl end=+'+ contained keepend contains=bbTodo,bbContinue,bbVarDeref,@Spell | ||
| 44 | |||
| 45 | " Vars definition | ||
| 46 | syn keyword bbExportFlag export contained nextgroup=bbIdentifier skipwhite | ||
| 47 | syn match bbIdentifier "[a-zA-Z0-9\-_\.\/\+]\+" display contained | ||
| 48 | syn match bbVarDeref "${[a-zA-Z0-9\-_\.\/\+]\+}" contained | ||
| 49 | syn match bbVarEq "\(:=\|+=\|=+\|\.=\|=\.\|?=\|=\)" contained nextgroup=bbVarValue | ||
| 50 | syn match bbVarDef "^\(export\s*\)\?\([a-zA-Z0-9\-_\.\/\+]\+\(_[${}a-zA-Z0-9\-_\.\/\+]\+\)\?\)\s*\(:=\|+=\|=+\|\.=\|=\.\|?=\|=\)\@=" contains=bbExportFlag,bbIdentifier,bbVarDeref nextgroup=bbVarEq | ||
| 51 | syn match bbVarValue ".*$" contained contains=bbString,bbVarDeref,bbVarPyValue | ||
| 52 | syn match bbVarPyValue "${@[a-zA-Z0-9\-_\.\(\)]\+}" contained | ||
| 53 | |||
| 54 | " Vars metadata flags | ||
| 55 | syn match bbVarFlagDef "^\([a-zA-Z0-9\-_\.]\+\)\(\[[a-zA-Z0-9\-_\.]\+\]\)\@=" contains=bbIdentifier nextgroup=bbVarFlagFlag | ||
| 56 | syn region bbVarFlagFlag matchgroup=bbArrayBrackets start="\[" end="\]\s*\(=\)\@=" keepend excludenl contained contains=bbIdentifier nextgroup=bbVarEq | ||
| 57 | |||
| 58 | " Includes and requires | ||
| 59 | syn keyword bbInclude inherit include require contained | ||
| 60 | syn match bbIncludeRest ".*$" contained contains=bbString,bbVarDeref | ||
| 61 | syn match bbIncludeLine "^\(inherit\|include\|require\)\s\+" contains=bbInclude nextgroup=bbIncludeRest | ||
| 62 | |||
| 63 | " Add taks and similar | ||
| 64 | syn keyword bbStatement addtask addhandler after before EXPORT_FUNCTIONS contained | ||
| 65 | syn match bbStatementRest ".*$" skipwhite contained contains=bbStatement | ||
| 66 | syn match bbStatementLine "^\(addtask\|addhandler\|after\|before\|EXPORT_FUNCTIONS\)\s\+" contains=bbStatement nextgroup=bbStatementRest | ||
| 67 | |||
| 68 | " OE Important Functions | ||
| 69 | syn keyword bbOEFunctions do_fetch do_unpack do_patch do_configure do_compile do_stage do_install do_package contained | ||
| 70 | |||
| 71 | " Generic Functions | ||
| 72 | syn match bbFunction "\h[0-9A-Za-z_-]*" display contained contains=bbOEFunctions | ||
| 79 | 73 | ||
| 80 | " BitBake shell metadata | 74 | " BitBake shell metadata |
| 81 | syn include @shell syntax/sh.vim | 75 | syn include @shell syntax/sh.vim |
| 82 | if exists("b:current_syntax") | 76 | if exists("b:current_syntax") |
| 83 | unlet b:current_syntax | 77 | unlet b:current_syntax |
| 84 | endif | 78 | endif |
| 79 | syn keyword bbShFakeRootFlag fakeroot contained | ||
| 80 | syn match bbShFuncDef "^\(fakeroot\s*\)\?\([0-9A-Za-z_}${-]\+\)\(python\)\@<!\(\s*()\s*\)\({\)\@=" contains=bbShFakeRootFlag,bbFunction,bbDelimiter nextgroup=bbShFuncRegion skipwhite | ||
| 81 | syn region bbShFuncRegion matchgroup=bbDelimiter start="{\s*$" end="^}\s*$" keepend contained contains=@shell | ||
| 85 | 82 | ||
| 86 | syn keyword bbFakerootFlag fakeroot contained nextgroup=bbFunction | 83 | " BitBake python metadata |
| 87 | syn match bbShellFuncDef "^\(fakeroot\s*\)\?\(\w\+\)\(python\)\@<!\(\s*()\s*\)\({\)\@=" contains=bbFakerootFlag,bbFunction,bbDelimiter nextgroup=bbShellFuncRegion skipwhite | 84 | syn include @python syntax/python.vim |
| 88 | syn region bbShellFuncRegion matchgroup=bbDelimiter start="{\s*$" end="^}\s*$" keepend contained contains=@shell | 85 | if exists("b:current_syntax") |
| 89 | "hi def link bbShellFuncRegion Comment | 86 | unlet b:current_syntax |
| 90 | 87 | endif | |
| 88 | syn keyword bbPyFlag python contained | ||
| 89 | syn match bbPyFuncDef "^\(python\s\+\)\([0-9A-Za-z_-]\+\)\?\(\s*()\s*\)\({\)\@=" contains=bbPyFlag,bbFunction,bbDelimiter nextgroup=bbPyFuncRegion skipwhite | ||
| 90 | syn region bbPyFuncRegion matchgroup=bbDelimiter start="{\s*$" end="^}\s*$" keepend contained contains=@python | ||
| 91 | 91 | ||
| 92 | " BitBake 'def'd python functions | 92 | " BitBake 'def'd python functions |
| 93 | syn keyword bbDef def contained | 93 | syn keyword bbPyDef def contained |
| 94 | syn region bbDefRegion start='^def\s\+\w\+\s*([^)]*)\s*:\s*$' end='^\(\s\|$\)\@!' contains=@python | 94 | syn region bbPyDefRegion start='^\(def\s\+\)\([0-9A-Za-z_-]\+\)\(\s*(.*)\s*\):\s*$' end='^\(\s\|$\)\@!' contains=@python |
| 95 | |||
| 96 | " Highlighting Definitions | ||
| 97 | hi def link bbUnmatched Error | ||
| 98 | hi def link bbInclude Include | ||
| 99 | hi def link bbTodo Todo | ||
| 100 | hi def link bbComment Comment | ||
| 101 | hi def link bbQuote String | ||
| 102 | hi def link bbString String | ||
| 103 | hi def link bbDelimiter Keyword | ||
| 104 | hi def link bbArrayBrackets Statement | ||
| 105 | hi def link bbContinue Special | ||
| 106 | hi def link bbExportFlag Type | ||
| 107 | hi def link bbIdentifier Identifier | ||
| 108 | hi def link bbVarDeref PreProc | ||
| 109 | hi def link bbVarDef Identifier | ||
| 110 | hi def link bbVarValue String | ||
| 111 | hi def link bbShFakeRootFlag Type | ||
| 112 | hi def link bbFunction Function | ||
| 113 | hi def link bbPyFlag Type | ||
| 114 | hi def link bbPyDef Statement | ||
| 115 | hi def link bbStatement Statement | ||
| 116 | hi def link bbStatementRest Identifier | ||
| 117 | hi def link bbOEFunctions Special | ||
| 118 | hi def link bbVarPyValue PreProc | ||
| 95 | 119 | ||
| 120 | let b:current_syntax = "bb" | ||
| 96 | 121 | ||
| 97 | " BitBake statements | ||
| 98 | syn keyword bbStatement include inherit require addtask addhandler EXPORT_FUNCTIONS display contained | ||
| 99 | syn match bbStatementLine "^\(include\|inherit\|require\|addtask\|addhandler\|EXPORT_FUNCTIONS\)\s\+" contains=bbStatement nextgroup=bbStatementRest | ||
| 100 | syn match bbStatementRest ".*$" contained contains=bbString,bbVarDeref | ||
| 101 | |||
| 102 | " Highlight | ||
| 103 | " | ||
| 104 | hi def link bbArrayBrackets Statement | ||
| 105 | hi def link bbUnmatched Error | ||
| 106 | hi def link bbContinue Special | ||
| 107 | hi def link bbDef Statement | ||
| 108 | hi def link bbPythonFlag Type | ||
| 109 | hi def link bbExportFlag Type | ||
| 110 | hi def link bbFakerootFlag Type | ||
| 111 | hi def link bbStatement Statement | ||
| 112 | hi def link bbString String | ||
| 113 | hi def link bbTodo Todo | ||
| 114 | hi def link bbComment Comment | ||
| 115 | hi def link bbOperator Operator | ||
| 116 | hi def link bbError Error | ||
| 117 | hi def link bbFunction Function | ||
| 118 | hi def link bbDelimiter Delimiter | ||
| 119 | hi def link bbIdentifier Identifier | ||
| 120 | hi def link bbVarEq Operator | ||
| 121 | hi def link bbQuote String | ||
| 122 | hi def link bbVarValue String | ||
| 123 | " hi def link bbVarInlinePy PreProc | ||
| 124 | hi def link bbVarDeref PreProc | ||
| 125 | hi def link bbVarBraces PreProc | ||
| 126 | 122 | ||
| 127 | let b:current_syntax = "bb" | ||
