mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 12:29:55 +00:00
bitbake: contrib/vim: More Python indenting; move indent file to correct directory
Signed-off-by: Chris Laplante <chris.laplante@agilent.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
d0ac956dc2
commit
80cf7d4a91
+21
@@ -79,6 +79,8 @@ function GetPythonIndent(lnum)
|
|||||||
\ . " =~ '\\(Comment\\|Todo\\|String\\)$'",
|
\ . " =~ '\\(Comment\\|Todo\\|String\\)$'",
|
||||||
\ searchpair_stopline, searchpair_timeout)
|
\ searchpair_stopline, searchpair_timeout)
|
||||||
if parlnum > 0
|
if parlnum > 0
|
||||||
|
" We may have found the opening brace of a BitBake Python task, e.g. 'python do_task {'
|
||||||
|
" If so, ignore it here - it will be handled later.
|
||||||
if s:is_python_func_def(parlnum)
|
if s:is_python_func_def(parlnum)
|
||||||
let parlnum = 0
|
let parlnum = 0
|
||||||
let plindent = indent(plnum)
|
let plindent = indent(plnum)
|
||||||
@@ -105,6 +107,13 @@ function GetPythonIndent(lnum)
|
|||||||
\ searchpair_stopline, searchpair_timeout)
|
\ searchpair_stopline, searchpair_timeout)
|
||||||
if p > 0
|
if p > 0
|
||||||
if s:is_python_func_def(p)
|
if s:is_python_func_def(p)
|
||||||
|
" Handle the user actually trying to close a BitBake Python task
|
||||||
|
let line = getline(a:lnum)
|
||||||
|
if line =~ '^\s*}'
|
||||||
|
return -2
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Otherwise ignore the brace
|
||||||
let p = 0
|
let p = 0
|
||||||
else
|
else
|
||||||
if p == plnum
|
if p == plnum
|
||||||
@@ -231,15 +240,27 @@ let b:did_indent = 1
|
|||||||
|
|
||||||
|
|
||||||
function BitbakeIndent(lnum)
|
function BitbakeIndent(lnum)
|
||||||
|
if !has('syntax_items')
|
||||||
|
return -1
|
||||||
|
endif
|
||||||
|
|
||||||
let stack = synstack(a:lnum, col("."))
|
let stack = synstack(a:lnum, col("."))
|
||||||
if len(stack) == 0
|
if len(stack) == 0
|
||||||
return -1
|
return -1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let name = synIDattr(stack[0], "name")
|
let name = synIDattr(stack[0], "name")
|
||||||
|
"echo name
|
||||||
|
|
||||||
if index(["bbPyDefRegion", "bbPyFuncRegion"], name) != -1
|
if index(["bbPyDefRegion", "bbPyFuncRegion"], name) != -1
|
||||||
let ret = GetPythonIndent(a:lnum)
|
let ret = GetPythonIndent(a:lnum)
|
||||||
|
" Should always be indented by at least one shiftwidth; but allow
|
||||||
|
" return of -1 (defer to autoindent) or -2 (force indent to 0)
|
||||||
|
if ret == 0
|
||||||
|
return shiftwidth()
|
||||||
|
elseif ret == -2
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
return ret
|
return ret
|
||||||
endif
|
endif
|
||||||
|
|
||||||
Reference in New Issue
Block a user