]> Sergey Matveev's repositories - dotfiles.git/blobdiff - vim/.vim/pack/stargrave/start/defsplit/autoload/defsplit.vim
Fix f-args usage in vim9script
[dotfiles.git] / vim / .vim / pack / stargrave / start / defsplit / autoload / defsplit.vim
index 74337e8f2c0e3f54371ef7d0b0914e11ee4f6f9d..8fb89e839c83c9d3a15c302c8c867bf8a5844408 100644 (file)
@@ -1,10 +1,10 @@
 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
@@ -46,8 +46,8 @@ enddef
 
 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
@@ -71,9 +71,9 @@ export def Do(brsAllowable: list<string>, singleLineComma: bool, ...args: list<n
     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
@@ -87,7 +87,7 @@ export def Do(brsAllowable: list<string>, singleLineComma: bool, ...args: list<n
         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)