diff runtime/indent/json.vim @ 22171:d4c7b3e9cd17

Update runtime files. Commit: https://github.com/vim/vim/commit/1c6737b20a5cf71751b180461cea22fc76d8870c Author: Bram Moolenaar <Bram@vim.org> Date: Mon Sep 7 22:18:52 2020 +0200 Update runtime files.
author Bram Moolenaar <Bram@vim.org>
date Mon, 07 Sep 2020 22:30:04 +0200
parents 63b0b7b79b25
children 11b656e74444
line wrap: on
line diff
--- a/runtime/indent/json.vim
+++ b/runtime/indent/json.vim
@@ -1,7 +1,7 @@
 " Vim indent file
 " Language:		JSON
 " Mantainer:		Eli Parra <eli@elzr.com> https://github.com/elzr/vim-json
-" Last Change:          2017 Jun 13
+" Last Change:          2020 Aug 30
 "   https://github.com/jakar/vim-json/commit/20b650e22aa750c4ab6a66aa646bdd95d7cd548a#diff-e81fc111b2052e306d126bd9989f7b7c
 " Original Author:	Rogerz Zhang <rogerz.zhang at gmail.com> http://github.com/rogerz/vim-json
 " Acknowledgement:      Based off of vim-javascript maintained by Darrick Wiebe 
@@ -19,7 +19,7 @@ let b:did_indent = 1
 setlocal nosmartindent
 
 " Now, set up our indentation expression and keys that trigger it.
-setlocal indentexpr=GetJSONIndent()
+setlocal indentexpr=GetJSONIndent(v:lnum)
 setlocal indentkeys=0{,0},0),0[,0],!^F,o,O,e
 
 " Only define the function once.
@@ -86,26 +86,28 @@ endfunction
 " 3. GetJSONIndent Function {{{1
 " =========================
 
-function GetJSONIndent()
+function GetJSONIndent(...)
   " 3.1. Setup {{{2
   " ----------
+  " For the current line, use the first argument if given, else v:lnum
+  let clnum = a:0 ? a:1 : v:lnum
 
-  " Set up variables for restoring position in file.  Could use v:lnum here.
+  " Set up variables for restoring position in file.  Could use clnum here.
   let vcol = col('.')
 
   " 3.2. Work on the current line {{{2
   " -----------------------------
 
   " Get the current line.
-  let line = getline(v:lnum)
+  let line = getline(clnum)
   let ind = -1
 
   " If we got a closing bracket on an empty line, find its match and indent
   " according to it.
   let col = matchend(line, '^\s*[]}]')
 
-  if col > 0 && !s:IsInString(v:lnum, col)
-    call cursor(v:lnum, col)
+  if col > 0 && !s:IsInString(clnum, col)
+    call cursor(clnum, col)
     let bs = strpart('{}[]', stridx('}]', line[col - 1]) * 2, 2)
 
     let pairstart = escape(bs[0], '[')
@@ -122,14 +124,14 @@ function GetJSONIndent()
   endif
 
   " If we are in a multi-line string, don't do anything to it.
-  if s:IsInString(v:lnum, matchend(line, '^\s*') + 1)
+  if s:IsInString(clnum, matchend(line, '^\s*') + 1)
     return indent('.')
   endif
 
   " 3.3. Work on the previous line. {{{2
   " -------------------------------
 
-  let lnum = prevnonblank(v:lnum - 1)
+  let lnum = prevnonblank(clnum - 1)
 
   if lnum == 0
     return 0
@@ -151,7 +153,7 @@ function GetJSONIndent()
     if counts[0] == '1' || counts[1] == '1' || counts[2] == '1'
       return ind + shiftwidth()
     else
-      call cursor(v:lnum, vcol)
+      call cursor(clnum, vcol)
     end
   endif