vim9script
-# Python function call splitter
+# Function call splitter
# Maintainer: Sergey Matveev <stargrave@stargrave.org>
# License: GNU General Public License version 3 of the License or later
#
-# This plugin splits Python function call on several lines.
+# This plugin splits function call on several lines.
#
# def foobar(self, foo: str, bar: Some[thing, too]) -> None:
# to
const Brs = {"(": ")", "[": "]", "{": "}"}
-export def Do(brsAllowable: list<string>, singleLineComma: bool, ...args: list<number>)
- var skip = len(args) == 0 ? 0 : args[1]
+export def Do(brsAllowable: list<string>, singleLineComma: bool, ...args: list<string>)
+ var skip = len(args) == 0 ? 0 : str2nr(args[0])
var shift = get(b:, "defsplit_shift", " ")
var line = getline(".")
var prfx: string
endwhile
var [curly, round, squar, outbuf] = [0, 0, 0, ""]
var ready = [strpart(line, 0, brfirst + 1)]
- var trailingComma = v:true
+ var trailingComma = true
for c in split(line[brfirst + 1 : brlast - 1], '\zs')
- if c ==# "*" | trailingComma = v:false | endif
+ if c ==# "*" | trailingComma = false | endif
if outbuf ==# "" && c ==# " " | continue | endif
outbuf ..= c
if c ==# "," && !curly && !round && !squar
elseif c ==# "}" | curly -= 1
endif
endfor
- if trailingComma && !(singleLineComma == v:true && len(ready) == 1)
+ if trailingComma && !(singleLineComma == true && len(ready) == 1)
outbuf = outbuf .. ","
endif
ready = add(ready, prfx .. shift .. outbuf)