[oe-commits] [bitbake] 02/13: bitbake: contrib/vim: Modify Python indentation to work with 'python do_task {'

git at git.openembedded.org git at git.openembedded.org
Wed Oct 23 22:00:06 UTC 2019


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository bitbake.

commit cd45a25b2a649e88ddd455bfa3dddc6a60340c03
Author: Chris Laplante via bitbake-devel <bitbake-devel at lists.openembedded.org>
AuthorDate: Thu Oct 17 12:36:48 2019 -0400

    bitbake: contrib/vim: Modify Python indentation to work with 'python do_task {'
    
    Signed-off-by: Chris Laplante <chris.laplante at agilent.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 bitbake/contrib/vim/bitbake.vim | 44 +++++++++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 17 deletions(-)

diff --git a/bitbake/contrib/vim/bitbake.vim b/bitbake/contrib/vim/bitbake.vim
index a210cf5..ff86c19 100644
--- a/bitbake/contrib/vim/bitbake.vim
+++ b/bitbake/contrib/vim/bitbake.vim
@@ -79,8 +79,14 @@ function GetPythonIndent(lnum)
             \ . " =~ '\\(Comment\\|Todo\\|String\\)$'",
             \ searchpair_stopline, searchpair_timeout)
     if parlnum > 0
-      let plindent = indent(parlnum)
-      let plnumstart = parlnum
+      if s:is_python_func_def(parlnum)
+        let parlnum = 0
+        let plindent = indent(plnum)
+        let plnumstart = plnum
+      else
+        let plindent = indent(parlnum)
+        let plnumstart = parlnum
+      endif
     else
       let plindent = indent(plnum)
       let plnumstart = plnum
@@ -98,22 +104,26 @@ function GetPythonIndent(lnum)
             \ . " =~ '\\(Comment\\|Todo\\|String\\)$'",
             \ searchpair_stopline, searchpair_timeout)
     if p > 0
-      if p == plnum
-        " When the start is inside parenthesis, only indent one 'shiftwidth'.
-        let pp = searchpair('(\|{\|\[', '', ')\|}\|\]', 'bW',
-            \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
-            \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
-            \ . " =~ '\\(Comment\\|Todo\\|String\\)$'",
-            \ searchpair_stopline, searchpair_timeout)
-        if pp > 0
-          return indent(plnum) + (exists("g:pyindent_nested_paren") ? eval(g:pyindent_nested_paren) : shiftwidth())
+        if s:is_python_func_def(p)
+          let p = 0
+        else
+          if p == plnum
+            " When the start is inside parenthesis, only indent one 'shiftwidth'.
+            let pp = searchpair('(\|{\|\[', '', ')\|}\|\]', 'bW',
+                \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
+                \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
+                \ . " =~ '\\(Comment\\|Todo\\|String\\)$'",
+                \ searchpair_stopline, searchpair_timeout)
+            if pp > 0
+              return indent(plnum) + (exists("g:pyindent_nested_paren") ? eval(g:pyindent_nested_paren) : shiftwidth())
+            endif
+            return indent(plnum) + (exists("g:pyindent_open_paren") ? eval(g:pyindent_open_paren) : (shiftwidth() * 2))
+          endif
+          if plnumstart == p
+            return indent(plnum)
+          endif
+          return plindent
         endif
-        return indent(plnum) + (exists("g:pyindent_open_paren") ? eval(g:pyindent_open_paren) : (shiftwidth() * 2))
-      endif
-      if plnumstart == p
-        return indent(plnum)
-      endif
-      return plindent
     endif
 
   endif

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list