diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2011-01-01 23:52:50 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2011-01-04 14:46:54 +0000 |
commit | e8c48e668c7525257926ab7db9b6e44aa2705483 (patch) | |
tree | 488cff5fe50da4a077f959959bd0f64b855744f9 /bitbake/contrib/vim/plugin | |
parent | 043adbfa0902dd06ed44a610a48ae3712e3ac1d3 (diff) | |
download | poky-e8c48e668c7525257926ab7db9b6e44aa2705483.tar.gz |
bitbake/contrib: Sync with bitbake upstream
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/contrib/vim/plugin')
-rwxr-xr-x | bitbake/contrib/vim/plugin/newbb.vim | 85 |
1 files changed, 85 insertions, 0 deletions
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 | |||