diff options
| -rw-r--r-- | bitbake/bitbake/contrib/vim/indent/bitbake.vim (renamed from bitbake/bitbake/contrib/vim/bitbake.vim) | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/bitbake/bitbake/contrib/vim/bitbake.vim b/bitbake/bitbake/contrib/vim/indent/bitbake.vim index ff86c19fac..1c35cb3c32 100644 --- a/bitbake/bitbake/contrib/vim/bitbake.vim +++ b/bitbake/bitbake/contrib/vim/indent/bitbake.vim | |||
| @@ -79,6 +79,8 @@ function GetPythonIndent(lnum) | |||
| 79 | \ . " =~ '\\(Comment\\|Todo\\|String\\)$'", | 79 | \ . " =~ '\\(Comment\\|Todo\\|String\\)$'", |
| 80 | \ searchpair_stopline, searchpair_timeout) | 80 | \ searchpair_stopline, searchpair_timeout) |
| 81 | if parlnum > 0 | 81 | if parlnum > 0 |
| 82 | " We may have found the opening brace of a BitBake Python task, e.g. 'python do_task {' | ||
| 83 | " If so, ignore it here - it will be handled later. | ||
| 82 | if s:is_python_func_def(parlnum) | 84 | if s:is_python_func_def(parlnum) |
| 83 | let parlnum = 0 | 85 | let parlnum = 0 |
| 84 | let plindent = indent(plnum) | 86 | let plindent = indent(plnum) |
| @@ -105,6 +107,13 @@ function GetPythonIndent(lnum) | |||
| 105 | \ searchpair_stopline, searchpair_timeout) | 107 | \ searchpair_stopline, searchpair_timeout) |
| 106 | if p > 0 | 108 | if p > 0 |
| 107 | if s:is_python_func_def(p) | 109 | if s:is_python_func_def(p) |
| 110 | " Handle the user actually trying to close a BitBake Python task | ||
| 111 | let line = getline(a:lnum) | ||
| 112 | if line =~ '^\s*}' | ||
| 113 | return -2 | ||
| 114 | endif | ||
| 115 | |||
| 116 | " Otherwise ignore the brace | ||
| 108 | let p = 0 | 117 | let p = 0 |
| 109 | else | 118 | else |
| 110 | if p == plnum | 119 | if p == plnum |
| @@ -231,15 +240,27 @@ let b:did_indent = 1 | |||
| 231 | 240 | ||
| 232 | 241 | ||
| 233 | function BitbakeIndent(lnum) | 242 | function BitbakeIndent(lnum) |
| 243 | if !has('syntax_items') | ||
| 244 | return -1 | ||
| 245 | endif | ||
| 246 | |||
| 234 | let stack = synstack(a:lnum, col(".")) | 247 | let stack = synstack(a:lnum, col(".")) |
| 235 | if len(stack) == 0 | 248 | if len(stack) == 0 |
| 236 | return -1 | 249 | return -1 |
| 237 | endif | 250 | endif |
| 238 | 251 | ||
| 239 | let name = synIDattr(stack[0], "name") | 252 | let name = synIDattr(stack[0], "name") |
| 253 | "echo name | ||
| 240 | 254 | ||
| 241 | if index(["bbPyDefRegion", "bbPyFuncRegion"], name) != -1 | 255 | if index(["bbPyDefRegion", "bbPyFuncRegion"], name) != -1 |
| 242 | let ret = GetPythonIndent(a:lnum) | 256 | let ret = GetPythonIndent(a:lnum) |
| 257 | " Should always be indented by at least one shiftwidth; but allow | ||
| 258 | " return of -1 (defer to autoindent) or -2 (force indent to 0) | ||
| 259 | if ret == 0 | ||
| 260 | return shiftwidth() | ||
| 261 | elseif ret == -2 | ||
| 262 | return 0 | ||
| 263 | endif | ||
| 243 | return ret | 264 | return ret |
| 244 | endif | 265 | endif |
| 245 | 266 | ||
