diff runtime/indent/bzl.vim @ 25402:bdda48f01a68

Update runtime files Commit: https://github.com/vim/vim/commit/53f7fccc9413c9f770694b56f40f242d383b2d5f Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jul 28 20:10:16 2021 +0200 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Wed, 28 Jul 2021 20:15:05 +0200
parents 63b0b7b79b25
children
line wrap: on
line diff
--- a/runtime/indent/bzl.vim
+++ b/runtime/indent/bzl.vim
@@ -1,7 +1,7 @@
 " Vim indent file
 " Language:	Bazel (http://bazel.io)
 " Maintainer:	David Barnett (https://github.com/google/vim-ft-bzl)
-" Last Change:	2017 Jun 13
+" Last Change:	2021 Jul 08
 
 if exists('b:did_indent')
   finish
@@ -41,30 +41,41 @@ function GetBzlIndent(lnum) abort
     if exists('g:pyindent_open_paren')
       let l:pyindent_open_paren = g:pyindent_open_paren
     endif
-    let g:pyindent_nested_paren = 'shiftwidth() * 2'
-    let g:pyindent_open_paren = 'shiftwidth() * 2'
+    let g:pyindent_nested_paren = 'shiftwidth()'
+    let g:pyindent_open_paren = 'shiftwidth()'
   endif
 
   let l:indent = -1
 
-  " Indent inside parens.
-  " Align with the open paren unless it is at the end of the line.
-  " E.g.
-  "   open_paren_not_at_EOL(100,
-  "                         (200,
-  "                          300),
-  "                         400)
-  "   open_paren_at_EOL(
-  "       100, 200, 300, 400)
   call cursor(a:lnum, 1)
   let [l:par_line, l:par_col] = searchpairpos('(\|{\|\[', '', ')\|}\|\]', 'bW',
       \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :" .
       \ " synIDattr(synID(line('.'), col('.'), 1), 'name')" .
       \ " =~ '\\(Comment\\|String\\)$'")
   if l:par_line > 0
-    call cursor(l:par_line, 1)
-    if l:par_col != col('$') - 1
-      let l:indent = l:par_col
+    " Indent inside parens.
+    if searchpair('(\|{\|\[', '', ')\|}\|\]', 'W',
+      \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :" .
+      \ " synIDattr(synID(line('.'), col('.'), 1), 'name')" .
+      \ " =~ '\\(Comment\\|String\\)$'") && line('.') == a:lnum
+      " If cursor is at close parens, match indent with open parens.
+      " E.g.
+      "   foo(
+      "   )
+      let l:indent = indent(l:par_line)
+    else
+      " Align with the open paren unless it is at the end of the line.
+      " E.g.
+      "   open_paren_not_at_EOL(100,
+      "                         (200,
+      "                          300),
+      "                         400)
+      "   open_paren_at_EOL(
+      "       100, 200, 300, 400)
+      call cursor(l:par_line, 1)
+      if l:par_col != col('$') - 1
+        let l:indent = l:par_col
+      endif
     endif
   endif