aboutsummaryrefslogtreecommitdiff
path: root/runtime/indent
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-04-29 21:57:46 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-04-29 23:35:37 -0400
commitf5d1f0bf0372ac57c8b1f814bb5b18f13b3b53de (patch)
treeac3ecc8d51aceea2c4d5b9557c5596bb1ce09a23 /runtime/indent
parent1e03e76dafb5d166bb3d9ed262695f306de6ac4d (diff)
downloadrneovim-f5d1f0bf0372ac57c8b1f814bb5b18f13b3b53de.tar.gz
rneovim-f5d1f0bf0372ac57c8b1f814bb5b18f13b3b53de.tar.bz2
rneovim-f5d1f0bf0372ac57c8b1f814bb5b18f13b3b53de.zip
vim-patch:1c6737b20a5c
Update runtime files. https://github.com/vim/vim/commit/1c6737b20a5cf71751b180461cea22fc76d8870c
Diffstat (limited to 'runtime/indent')
-rw-r--r--runtime/indent/json.vim22
1 files changed, 12 insertions, 10 deletions
diff --git a/runtime/indent/json.vim b/runtime/indent/json.vim
index b66a03d81b..c649e37013 100644
--- 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