neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

vimfn.lua (424740B)


      1 --- @meta _
      2 -- THIS FILE IS GENERATED
      3 -- DO NOT EDIT
      4 error('Cannot require a meta file')
      5 
      6 --- Return the absolute value of {expr}.  When {expr} evaluates to
      7 --- a |Float| abs() returns a |Float|.  When {expr} can be
      8 --- converted to a |Number| abs() returns a |Number|.  Otherwise
      9 --- abs() gives an error message and returns -1.
     10 --- Examples: >vim
     11 ---   echo abs(1.456)
     12 --- <  1.456  >vim
     13 ---   echo abs(-5.456)
     14 --- <  5.456  >vim
     15 ---   echo abs(-4)
     16 --- <  4
     17 ---
     18 --- @param expr number
     19 --- @return number
     20 function vim.fn.abs(expr) end
     21 
     22 --- Return the arc cosine of {expr} measured in radians, as a
     23 --- |Float| in the range of [0, pi].
     24 --- {expr} must evaluate to a |Float| or a |Number| in the range
     25 --- [-1, 1].
     26 --- Returns NaN if {expr} is outside the range [-1, 1].  Returns
     27 --- 0.0 if {expr} is not a |Float| or a |Number|.
     28 --- Examples: >vim
     29 ---   echo acos(0)
     30 --- <  1.570796 >vim
     31 ---   echo acos(-0.5)
     32 --- <  2.094395
     33 ---
     34 --- @param expr number
     35 --- @return number
     36 function vim.fn.acos(expr) end
     37 
     38 --- Append the item {expr} to |List| or |Blob| {object}.  Returns
     39 --- the resulting |List| or |Blob|.  Examples: >vim
     40 ---   let alist = add([1, 2, 3], item)
     41 ---   call add(mylist, "woodstock")
     42 --- <Note that when {expr} is a |List| it is appended as a single
     43 --- item.  Use |extend()| to concatenate |Lists|.
     44 --- When {object} is a |Blob| then {expr} must be a number.
     45 --- Use |insert()| to add an item at another position.
     46 --- Returns 1 if {object} is not a |List| or a |Blob|.
     47 ---
     48 --- @param object any
     49 --- @param expr any
     50 --- @return any # Resulting |List| or |Blob|, or 1 if {object} is not a |List| or a |Blob|.
     51 function vim.fn.add(object, expr) end
     52 
     53 --- Bitwise AND on the two arguments.  The arguments are converted
     54 --- to a number.  A List, Dict or Float argument causes an error.
     55 --- Also see |or()| and |xor()|.
     56 --- Example: >vim
     57 ---   let flag = and(bits, 0x80)
     58 --- <
     59 ---
     60 --- @param expr number
     61 --- @param expr1 number
     62 --- @return integer
     63 vim.fn['and'] = function(expr, expr1) end
     64 
     65 --- Returns Dictionary of |api-metadata|.
     66 ---
     67 --- View it in a nice human-readable format: >vim
     68 ---        lua vim.print(vim.fn.api_info())
     69 --- <
     70 ---
     71 --- @return table
     72 function vim.fn.api_info() end
     73 
     74 --- When {text} is a |List|: Append each item of the |List| as a
     75 --- text line below line {lnum} in the current buffer.
     76 --- Otherwise append {text} as one text line below line {lnum} in
     77 --- the current buffer.
     78 --- Any type of item is accepted and converted to a String.
     79 --- {lnum} can be zero to insert a line before the first one.
     80 --- {lnum} is used like with |getline()|.
     81 --- Returns 1 for failure ({lnum} out of range or out of memory),
     82 --- 0 for success.  When {text} is an empty list zero is returned,
     83 --- no matter the value of {lnum}.  Example: >vim
     84 ---   let failed = append(line('$'), "# THE END")
     85 ---   let failed = append(0, ["Chapter 1", "the beginning"])
     86 --- <
     87 ---
     88 --- @param lnum integer|string
     89 --- @param text string|string[]
     90 --- @return 0|1
     91 function vim.fn.append(lnum, text) end
     92 
     93 --- Like |append()| but append the text in buffer {expr}.
     94 ---
     95 --- This function works only for loaded buffers.  First call
     96 --- |bufload()| if needed.
     97 ---
     98 --- For the use of {buf}, see |bufname()|.
     99 ---
    100 --- {lnum} is the line number to append below.  Note that using
    101 --- |line()| would use the current buffer, not the one appending
    102 --- to.  Use "$" to append at the end of the buffer.  Other string
    103 --- values are not supported.
    104 ---
    105 --- On success 0 is returned, on failure 1 is returned.
    106 ---
    107 --- If {buf} is not a valid buffer or {lnum} is not valid, an
    108 --- error message is given.  Example: >vim
    109 ---   let failed = appendbufline(13, 0, "# THE START")
    110 --- <However, when {text} is an empty list then no error is given
    111 --- for an invalid {lnum}, since {lnum} isn't actually used.
    112 ---
    113 --- @param buf integer|string
    114 --- @param lnum integer
    115 --- @param text string
    116 --- @return 0|1
    117 function vim.fn.appendbufline(buf, lnum, text) end
    118 
    119 --- The result is the number of files in the argument list.  See
    120 --- |arglist|.
    121 --- If {winid} is not supplied, the argument list of the current
    122 --- window is used.
    123 --- If {winid} is -1, the global argument list is used.
    124 --- Otherwise {winid} specifies the window of which the argument
    125 --- list is used: either the window number or the window ID.
    126 --- Returns -1 if the {winid} argument is invalid.
    127 ---
    128 --- @param winid? integer
    129 --- @return integer
    130 function vim.fn.argc(winid) end
    131 
    132 --- The result is the current index in the argument list.  0 is
    133 --- the first file.  |argc()| - 1 is the last one.  See |arglist|.
    134 ---
    135 --- @return integer
    136 function vim.fn.argidx() end
    137 
    138 --- Return the argument list ID.  This is a number which
    139 --- identifies the argument list being used.  Zero is used for the
    140 --- global argument list.  See |arglist|.
    141 --- Returns -1 if the arguments are invalid.
    142 ---
    143 --- Without arguments use the current window.
    144 --- With {winnr} only use this window in the current tab page.
    145 --- With {winnr} and {tabnr} use the window in the specified tab
    146 --- page.
    147 --- {winnr} can be the window number or the |window-ID|.
    148 ---
    149 --- @param winnr? integer
    150 --- @param tabnr? integer
    151 --- @return integer
    152 function vim.fn.arglistid(winnr, tabnr) end
    153 
    154 --- The result is the {nr}th file in the argument list.  See
    155 --- |arglist|.  "argv(0)" is the first one.  Example: >vim
    156 ---   let i = 0
    157 ---   while i < argc()
    158 ---     let f = escape(fnameescape(argv(i)), '.')
    159 ---     exe 'amenu Arg.' .. f .. ' :e ' .. f .. '<CR>'
    160 ---     let i = i + 1
    161 ---   endwhile
    162 --- <Without the {nr} argument, or when {nr} is -1, a |List| with
    163 --- the whole |arglist| is returned.
    164 ---
    165 --- The {winid} argument specifies the window ID, see |argc()|.
    166 --- For the Vim command line arguments see |v:argv|.
    167 ---
    168 --- Returns an empty string if {nr}th argument is not present in
    169 --- the argument list.  Returns an empty List if the {winid}
    170 --- argument is invalid.
    171 ---
    172 --- @param nr? integer
    173 --- @param winid? integer
    174 --- @return string|string[]
    175 function vim.fn.argv(nr, winid) end
    176 
    177 --- Return the arc sine of {expr} measured in radians, as a |Float|
    178 --- in the range of [-pi/2, pi/2].
    179 --- {expr} must evaluate to a |Float| or a |Number| in the range
    180 --- [-1, 1].
    181 --- Returns NaN if {expr} is outside the range [-1, 1].  Returns
    182 --- 0.0 if {expr} is not a |Float| or a |Number|.
    183 --- Examples: >vim
    184 ---   echo asin(0.8)
    185 --- <  0.927295 >vim
    186 ---   echo asin(-0.5)
    187 --- <  -0.523599
    188 ---
    189 --- @param expr any
    190 --- @return number
    191 function vim.fn.asin(expr) end
    192 
    193 --- Run {cmd} and add an error message to |v:errors| if it does
    194 --- NOT produce a beep or visual bell.
    195 --- Also see |assert_fails()|, |assert_nobeep()| and
    196 --- |assert-return|.
    197 ---
    198 --- @param cmd string
    199 --- @return 0|1
    200 function vim.fn.assert_beeps(cmd) end
    201 
    202 --- When {expected} and {actual} are not equal an error message is
    203 --- added to |v:errors| and 1 is returned.  Otherwise zero is
    204 --- returned. |assert-return|
    205 --- The error is in the form "Expected {expected} but got
    206 --- {actual}".  When {msg} is present it is prefixed to that,
    207 --- along with the location of the assert when run from a script.
    208 ---
    209 --- There is no automatic conversion, the String "4" is different
    210 --- from the Number 4.  And the number 4 is different from the
    211 --- Float 4.0.  The value of 'ignorecase' is not used here, case
    212 --- always matters.
    213 --- Example: >vim
    214 ---   call assert_equal('foo', 'bar', 'baz')
    215 --- <Will add the following to |v:errors|: >
    216 ---   test.vim line 12: baz: Expected 'foo' but got 'bar'
    217 --- <
    218 ---
    219 --- @param expected any
    220 --- @param actual any
    221 --- @param msg? any
    222 --- @return 0|1
    223 function vim.fn.assert_equal(expected, actual, msg) end
    224 
    225 --- When the files {fname_one} and {fname_two} do not contain
    226 --- exactly the same text an error message is added to |v:errors|.
    227 --- Also see |assert-return|.
    228 --- When {fname_one} or {fname_two} does not exist the error will
    229 --- mention that.
    230 ---
    231 --- @param fname_one string
    232 --- @param fname_two string
    233 --- @return 0|1
    234 function vim.fn.assert_equalfile(fname_one, fname_two) end
    235 
    236 --- When v:exception does not contain the string {error} an error
    237 --- message is added to |v:errors|.  Also see |assert-return|.
    238 --- This can be used to assert that a command throws an exception.
    239 --- Using the error number, followed by a colon, avoids problems
    240 --- with translations: >vim
    241 ---   try
    242 ---     commandthatfails
    243 ---     call assert_false(1, 'command should have failed')
    244 ---   catch
    245 ---     call assert_exception('E492:')
    246 ---   endtry
    247 --- <
    248 ---
    249 --- @param error any
    250 --- @param msg? any
    251 --- @return 0|1
    252 function vim.fn.assert_exception(error, msg) end
    253 
    254 --- Run {cmd} and add an error message to |v:errors| if it does
    255 --- NOT produce an error or when {error} is not found in the
    256 --- error message.  Also see |assert-return|.
    257 ---
    258 --- When {error} is a string it must be found literally in the
    259 --- first reported error. Most often this will be the error code,
    260 --- including the colon, e.g. "E123:". >vim
    261 ---   call assert_fails('bad cmd', 'E987:')
    262 --- <
    263 --- When {error} is a |List| with one or two strings, these are
    264 --- used as patterns.  The first pattern is matched against the
    265 --- first reported error: >vim
    266 ---   call assert_fails('cmd', ['E987:.*expected bool'])
    267 --- <The second pattern, if present, is matched against the last
    268 --- reported error.  To only match the last error use an empty
    269 --- string for the first error: >vim
    270 ---   call assert_fails('cmd', ['', 'E987:'])
    271 --- <
    272 --- If {msg} is empty then it is not used.  Do this to get the
    273 --- default message when passing the {lnum} argument.
    274 ---           *E1115*
    275 --- When {lnum} is present and not negative, and the {error}
    276 --- argument is present and matches, then this is compared with
    277 --- the line number at which the error was reported. That can be
    278 --- the line number in a function or in a script.
    279 ---           *E1116*
    280 --- When {context} is present it is used as a pattern and matched
    281 --- against the context (script name or function name) where
    282 --- {lnum} is located in.
    283 ---
    284 --- Note that beeping is not considered an error, and some failing
    285 --- commands only beep.  Use |assert_beeps()| for those.
    286 ---
    287 --- @param cmd string
    288 --- @param error? any
    289 --- @param msg? any
    290 --- @param lnum? integer
    291 --- @param context? any
    292 --- @return 0|1
    293 function vim.fn.assert_fails(cmd, error, msg, lnum, context) end
    294 
    295 --- When {actual} is not false an error message is added to
    296 --- |v:errors|, like with |assert_equal()|.
    297 --- The error is in the form "Expected False but got {actual}".
    298 --- When {msg} is present it is prefixed to that, along with the
    299 --- location of the assert when run from a script.
    300 --- Also see |assert-return|.
    301 ---
    302 --- A value is false when it is zero. When {actual} is not a
    303 --- number the assert fails.
    304 ---
    305 --- @param actual any
    306 --- @param msg? any
    307 --- @return 0|1
    308 function vim.fn.assert_false(actual, msg) end
    309 
    310 --- This asserts number and |Float| values.  When {actual}  is lower
    311 --- than {lower} or higher than {upper} an error message is added
    312 --- to |v:errors|.  Also see |assert-return|.
    313 --- The error is in the form "Expected range {lower} - {upper},
    314 --- but got {actual}".  When {msg} is present it is prefixed to
    315 --- that.
    316 ---
    317 --- @param lower number
    318 --- @param upper number
    319 --- @param actual number
    320 --- @param msg? string
    321 --- @return 0|1
    322 function vim.fn.assert_inrange(lower, upper, actual, msg) end
    323 
    324 --- When {pattern} does not match {actual} an error message is
    325 --- added to |v:errors|.  Also see |assert-return|.
    326 --- The error is in the form "Pattern {pattern} does not match
    327 --- {actual}".  When {msg} is present it is prefixed to that,
    328 --- along with the location of the assert when run from a script.
    329 ---
    330 --- {pattern} is used as with |expr-=~|: The matching is always done
    331 --- like 'magic' was set and 'cpoptions' is empty, no matter what
    332 --- the actual value of 'magic' or 'cpoptions' is.
    333 ---
    334 --- {actual} is used as a string, automatic conversion applies.
    335 --- Use "^" and "$" to match with the start and end of the text.
    336 --- Use both to match the whole text.
    337 ---
    338 --- Example: >vim
    339 ---   call assert_match('^f.*o$', 'foobar')
    340 --- <Will result in a string to be added to |v:errors|: >
    341 ---   test.vim line 12: Pattern '^f.*o$' does not match 'foobar'
    342 --- <
    343 ---
    344 --- @param pattern string
    345 --- @param actual string
    346 --- @param msg? string
    347 --- @return 0|1
    348 function vim.fn.assert_match(pattern, actual, msg) end
    349 
    350 --- Run {cmd} and add an error message to |v:errors| if it
    351 --- produces a beep or visual bell.
    352 --- Also see |assert_beeps()|.
    353 ---
    354 --- @param cmd string
    355 --- @return 0|1
    356 function vim.fn.assert_nobeep(cmd) end
    357 
    358 --- The opposite of `assert_equal()`: add an error message to
    359 --- |v:errors| when {expected} and {actual} are equal.
    360 --- Also see |assert-return|.
    361 ---
    362 --- @param expected any
    363 --- @param actual any
    364 --- @param msg? any
    365 --- @return 0|1
    366 function vim.fn.assert_notequal(expected, actual, msg) end
    367 
    368 --- The opposite of `assert_match()`: add an error message to
    369 --- |v:errors| when {pattern} matches {actual}.
    370 --- Also see |assert-return|.
    371 ---
    372 --- @param pattern string
    373 --- @param actual string
    374 --- @param msg? string
    375 --- @return 0|1
    376 function vim.fn.assert_notmatch(pattern, actual, msg) end
    377 
    378 --- Report a test failure directly, using String {msg}.
    379 --- Always returns one.
    380 ---
    381 --- @param msg string
    382 --- @return 0|1
    383 function vim.fn.assert_report(msg) end
    384 
    385 --- When {actual} is not true an error message is added to
    386 --- |v:errors|, like with |assert_equal()|.
    387 --- Also see |assert-return|.
    388 --- A value is |TRUE| when it is a non-zero number or |v:true|.
    389 --- When {actual} is not a number or |v:true| the assert fails.
    390 --- When {msg} is given it is prefixed to the default message,
    391 --- along with the location of the assert when run from a script.
    392 ---
    393 --- @param actual any
    394 --- @param msg? string
    395 --- @return 0|1
    396 function vim.fn.assert_true(actual, msg) end
    397 
    398 --- Return the principal value of the arc tangent of {expr}, in
    399 --- the range [-pi/2, +pi/2] radians, as a |Float|.
    400 --- {expr} must evaluate to a |Float| or a |Number|.
    401 --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
    402 --- Examples: >vim
    403 ---   echo atan(100)
    404 --- <  1.560797 >vim
    405 ---   echo atan(-4.01)
    406 --- <  -1.326405
    407 ---
    408 --- @param expr number
    409 --- @return number
    410 function vim.fn.atan(expr) end
    411 
    412 --- Return the arc tangent of {expr1} / {expr2}, measured in
    413 --- radians, as a |Float| in the range [-pi, pi].
    414 --- {expr1} and {expr2} must evaluate to a |Float| or a |Number|.
    415 --- Returns 0.0 if {expr1} or {expr2} is not a |Float| or a
    416 --- |Number|.
    417 --- Examples: >vim
    418 ---   echo atan2(-1, 1)
    419 --- <  -0.785398 >vim
    420 ---   echo atan2(1, -1)
    421 --- <  2.356194
    422 ---
    423 --- @param expr1 number
    424 --- @param expr2 number
    425 --- @return number
    426 function vim.fn.atan2(expr1, expr2) end
    427 
    428 --- Return a List containing the number value of each byte in Blob
    429 --- {blob}.  Examples: >vim
    430 ---   blob2list(0z0102.0304)  " returns [1, 2, 3, 4]
    431 ---   blob2list(0z)    " returns []
    432 --- <Returns an empty List on error.  |list2blob()| does the
    433 --- opposite.
    434 ---
    435 --- @param blob any
    436 --- @return any[]
    437 function vim.fn.blob2list(blob) end
    438 
    439 --- Put up a file requester.  This only works when "has("browse")"
    440 --- returns |TRUE| (only in some GUI versions).
    441 --- The input fields are:
    442 ---     {save}  when |TRUE|, select file to write
    443 ---     {title}  title for the requester
    444 ---     {initdir}  directory to start browsing in
    445 ---     {default}  default file name
    446 --- An empty string is returned when the "Cancel" button is hit,
    447 --- something went wrong, or browsing is not possible.
    448 ---
    449 --- @param save any
    450 --- @param title string
    451 --- @param initdir string
    452 --- @param default string
    453 --- @return 0|1
    454 function vim.fn.browse(save, title, initdir, default) end
    455 
    456 --- Put up a directory requester.  This only works when
    457 --- "has("browse")" returns |TRUE| (only in some GUI versions).
    458 --- On systems where a directory browser is not supported a file
    459 --- browser is used.  In that case: select a file in the directory
    460 --- to be used.
    461 --- The input fields are:
    462 ---     {title}  title for the requester
    463 ---     {initdir}  directory to start browsing in
    464 --- When the "Cancel" button is hit, something went wrong, or
    465 --- browsing is not possible, an empty string is returned.
    466 ---
    467 --- @param title string
    468 --- @param initdir string
    469 --- @return 0|1
    470 function vim.fn.browsedir(title, initdir) end
    471 
    472 --- Add a buffer to the buffer list with name {name} (must be a
    473 --- String).
    474 --- If a buffer for file {name} already exists, return that buffer
    475 --- number.  Otherwise return the buffer number of the newly
    476 --- created buffer.  When {name} is an empty string then a new
    477 --- buffer is always created.
    478 --- The buffer will not have 'buflisted' set and not be loaded
    479 --- yet.  To add some text to the buffer use this: >vim
    480 ---   let bufnr = bufadd('someName')
    481 ---   call bufload(bufnr)
    482 ---   call setbufline(bufnr, 1, ['some', 'text'])
    483 --- <Returns 0 on error.
    484 ---
    485 --- @param name string
    486 --- @return integer
    487 function vim.fn.bufadd(name) end
    488 
    489 --- The result is a Number, which is |TRUE| if a buffer called
    490 --- {buf} exists.
    491 --- If the {buf} argument is a number, buffer numbers are used.
    492 --- Number zero is the alternate buffer for the current window.
    493 ---
    494 --- If the {buf} argument is a string it must match a buffer name
    495 --- exactly.  The name can be:
    496 --- - Relative to the current directory.
    497 --- - A full path.
    498 --- - The name of a buffer with 'buftype' set to "nofile".
    499 --- - A URL name.
    500 --- Unlisted buffers will be found.
    501 --- Note that help files are listed by their short name in the
    502 --- output of |:buffers|, but bufexists() requires using their
    503 --- long name to be able to find them.
    504 --- bufexists() may report a buffer exists, but to use the name
    505 --- with a |:buffer| command you may need to use |expand()|.  Esp
    506 --- for MS-Windows 8.3 names in the form "c:\DOCUME~1"
    507 --- Use "bufexists(0)" to test for the existence of an alternate
    508 --- file name.
    509 ---
    510 --- @param buf any
    511 --- @return 0|1
    512 function vim.fn.bufexists(buf) end
    513 
    514 --- @deprecated
    515 --- Obsolete name for |bufexists()|.
    516 ---
    517 --- @param ... any
    518 --- @return 0|1
    519 function vim.fn.buffer_exists(...) end
    520 
    521 --- @deprecated
    522 --- Obsolete name for |bufname()|.
    523 ---
    524 --- @param ... any
    525 --- @return string
    526 function vim.fn.buffer_name(...) end
    527 
    528 --- @deprecated
    529 --- Obsolete name for |bufnr()|.
    530 ---
    531 --- @param ... any
    532 --- @return integer
    533 function vim.fn.buffer_number(...) end
    534 
    535 --- The result is a Number, which is |TRUE| if a buffer called
    536 --- {buf} exists and is listed (has the 'buflisted' option set).
    537 --- The {buf} argument is used like with |bufexists()|.
    538 ---
    539 --- @param buf any
    540 --- @return 0|1
    541 function vim.fn.buflisted(buf) end
    542 
    543 --- Ensure the buffer {buf} is loaded.  When the buffer name
    544 --- refers to an existing file then the file is read.  Otherwise
    545 --- the buffer will be empty.  If the buffer was already loaded
    546 --- then there is no change.  If the buffer is not related to a
    547 --- file then no file is read (e.g., when 'buftype' is "nofile").
    548 --- If there is an existing swap file for the file of the buffer,
    549 --- there will be no dialog, the buffer will be loaded anyway.
    550 --- The {buf} argument is used like with |bufexists()|.
    551 ---
    552 --- @param buf any
    553 function vim.fn.bufload(buf) end
    554 
    555 --- The result is a Number, which is |TRUE| if a buffer called
    556 --- {buf} exists and is loaded (shown in a window or hidden).
    557 --- The {buf} argument is used like with |bufexists()|.
    558 ---
    559 --- @param buf any
    560 --- @return 0|1
    561 function vim.fn.bufloaded(buf) end
    562 
    563 --- The result is the name of a buffer.  Mostly as it is displayed
    564 --- by the `:ls` command, but not using special names such as
    565 --- "[No Name]".
    566 --- If {buf} is omitted the current buffer is used.
    567 --- If {buf} is a Number, that buffer number's name is given.
    568 --- Number zero is the alternate buffer for the current window.
    569 --- If {buf} is a String, it is used as a |file-pattern| to match
    570 --- with the buffer names.  This is always done like 'magic' is
    571 --- set and 'cpoptions' is empty.  When there is more than one
    572 --- match an empty string is returned.
    573 --- "" or "%" can be used for the current buffer, "#" for the
    574 --- alternate buffer.
    575 --- A full match is preferred, otherwise a match at the start, end
    576 --- or middle of the buffer name is accepted.  If you only want a
    577 --- full match then put "^" at the start and "$" at the end of the
    578 --- pattern.
    579 --- Listed buffers are found first.  If there is a single match
    580 --- with a listed buffer, that one is returned.  Next unlisted
    581 --- buffers are searched for.
    582 --- If the {buf} is a String, but you want to use it as a buffer
    583 --- number, force it to be a Number by adding zero to it: >vim
    584 ---   echo bufname("3" + 0)
    585 --- <If the buffer doesn't exist, or doesn't have a name, an empty
    586 --- string is returned. >vim
    587 ---   echo bufname("#")  " alternate buffer name
    588 ---   echo bufname(3)    " name of buffer 3
    589 ---   echo bufname("%")  " name of current buffer
    590 ---   echo bufname("file2")  " name of buffer where "file2" matches.
    591 --- <
    592 ---
    593 --- @param buf? integer|string
    594 --- @return string
    595 function vim.fn.bufname(buf) end
    596 
    597 --- The result is the number of a buffer, as it is displayed by
    598 --- the `:ls` command.  For the use of {buf}, see |bufname()|
    599 --- above.
    600 --- If the buffer doesn't exist, -1 is returned.  Or, if the
    601 --- {create} argument is present and TRUE, a new, unlisted,
    602 --- buffer is created and its number is returned.  Example: >vim
    603 ---   let newbuf = bufnr('Scratch001', 1)
    604 --- <Using an empty name uses the current buffer.  To create a new
    605 --- buffer with an empty name use |bufadd()|.
    606 ---
    607 --- bufnr("$") is the last buffer: >vim
    608 ---   let last_buffer = bufnr("$")
    609 --- <The result is a Number, which is the highest buffer number
    610 --- of existing buffers.  Note that not all buffers with a smaller
    611 --- number necessarily exist, because ":bwipeout" may have removed
    612 --- them.  Use |bufexists()| to test for the existence of a buffer.
    613 ---
    614 --- @param buf? integer|string
    615 --- @param create? any
    616 --- @return integer
    617 function vim.fn.bufnr(buf, create) end
    618 
    619 --- The result is a Number, which is the |window-ID| of the first
    620 --- window associated with buffer {buf}.  For the use of {buf},
    621 --- see |bufname()| above.  If buffer {buf} doesn't exist or
    622 --- there is no such window, -1 is returned.  Example: >vim
    623 ---
    624 ---   echo "A window containing buffer 1 is " .. (bufwinid(1))
    625 --- <
    626 --- Only deals with the current tab page.  See |win_findbuf()| for
    627 --- finding more.
    628 ---
    629 --- @param buf any
    630 --- @return integer
    631 function vim.fn.bufwinid(buf) end
    632 
    633 --- Like |bufwinid()| but return the window number instead of the
    634 --- |window-ID|.
    635 --- If buffer {buf} doesn't exist or there is no such window, -1
    636 --- is returned.  Example: >vim
    637 ---
    638 ---   echo "A window containing buffer 1 is " .. (bufwinnr(1))
    639 ---
    640 --- <The number can be used with |CTRL-W_w| and ":wincmd w"
    641 --- |:wincmd|.
    642 ---
    643 --- @param buf any
    644 --- @return integer
    645 function vim.fn.bufwinnr(buf) end
    646 
    647 --- Return the line number that contains the character at byte
    648 --- count {byte} in the current buffer.  This includes the
    649 --- end-of-line character, depending on the 'fileformat' option
    650 --- for the current buffer.  The first character has byte count
    651 --- one.
    652 --- Also see |line2byte()|, |go| and |:goto|.
    653 ---
    654 --- Returns -1 if the {byte} value is invalid.
    655 ---
    656 --- @param byte any
    657 --- @return integer
    658 function vim.fn.byte2line(byte) end
    659 
    660 --- Return byte index of the {nr}th character in the String
    661 --- {expr}.  Use zero for the first character, it then returns
    662 --- zero.
    663 --- If there are no multibyte characters the returned value is
    664 --- equal to {nr}.
    665 --- Composing characters are not counted separately, their byte
    666 --- length is added to the preceding base character.  See
    667 --- |byteidxcomp()| below for counting composing characters
    668 --- separately.
    669 --- When {utf16} is present and TRUE, {nr} is used as the UTF-16
    670 --- index in the String {expr} instead of as the character index.
    671 --- The UTF-16 index is the index in the string when it is encoded
    672 --- with 16-bit words.  If the specified UTF-16 index is in the
    673 --- middle of a character (e.g. in a 4-byte character), then the
    674 --- byte index of the first byte in the character is returned.
    675 --- Refer to |string-offset-encoding| for more information.
    676 --- Example : >vim
    677 ---   echo matchstr(str, ".", byteidx(str, 3))
    678 --- <will display the fourth character.  Another way to do the
    679 --- same: >vim
    680 ---   let s = strpart(str, byteidx(str, 3))
    681 ---   echo strpart(s, 0, byteidx(s, 1))
    682 --- <Also see |strgetchar()| and |strcharpart()|.
    683 ---
    684 --- If there are less than {nr} characters -1 is returned.
    685 --- If there are exactly {nr} characters the length of the string
    686 --- in bytes is returned.
    687 --- See |charidx()| and |utf16idx()| for getting the character and
    688 --- UTF-16 index respectively from the byte index.
    689 --- Examples: >vim
    690 ---   echo byteidx('a😊😊', 2)  " returns 5
    691 ---   echo byteidx('a😊😊', 2, 1)  " returns 1
    692 ---   echo byteidx('a😊😊', 3, 1)  " returns 5
    693 --- <
    694 ---
    695 --- @param expr any
    696 --- @param nr integer
    697 --- @param utf16? any
    698 --- @return integer
    699 function vim.fn.byteidx(expr, nr, utf16) end
    700 
    701 --- Like |byteidx()|, except that a composing character is counted
    702 --- as a separate character.  Example: >vim
    703 ---   let s = 'e' .. nr2char(0x301)
    704 ---   echo byteidx(s, 1)
    705 ---   echo byteidxcomp(s, 1)
    706 ---   echo byteidxcomp(s, 2)
    707 --- <The first and third echo result in 3 ('e' plus composing
    708 --- character is 3 bytes), the second echo results in 1 ('e' is
    709 --- one byte).
    710 ---
    711 --- @param expr any
    712 --- @param nr integer
    713 --- @param utf16? any
    714 --- @return integer
    715 function vim.fn.byteidxcomp(expr, nr, utf16) end
    716 
    717 --- Call function {func} with the items in |List| {arglist} as
    718 --- arguments.
    719 --- {func} can either be a |Funcref| or the name of a function.
    720 --- a:firstline and a:lastline are set to the cursor line.
    721 --- Returns the return value of the called function.
    722 --- {dict} is for functions with the "dict" attribute.  It will be
    723 --- used to set the local variable "self". |Dictionary-function|
    724 ---
    725 --- @param func any
    726 --- @param arglist any
    727 --- @param dict? any
    728 --- @return any
    729 function vim.fn.call(func, arglist, dict) end
    730 
    731 --- Return the smallest integral value greater than or equal to
    732 --- {expr} as a |Float| (round up).
    733 --- {expr} must evaluate to a |Float| or a |Number|.
    734 --- Examples: >vim
    735 ---   echo ceil(1.456)
    736 --- <  2.0  >vim
    737 ---   echo ceil(-5.456)
    738 --- <  -5.0  >vim
    739 ---   echo ceil(4.0)
    740 --- <  4.0
    741 ---
    742 --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
    743 ---
    744 --- @param expr number
    745 --- @return number
    746 function vim.fn.ceil(expr) end
    747 
    748 --- Close a channel or a specific stream associated with it.
    749 --- For a job, {stream} can be one of "stdin", "stdout",
    750 --- "stderr" or "rpc" (closes stdin/stdout for a job started
    751 --- with `"rpc":v:true`) If {stream} is omitted, all streams
    752 --- are closed. If the channel is a pty, this will then close the
    753 --- pty master, sending SIGHUP to the job process.
    754 --- For a socket, there is only one stream, and {stream} should be
    755 --- omitted.
    756 ---
    757 --- @param id integer
    758 --- @param stream? string
    759 --- @return 0|1
    760 function vim.fn.chanclose(id, stream) end
    761 
    762 --- Return the number of the most recent change.  This is the same
    763 --- number as what is displayed with |:undolist| and can be used
    764 --- with the |:undo| command.
    765 --- When a change was made it is the number of that change.  After
    766 --- redo it is the number of the redone change.  After undo it is
    767 --- one less than the number of the undone change.
    768 --- Returns 0 if the undo list is empty.
    769 ---
    770 --- @return integer
    771 function vim.fn.changenr() end
    772 
    773 --- Send data to channel {id}. For a job, it writes it to the
    774 --- stdin of the process. For the stdio channel |channel-stdio|,
    775 --- it writes to Nvim's stdout.  Returns the number of bytes
    776 --- written if the write succeeded, 0 otherwise.
    777 --- See |channel-bytes| for more information.
    778 ---
    779 --- {data} may be a string, string convertible, |Blob|, or a list.
    780 --- If {data} is a list, the items will be joined by newlines; any
    781 --- newlines in an item will be sent as NUL. To send a final
    782 --- newline, include a final empty string. Example: >vim
    783 ---   call chansend(id, ["abc", "123\n456", ""])
    784 --- <will send "abc<NL>123<NUL>456<NL>".
    785 ---
    786 --- chansend() writes raw data, not RPC messages.  If the channel
    787 --- was created with `"rpc":v:true` then the channel expects RPC
    788 --- messages, use |rpcnotify()| and |rpcrequest()| instead.
    789 ---
    790 --- @param id number
    791 --- @param data string|string[]
    792 --- @return 0|1
    793 function vim.fn.chansend(id, data) end
    794 
    795 --- Return Number value of the first char in {string}.
    796 --- Examples: >vim
    797 ---   echo char2nr(" ")  " returns 32
    798 ---   echo char2nr("ABC")  " returns 65
    799 ---   echo char2nr("á")  " returns 225
    800 ---   echo char2nr("á"[0])  " returns 195
    801 ---   echo char2nr("\<M-x>")  " returns 128
    802 --- <Non-ASCII characters are always treated as UTF-8 characters.
    803 --- {utf8} is ignored, it exists only for backwards-compatibility.
    804 --- A combining character is a separate character.
    805 --- |nr2char()| does the opposite.
    806 ---
    807 --- Returns 0 if {string} is not a |String|.
    808 ---
    809 --- @param string string
    810 --- @param utf8? any
    811 --- @return 0|1
    812 function vim.fn.char2nr(string, utf8) end
    813 
    814 --- Return the character class of the first character in {string}.
    815 --- The character class is one of:
    816 ---   0  blank
    817 ---   1  punctuation
    818 ---   2  word character (depends on 'iskeyword')
    819 ---   3  emoji
    820 ---   other  specific Unicode class
    821 --- The class is used in patterns and word motions.
    822 --- Returns 0 if {string} is not a |String|.
    823 ---
    824 --- @param string string
    825 --- @return 0|1|2|3|'other'
    826 function vim.fn.charclass(string) end
    827 
    828 --- Same as |col()| but returns the character index of the column
    829 --- position given with {expr} instead of the byte position.
    830 ---
    831 --- Example:
    832 --- With the cursor on '세' in line 5 with text "여보세요": >vim
    833 ---   echo charcol('.')  " returns 3
    834 ---   echo col('.')    " returns 7
    835 --- <
    836 ---
    837 --- @param expr string|any[]
    838 --- @param winid? integer
    839 --- @return integer
    840 function vim.fn.charcol(expr, winid) end
    841 
    842 --- Return the character index of the byte at {idx} in {string}.
    843 --- The index of the first character is zero.
    844 --- If there are no multibyte characters the returned value is
    845 --- equal to {idx}.
    846 ---
    847 --- When {countcc} is omitted or |FALSE|, then composing characters
    848 --- are not counted separately, their byte length is added to the
    849 --- preceding base character.
    850 --- When {countcc} is |TRUE|, then composing characters are
    851 --- counted as separate characters.
    852 ---
    853 --- When {utf16} is present and TRUE, {idx} is used as the UTF-16
    854 --- index in the String {expr} instead of as the byte index.
    855 ---
    856 --- Returns -1 if the arguments are invalid or if there are less
    857 --- than {idx} bytes.  If there are exactly {idx} bytes the length
    858 --- of the string in characters is returned.
    859 ---
    860 --- An error is given and -1 is returned if the first argument is
    861 --- not a string, the second argument is not a number or when the
    862 --- third argument is present and is not zero or one.
    863 ---
    864 --- See |byteidx()| and |byteidxcomp()| for getting the byte index
    865 --- from the character index and |utf16idx()| for getting the
    866 --- UTF-16 index from the character index.
    867 --- Refer to |string-offset-encoding| for more information.
    868 --- Examples: >vim
    869 ---   echo charidx('áb́ć', 3)    " returns 1
    870 ---   echo charidx('áb́ć', 6, 1)  " returns 4
    871 ---   echo charidx('áb́ć', 16)    " returns -1
    872 ---   echo charidx('a😊😊', 4, 0, 1)  " returns 2
    873 --- <
    874 ---
    875 --- @param string string
    876 --- @param idx integer
    877 --- @param countcc? boolean
    878 --- @param utf16? boolean
    879 --- @return integer
    880 function vim.fn.charidx(string, idx, countcc, utf16) end
    881 
    882 --- Changes the current working directory to {dir}.  The scope of
    883 --- the change is determined as follows:
    884 --- If {scope} is not present, the current working directory is
    885 --- changed to the scope of the current directory:
    886 ---     - If the window local directory (|:lcd|) is set, it
    887 ---       changes the current working directory for that scope.
    888 ---     - Otherwise, if the tab page local directory (|:tcd|) is
    889 ---       set, it changes the current directory for that scope.
    890 ---     - Otherwise, changes the global directory for that scope.
    891 ---
    892 --- If {scope} is present, changes the current working directory
    893 --- for the specified scope:
    894 ---     "window"  Changes the window local directory.  |:lcd|
    895 ---     "tabpage"  Changes the tab page local directory.  |:tcd|
    896 ---     "global"  Changes the global directory.  |:cd|
    897 ---
    898 --- {dir} must be a String.
    899 --- If successful, returns the previous working directory.  Pass
    900 --- this to another chdir() to restore the directory.
    901 --- On failure, returns an empty string.
    902 ---
    903 --- Example: >vim
    904 ---   let save_dir = chdir(newdir)
    905 ---   if save_dir != ""
    906 ---      " ... do some work
    907 ---      call chdir(save_dir)
    908 ---   endif
    909 --- <
    910 ---
    911 --- @param dir string
    912 --- @param scope? string
    913 --- @return string
    914 function vim.fn.chdir(dir, scope) end
    915 
    916 --- Get the amount of indent for line {lnum} according the
    917 --- |C-indenting| rules, as with 'cindent'.
    918 --- The indent is counted in spaces, the value of 'tabstop' is
    919 --- relevant.  {lnum} is used just like in |getline()|.
    920 --- When {lnum} is invalid -1 is returned.
    921 ---
    922 --- To get or set indent of lines in a string, see |vim.text.indent()|.
    923 ---
    924 --- @param lnum integer|string
    925 --- @return integer
    926 function vim.fn.cindent(lnum) end
    927 
    928 --- Clears all matches previously defined for the current window
    929 --- by |matchadd()| and the |:match| commands.
    930 --- If {win} is specified, use the window with this number or
    931 --- window ID instead of the current window.
    932 ---
    933 --- @param win? integer
    934 function vim.fn.clearmatches(win) end
    935 
    936 --- Returns a |Dictionary| with information about cmdline
    937 --- completion.  See |cmdline-completion|.
    938 --- The items are:
    939 ---    cmdline_orig  The original command-line string before
    940 ---     completion began.
    941 ---    pum_visible  |TRUE| if popup menu is visible.
    942 ---     See |pumvisible()|.
    943 ---    matches  List of all completion candidates.  Each item
    944 ---     is a string.
    945 ---    selected  Selected item index.  First index is zero.
    946 ---     Index is -1 if no item is selected (showing
    947 ---     typed text only, or the last completion after
    948 ---     no item is selected when using the <Up> or
    949 ---     <Down> keys)
    950 ---
    951 --- Returns an empty |Dictionary| if no completion was attempted,
    952 --- if there was only one candidate and it was fully completed, or
    953 --- if an error occurred.
    954 ---
    955 --- @return table<string,any>
    956 function vim.fn.cmdcomplete_info() end
    957 
    958 --- The result is a Number, which is the byte index of the column
    959 --- position given with {expr}.
    960 --- For accepted positions see |getpos()|.
    961 --- When {expr} is "$", it means the end of the cursor line, so
    962 --- the result is the number of bytes in the cursor line plus one.
    963 --- Additionally {expr} can be [lnum, col]: a |List| with the line
    964 --- and column number.  Most useful when the column is "$", to get
    965 --- the last column of a specific line.  When "lnum" or "col" is
    966 --- out of range then col() returns zero.
    967 ---
    968 --- With the optional {winid} argument the values are obtained for
    969 --- that window instead of the current window.
    970 ---
    971 --- To get the line number use |line()|.  To get both use
    972 --- |getpos()|.
    973 ---
    974 --- For the screen column position use |virtcol()|.  For the
    975 --- character position use |charcol()|.
    976 ---
    977 --- Note that only marks in the current file can be used.
    978 ---
    979 --- Examples: >vim
    980 ---   echo col(".")      " column of cursor
    981 ---   echo col("$")      " length of cursor line plus one
    982 ---   echo col("'t")      " column of mark t
    983 ---   echo col("'" .. markname)  " column of mark markname
    984 --- <
    985 --- The first column is 1.  Returns 0 if {expr} is invalid or when
    986 --- the window with ID {winid} is not found.
    987 --- For an uppercase mark the column may actually be in another
    988 --- buffer.
    989 --- For the cursor position, when 'virtualedit' is active, the
    990 --- column is one higher if the cursor is after the end of the
    991 --- line.  Also, when using a <Cmd> mapping the cursor isn't
    992 --- moved, this can be used to obtain the column in Insert mode: >vim
    993 ---   imap <F2> <Cmd>echo col(".").."\n"<CR>
    994 --- <
    995 ---
    996 --- @param expr string|any[]
    997 --- @param winid? integer
    998 --- @return integer
    999 function vim.fn.col(expr, winid) end
   1000 
   1001 --- Set the matches for Insert mode completion.  Can only be used
   1002 --- in Insert mode.  Typically invoked from a mapping with
   1003 --- CTRL-R = (see |i_CTRL-R|), but may also be called from a
   1004 --- |<Cmd>| mapping.  It does not work after CTRL-O or with an
   1005 --- expression mapping.
   1006 --- {startcol} is the byte offset in the line where the completed
   1007 --- text start.  The text up to the cursor is the original text
   1008 --- that will be replaced by the matches.  Use col('.') for an
   1009 --- empty string.  "col('.') - 1" will replace one character by a
   1010 --- match.
   1011 --- {matches} must be a |List|.  Each |List| item is one match.
   1012 --- See |complete-items| for the kind of items that are possible.
   1013 --- "longest" in 'completeopt' is ignored.
   1014 --- Note that the after calling this function you need to avoid
   1015 --- inserting anything that would cause completion to stop.
   1016 --- The match can be selected with CTRL-N and CTRL-P as usual with
   1017 --- Insert mode completion.  The popup menu will appear if
   1018 --- specified, see |ins-completion-menu|.
   1019 --- Example: >vim
   1020 ---
   1021 --- inoremap <F5> <C-R>=ListMonths()<CR>
   1022 ---
   1023 --- func ListMonths()
   1024 ---   call complete(col('.'), ['January', 'February', 'March',
   1025 ---   \ 'April', 'May', 'June', 'July', 'August',
   1026 ---   \ 'September', 'October', 'November', 'December'])
   1027 ---   return ''
   1028 --- endfunc
   1029 ---
   1030 --- <This isn't very useful, but it shows how it works.  Note that
   1031 --- an empty string is returned to avoid a zero being inserted.
   1032 ---
   1033 --- @param startcol integer
   1034 --- @param matches any[]
   1035 function vim.fn.complete(startcol, matches) end
   1036 
   1037 --- Add {expr} to the list of matches.  Only to be used by the
   1038 --- function specified with the 'completefunc' option.
   1039 --- Returns 0 for failure (empty string or out of memory),
   1040 --- 1 when the match was added, 2 when the match was already in
   1041 --- the list.
   1042 --- See |complete-functions| for an explanation of {expr}.  It is
   1043 --- the same as one item in the list that 'omnifunc' would return.
   1044 ---
   1045 --- @param expr any
   1046 --- @return 0|1|2
   1047 function vim.fn.complete_add(expr) end
   1048 
   1049 --- Check for a key typed while looking for completion matches.
   1050 --- This is to be used when looking for matches takes some time.
   1051 --- Returns |TRUE| when searching for matches is to be aborted,
   1052 --- zero otherwise.
   1053 --- Only to be used by the function specified with the
   1054 --- 'completefunc' option.
   1055 ---
   1056 --- @return 0|1
   1057 function vim.fn.complete_check() end
   1058 
   1059 --- Returns a |Dictionary| with information about Insert mode
   1060 --- completion.  See |ins-completion|.
   1061 --- The items are:
   1062 ---    completed  Return a dictionary containing the entries of
   1063 ---     the currently selected index item.
   1064 ---    items  List of all completion candidates.  Each item
   1065 ---     is a dictionary containing the entries "word",
   1066 ---     "abbr", "menu", "kind", "info" and
   1067 ---     "user_data".
   1068 ---     See |complete-items|.
   1069 ---    matches  Same as "items", but only returns items that
   1070 ---     are matching current query.  If both "matches"
   1071 ---     and "items" are in "what", the returned list
   1072 ---     will still be named "items", but each item
   1073 ---     will have an additional "match" field.
   1074 ---    mode    Current completion mode name string.
   1075 ---     See |complete_info_mode| for the values.
   1076 ---    preinserted_text
   1077 ---     The actual text that is pre-inserted, see
   1078 ---     |preinserted()|.
   1079 ---    pum_visible  |TRUE| if popup menu is visible.
   1080 ---     See |pumvisible()|.
   1081 ---    selected  Selected item index.  First index is zero.
   1082 ---     Index is -1 if no item is selected (showing
   1083 ---     typed text only, or the last completion after
   1084 ---     no item is selected when using the <Up> or
   1085 ---     <Down> keys)
   1086 ---    preview_winid     Info floating preview window id.
   1087 ---    preview_bufnr     Info floating preview buffer id.
   1088 ---
   1089 ---           *complete_info_mode*
   1090 --- mode values are:
   1091 ---    ""         Not in completion mode
   1092 ---    "keyword"       Keyword completion |i_CTRL-X_CTRL-N|
   1093 ---    "ctrl_x"       Just pressed CTRL-X |i_CTRL-X|
   1094 ---    "scroll"       Scrolling with |i_CTRL-X_CTRL-E| or
   1095 ---          |i_CTRL-X_CTRL-Y|
   1096 ---    "whole_line"       Whole lines |i_CTRL-X_CTRL-L|
   1097 ---    "files"       File names |i_CTRL-X_CTRL-F|
   1098 ---    "tags"       Tags |i_CTRL-X_CTRL-]|
   1099 ---    "path_defines"    Definition completion |i_CTRL-X_CTRL-D|
   1100 ---    "path_patterns"   Include completion |i_CTRL-X_CTRL-I|
   1101 ---    "dictionary"       Dictionary |i_CTRL-X_CTRL-K|
   1102 ---    "thesaurus"       Thesaurus |i_CTRL-X_CTRL-T|
   1103 ---    "cmdline"       Vim Command line |i_CTRL-X_CTRL-V|
   1104 ---    "function"       User defined completion |i_CTRL-X_CTRL-U|
   1105 ---    "omni"       Omni completion |i_CTRL-X_CTRL-O|
   1106 ---    "spell"       Spelling suggestions |i_CTRL-X_s|
   1107 ---    "eval"       |complete()| completion
   1108 ---    "register"       Words from registers |i_CTRL-X_CTRL-R|
   1109 ---    "unknown"       Other internal modes
   1110 ---
   1111 --- If the optional {what} list argument is supplied, then only
   1112 --- the items listed in {what} are returned.  Unsupported items in
   1113 --- {what} are silently ignored.
   1114 ---
   1115 --- To get the position and size of the popup menu, see
   1116 --- |pum_getpos()|.  It's also available in |v:event| during the
   1117 --- |CompleteChanged| event.
   1118 ---
   1119 --- Returns an empty |Dictionary| on error.
   1120 ---
   1121 --- Examples: >vim
   1122 ---   " Get all items
   1123 ---   call complete_info()
   1124 ---   " Get only 'mode'
   1125 ---   call complete_info(['mode'])
   1126 ---   " Get only 'mode' and 'pum_visible'
   1127 ---   call complete_info(['mode', 'pum_visible'])
   1128 --- <
   1129 ---
   1130 --- @param what? any[]
   1131 --- @return table
   1132 function vim.fn.complete_info(what) end
   1133 
   1134 --- confirm() offers the user a dialog, from which a choice can be
   1135 --- made.  It returns the number of the choice.  For the first
   1136 --- choice this is 1.
   1137 ---
   1138 --- {msg} is displayed in a dialog with {choices} as the
   1139 --- alternatives.  When {choices} is missing or empty, "&OK" is
   1140 --- used (and translated).
   1141 --- {msg} is a String, use '\n' to include a newline.  Only on
   1142 --- some systems the string is wrapped when it doesn't fit.
   1143 ---
   1144 --- {choices} is a String, with the individual choices separated
   1145 --- by '\n', e.g. >vim
   1146 ---   confirm("Save changes?", "&Yes\n&No\n&Cancel")
   1147 --- <The letter after the '&' is the shortcut key for that choice.
   1148 --- Thus you can type 'c' to select "Cancel".  The shortcut does
   1149 --- not need to be the first letter: >vim
   1150 ---   confirm("file has been modified", "&Save\nSave &All")
   1151 --- <For the console, the first letter of each choice is used as
   1152 --- the default shortcut key.  Case is ignored.
   1153 ---
   1154 --- The optional {type} String argument gives the type of dialog.
   1155 --- It can be one of these values: "Error", "Question", "Info",
   1156 --- "Warning" or "Generic".  Only the first character is relevant.
   1157 --- When {type} is omitted, "Generic" is used.
   1158 ---
   1159 --- The optional {type} argument gives the type of dialog.  This
   1160 --- is only used for the icon of the Win32 GUI.  It can be one of
   1161 --- these values: "Error", "Question", "Info", "Warning" or
   1162 --- "Generic".  Only the first character is relevant.
   1163 --- When {type} is omitted, "Generic" is used.
   1164 ---
   1165 --- If the user aborts the dialog by pressing <Esc>, CTRL-C,
   1166 --- or another valid interrupt key, confirm() returns 0.
   1167 ---
   1168 --- An example: >vim
   1169 ---    let choice = confirm("What do you want?",
   1170 ---       \ "&Apples\n&Oranges\n&Bananas", 2)
   1171 ---    if choice == 0
   1172 ---   echo "make up your mind!"
   1173 ---    elseif choice == 3
   1174 ---   echo "tasteful"
   1175 ---    else
   1176 ---   echo "I prefer bananas myself."
   1177 ---    endif
   1178 --- <In a GUI dialog, buttons are used.  The layout of the buttons
   1179 --- depends on the 'v' flag in 'guioptions'.  If it is included,
   1180 --- the buttons are always put vertically.  Otherwise,  confirm()
   1181 --- tries to put the buttons in one horizontal line.  If they
   1182 --- don't fit, a vertical layout is used anyway.  For some systems
   1183 --- the horizontal layout is always used.
   1184 ---
   1185 --- @param msg string
   1186 --- @param choices? string
   1187 --- @param default? integer
   1188 --- @param type? string
   1189 --- @return integer
   1190 function vim.fn.confirm(msg, choices, default, type) end
   1191 
   1192 --- Make a copy of {expr}.  For Numbers and Strings this isn't
   1193 --- different from using {expr} directly.
   1194 --- When {expr} is a |List| a shallow copy is created.  This means
   1195 --- that the original |List| can be changed without changing the
   1196 --- copy, and vice versa.  But the items are identical, thus
   1197 --- changing an item changes the contents of both |Lists|.
   1198 --- A |Dictionary| is copied in a similar way as a |List|.
   1199 --- Also see |deepcopy()|.
   1200 ---
   1201 --- @generic T
   1202 --- @param expr T
   1203 --- @return T
   1204 function vim.fn.copy(expr) end
   1205 
   1206 --- Return the cosine of {expr}, measured in radians, as a |Float|.
   1207 --- {expr} must evaluate to a |Float| or a |Number|.
   1208 --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
   1209 --- Examples: >vim
   1210 ---   echo cos(100)
   1211 --- <  0.862319 >vim
   1212 ---   echo cos(-4.01)
   1213 --- <  -0.646043
   1214 ---
   1215 --- @param expr number
   1216 --- @return number
   1217 function vim.fn.cos(expr) end
   1218 
   1219 --- Return the hyperbolic cosine of {expr} as a |Float| in the range
   1220 --- [1, inf].
   1221 --- {expr} must evaluate to a |Float| or a |Number|.
   1222 --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
   1223 --- Examples: >vim
   1224 ---   echo cosh(0.5)
   1225 --- <  1.127626 >vim
   1226 ---   echo cosh(-0.5)
   1227 --- <  -1.127626
   1228 ---
   1229 --- @param expr number
   1230 --- @return number
   1231 function vim.fn.cosh(expr) end
   1232 
   1233 --- Return the number of times an item with value {expr} appears
   1234 --- in |String|, |List| or |Dictionary| {comp}.
   1235 ---
   1236 --- If {start} is given then start with the item with this index.
   1237 --- {start} can only be used with a |List|.
   1238 ---
   1239 --- When {ic} is given and it's |TRUE| then case is ignored.
   1240 ---
   1241 --- When {comp} is a string then the number of not overlapping
   1242 --- occurrences of {expr} is returned.  Zero is returned when
   1243 --- {expr} is an empty string.
   1244 ---
   1245 --- @param comp string|table|any[]
   1246 --- @param expr any
   1247 --- @param ic? boolean
   1248 --- @param start? integer
   1249 --- @return integer
   1250 function vim.fn.count(comp, expr, ic, start) end
   1251 
   1252 --- Returns a |Dictionary| representing the |context| at {index}
   1253 --- from the top of the |context-stack| (see |context-dict|).
   1254 --- If {index} is not given, it is assumed to be 0 (i.e.: top).
   1255 ---
   1256 --- @param index? integer
   1257 --- @return table
   1258 function vim.fn.ctxget(index) end
   1259 
   1260 --- Pops and restores the |context| at the top of the
   1261 --- |context-stack|.
   1262 ---
   1263 --- @return any
   1264 function vim.fn.ctxpop() end
   1265 
   1266 --- Pushes the current editor state (|context|) on the
   1267 --- |context-stack|.
   1268 --- If {types} is given and is a |List| of |String|s, it specifies
   1269 --- which |context-types| to include in the pushed context.
   1270 --- Otherwise, all context types are included.
   1271 ---
   1272 --- @param types? string[]
   1273 --- @return any
   1274 function vim.fn.ctxpush(types) end
   1275 
   1276 --- Sets the |context| at {index} from the top of the
   1277 --- |context-stack| to that represented by {context}.
   1278 --- {context} is a Dictionary with context data (|context-dict|).
   1279 --- If {index} is not given, it is assumed to be 0 (i.e.: top).
   1280 ---
   1281 --- @param context table
   1282 --- @param index? integer
   1283 --- @return integer
   1284 function vim.fn.ctxset(context, index) end
   1285 
   1286 --- Returns the size of the |context-stack|.
   1287 ---
   1288 --- @return any
   1289 function vim.fn.ctxsize() end
   1290 
   1291 --- @param lnum integer|string
   1292 --- @param col? integer
   1293 --- @param off? integer
   1294 --- @return any
   1295 function vim.fn.cursor(lnum, col, off) end
   1296 
   1297 --- Positions the cursor at the column (byte count) {col} in the
   1298 --- line {lnum}.  The first column is one.
   1299 ---
   1300 --- When there is one argument {list} this is used as a |List|
   1301 --- with two, three or four item:
   1302 ---   [{lnum}, {col}]
   1303 ---   [{lnum}, {col}, {off}]
   1304 ---   [{lnum}, {col}, {off}, {curswant}]
   1305 --- This is like the return value of |getpos()| or |getcurpos()|,
   1306 --- but without the first item.
   1307 ---
   1308 --- To position the cursor using {col} as the character count, use
   1309 --- |setcursorcharpos()|.
   1310 ---
   1311 --- Does not change the jumplist.
   1312 --- {lnum} is used like with |getline()|, except that if {lnum} is
   1313 --- zero, the cursor will stay in the current line.
   1314 --- If {lnum} is greater than the number of lines in the buffer,
   1315 --- the cursor will be positioned at the last line in the buffer.
   1316 --- If {col} is greater than the number of bytes in the line,
   1317 --- the cursor will be positioned at the last character in the
   1318 --- line.
   1319 --- If {col} is zero, the cursor will stay in the current column.
   1320 --- If {curswant} is given it is used to set the preferred column
   1321 --- for vertical movement.  Otherwise {col} is used.
   1322 ---
   1323 --- When 'virtualedit' is used {off} specifies the offset in
   1324 --- screen columns from the start of the character.  E.g., a
   1325 --- position within a <Tab> or after the last character.
   1326 --- Returns 0 when the position could be set, -1 otherwise.
   1327 ---
   1328 --- @param list integer[]
   1329 --- @return any
   1330 function vim.fn.cursor(list) end
   1331 
   1332 --- Specifically used to interrupt a program being debugged.  It
   1333 --- will cause process {pid} to get a SIGTRAP.  Behavior for other
   1334 --- processes is undefined.  See |terminal-debug|.
   1335 --- (Sends a SIGINT to a process {pid} other than MS-Windows)
   1336 ---
   1337 --- Returns |TRUE| if successfully interrupted the program.
   1338 --- Otherwise returns |FALSE|.
   1339 ---
   1340 --- @param pid integer
   1341 --- @return any
   1342 function vim.fn.debugbreak(pid) end
   1343 
   1344 --- Make a copy of {expr}.  For Numbers and Strings this isn't
   1345 --- different from using {expr} directly.
   1346 --- When {expr} is a |List| a full copy is created.  This means
   1347 --- that the original |List| can be changed without changing the
   1348 --- copy, and vice versa.  When an item is a |List|, a copy for it
   1349 --- is made, recursively.  Thus changing an item in the copy does
   1350 --- not change the contents of the original |List|.
   1351 ---
   1352 --- When {noref} is omitted or zero a contained |List| or
   1353 --- |Dictionary| is only copied once.  All references point to
   1354 --- this single copy.  With {noref} set to 1 every occurrence of a
   1355 --- |List| or |Dictionary| results in a new copy.  This also means
   1356 --- that a cyclic reference causes deepcopy() to fail.
   1357 ---           *E724*
   1358 --- Nesting is possible up to 100 levels.  When there is an item
   1359 --- that refers back to a higher level making a deep copy with
   1360 --- {noref} set to 1 will fail.
   1361 --- Also see |copy()|.
   1362 ---
   1363 --- @generic T
   1364 --- @param expr T
   1365 --- @param noref? boolean
   1366 --- @return T
   1367 function vim.fn.deepcopy(expr, noref) end
   1368 
   1369 --- Without {flags} or with {flags} empty: Deletes the file by the
   1370 --- name {fname}.
   1371 ---
   1372 --- This also works when {fname} is a symbolic link.  The symbolic
   1373 --- link itself is deleted, not what it points to.
   1374 ---
   1375 --- When {flags} is "d": Deletes the directory by the name
   1376 --- {fname}.  This fails when directory {fname} is not empty.
   1377 ---
   1378 --- When {flags} is "rf": Deletes the directory by the name
   1379 --- {fname} and everything in it, recursively.  BE CAREFUL!
   1380 --- Note: on MS-Windows it is not possible to delete a directory
   1381 --- that is being used.
   1382 ---
   1383 --- The result is a Number, which is 0/false if the delete
   1384 --- operation was successful and -1/true when the deletion failed
   1385 --- or partly failed.
   1386 ---
   1387 --- @param fname string
   1388 --- @param flags? string
   1389 --- @return integer
   1390 function vim.fn.delete(fname, flags) end
   1391 
   1392 --- Delete lines {first} to {last} (inclusive) from buffer {buf}.
   1393 --- If {last} is omitted then delete line {first} only.
   1394 --- On success 0 is returned, on failure 1 is returned.
   1395 ---
   1396 --- This function works only for loaded buffers.  First call
   1397 --- |bufload()| if needed.
   1398 ---
   1399 --- For the use of {buf}, see |bufname()| above.
   1400 ---
   1401 --- {first} and {last} are used like with |getline()|.  Note that
   1402 --- when using |line()| this refers to the current buffer.  Use "$"
   1403 --- to refer to the last line in buffer {buf}.
   1404 ---
   1405 --- @param buf integer|string
   1406 --- @param first integer|string
   1407 --- @param last? integer|string
   1408 --- @return any
   1409 function vim.fn.deletebufline(buf, first, last) end
   1410 
   1411 --- Adds a watcher to a dictionary. A dictionary watcher is
   1412 --- identified by three components:
   1413 ---
   1414 --- - A dictionary({dict});
   1415 --- - A key pattern({pattern}).
   1416 --- - A function({callback}).
   1417 ---
   1418 --- After this is called, every change on {dict} and on keys
   1419 --- matching {pattern} will result in {callback} being invoked.
   1420 ---
   1421 --- For example, to watch all global variables: >vim
   1422 ---   silent! call dictwatcherdel(g:, '*', 'OnDictChanged')
   1423 ---   function! OnDictChanged(d,k,z)
   1424 ---     echomsg string(a:k) string(a:z)
   1425 ---   endfunction
   1426 ---   call dictwatcheradd(g:, '*', 'OnDictChanged')
   1427 --- <
   1428 --- For now {pattern} only accepts very simple patterns that can
   1429 --- contain a "*" at the end of the string, in which case it will
   1430 --- match every key that begins with the substring before the "*".
   1431 --- That means if "*" is not the last character of {pattern}, only
   1432 --- keys that are exactly equal as {pattern} will be matched.
   1433 ---
   1434 --- The {callback} receives three arguments:
   1435 ---
   1436 --- - The dictionary being watched.
   1437 --- - The key which changed.
   1438 --- - A dictionary containing the new and old values for the key.
   1439 ---
   1440 --- The type of change can be determined by examining the keys
   1441 --- present on the third argument:
   1442 ---
   1443 --- - If contains both `old` and `new`, the key was updated.
   1444 --- - If it contains only `new`, the key was added.
   1445 --- - If it contains only `old`, the key was deleted.
   1446 ---
   1447 --- This function can be used by plugins to implement options with
   1448 --- validation and parsing logic.
   1449 ---
   1450 --- @param dict table
   1451 --- @param pattern string
   1452 --- @param callback function
   1453 --- @return any
   1454 function vim.fn.dictwatcheradd(dict, pattern, callback) end
   1455 
   1456 --- Removes a watcher added  with |dictwatcheradd()|. All three
   1457 --- arguments must match the ones passed to |dictwatcheradd()| in
   1458 --- order for the watcher to be successfully deleted.
   1459 ---
   1460 --- @param dict any
   1461 --- @param pattern string
   1462 --- @param callback function
   1463 --- @return any
   1464 function vim.fn.dictwatcherdel(dict, pattern, callback) end
   1465 
   1466 --- Returns |TRUE| when autocommands are being executed and the
   1467 --- FileType event has been triggered at least once.  Can be used
   1468 --- to avoid triggering the FileType event again in the scripts
   1469 --- that detect the file type. |FileType|
   1470 --- Returns |FALSE| when `:setf FALLBACK` was used.
   1471 --- When editing another file, the counter is reset, thus this
   1472 --- really checks if the FileType event has been triggered for the
   1473 --- current buffer.  This allows an autocommand that starts
   1474 --- editing another buffer to set 'filetype' and load a syntax
   1475 --- file.
   1476 ---
   1477 --- @return integer
   1478 function vim.fn.did_filetype() end
   1479 
   1480 --- Returns the number of filler lines above line {lnum}.
   1481 --- These are the lines that were inserted at this point in
   1482 --- another diff'ed window.  These filler lines are shown in the
   1483 --- display but don't exist in the buffer.
   1484 --- {lnum} is used like with |getline()|.  Thus "." is the current
   1485 --- line, "'m" mark m, etc.
   1486 --- Returns 0 if the current window is not in diff mode.
   1487 ---
   1488 --- @param lnum integer|string
   1489 --- @return integer
   1490 function vim.fn.diff_filler(lnum) end
   1491 
   1492 --- Returns the highlight ID for diff mode at line {lnum} column
   1493 --- {col} (byte index).  When the current line does not have a
   1494 --- diff change zero is returned.
   1495 --- {lnum} is used like with |getline()|.  Thus "." is the current
   1496 --- line, "'m" mark m, etc.
   1497 --- {col} is 1 for the leftmost column, {lnum} is 1 for the first
   1498 --- line.
   1499 --- The highlight ID can be used with |synIDattr()| to obtain
   1500 --- syntax information about the highlighting.
   1501 ---
   1502 --- @param lnum integer|string
   1503 --- @param col integer
   1504 --- @return any
   1505 function vim.fn.diff_hlID(lnum, col) end
   1506 
   1507 --- Return the digraph of {chars}.  This should be a string with
   1508 --- exactly two characters.  If {chars} are not just two
   1509 --- characters, or the digraph of {chars} does not exist, an error
   1510 --- is given and an empty string is returned.
   1511 ---
   1512 --- Also see |digraph_getlist()|.
   1513 ---
   1514 --- Examples: >vim
   1515 --- " Get a built-in digraph
   1516 --- echo digraph_get('00')    " Returns '∞'
   1517 ---
   1518 --- " Get a user-defined digraph
   1519 --- call digraph_set('aa', 'あ')
   1520 --- echo digraph_get('aa')    " Returns 'あ'
   1521 --- <
   1522 ---
   1523 --- @param chars string
   1524 --- @return string
   1525 function vim.fn.digraph_get(chars) end
   1526 
   1527 --- Return a list of digraphs.  If the {listall} argument is given
   1528 --- and it is TRUE, return all digraphs, including the default
   1529 --- digraphs.  Otherwise, return only user-defined digraphs.
   1530 ---
   1531 --- Also see |digraph_get()|.
   1532 ---
   1533 --- Examples: >vim
   1534 --- " Get user-defined digraphs
   1535 --- echo digraph_getlist()
   1536 ---
   1537 --- " Get all the digraphs, including default digraphs
   1538 --- echo digraph_getlist(1)
   1539 --- <
   1540 ---
   1541 --- @param listall? boolean
   1542 --- @return string[][]
   1543 function vim.fn.digraph_getlist(listall) end
   1544 
   1545 --- Add digraph {chars} to the list.  {chars} must be a string
   1546 --- with two characters.  {digraph} is a string with one UTF-8
   1547 --- encoded character.  *E1215*
   1548 --- Be careful, composing characters are NOT ignored.  This
   1549 --- function is similar to |:digraphs| command, but useful to add
   1550 --- digraphs start with a white space.
   1551 ---
   1552 --- The function result is v:true if |digraph| is registered.  If
   1553 --- this fails an error message is given and v:false is returned.
   1554 ---
   1555 --- If you want to define multiple digraphs at once, you can use
   1556 --- |digraph_setlist()|.
   1557 ---
   1558 --- Example: >vim
   1559 ---   call digraph_set('  ', 'あ')
   1560 --- <
   1561 ---
   1562 --- @param chars string
   1563 --- @param digraph string
   1564 --- @return any
   1565 function vim.fn.digraph_set(chars, digraph) end
   1566 
   1567 --- Similar to |digraph_set()| but this function can add multiple
   1568 --- digraphs at once.  {digraphlist} is a list composed of lists,
   1569 --- where each list contains two strings with {chars} and
   1570 --- {digraph} as in |digraph_set()|. *E1216*
   1571 --- Example: >vim
   1572 ---     call digraph_setlist([['aa', 'あ'], ['ii', 'い']])
   1573 --- <
   1574 --- It is similar to the following: >vim
   1575 ---     for [chars, digraph] in [['aa', 'あ'], ['ii', 'い']]
   1576 ---     call digraph_set(chars, digraph)
   1577 ---     endfor
   1578 --- <Except that the function returns after the first error,
   1579 --- following digraphs will not be added.
   1580 ---
   1581 --- @param digraphlist table<integer,string[]>
   1582 --- @return any
   1583 function vim.fn.digraph_setlist(digraphlist) end
   1584 
   1585 --- Return the Number 1 if {expr} is empty, zero otherwise.
   1586 --- - A |List| or |Dictionary| is empty when it does not have any
   1587 ---   items.
   1588 --- - A |String| is empty when its length is zero.
   1589 --- - A |Number| and |Float| are empty when their value is zero.
   1590 --- - |v:false| and |v:null| are empty, |v:true| is not.
   1591 --- - A |Blob| is empty when its length is zero.
   1592 ---
   1593 --- @param expr any
   1594 --- @return integer
   1595 function vim.fn.empty(expr) end
   1596 
   1597 --- Return all of environment variables as dictionary.  You can
   1598 --- check if an environment variable exists like this: >vim
   1599 ---   echo has_key(environ(), 'HOME')
   1600 --- <Note that the variable name may be CamelCase; to ignore case
   1601 --- use this: >vim
   1602 ---   echo index(keys(environ()), 'HOME', 0, 1) != -1
   1603 --- <
   1604 ---
   1605 --- @return any
   1606 function vim.fn.environ() end
   1607 
   1608 --- Escape the characters in {chars} that occur in {string} with a
   1609 --- backslash.  Example: >vim
   1610 ---   echo escape('c:\program files\vim', ' \')
   1611 --- <results in: >
   1612 ---   c:\\program\ files\\vim
   1613 --- <Also see |shellescape()| and |fnameescape()|.
   1614 ---
   1615 --- @param string string
   1616 --- @param chars string
   1617 --- @return string
   1618 function vim.fn.escape(string, chars) end
   1619 
   1620 --- Evaluate {string} and return the result.  Especially useful to
   1621 --- turn the result of |string()| back into the original value.
   1622 --- This works for Numbers, Floats, Strings, Blobs and composites
   1623 --- of them.  Also works for |Funcref|s that refer to existing
   1624 --- functions.
   1625 ---
   1626 --- @param string string
   1627 --- @return any
   1628 function vim.fn.eval(string) end
   1629 
   1630 --- Returns 1 when inside an event handler.  That is that Vim got
   1631 --- interrupted while waiting for the user to type a character,
   1632 --- e.g., when dropping a file on Vim.  This means interactive
   1633 --- commands cannot be used.  Otherwise zero is returned.
   1634 ---
   1635 --- @return any
   1636 function vim.fn.eventhandler() end
   1637 
   1638 --- This function checks if an executable with the name {expr}
   1639 --- exists.  {expr} must be the name of the program without any
   1640 --- arguments.
   1641 ---
   1642 --- executable() uses the value of $PATH and/or the normal
   1643 --- searchpath for programs.
   1644 ---           *PATHEXT*
   1645 --- On MS-Windows the ".exe", ".bat", etc. can optionally be
   1646 --- included.  Then the extensions in $PATHEXT are tried.  Thus if
   1647 --- "foo.exe" does not exist, "foo.exe.bat" can be found.  If
   1648 --- $PATHEXT is not set then ".com;.exe;.bat;.cmd" is used.  A dot
   1649 --- by itself can be used in $PATHEXT to try using the name
   1650 --- without an extension.  When 'shell' looks like a Unix shell,
   1651 --- then the name is also tried without adding an extension.
   1652 --- On MS-Windows it only checks if the file exists and is not a
   1653 --- directory, not if it's really executable.
   1654 ---
   1655 --- On MS-Windows an executable in the same directory as the Vim
   1656 --- executable is always found (it's added to $PATH at |startup|).
   1657 ---       *$NoDefaultCurrentDirectoryInExePath*
   1658 --- On MS-Windows when using cmd.exe as 'shell' an executable in
   1659 --- Vim's current working directory is also normally found, which
   1660 --- can be disabled by setting the
   1661 --- `$NoDefaultCurrentDirectoryInExePath` environment variable.
   1662 --- This variable is always set by Vim when executing external
   1663 --- commands (e.g., via |:!|, |:make|, or |system()|) for security
   1664 --- reasons.
   1665 ---
   1666 --- The result is a Number:
   1667 ---   1  exists
   1668 ---   0  does not exist
   1669 --- |exepath()| can be used to get the full path of an executable.
   1670 ---
   1671 --- @param expr string
   1672 --- @return 0|1
   1673 function vim.fn.executable(expr) end
   1674 
   1675 --- Execute {command} and capture its output.
   1676 --- If {command} is a |String|, returns {command} output.
   1677 --- If {command} is a |List|, returns concatenated outputs.
   1678 --- Line continuations in {command} are not recognized.
   1679 --- Examples: >vim
   1680 ---   echo execute('echon "foo"')
   1681 --- <  foo >vim
   1682 ---   echo execute(['echon "foo"', 'echon "bar"'])
   1683 --- <  foobar
   1684 ---
   1685 --- The optional {silent} argument can have these values:
   1686 ---   ""    no `:silent` used
   1687 ---   "silent"  `:silent` used
   1688 ---   "silent!"  `:silent!` used
   1689 --- The default is "silent".  Note that with "silent!", unlike
   1690 --- `:redir`, error messages are dropped.
   1691 ---
   1692 --- To get a list of lines use `split()` on the result: >vim
   1693 ---   execute('args')->split("\n")
   1694 ---
   1695 --- <This function is not available in the |sandbox|.
   1696 --- Note: If nested, an outer execute() will not observe output of
   1697 --- the inner calls.
   1698 --- Note: Text attributes (highlights) are not captured.
   1699 --- To execute a command in another window than the current one
   1700 --- use `win_execute()`.
   1701 ---
   1702 --- @param command string|string[]
   1703 --- @param silent? ''|'silent'|'silent!'
   1704 --- @return string
   1705 function vim.fn.execute(command, silent) end
   1706 
   1707 --- Returns the full path of {expr} if it is an executable and
   1708 --- given as a (partial or full) path or is found in $PATH.
   1709 --- Returns empty string otherwise.
   1710 --- If {expr} starts with "./" the |current-directory| is used.
   1711 ---
   1712 --- @param expr string
   1713 --- @return string
   1714 function vim.fn.exepath(expr) end
   1715 
   1716 --- The result is a Number, which is |TRUE| if {expr} is
   1717 --- defined, zero otherwise.
   1718 ---
   1719 --- For checking for a supported feature use |has()|.
   1720 --- For checking if a file exists use |filereadable()|.
   1721 ---
   1722 --- The {expr} argument is a string, which contains one of these:
   1723 ---   varname    internal variable (see
   1724 ---   dict.key  |internal-variables|).  Also works
   1725 ---   list[i]    for |curly-braces-names|, |Dictionary|
   1726 ---       entries, |List| items, etc.
   1727 ---       Beware that evaluating an index may
   1728 ---       cause an error message for an invalid
   1729 ---       expression.  E.g.: >vim
   1730 ---          let l = [1, 2, 3]
   1731 ---          echo exists("l[5]")
   1732 --- <         0 >vim
   1733 ---          echo exists("l[xx]")
   1734 --- <         E121: Undefined variable: xx
   1735 ---          0
   1736 ---   &option-name  Vim option (only checks if it exists,
   1737 ---       not if it really works)
   1738 ---   +option-name  Vim option that works.
   1739 ---   $ENVNAME  environment variable (could also be
   1740 ---       done by comparing with an empty
   1741 ---       string)
   1742 ---   `*funcname`  built-in function (see |functions|)
   1743 ---       or user defined function (see
   1744 ---       |user-function|). Also works for a
   1745 ---       variable that is a Funcref.
   1746 ---   :cmdname  Ex command: built-in command, user
   1747 ---       command or command modifier |:command|.
   1748 ---       Returns:
   1749 ---       1  for match with start of a command
   1750 ---       2  full match with a command
   1751 ---       3  matches several user commands
   1752 ---       To check for a supported command
   1753 ---       always check the return value to be 2.
   1754 ---   :2match    The |:2match| command.
   1755 ---   :3match    The |:3match| command (but you
   1756 ---       probably should not use it, it is
   1757 ---       reserved for internal usage)
   1758 ---   #event    autocommand defined for this event
   1759 ---   #event#pattern  autocommand defined for this event and
   1760 ---       pattern (the pattern is taken
   1761 ---       literally and compared to the
   1762 ---       autocommand patterns character by
   1763 ---       character)
   1764 ---   #group    autocommand group exists
   1765 ---   #group#event  autocommand defined for this group and
   1766 ---       event.
   1767 ---   #group#event#pattern
   1768 ---       autocommand defined for this group,
   1769 ---       event and pattern.
   1770 ---   ##event    autocommand for this event is
   1771 ---       supported.
   1772 ---
   1773 --- Examples: >vim
   1774 ---   echo exists("&mouse")
   1775 ---   echo exists("$HOSTNAME")
   1776 ---   echo exists("*strftime")
   1777 ---   echo exists("*s:MyFunc")
   1778 ---   echo exists("*MyFunc")
   1779 ---   echo exists("*v:lua.Func")
   1780 ---   echo exists("bufcount")
   1781 ---   echo exists(":Make")
   1782 ---   echo exists("#CursorHold")
   1783 ---   echo exists("#BufReadPre#*.gz")
   1784 ---   echo exists("#filetypeindent")
   1785 ---   echo exists("#filetypeindent#FileType")
   1786 ---   echo exists("#filetypeindent#FileType#*")
   1787 ---   echo exists("##ColorScheme")
   1788 --- <There must be no space between the symbol (&/$/*/#) and the
   1789 --- name.
   1790 --- There must be no extra characters after the name, although in
   1791 --- a few cases this is ignored.  That may become stricter in the
   1792 --- future, thus don't count on it!
   1793 --- Working example: >vim
   1794 ---   echo exists(":make")
   1795 --- <NOT working example: >vim
   1796 ---   echo exists(":make install")
   1797 ---
   1798 --- <Note that the argument must be a string, not the name of the
   1799 --- variable itself.  For example: >vim
   1800 ---   echo exists(bufcount)
   1801 --- <This doesn't check for existence of the "bufcount" variable,
   1802 --- but gets the value of "bufcount", and checks if that exists.
   1803 ---
   1804 --- @param expr string
   1805 --- @return 0|1
   1806 function vim.fn.exists(expr) end
   1807 
   1808 --- Return the exponential of {expr} as a |Float| in the range
   1809 --- [0, inf].
   1810 --- {expr} must evaluate to a |Float| or a |Number|.
   1811 --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
   1812 --- Examples: >vim
   1813 ---   echo exp(2)
   1814 --- <  7.389056 >vim
   1815 ---   echo exp(-1)
   1816 --- <  0.367879
   1817 ---
   1818 --- @param expr number
   1819 --- @return any
   1820 function vim.fn.exp(expr) end
   1821 
   1822 --- Expand wildcards and the following special keywords in
   1823 --- {string}.  'wildignorecase' applies.
   1824 ---
   1825 --- If {list} is given and it is |TRUE|, a List will be returned.
   1826 --- Otherwise the result is a String and when there are several
   1827 --- matches, they are separated by <NL> characters.
   1828 ---
   1829 --- If the expansion fails, the result is an empty string.  A name
   1830 --- for a non-existing file is not included, unless {string} does
   1831 --- not start with '%', '#' or '<', see below.
   1832 ---
   1833 --- When {string} starts with '%', '#' or '<', the expansion is
   1834 --- done like for the |cmdline-special| variables with their
   1835 --- associated modifiers.  Here is a short overview:
   1836 ---
   1837 ---   %    Current file name
   1838 ---   #    Alternate file name
   1839 ---   #n    Alternate file name n
   1840 ---   <cfile>    File name under the cursor
   1841 ---   <afile>    Autocmd file name
   1842 ---   <abuf>    Autocmd buffer number (as a String!)
   1843 ---   <amatch>  Autocmd matched name
   1844 ---   <cexpr>    C expression under the cursor
   1845 ---   <sfile>    Deprecated, use <script> or <stack>
   1846 ---   <slnum>    Sourced script line number or function
   1847 ---       line number
   1848 ---   <sflnum>  Script file line number, also when in
   1849 ---       a function
   1850 ---   <SID>    "<SNR>123_"  where "123" is the
   1851 ---       current script ID  |<SID>|
   1852 ---   <script>  Sourced script file, or script file
   1853 ---       where the current function was defined.
   1854 ---       For Lua see |lua-script-location|.
   1855 ---   <stack>    Call stack
   1856 ---   <cword>    Word under the cursor
   1857 ---   <cWORD>    WORD under the cursor
   1858 ---   <client>  The {clientid} of the last received
   1859 ---       message
   1860 --- Modifiers:
   1861 ---   :p    Expand to full path
   1862 ---   :h    Head (last path component removed)
   1863 ---   :t    Tail (last path component only)
   1864 ---   :r    Root (one extension removed)
   1865 ---   :e    Extension only
   1866 ---
   1867 --- More modifiers are supported, for the full list see
   1868 --- |filename-modifiers|.
   1869 ---
   1870 --- Example: >vim
   1871 ---   let &tags = expand("%:p:h") .. "/tags"
   1872 --- <Note that when expanding a string that starts with '%', '#' or
   1873 --- '<', any following text is ignored.  This does NOT work: >vim
   1874 ---   let doesntwork = expand("%:h.bak")
   1875 --- <Use this: >vim
   1876 ---   let doeswork = expand("%:h") .. ".bak"
   1877 --- <Also note that expanding "<cfile>" and others only returns the
   1878 --- referenced file name without further expansion.  If "<cfile>"
   1879 --- is "~/.cshrc", you need to do another expand() to have the
   1880 --- "~/" expanded into the path of the home directory: >vim
   1881 ---   echo expand(expand("<cfile>"))
   1882 --- <
   1883 --- There cannot be white space between the variables and the
   1884 --- following modifier.  The |fnamemodify()| function can be used
   1885 --- to modify normal file names.
   1886 ---
   1887 --- When using '%' or '#', and the current or alternate file name
   1888 --- is not defined, an empty string is used.  Using "%:p" in a
   1889 --- buffer with no name, results in the current directory, with a
   1890 --- '/' added.
   1891 --- When 'verbose' is set then expanding '%', '#' and <> items
   1892 --- will result in an error message if the argument cannot be
   1893 --- expanded.
   1894 ---
   1895 --- When {string} does not start with '%', '#' or '<', it is
   1896 --- expanded like a file name is expanded on the command line.
   1897 --- 'suffixes' and 'wildignore' are used, unless the optional
   1898 --- {nosuf} argument is given and it is |TRUE|.
   1899 --- Names for non-existing files are included.  The "**" item can
   1900 --- be used to search in a directory tree.  For example, to find
   1901 --- all "README" files in the current directory and below: >vim
   1902 ---   echo expand("**/README")
   1903 --- <
   1904 --- expand() can also be used to expand variables and environment
   1905 --- variables that are only known in a shell.  But this can be
   1906 --- slow, because a shell may be used to do the expansion.  See
   1907 --- |expr-env-expand|.
   1908 --- The expanded variable is still handled like a list of file
   1909 --- names.  When an environment variable cannot be expanded, it is
   1910 --- left unchanged.  Thus ":echo expand('$FOOBAR')" results in
   1911 --- "$FOOBAR".
   1912 ---
   1913 --- See |glob()| for finding existing files.  See |system()| for
   1914 --- getting the raw output of an external command.
   1915 ---
   1916 --- @param string string
   1917 --- @param nosuf? boolean
   1918 --- @param list? nil|false
   1919 --- @return string
   1920 function vim.fn.expand(string, nosuf, list) end
   1921 
   1922 --- @param string string
   1923 --- @param nosuf boolean
   1924 --- @param list true|number|string|table
   1925 --- @return string|string[]
   1926 function vim.fn.expand(string, nosuf, list) end
   1927 
   1928 --- Expand special items in String {string} like what is done for
   1929 --- an Ex command such as `:edit`.  This expands special keywords,
   1930 --- like with |expand()|, and environment variables, anywhere in
   1931 --- {string}.  "~user" and "~/path" are only expanded at the
   1932 --- start.
   1933 ---
   1934 --- The following items are supported in the {options} Dict
   1935 --- argument:
   1936 ---     errmsg  If set to TRUE, error messages are displayed
   1937 ---     if an error is encountered during expansion.
   1938 ---     By default, error messages are not displayed.
   1939 ---
   1940 --- Returns the expanded string.  If an error is encountered
   1941 --- during expansion, the unmodified {string} is returned.
   1942 ---
   1943 --- Example: >vim
   1944 ---   echo expandcmd('make %<.o')
   1945 --- < >
   1946 ---   make /path/runtime/doc/builtin.o
   1947 --- < >vim
   1948 ---   echo expandcmd('make %<.o', {'errmsg': v:true})
   1949 --- <
   1950 ---
   1951 --- @param string string
   1952 --- @param options? table
   1953 --- @return any
   1954 function vim.fn.expandcmd(string, options) end
   1955 
   1956 --- {expr1} and {expr2} must be both |Lists| or both
   1957 --- |Dictionaries|.
   1958 ---
   1959 --- If they are |Lists|: Append {expr2} to {expr1}.
   1960 --- If {expr3} is given insert the items of {expr2} before the
   1961 --- item with index {expr3} in {expr1}.  When {expr3} is zero
   1962 --- insert before the first item.  When {expr3} is equal to
   1963 --- len({expr1}) then {expr2} is appended.
   1964 --- Examples: >vim
   1965 ---   echo sort(extend(mylist, [7, 5]))
   1966 ---   call extend(mylist, [2, 3], 1)
   1967 --- <When {expr1} is the same List as {expr2} then the number of
   1968 --- items copied is equal to the original length of the List.
   1969 --- E.g., when {expr3} is 1 you get N new copies of the first item
   1970 --- (where N is the original length of the List).
   1971 --- Use |add()| to concatenate one item to a list.  To concatenate
   1972 --- two lists into a new list use the + operator: >vim
   1973 ---   let newlist = [1, 2, 3] + [4, 5]
   1974 --- <
   1975 --- If they are |Dictionaries|:
   1976 --- Add all entries from {expr2} to {expr1}.
   1977 --- If a key exists in both {expr1} and {expr2} then {expr3} is
   1978 --- used to decide what to do:
   1979 --- {expr3} = "keep": keep the value of {expr1}
   1980 --- {expr3} = "force": use the value of {expr2}
   1981 --- {expr3} = "error": give an error message    *E737*
   1982 --- When {expr3} is omitted then "force" is assumed.
   1983 ---
   1984 --- {expr1} is changed when {expr2} is not empty.  If necessary
   1985 --- make a copy of {expr1} first or use |extendnew()| to return a
   1986 --- new List/Dictionary.
   1987 --- {expr2} remains unchanged.
   1988 --- When {expr1} is locked and {expr2} is not empty the operation
   1989 --- fails.
   1990 --- Returns {expr1}.  Returns 0 on error.
   1991 ---
   1992 --- @param expr1 table
   1993 --- @param expr2 table
   1994 --- @param expr3? table
   1995 --- @return any
   1996 function vim.fn.extend(expr1, expr2, expr3) end
   1997 
   1998 --- Like |extend()| but instead of adding items to {expr1} a new
   1999 --- List or Dictionary is created and returned.  {expr1} remains
   2000 --- unchanged.
   2001 ---
   2002 --- @param expr1 table
   2003 --- @param expr2 table
   2004 --- @param expr3? table
   2005 --- @return any
   2006 function vim.fn.extendnew(expr1, expr2, expr3) end
   2007 
   2008 --- Characters in {string} are queued for processing as if they
   2009 --- come from a mapping or were typed by the user.
   2010 ---
   2011 --- By default the string is added to the end of the typeahead
   2012 --- buffer, thus if a mapping is still being executed the
   2013 --- characters come after them.  Use the 'i' flag to insert before
   2014 --- other characters, they will be executed next, before any
   2015 --- characters from a mapping.
   2016 ---
   2017 --- The function does not wait for processing of keys contained in
   2018 --- {string}.
   2019 ---
   2020 --- To include special keys into {string}, use double-quotes
   2021 --- and "\..." notation |expr-quote|.  For example,
   2022 --- feedkeys("\<CR>") simulates pressing of the <Enter> key.  But
   2023 --- feedkeys('\<CR>') pushes 5 characters.
   2024 --- The |<Ignore>| keycode may be used to exit the
   2025 --- wait-for-character without doing anything.
   2026 ---
   2027 --- {mode} is a String, which can contain these character flags:
   2028 --- 'm'  Remap keys.  This is default.  If {mode} is absent,
   2029 ---   keys are remapped.
   2030 --- 'n'  Do not remap keys.
   2031 --- 't'  Handle keys as if typed; otherwise they are handled as
   2032 ---   if coming from a mapping.  This matters for undo,
   2033 ---   opening folds, etc.
   2034 --- 'L'  Lowlevel input.  Other flags are not used.
   2035 --- 'i'  Insert the string instead of appending (see above).
   2036 --- 'x'  Execute commands until typeahead is empty.  This is
   2037 ---   similar to using ":normal!".  You can call feedkeys()
   2038 ---   several times without 'x' and then one time with 'x'
   2039 ---   (possibly with an empty {string}) to execute all the
   2040 ---   typeahead.  Note that when Vim ends in Insert mode it
   2041 ---   will behave as if <Esc> is typed, to avoid getting
   2042 ---   stuck, waiting for a character to be typed before the
   2043 ---   script continues.
   2044 ---   Note that if you manage to call feedkeys() while
   2045 ---   executing commands, thus calling it recursively, then
   2046 ---   all typeahead will be consumed by the last call.
   2047 --- '!'  When used with 'x' will not end Insert mode.  Can be
   2048 ---   used in a test when a timer is set to exit Insert mode
   2049 ---   a little later.  Useful for testing CursorHoldI.
   2050 ---
   2051 --- Return value is always 0.
   2052 ---
   2053 --- @param string string
   2054 --- @param mode? string
   2055 --- @return any
   2056 function vim.fn.feedkeys(string, mode) end
   2057 
   2058 --- @deprecated
   2059 --- Obsolete name for |filereadable()|.
   2060 ---
   2061 --- @param file string
   2062 --- @return any
   2063 function vim.fn.file_readable(file) end
   2064 
   2065 --- Copy the file pointed to by the name {from} to {to}.  The
   2066 --- result is a Number, which is |TRUE| if the file was copied
   2067 --- successfully, and |FALSE| when it failed.
   2068 --- If a file with name {to} already exists, it will fail.
   2069 --- Note that it does not handle directories (yet).
   2070 ---
   2071 --- This function is not available in the |sandbox|.
   2072 ---
   2073 --- @param from string
   2074 --- @param to string
   2075 --- @return 0|1
   2076 function vim.fn.filecopy(from, to) end
   2077 
   2078 --- The result is a Number, which is |TRUE| when a file with the
   2079 --- name {file} exists, and can be read.  If {file} doesn't exist,
   2080 --- or is a directory, the result is |FALSE|.  {file} is any
   2081 --- expression, which is used as a String.
   2082 --- If you don't care about the file being readable you can use
   2083 --- |glob()|.
   2084 --- {file} is used as-is, you may want to expand wildcards first: >vim
   2085 ---   echo filereadable('~/.vimrc')
   2086 --- < >
   2087 ---   0
   2088 --- < >vim
   2089 ---   echo filereadable(expand('~/.vimrc'))
   2090 --- < >
   2091 ---   1
   2092 --- <
   2093 ---
   2094 --- @param file string
   2095 --- @return 0|1
   2096 function vim.fn.filereadable(file) end
   2097 
   2098 --- The result is a Number, which is 1 when a file with the
   2099 --- name {file} exists, and can be written.  If {file} doesn't
   2100 --- exist, or is not writable, the result is 0.  If {file} is a
   2101 --- directory, and we can write to it, the result is 2.
   2102 ---
   2103 --- @param file string
   2104 --- @return 0|1
   2105 function vim.fn.filewritable(file) end
   2106 
   2107 --- {expr1} must be a |List|, |String|, |Blob| or |Dictionary|.
   2108 --- For each item in {expr1} evaluate {expr2} and when the result
   2109 --- is zero or false remove the item from the |List| or
   2110 --- |Dictionary|.  Similarly for each byte in a |Blob| and each
   2111 --- character in a |String|.
   2112 ---
   2113 --- {expr2} must be a |string| or |Funcref|.
   2114 ---
   2115 --- If {expr2} is a |string|, inside {expr2} |v:val| has the value
   2116 --- of the current item.  For a |Dictionary| |v:key| has the key
   2117 --- of the current item and for a |List| |v:key| has the index of
   2118 --- the current item.  For a |Blob| |v:key| has the index of the
   2119 --- current byte.  For a |String| |v:key| has the index of the
   2120 --- current character.
   2121 --- Examples: >vim
   2122 ---   call filter(mylist, 'v:val !~ "OLD"')
   2123 --- <Removes the items where "OLD" appears. >vim
   2124 ---   call filter(mydict, 'v:key >= 8')
   2125 --- <Removes the items with a key below 8. >vim
   2126 ---   call filter(var, 0)
   2127 --- <Removes all the items, thus clears the |List| or |Dictionary|.
   2128 ---
   2129 --- Note that {expr2} is the result of expression and is then
   2130 --- used as an expression again.  Often it is good to use a
   2131 --- |literal-string| to avoid having to double backslashes.
   2132 ---
   2133 --- If {expr2} is a |Funcref| it must take two arguments:
   2134 ---   1. the key or the index of the current item.
   2135 ---   2. the value of the current item.
   2136 --- The function must return |TRUE| if the item should be kept.
   2137 --- Example that keeps the odd items of a list: >vim
   2138 ---   func Odd(idx, val)
   2139 ---     return a:idx % 2 == 1
   2140 ---   endfunc
   2141 ---   call filter(mylist, function('Odd'))
   2142 --- <It is shorter when using a |lambda|: >vim
   2143 ---   call filter(myList, {idx, val -> idx * val <= 42})
   2144 --- <If you do not use "val" you can leave it out: >vim
   2145 ---   call filter(myList, {idx -> idx % 2 == 1})
   2146 --- <
   2147 --- For a |List| and a |Dictionary| the operation is done
   2148 --- in-place.  If you want it to remain unmodified make a copy
   2149 --- first: >vim
   2150 ---   let l = filter(copy(mylist), 'v:val =~ "KEEP"')
   2151 ---
   2152 --- <Returns {expr1}, the |List| or |Dictionary| that was filtered,
   2153 --- or a new |Blob| or |String|.
   2154 --- When an error is encountered while evaluating {expr2} no
   2155 --- further items in {expr1} are processed.
   2156 --- When {expr2} is a Funcref errors inside a function are
   2157 --- ignored, unless it was defined with the "abort" flag.
   2158 ---
   2159 --- @param expr1 string|table
   2160 --- @param expr2 string|function
   2161 --- @return any
   2162 function vim.fn.filter(expr1, expr2) end
   2163 
   2164 --- Find directory {name} in {path}.  Supports both downwards and
   2165 --- upwards recursive directory searches.  See |file-searching|
   2166 --- for the syntax of {path}.
   2167 ---
   2168 --- Returns the path of the first found match.  When the found
   2169 --- directory is below the current directory a relative path is
   2170 --- returned.  Otherwise a full path is returned.
   2171 --- If {path} is omitted or empty then 'path' is used.
   2172 ---
   2173 --- If the optional {count} is given, find {count}'s occurrence of
   2174 --- {name} in {path} instead of the first one.
   2175 --- When {count} is negative return all the matches in a |List|.
   2176 ---
   2177 --- Returns an empty string if the directory is not found.
   2178 ---
   2179 --- This is quite similar to the ex-command `:find`.
   2180 ---
   2181 --- @param name string
   2182 --- @param path? string
   2183 --- @param count? integer
   2184 --- @return string|string[]
   2185 function vim.fn.finddir(name, path, count) end
   2186 
   2187 --- Just like |finddir()|, but find a file instead of a directory.
   2188 --- Uses 'suffixesadd'.
   2189 --- Example: >vim
   2190 ---   echo findfile("tags.vim", ".;")
   2191 --- <Searches from the directory of the current file upwards until
   2192 --- it finds the file "tags.vim".
   2193 ---
   2194 --- @param name string
   2195 --- @param path? string
   2196 --- @param count? integer
   2197 --- @return string|string[]
   2198 function vim.fn.findfile(name, path, count) end
   2199 
   2200 --- Flatten {list} up to {maxdepth} levels.  Without {maxdepth}
   2201 --- the result is a |List| without nesting, as if {maxdepth} is
   2202 --- a very large number.
   2203 --- The {list} is changed in place, use |flattennew()| if you do
   2204 --- not want that.
   2205 ---           *E900*
   2206 --- {maxdepth} means how deep in nested lists changes are made.
   2207 --- {list} is not modified when {maxdepth} is 0.
   2208 --- {maxdepth} must be positive number.
   2209 ---
   2210 --- If there is an error the number zero is returned.
   2211 ---
   2212 --- Example: >vim
   2213 ---   echo flatten([1, [2, [3, 4]], 5])
   2214 --- <  [1, 2, 3, 4, 5] >vim
   2215 ---   echo flatten([1, [2, [3, 4]], 5], 1)
   2216 --- <  [1, 2, [3, 4], 5]
   2217 ---
   2218 --- @param list any[]
   2219 --- @param maxdepth? integer
   2220 --- @return any[]|0
   2221 function vim.fn.flatten(list, maxdepth) end
   2222 
   2223 --- Like |flatten()| but first make a copy of {list}.
   2224 ---
   2225 --- @param list any[]
   2226 --- @param maxdepth? integer
   2227 --- @return any[]|0
   2228 function vim.fn.flattennew(list, maxdepth) end
   2229 
   2230 --- Convert {expr} to a Number by omitting the part after the
   2231 --- decimal point.
   2232 --- {expr} must evaluate to a |Float| or a |Number|.
   2233 --- Returns 0 if {expr} is not a |Float| or a |Number|.
   2234 --- When the value of {expr} is out of range for a |Number| the
   2235 --- result is truncated to 0x7fffffff or -0x7fffffff (or when
   2236 --- 64-bit Number support is enabled, 0x7fffffffffffffff or
   2237 --- -0x7fffffffffffffff).  NaN results in -0x80000000 (or when
   2238 --- 64-bit Number support is enabled, -0x8000000000000000).
   2239 --- Examples: >vim
   2240 ---   echo float2nr(3.95)
   2241 --- <  3  >vim
   2242 ---   echo float2nr(-23.45)
   2243 --- <  -23  >vim
   2244 ---   echo float2nr(1.0e100)
   2245 --- <  2147483647  (or 9223372036854775807) >vim
   2246 ---   echo float2nr(-1.0e150)
   2247 --- <  -2147483647 (or -9223372036854775807) >vim
   2248 ---   echo float2nr(1.0e-100)
   2249 --- <  0
   2250 ---
   2251 --- @param expr number
   2252 --- @return any
   2253 function vim.fn.float2nr(expr) end
   2254 
   2255 --- Return the largest integral value less than or equal to
   2256 --- {expr} as a |Float| (round down).
   2257 --- {expr} must evaluate to a |Float| or a |Number|.
   2258 --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
   2259 --- Examples: >vim
   2260 ---   echo floor(1.856)
   2261 --- <  1.0  >vim
   2262 ---   echo floor(-5.456)
   2263 --- <  -6.0  >vim
   2264 ---   echo floor(4.0)
   2265 --- <  4.0
   2266 ---
   2267 --- @param expr number
   2268 --- @return any
   2269 function vim.fn.floor(expr) end
   2270 
   2271 --- Return the remainder of {expr1} / {expr2}, even if the
   2272 --- division is not representable.  Returns {expr1} - i * {expr2}
   2273 --- for some integer i such that if {expr2} is non-zero, the
   2274 --- result has the same sign as {expr1} and magnitude less than
   2275 --- the magnitude of {expr2}.  If {expr2} is zero, the value
   2276 --- returned is zero.  The value returned is a |Float|.
   2277 --- {expr1} and {expr2} must evaluate to a |Float| or a |Number|.
   2278 --- Returns 0.0 if {expr1} or {expr2} is not a |Float| or a
   2279 --- |Number|.
   2280 --- Examples: >vim
   2281 ---   echo fmod(12.33, 1.22)
   2282 --- <  0.13 >vim
   2283 ---   echo fmod(-12.33, 1.22)
   2284 --- <  -0.13
   2285 ---
   2286 --- @param expr1 number
   2287 --- @param expr2 number
   2288 --- @return any
   2289 function vim.fn.fmod(expr1, expr2) end
   2290 
   2291 --- Escape {string} for use as file name command argument.  All
   2292 --- characters that have a special meaning, such as `'%'` and `'|'`
   2293 --- are escaped with a backslash. For most systems the characters
   2294 --- escaped are: >
   2295 ---   \t\n *?[{`$\\%#'\"|!<
   2296 --- <For systems where a backslash appears in a filename, it
   2297 --- depends on the value of 'isfname'. A leading '+' and '>' is
   2298 --- also escaped (special after |:edit| and |:write|).  And a "-"
   2299 --- by itself (special after |:cd|).
   2300 --- Returns an empty string on error.
   2301 --- Example: >vim
   2302 ---   let fname = '+some str%nge|name'
   2303 ---   exe "edit " .. fnameescape(fname)
   2304 --- <results in executing: >vim
   2305 ---   edit \+some\ str\%nge\|name
   2306 --- <
   2307 ---
   2308 --- @param string string
   2309 --- @return string
   2310 function vim.fn.fnameescape(string) end
   2311 
   2312 --- Modify file name {fname} according to {mods}.  {mods} is a
   2313 --- string of characters like it is used for file names on the
   2314 --- command line.  See |filename-modifiers|.
   2315 --- Example: >vim
   2316 ---   echo fnamemodify("main.c", ":p:h")
   2317 --- <results in: >
   2318 ---   /home/user/vim/vim/src
   2319 --- <If {mods} is empty or an unsupported modifier is used then
   2320 --- {fname} is returned.
   2321 --- When {fname} is empty then with {mods} ":h" returns ".", so
   2322 --- that `:cd` can be used with it.  This is different from
   2323 --- expand('%:h') without a buffer name, which returns an empty
   2324 --- string.
   2325 --- Note: Environment variables don't work in {fname}, use
   2326 --- |expand()| first then.
   2327 ---
   2328 --- @param fname string
   2329 --- @param mods string
   2330 --- @return string
   2331 function vim.fn.fnamemodify(fname, mods) end
   2332 
   2333 --- The result is a Number.  If the line {lnum} is in a closed
   2334 --- fold, the result is the number of the first line in that fold.
   2335 --- If the line {lnum} is not in a closed fold, -1 is returned.
   2336 --- {lnum} is used like with |getline()|.  Thus "." is the current
   2337 --- line, "'m" mark m, etc.
   2338 ---
   2339 --- @param lnum integer|string
   2340 --- @return integer
   2341 function vim.fn.foldclosed(lnum) end
   2342 
   2343 --- The result is a Number.  If the line {lnum} is in a closed
   2344 --- fold, the result is the number of the last line in that fold.
   2345 --- If the line {lnum} is not in a closed fold, -1 is returned.
   2346 --- {lnum} is used like with |getline()|.  Thus "." is the current
   2347 --- line, "'m" mark m, etc.
   2348 ---
   2349 --- @param lnum integer|string
   2350 --- @return integer
   2351 function vim.fn.foldclosedend(lnum) end
   2352 
   2353 --- The result is a Number, which is the foldlevel of line {lnum}
   2354 --- in the current buffer.  For nested folds the deepest level is
   2355 --- returned.  If there is no fold at line {lnum}, zero is
   2356 --- returned.  It doesn't matter if the folds are open or closed.
   2357 --- When used while updating folds (from 'foldexpr') -1 is
   2358 --- returned for lines where folds are still to be updated and the
   2359 --- foldlevel is unknown.  As a special case the level of the
   2360 --- previous line is usually available.
   2361 --- {lnum} is used like with |getline()|.  Thus "." is the current
   2362 --- line, "'m" mark m, etc.
   2363 ---
   2364 --- @param lnum integer|string
   2365 --- @return integer
   2366 function vim.fn.foldlevel(lnum) end
   2367 
   2368 --- Returns a String, to be displayed for a closed fold.  This is
   2369 --- the default function used for the 'foldtext' option and should
   2370 --- only be called from evaluating 'foldtext'.  It uses the
   2371 --- |v:foldstart|, |v:foldend| and |v:folddashes| variables.
   2372 --- The returned string looks like this: >
   2373 ---   +-- 45 lines: abcdef
   2374 --- <The number of leading dashes depends on the foldlevel.  The
   2375 --- "45" is the number of lines in the fold.  "abcdef" is the text
   2376 --- in the first non-blank line of the fold.  Leading white space,
   2377 --- "//" or "/*" and the text from the 'foldmarker' and
   2378 --- 'commentstring' options is removed.
   2379 --- When used to draw the actual foldtext, the rest of the line
   2380 --- will be filled with the fold char from the 'fillchars'
   2381 --- setting.
   2382 --- Returns an empty string when there is no fold.
   2383 ---
   2384 --- @return string
   2385 function vim.fn.foldtext() end
   2386 
   2387 --- Returns the text that is displayed for the closed fold at line
   2388 --- {lnum}.  Evaluates 'foldtext' in the appropriate context.
   2389 --- When there is no closed fold at {lnum} an empty string is
   2390 --- returned.
   2391 --- {lnum} is used like with |getline()|.  Thus "." is the current
   2392 --- line, "'m" mark m, etc.
   2393 --- Useful when exporting folded text, e.g., to HTML.
   2394 ---
   2395 --- @param lnum integer|string
   2396 --- @return string
   2397 function vim.fn.foldtextresult(lnum) end
   2398 
   2399 --- {expr1} must be a |List|, |String|, |Blob| or |Dictionary|.
   2400 --- For each item in {expr1} execute {expr2}.  {expr1} is not
   2401 --- modified; its values may be, as with |:lockvar| 1. |E741|
   2402 --- See |map()| and |filter()| to modify {expr1}.
   2403 ---
   2404 --- {expr2} must be a |string| or |Funcref|.
   2405 ---
   2406 --- If {expr2} is a |string|, inside {expr2} |v:val| has the value
   2407 --- of the current item.  For a |Dictionary| |v:key| has the key
   2408 --- of the current item and for a |List| |v:key| has the index of
   2409 --- the current item.  For a |Blob| |v:key| has the index of the
   2410 --- current byte.  For a |String| |v:key| has the index of the
   2411 --- current character.
   2412 --- Examples: >vim
   2413 ---   call foreach(mylist, 'let used[v:val] = v:true')
   2414 --- <This records the items that are in the {expr1} list.
   2415 ---
   2416 --- Note that {expr2} is the result of expression and is then used
   2417 --- as a command.  Often it is good to use a |literal-string| to
   2418 --- avoid having to double backslashes.
   2419 ---
   2420 --- If {expr2} is a |Funcref| it must take two arguments:
   2421 ---   1. the key or the index of the current item.
   2422 ---   2. the value of the current item.
   2423 --- With a lambda you don't get an error if it only accepts one
   2424 --- argument.
   2425 --- If the function returns a value, it is ignored.
   2426 ---
   2427 --- Returns {expr1} in all cases.
   2428 --- When an error is encountered while executing {expr2} no
   2429 --- further items in {expr1} are processed.
   2430 --- When {expr2} is a Funcref errors inside a function are
   2431 --- ignored, unless it was defined with the "abort" flag.
   2432 ---
   2433 --- @param expr1 string|table
   2434 --- @param expr2 string|function
   2435 --- @return string|table
   2436 function vim.fn.foreach(expr1, expr2) end
   2437 
   2438 --- Get the full command name from a short abbreviated command
   2439 --- name; see |20.2| for details on command abbreviations.
   2440 ---
   2441 --- The string argument {name} may start with a `:` and can
   2442 --- include a [range], these are skipped and not returned.
   2443 --- Returns an empty string if a command doesn't exist or if it's
   2444 --- ambiguous (for user-defined commands).
   2445 ---
   2446 --- For example `fullcommand('s')`, `fullcommand('sub')`,
   2447 --- `fullcommand(':%substitute')` all return "substitute".
   2448 ---
   2449 --- @param name string
   2450 --- @return string
   2451 function vim.fn.fullcommand(name) end
   2452 
   2453 --- Just like |function()|, but the returned Funcref will lookup
   2454 --- the function by reference, not by name.  This matters when the
   2455 --- function {name} is redefined later.
   2456 ---
   2457 --- Unlike |function()|, {name} must be an existing user function.
   2458 --- It only works for an autoloaded function if it has already
   2459 --- been loaded (to avoid mistakenly loading the autoload script
   2460 --- when only intending to use the function name, use |function()|
   2461 --- instead).  {name} cannot be a builtin function.
   2462 --- Returns 0 on error.
   2463 ---
   2464 --- @param name string
   2465 --- @param arglist? any
   2466 --- @param dict? any
   2467 --- @return any
   2468 function vim.fn.funcref(name, arglist, dict) end
   2469 
   2470 --- Return a |Funcref| variable that refers to function {name}.
   2471 --- {name} can be the name of a user defined function or an
   2472 --- internal function.
   2473 ---
   2474 --- {name} can also be a Funcref or a partial. When it is a
   2475 --- partial the dict stored in it will be used and the {dict}
   2476 --- argument is not allowed.  E.g.: >vim
   2477 ---   let FuncWithArg = function(dict.Func, [arg])
   2478 ---   let Broken = function(dict.Func, [arg], dict)
   2479 --- <
   2480 --- When using the Funcref the function will be found by {name},
   2481 --- also when it was redefined later. Use |funcref()| to keep the
   2482 --- same function.
   2483 ---
   2484 --- When {arglist} or {dict} is present this creates a partial.
   2485 --- That means the argument list and/or the dictionary is stored
   2486 --- in the Funcref and will be used when the Funcref is called.
   2487 ---
   2488 --- The arguments are passed to the function in front of other
   2489 --- arguments, but after any argument from |method|.  Example: >vim
   2490 ---   func Callback(arg1, arg2, name)
   2491 ---   "...
   2492 ---   endfunc
   2493 ---   let Partial = function('Callback', ['one', 'two'])
   2494 ---   "...
   2495 ---   call Partial('name')
   2496 --- <Invokes the function as with: >vim
   2497 ---   call Callback('one', 'two', 'name')
   2498 ---
   2499 --- <With a |method|: >vim
   2500 ---   func Callback(one, two, three)
   2501 ---   "...
   2502 ---   endfunc
   2503 ---   let Partial = function('Callback', ['two'])
   2504 ---   "...
   2505 ---   eval 'one'->Partial('three')
   2506 --- <Invokes the function as with: >vim
   2507 ---   call Callback('one', 'two', 'three')
   2508 ---
   2509 --- <The function() call can be nested to add more arguments to the
   2510 --- Funcref.  The extra arguments are appended to the list of
   2511 --- arguments.  Example: >vim
   2512 ---   func Callback(arg1, arg2, name)
   2513 ---   "...
   2514 ---   endfunc
   2515 ---   let Func = function('Callback', ['one'])
   2516 ---   let Func2 = function(Func, ['two'])
   2517 ---   "...
   2518 ---   call Func2('name')
   2519 --- <Invokes the function as with: >vim
   2520 ---   call Callback('one', 'two', 'name')
   2521 ---
   2522 --- <The Dictionary is only useful when calling a "dict" function.
   2523 --- In that case the {dict} is passed in as "self".  Example: >vim
   2524 ---   function Callback() dict
   2525 ---      echo "called for " .. self.name
   2526 ---   endfunction
   2527 ---   "...
   2528 ---   let context = {"name": "example"}
   2529 ---   let Func = function('Callback', context)
   2530 ---   "...
   2531 ---   call Func()  " will echo: called for example
   2532 --- <The use of function() is not needed when there are no extra
   2533 --- arguments, these two are equivalent, if Callback() is defined
   2534 --- as context.Callback(): >vim
   2535 ---   let Func = function('Callback', context)
   2536 ---   let Func = context.Callback
   2537 ---
   2538 --- <The argument list and the Dictionary can be combined: >vim
   2539 ---   function Callback(arg1, count) dict
   2540 ---   "...
   2541 ---   endfunction
   2542 ---   let context = {"name": "example"}
   2543 ---   let Func = function('Callback', ['one'], context)
   2544 ---   "...
   2545 ---   call Func(500)
   2546 --- <Invokes the function as with: >vim
   2547 ---   call context.Callback('one', 500)
   2548 --- <
   2549 --- Returns 0 on error.
   2550 ---
   2551 --- @param name string
   2552 --- @param arglist? any
   2553 --- @param dict? any
   2554 --- @return any
   2555 vim.fn['function'] = function(name, arglist, dict) end
   2556 
   2557 --- Cleanup unused |Lists| and |Dictionaries| that have circular
   2558 --- references.
   2559 ---
   2560 --- There is hardly ever a need to invoke this function, as it is
   2561 --- automatically done when Vim runs out of memory or is waiting
   2562 --- for the user to press a key after 'updatetime'.  Items without
   2563 --- circular references are always freed when they become unused.
   2564 --- This is useful if you have deleted a very big |List| and/or
   2565 --- |Dictionary| with circular references in a script that runs
   2566 --- for a long time.
   2567 ---
   2568 --- When the optional {atexit} argument is one, garbage
   2569 --- collection will also be done when exiting Vim, if it wasn't
   2570 --- done before.  This is useful when checking for memory leaks.
   2571 ---
   2572 --- The garbage collection is not done immediately but only when
   2573 --- it's safe to perform.  This is when waiting for the user to
   2574 --- type a character.
   2575 ---
   2576 --- @param atexit? boolean
   2577 --- @return any
   2578 function vim.fn.garbagecollect(atexit) end
   2579 
   2580 --- Get item {idx} from |List| {list}.  When this item is not
   2581 --- available return {default}.  Return zero when {default} is
   2582 --- omitted.
   2583 ---
   2584 --- @param list any[]
   2585 --- @param idx integer
   2586 --- @param default? any
   2587 --- @return any
   2588 function vim.fn.get(list, idx, default) end
   2589 
   2590 --- Get byte {idx} from |Blob| {blob}.  When this byte is not
   2591 --- available return {default}.  Return -1 when {default} is
   2592 --- omitted.
   2593 ---
   2594 --- @param blob string
   2595 --- @param idx integer
   2596 --- @param default? any
   2597 --- @return any
   2598 function vim.fn.get(blob, idx, default) end
   2599 
   2600 --- Get item with key {key} from |Dictionary| {dict}.  When this
   2601 --- item is not available return {default}.  Return zero when
   2602 --- {default} is omitted.  Useful example: >vim
   2603 ---   let val = get(g:, 'var_name', 'default')
   2604 --- <This gets the value of g:var_name if it exists, and uses
   2605 --- "default" when it does not exist.
   2606 ---
   2607 --- @param dict table<string,any>
   2608 --- @param key string
   2609 --- @param default? any
   2610 --- @return any
   2611 function vim.fn.get(dict, key, default) end
   2612 
   2613 --- Get item {what} from |Funcref| {func}.  Possible values for
   2614 --- {what} are:
   2615 ---   "name"    The function name
   2616 ---   "func"    The function
   2617 ---   "dict"    The dictionary
   2618 ---   "args"    The list with arguments
   2619 ---   "arity"   A dictionary with information about the number of
   2620 ---       arguments accepted by the function (minus the
   2621 ---       {arglist}) with the following fields:
   2622 ---     required    the number of positional arguments
   2623 ---     optional    the number of optional arguments,
   2624 ---           in addition to the required ones
   2625 ---     varargs     |TRUE| if the function accepts a
   2626 ---           variable number of arguments |...|
   2627 ---
   2628 ---     Note: There is no error, if the {arglist} of
   2629 ---     the Funcref contains more arguments than the
   2630 ---     Funcref expects, it's not validated.
   2631 ---
   2632 --- Returns zero on error.
   2633 ---
   2634 --- @param func function
   2635 --- @param what string
   2636 --- @return any
   2637 function vim.fn.get(func, what) end
   2638 
   2639 --- @param buf? integer|string
   2640 --- @return vim.fn.getbufinfo.ret.item[]
   2641 function vim.fn.getbufinfo(buf) end
   2642 
   2643 --- Get information about buffers as a List of Dictionaries.
   2644 ---
   2645 --- Without an argument information about all the buffers is
   2646 --- returned.
   2647 ---
   2648 --- When the argument is a |Dictionary| only the buffers matching
   2649 --- the specified criteria are returned.  The following keys can
   2650 --- be specified in {dict}:
   2651 ---   buflisted  include only listed buffers.
   2652 ---   bufloaded  include only loaded buffers.
   2653 ---   bufmodified  include only modified buffers.
   2654 ---
   2655 --- Otherwise, {buf} specifies a particular buffer to return
   2656 --- information for.  For the use of {buf}, see |bufname()|
   2657 --- above.  If the buffer is found the returned List has one item.
   2658 --- Otherwise the result is an empty list.
   2659 ---
   2660 --- Each returned List item is a dictionary with the following
   2661 --- entries:
   2662 ---   bufnr    Buffer number.
   2663 ---   changed    TRUE if the buffer is modified.
   2664 ---   changedtick  Number of changes made to the buffer.
   2665 ---   command    TRUE if the buffer belongs to the
   2666 ---       command-line window |cmdwin|.
   2667 ---   hidden    TRUE if the buffer is hidden.
   2668 ---   lastused  Timestamp in seconds, like
   2669 ---       |localtime()|, when the buffer was
   2670 ---       last used.
   2671 ---   listed    TRUE if the buffer is listed.
   2672 ---   lnum    Line number used for the buffer when
   2673 ---       opened in the current window.
   2674 ---       Only valid if the buffer has been
   2675 ---       displayed in the window in the past.
   2676 ---       If you want the line number of the
   2677 ---       last known cursor position in a given
   2678 ---       window, use |line()|: >vim
   2679 ---         echo line('.', {winid})
   2680 --- <
   2681 ---   linecount  Number of lines in the buffer (only
   2682 ---       valid when loaded)
   2683 ---   loaded    TRUE if the buffer is loaded.
   2684 ---   name    Full path to the file in the buffer.
   2685 ---   signs    List of signs placed in the buffer.
   2686 ---       Each list item is a dictionary with
   2687 ---       the following fields:
   2688 ---           id    sign identifier
   2689 ---           lnum  line number
   2690 ---           name  sign name
   2691 ---   variables  A reference to the dictionary with
   2692 ---       buffer-local variables.
   2693 ---   windows    List of |window-ID|s that display this
   2694 ---       buffer
   2695 ---
   2696 --- Examples: >vim
   2697 ---   for buf in getbufinfo()
   2698 ---       echo buf.name
   2699 ---   endfor
   2700 ---   for buf in getbufinfo({'buflisted':1})
   2701 ---       if buf.changed
   2702 ---     " ....
   2703 ---       endif
   2704 ---   endfor
   2705 --- <
   2706 --- To get buffer-local options use: >vim
   2707 ---   getbufvar({bufnr}, '&option_name')
   2708 --- <
   2709 ---
   2710 --- @param dict? vim.fn.getbufinfo.dict
   2711 --- @return vim.fn.getbufinfo.ret.item[]
   2712 function vim.fn.getbufinfo(dict) end
   2713 
   2714 --- Return a |List| with the lines starting from {lnum} to {end}
   2715 --- (inclusive) in the buffer {buf}.  If {end} is omitted, a
   2716 --- |List| with only the line {lnum} is returned.  See
   2717 --- `getbufoneline()` for only getting the line.
   2718 ---
   2719 --- For the use of {buf}, see |bufname()| above.
   2720 ---
   2721 --- For {lnum} and {end} "$" can be used for the last line of the
   2722 --- buffer.  Otherwise a number must be used.
   2723 ---
   2724 --- When {lnum} is smaller than 1 or bigger than the number of
   2725 --- lines in the buffer, an empty |List| is returned.
   2726 ---
   2727 --- When {end} is greater than the number of lines in the buffer,
   2728 --- it is treated as {end} is set to the number of lines in the
   2729 --- buffer.  When {end} is before {lnum} an empty |List| is
   2730 --- returned.
   2731 ---
   2732 --- This function works only for loaded buffers.  For unloaded and
   2733 --- non-existing buffers, an empty |List| is returned.
   2734 ---
   2735 --- Example: >vim
   2736 ---   let lines = getbufline(bufnr("myfile"), 1, "$")
   2737 --- <
   2738 ---
   2739 --- @param buf integer|string
   2740 --- @param lnum integer
   2741 --- @param end_? integer
   2742 --- @return string[]
   2743 function vim.fn.getbufline(buf, lnum, end_) end
   2744 
   2745 --- Just like `getbufline()` but only get one line and return it
   2746 --- as a string.
   2747 ---
   2748 --- @param buf integer|string
   2749 --- @param lnum integer
   2750 --- @return string
   2751 function vim.fn.getbufoneline(buf, lnum) end
   2752 
   2753 --- The result is the value of option or local buffer variable
   2754 --- {varname} in buffer {buf}.  Note that the name without "b:"
   2755 --- must be used.
   2756 --- The {varname} argument is a string.
   2757 --- When {varname} is empty returns a |Dictionary| with all the
   2758 --- buffer-local variables.
   2759 --- When {varname} is equal to "&" returns a |Dictionary| with all
   2760 --- the buffer-local options.
   2761 --- Otherwise, when {varname} starts with "&" returns the value of
   2762 --- a buffer-local option.
   2763 --- This also works for a global or buffer-local option, but it
   2764 --- doesn't work for a global variable, window-local variable or
   2765 --- window-local option.
   2766 --- For the use of {buf}, see |bufname()| above.
   2767 --- When the buffer or variable doesn't exist {def} or an empty
   2768 --- string is returned, there is no error message.
   2769 --- Examples: >vim
   2770 ---   let bufmodified = getbufvar(1, "&mod")
   2771 ---   echo "todo myvar = " .. getbufvar("todo", "myvar")
   2772 --- <
   2773 ---
   2774 --- @param buf integer|string
   2775 --- @param varname string
   2776 --- @param def? any
   2777 --- @return any
   2778 function vim.fn.getbufvar(buf, varname, def) end
   2779 
   2780 --- Returns a |List| of cell widths of character ranges overridden
   2781 --- by |setcellwidths()|.  The format is equal to the argument of
   2782 --- |setcellwidths()|.  If no character ranges have their cell
   2783 --- widths overridden, an empty List is returned.
   2784 ---
   2785 --- @return any
   2786 function vim.fn.getcellwidths() end
   2787 
   2788 --- Returns the |changelist| for the buffer {buf}.  For the use
   2789 --- of {buf}, see |bufname()| above.  If buffer {buf} doesn't
   2790 --- exist, an empty list is returned.
   2791 ---
   2792 --- The returned list contains two entries: a list with the change
   2793 --- locations and the current position in the list.  Each
   2794 --- entry in the change list is a dictionary with the following
   2795 --- entries:
   2796 ---   col    column number
   2797 ---   coladd    column offset for 'virtualedit'
   2798 ---   lnum    line number
   2799 --- If buffer {buf} is the current buffer, then the current
   2800 --- position refers to the position in the list.  For other
   2801 --- buffers, it is set to the length of the list.
   2802 ---
   2803 --- @param buf? integer|string
   2804 --- @return table[]
   2805 function vim.fn.getchangelist(buf) end
   2806 
   2807 --- Get a single character from the user or input stream.
   2808 --- If {expr} is omitted or is -1, wait until a character is
   2809 ---   available.
   2810 --- If {expr} is 0, only get a character when one is available.
   2811 ---   Return zero otherwise.
   2812 --- If {expr} is 1, only check if a character is available, it is
   2813 ---   not consumed.  Return zero if no character available.
   2814 --- To always get a string, specify "number" as |FALSE| in {opts}.
   2815 ---
   2816 --- Without {expr} and when {expr} is 0 a whole character or
   2817 --- special key is returned.  If it is a single character, the
   2818 --- result is a Number.  Use |nr2char()| to convert it to a String.
   2819 --- Otherwise a String is returned with the encoded character.
   2820 --- For a special key it's a String with a sequence of bytes
   2821 --- starting with 0x80 (decimal: 128).  This is the same value as
   2822 --- the String "\<Key>", e.g., "\<Left>".  The returned value is
   2823 --- also a String when a modifier (shift, control, alt) was used
   2824 --- that is not included in the character.  |keytrans()| can also
   2825 --- be used to convert a returned String into a readable form.
   2826 ---
   2827 --- When {expr} is 0 and Esc is typed, there will be a short delay
   2828 --- while Vim waits to see if this is the start of an escape
   2829 --- sequence.
   2830 ---
   2831 --- When {expr} is 1 only the first byte is returned.  For a
   2832 --- one-byte character it is the character itself as a number.
   2833 --- Use |nr2char()| to convert it to a String.
   2834 ---
   2835 --- Use |getcharmod()| to obtain any additional modifiers.
   2836 ---
   2837 --- The optional argument {opts} is a Dict and supports the
   2838 --- following items:
   2839 ---
   2840 ---   cursor    A String specifying cursor behavior
   2841 ---       when waiting for a character.
   2842 ---       "hide": hide the cursor.
   2843 ---       "keep": keep current cursor unchanged.
   2844 ---       "msg": move cursor to message area.
   2845 ---       (default: automagically decide
   2846 ---       between "keep" and "msg")
   2847 ---
   2848 ---   number    If |TRUE|, return a Number when getting
   2849 ---       a single character.
   2850 ---       If |FALSE|, the return value is always
   2851 ---       converted to a String, and an empty
   2852 ---       String (instead of 0) is returned when
   2853 ---       no character is available.
   2854 ---       (default: |TRUE|)
   2855 ---
   2856 ---   simplify  If |TRUE|, include modifiers in the
   2857 ---       character if possible.  E.g., return
   2858 ---       the same value for CTRL-I and <Tab>.
   2859 ---       If |FALSE|, don't include modifiers in
   2860 ---       the character.
   2861 ---       (default: |TRUE|)
   2862 ---
   2863 --- When the user clicks a mouse button, the mouse event will be
   2864 --- returned.  The position can then be found in |v:mouse_col|,
   2865 --- |v:mouse_lnum|, |v:mouse_winid| and |v:mouse_win|.
   2866 --- |getmousepos()| can also be used.  Mouse move events will be
   2867 --- ignored.
   2868 --- This example positions the mouse as it would normally happen: >vim
   2869 ---   let c = getchar()
   2870 ---   if c == "\<LeftMouse>" && v:mouse_win > 0
   2871 ---     exe v:mouse_win .. "wincmd w"
   2872 ---     exe v:mouse_lnum
   2873 ---     exe "normal " .. v:mouse_col .. "|"
   2874 ---   endif
   2875 --- <
   2876 --- There is no prompt, you will somehow have to make clear to the
   2877 --- user that a character has to be typed.  The screen is not
   2878 --- redrawn, e.g. when resizing the window.
   2879 ---
   2880 --- There is no mapping for the character.
   2881 --- Key codes are replaced, thus when the user presses the <Del>
   2882 --- key you get the code for the <Del> key, not the raw character
   2883 --- sequence.  Examples: >vim
   2884 ---   getchar() == "\<Del>"
   2885 ---   getchar() == "\<S-Left>"
   2886 --- <This example redefines "f" to ignore case: >vim
   2887 ---   nmap f :call FindChar()<CR>
   2888 ---   function FindChar()
   2889 ---     let c = nr2char(getchar())
   2890 ---     while col('.') < col('$') - 1
   2891 ---       normal l
   2892 ---       if getline('.')[col('.') - 1] ==? c
   2893 ---         break
   2894 ---       endif
   2895 ---     endwhile
   2896 ---   endfunction
   2897 --- <
   2898 ---
   2899 --- @param expr? -1|0|1
   2900 --- @param opts? table
   2901 --- @return integer|string
   2902 function vim.fn.getchar(expr, opts) end
   2903 
   2904 --- The result is a Number which is the state of the modifiers for
   2905 --- the last obtained character with |getchar()| or in another way.
   2906 --- These values are added together:
   2907 ---   2  shift
   2908 ---   4  control
   2909 ---   8  alt (meta)
   2910 ---   16  meta (when it's different from ALT)
   2911 ---   32  mouse double click
   2912 ---   64  mouse triple click
   2913 ---   96  mouse quadruple click (== 32 + 64)
   2914 ---   128  command (Mac) or super
   2915 --- Only the modifiers that have not been included in the
   2916 --- character itself are obtained.  Thus Shift-a results in "A"
   2917 --- without a modifier.  Returns 0 if no modifiers are used.
   2918 ---
   2919 --- @return integer
   2920 function vim.fn.getcharmod() end
   2921 
   2922 --- Get the position for String {expr}.  Same as |getpos()| but the
   2923 --- column number in the returned List is a character index
   2924 --- instead of a byte index.
   2925 --- If |getpos()| returns a very large column number, equal to
   2926 --- |v:maxcol|, then getcharpos() will return the character index
   2927 --- of the last character.
   2928 ---
   2929 --- Example:
   2930 --- With the cursor on '세' in line 5 with text "여보세요": >vim
   2931 ---   getcharpos('.')    returns [0, 5, 3, 0]
   2932 ---   getpos('.')    returns [0, 5, 7, 0]
   2933 --- <
   2934 ---
   2935 --- @param expr string
   2936 --- @return integer[]
   2937 function vim.fn.getcharpos(expr) end
   2938 
   2939 --- Return the current character search information as a {dict}
   2940 --- with the following entries:
   2941 ---
   2942 ---     char  character previously used for a character
   2943 ---     search (|t|, |f|, |T|, or |F|); empty string
   2944 ---     if no character search has been performed
   2945 ---     forward  direction of character search; 1 for forward,
   2946 ---     0 for backward
   2947 ---     until  type of character search; 1 for a |t| or |T|
   2948 ---     character search, 0 for an |f| or |F|
   2949 ---     character search
   2950 ---
   2951 --- This can be useful to always have |;| and |,| search
   2952 --- forward/backward regardless of the direction of the previous
   2953 --- character search: >vim
   2954 ---   nnoremap <expr> ; getcharsearch().forward ? ';' : ','
   2955 ---   nnoremap <expr> , getcharsearch().forward ? ',' : ';'
   2956 --- <Also see |setcharsearch()|.
   2957 ---
   2958 --- @return { char: string, forward: 1|0, until: 1|0 }
   2959 function vim.fn.getcharsearch() end
   2960 
   2961 --- The same as |getchar()|, except that this always returns a
   2962 --- String, and "number" isn't allowed in {opts}.
   2963 ---
   2964 --- @param expr? -1|0|1
   2965 --- @param opts? table
   2966 --- @return string
   2967 function vim.fn.getcharstr(expr, opts) end
   2968 
   2969 --- Return completion pattern of the current command-line.
   2970 --- Only works when the command line is being edited, thus
   2971 --- requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
   2972 --- Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
   2973 --- |getcmdprompt()|, |getcmdcompltype()| and |setcmdline()|.
   2974 --- Returns an empty string when completion is not defined.
   2975 ---
   2976 --- @return string
   2977 function vim.fn.getcmdcomplpat() end
   2978 
   2979 --- Return the type of the current command-line completion.
   2980 --- Only works when the command line is being edited, thus
   2981 --- requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
   2982 --- See |:command-completion| for the return string.
   2983 --- Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
   2984 --- |getcmdprompt()|, |getcmdcomplpat()| and |setcmdline()|.
   2985 --- Returns an empty string when completion is not defined.
   2986 ---
   2987 --- To get the type of the command-line completion for a specified
   2988 --- string, use |getcompletiontype()|.
   2989 ---
   2990 --- @return string
   2991 function vim.fn.getcmdcompltype() end
   2992 
   2993 --- Return the current command-line input.  Only works when the
   2994 --- command line is being edited, thus requires use of
   2995 --- |c_CTRL-\_e| or |c_CTRL-R_=|.
   2996 --- Example: >vim
   2997 ---   cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR>
   2998 --- <Also see |getcmdtype()|, |getcmdpos()|, |setcmdpos()|,
   2999 --- |getcmdprompt()| and |setcmdline()|.
   3000 --- Returns an empty string when entering a password or using
   3001 --- |inputsecret()|.
   3002 ---
   3003 --- @return string
   3004 function vim.fn.getcmdline() end
   3005 
   3006 --- Return the position of the cursor in the command line as a
   3007 --- byte count.  The first column is 1.
   3008 --- Only works when editing the command line, thus requires use of
   3009 --- |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
   3010 --- Returns 0 otherwise.
   3011 --- Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
   3012 --- |getcmdprompt()| and |setcmdline()|.
   3013 ---
   3014 --- @return integer
   3015 function vim.fn.getcmdpos() end
   3016 
   3017 --- Return the current command-line prompt when using functions
   3018 --- like |input()| or |confirm()|.
   3019 --- Only works when the command line is being edited, thus
   3020 --- requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
   3021 --- Also see |getcmdtype()|, |getcmdline()|, |getcmdpos()|,
   3022 --- |setcmdpos()| and |setcmdline()|.
   3023 ---
   3024 --- @return string
   3025 function vim.fn.getcmdprompt() end
   3026 
   3027 --- Return the screen position of the cursor in the command line
   3028 --- as a byte count.  The first column is 1.
   3029 --- Instead of |getcmdpos()|, it adds the prompt position.
   3030 --- Only works when editing the command line, thus requires use of
   3031 --- |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
   3032 --- Returns 0 otherwise.
   3033 --- Also see |getcmdpos()|, |setcmdpos()|, |getcmdline()| and
   3034 --- |setcmdline()|.
   3035 ---
   3036 --- @return integer
   3037 function vim.fn.getcmdscreenpos() end
   3038 
   3039 --- Return the current command-line type.  Possible return values
   3040 --- are:
   3041 ---     :  normal Ex command
   3042 ---     >  debug mode command |debug-mode|
   3043 ---     /  forward search command
   3044 ---     ?  backward search command
   3045 ---     \@  |input()| command
   3046 ---     `-`  |:insert| or |:append| command
   3047 ---     =  |i_CTRL-R_=|
   3048 --- Only works when editing the command line, thus requires use of
   3049 --- |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
   3050 --- Returns an empty string otherwise.
   3051 --- Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|.
   3052 ---
   3053 --- @return ':'|'>'|'/'|'?'|'@'|'-'|'='|''
   3054 function vim.fn.getcmdtype() end
   3055 
   3056 --- Return the current |command-line-window| type.  Possible return
   3057 --- values are the same as |getcmdtype()|.  Returns an empty string
   3058 --- when not in the command-line window.
   3059 ---
   3060 --- @return ':'|'>'|'/'|'?'|'@'|'-'|'='|''
   3061 function vim.fn.getcmdwintype() end
   3062 
   3063 --- Return a list of command-line completion matches.  The String
   3064 --- {type} argument specifies what for.  The following completion
   3065 --- types are supported:
   3066 ---
   3067 --- arglist    file names in argument list
   3068 --- augroup    autocmd groups
   3069 --- buffer    buffer names
   3070 --- breakpoint  |:breakadd| and |:breakdel| suboptions
   3071 --- cmdline    |cmdline-completion| result
   3072 --- color    color schemes
   3073 --- command    Ex command
   3074 --- compiler  compilers
   3075 --- custom,{func}  custom completion, defined via {func}
   3076 --- customlist,{func} custom completion, defined via {func}
   3077 --- diff_buffer  |:diffget| and |:diffput| completion
   3078 --- dir    directory names
   3079 --- dir_in_path  directory names in 'cdpath'
   3080 --- environment  environment variable names
   3081 --- event    autocommand events
   3082 --- expression  Vim expression
   3083 --- file    file and directory names
   3084 --- file_in_path  file and directory names in 'path'
   3085 --- filetype  filetype names 'filetype'
   3086 --- filetypecmd  |:filetype| suboptions
   3087 --- function  function name
   3088 --- help    help subjects
   3089 --- highlight  highlight groups
   3090 --- history    |:history| suboptions
   3091 --- keymap    keyboard mappings
   3092 --- locale    locale names (as output of locale -a)
   3093 --- mapclear  buffer argument
   3094 --- mapping    mapping name
   3095 --- menu    menus
   3096 --- messages  |:messages| suboptions
   3097 --- option    options
   3098 --- packadd    optional package |pack-add| names
   3099 --- retab    |:retab| suboptions
   3100 --- runtime    |:runtime| completion
   3101 --- scriptnames  sourced script names |:scriptnames|
   3102 --- shellcmd  Shell command
   3103 --- shellcmdline  Shell command line with filename arguments
   3104 --- sign    |:sign| suboptions
   3105 --- syntax    syntax file names 'syntax'
   3106 --- syntime    |:syntime| suboptions
   3107 --- tag    tags
   3108 --- tag_listfiles  tags, file names
   3109 --- user    user names
   3110 --- var    user variables
   3111 ---
   3112 --- If {pat} is an empty string, then all the matches are
   3113 --- returned.  Otherwise only items matching {pat} are returned.
   3114 --- See |wildcards| for the use of special characters in {pat}.
   3115 ---
   3116 --- If the optional {filtered} flag is set to 1, then 'wildignore'
   3117 --- is applied to filter the results.  Otherwise all the matches
   3118 --- are returned.  The 'wildignorecase' option always applies.
   3119 ---
   3120 --- If the 'wildoptions' option contains "fuzzy", then fuzzy
   3121 --- matching is used to get the completion matches.  Otherwise
   3122 --- regular expression matching is used.  Thus this function
   3123 --- follows the user preference, what happens on the command line.
   3124 --- If you do not want this you can make 'wildoptions' empty
   3125 --- before calling getcompletion() and restore it afterwards.
   3126 ---
   3127 --- If {type} is "cmdline", then the |cmdline-completion| result is
   3128 --- returned.  For example, to complete the possible values after
   3129 --- a ":call" command: >vim
   3130 ---   echo getcompletion('call ', 'cmdline')
   3131 --- <
   3132 --- If there are no matches, an empty list is returned.  An
   3133 --- invalid value for {type} produces an error.
   3134 ---
   3135 --- @param pat string
   3136 --- @param type string
   3137 --- @param filtered? boolean
   3138 --- @return string[]
   3139 function vim.fn.getcompletion(pat, type, filtered) end
   3140 
   3141 --- Return the type of the command-line completion using {pat}.
   3142 --- When no corresponding completion type is found, an empty
   3143 --- string is returned.
   3144 --- To get the current command-line completion type, use
   3145 --- |getcmdcompltype()|.
   3146 ---
   3147 --- @param pat string
   3148 --- @return string
   3149 function vim.fn.getcompletiontype(pat) end
   3150 
   3151 --- Get the position of the cursor.  This is like getpos('.'), but
   3152 --- includes an extra "curswant" item in the list:
   3153 ---     [0, lnum, col, off, curswant] ~
   3154 --- The "curswant" number is the preferred column when moving the
   3155 --- cursor vertically.  After |$| command it will be a very large
   3156 --- number equal to |v:maxcol|.  Also see |getcursorcharpos()| and
   3157 --- |getpos()|.
   3158 --- The first "bufnum" item is always zero.  The byte position of
   3159 --- the cursor is returned in "col".  To get the character
   3160 --- position, use |getcursorcharpos()|.
   3161 ---
   3162 --- The optional {winid} argument can specify the window.  It can
   3163 --- be the window number or the |window-ID|.  The last known
   3164 --- cursor position is returned, this may be invalid for the
   3165 --- current value of the buffer if it is not the current window.
   3166 --- If {winid} is invalid a list with zeroes is returned.
   3167 ---
   3168 --- This can be used to save and restore the cursor position: >vim
   3169 ---   let save_cursor = getcurpos()
   3170 ---   MoveTheCursorAround
   3171 ---   call setpos('.', save_cursor)
   3172 --- <Note that this only works within the window.  See
   3173 --- |winrestview()| for restoring more state.
   3174 ---
   3175 --- @param winid? integer
   3176 --- @return [integer, integer, integer, integer, integer]
   3177 function vim.fn.getcurpos(winid) end
   3178 
   3179 --- Same as |getcurpos()| but the column number in the returned
   3180 --- List is a character index instead of a byte index.
   3181 ---
   3182 --- Example:
   3183 --- With the cursor on '보' in line 3 with text "여보세요": >vim
   3184 ---   getcursorcharpos()  " returns [0, 3, 2, 0, 3]
   3185 ---   getcurpos()    " returns [0, 3, 4, 0, 3]
   3186 --- <
   3187 ---
   3188 --- @param winid? integer
   3189 --- @return any
   3190 function vim.fn.getcursorcharpos(winid) end
   3191 
   3192 --- With no arguments, returns the name of the effective
   3193 --- |current-directory|. With {winnr} or {tabnr} the working
   3194 --- directory of that scope is returned, and 'autochdir' is
   3195 --- ignored. Tabs and windows are identified by their respective
   3196 --- numbers, 0 means current tab or window. Missing tab number
   3197 --- implies 0. Thus the following are equivalent: >vim
   3198 ---   getcwd(0)
   3199 ---   getcwd(0, 0)
   3200 --- <If {winnr} is -1 it is ignored, only the tab is resolved.
   3201 --- {winnr} can be the window number or the |window-ID|.
   3202 --- If both {winnr} and {tabnr} are -1 the global working
   3203 --- directory is returned.
   3204 --- Note: When {tabnr} is -1 Vim returns an empty string to
   3205 --- signal that it is invalid, whereas Nvim returns either the
   3206 --- global working directory if {winnr} is -1 or the working
   3207 --- directory of the window indicated by {winnr}.
   3208 --- Throw error if the arguments are invalid. |E5000| |E5001| |E5002|
   3209 ---
   3210 --- @param winnr? integer
   3211 --- @param tabnr? integer
   3212 --- @return string
   3213 function vim.fn.getcwd(winnr, tabnr) end
   3214 
   3215 --- Return the value of environment variable {name}.  The {name}
   3216 --- argument is a string, without a leading '$'.  Example: >vim
   3217 ---   myHome = getenv('HOME')
   3218 ---
   3219 --- <When the variable does not exist |v:null| is returned.  That
   3220 --- is different from a variable set to an empty string.
   3221 --- See also |expr-env|.
   3222 ---
   3223 --- @param name string
   3224 --- @return string
   3225 function vim.fn.getenv(name) end
   3226 
   3227 --- Without an argument returns the name of the normal font being
   3228 --- used.  Like what is used for the Normal highlight group
   3229 --- |hl-Normal|.
   3230 --- With an argument a check is done whether String {name} is a
   3231 --- valid font name.  If not then an empty string is returned.
   3232 --- Otherwise the actual font name is returned, or {name} if the
   3233 --- GUI does not support obtaining the real name.
   3234 --- Only works when the GUI is running, thus not in your vimrc or
   3235 --- gvimrc file.  Use the |GUIEnter| autocommand to use this
   3236 --- function just after the GUI has started.
   3237 ---
   3238 --- @param name? string
   3239 --- @return string
   3240 function vim.fn.getfontname(name) end
   3241 
   3242 --- The result is a String, which is the read, write, and execute
   3243 --- permissions of the given file {fname}.
   3244 --- If {fname} does not exist or its directory cannot be read, an
   3245 --- empty string is returned.
   3246 --- The result is of the form "rwxrwxrwx", where each group of
   3247 --- "rwx" flags represent, in turn, the permissions of the owner
   3248 --- of the file, the group the file belongs to, and other users.
   3249 --- If a user does not have a given permission the flag for this
   3250 --- is replaced with the string "-".  Examples: >vim
   3251 ---   echo getfperm("/etc/passwd")
   3252 ---   echo getfperm(expand("~/.config/nvim/init.vim"))
   3253 --- <This will hopefully (from a security point of view) display
   3254 --- the string "rw-r--r--" or even "rw-------".
   3255 ---
   3256 --- For setting permissions use |setfperm()|.
   3257 ---
   3258 --- @param fname string
   3259 --- @return string
   3260 function vim.fn.getfperm(fname) end
   3261 
   3262 --- The result is a Number, which is the size in bytes of the
   3263 --- given file {fname}.
   3264 --- If {fname} is a directory, 0 is returned.
   3265 --- If the file {fname} can't be found, -1 is returned.
   3266 --- If the size of {fname} is too big to fit in a Number then -2
   3267 --- is returned.
   3268 ---
   3269 --- @param fname string
   3270 --- @return integer
   3271 function vim.fn.getfsize(fname) end
   3272 
   3273 --- The result is a Number, which is the last modification time of
   3274 --- the given file {fname}.  The value is measured as seconds
   3275 --- since 1st Jan 1970, and may be passed to |strftime()|.  See also
   3276 --- |localtime()| and |strftime()|.
   3277 --- If the file {fname} can't be found -1 is returned.
   3278 ---
   3279 --- @param fname string
   3280 --- @return integer
   3281 function vim.fn.getftime(fname) end
   3282 
   3283 --- The result is a String, which is a description of the kind of
   3284 --- file of the given file {fname}.
   3285 --- If {fname} does not exist an empty string is returned.
   3286 --- Here is a table over different kinds of files and their
   3287 --- results:
   3288 ---   Normal file    "file"
   3289 ---   Directory    "dir"
   3290 ---   Symbolic link    "link"
   3291 ---   Block device    "bdev"
   3292 ---   Character device  "cdev"
   3293 ---   Socket      "socket"
   3294 ---   FIFO      "fifo"
   3295 ---   All other    "other"
   3296 --- Example: >vim
   3297 ---   getftype("/home")
   3298 --- <Note that a type such as "link" will only be returned on
   3299 --- systems that support it.  On some systems only "dir" and
   3300 --- "file" are returned.
   3301 ---
   3302 --- @param fname string
   3303 --- @return 'file'|'dir'|'link'|'bdev'|'cdev'|'socket'|'fifo'|'other'
   3304 function vim.fn.getftype(fname) end
   3305 
   3306 --- Returns the |jumplist| for the specified window.
   3307 ---
   3308 --- Without arguments use the current window.
   3309 --- With {winnr} only use this window in the current tab page.
   3310 --- {winnr} can also be a |window-ID|.
   3311 --- With {winnr} and {tabnr} use the window in the specified tab
   3312 --- page.   If {winnr} or {tabnr} is invalid, an empty list is
   3313 --- returned.
   3314 ---
   3315 --- The returned list contains two entries: a list with the jump
   3316 --- locations and the last used jump position number in the list.
   3317 --- Each entry in the jump location list is a dictionary with
   3318 --- the following entries:
   3319 ---   bufnr    buffer number
   3320 ---   col    column number
   3321 ---   coladd    column offset for 'virtualedit'
   3322 ---   filename  filename if available
   3323 ---   lnum    line number
   3324 ---
   3325 --- @param winnr? integer
   3326 --- @param tabnr? integer
   3327 --- @return vim.fn.getjumplist.ret
   3328 function vim.fn.getjumplist(winnr, tabnr) end
   3329 
   3330 --- Without {end} the result is a String, which is line {lnum}
   3331 --- from the current buffer.  Example: >vim
   3332 ---   getline(1)
   3333 --- <When {lnum} is a String that doesn't start with a
   3334 --- digit, |line()| is called to translate the String into a Number.
   3335 --- To get the line under the cursor: >vim
   3336 ---   getline(".")
   3337 --- <When {lnum} is a number smaller than 1 or bigger than the
   3338 --- number of lines in the buffer, an empty string is returned.
   3339 ---
   3340 --- When {end} is given the result is a |List| where each item is
   3341 --- a line from the current buffer in the range {lnum} to {end},
   3342 --- including line {end}.
   3343 --- {end} is used in the same way as {lnum}.
   3344 --- Non-existing lines are silently omitted.
   3345 --- When {end} is before {lnum} an empty |List| is returned.
   3346 --- Example: >vim
   3347 ---   let start = line('.')
   3348 ---   let end = search("^$") - 1
   3349 ---   let lines = getline(start, end)
   3350 ---
   3351 --- <To get lines from another buffer see |getbufline()| and
   3352 --- |getbufoneline()|
   3353 ---
   3354 --- @param lnum integer|string
   3355 --- @param end_? nil|false
   3356 --- @return string
   3357 function vim.fn.getline(lnum, end_) end
   3358 
   3359 --- @param lnum integer|string
   3360 --- @param end_ true|number|string|table
   3361 --- @return string|string[]
   3362 function vim.fn.getline(lnum, end_) end
   3363 
   3364 --- Returns a |List| with all the entries in the location list for
   3365 --- window {nr}.  {nr} can be the window number or the |window-ID|.
   3366 --- When {nr} is zero the current window is used.
   3367 ---
   3368 --- For a location list window, the displayed location list is
   3369 --- returned.  For an invalid window number {nr}, an empty list is
   3370 --- returned.  Otherwise, same as |getqflist()|.
   3371 ---
   3372 --- If the optional {what} dictionary argument is supplied, then
   3373 --- returns the items listed in {what} as a dictionary.  Refer to
   3374 --- |getqflist()| for the supported items in {what}.
   3375 ---
   3376 --- In addition to the items supported by |getqflist()| in {what},
   3377 --- the following item is supported by |getloclist()|:
   3378 ---
   3379 ---   filewinid  id of the window used to display files
   3380 ---       from the location list.  This field is
   3381 ---       applicable only when called from a
   3382 ---       location list window.  See
   3383 ---       |location-list-file-window| for more
   3384 ---       details.
   3385 ---
   3386 --- Returns a |Dictionary| with default values if there is no
   3387 --- location list for the window {nr}.
   3388 --- Returns an empty Dictionary if window {nr} does not exist.
   3389 ---
   3390 --- Examples (See also |getqflist-examples|): >vim
   3391 ---   echo getloclist(3, {'all': 0})
   3392 ---   echo getloclist(5, {'filewinid': 0})
   3393 --- <
   3394 ---
   3395 --- @param nr integer
   3396 --- @param what? table
   3397 --- @return any
   3398 function vim.fn.getloclist(nr, what) end
   3399 
   3400 --- Without the {buf} argument returns a |List| with information
   3401 --- about all the global marks. |mark|
   3402 ---
   3403 --- If the optional {buf} argument is specified, returns the
   3404 --- local marks defined in buffer {buf}.  For the use of {buf},
   3405 --- see |bufname()|.  If {buf} is invalid, an empty list is
   3406 --- returned.
   3407 ---
   3408 --- Each item in the returned List is a |Dict| with the following:
   3409 ---     mark   name of the mark prefixed by "'"
   3410 ---     pos     a |List| with the position of the mark:
   3411 ---     [bufnum, lnum, col, off]
   3412 ---      Refer to |getpos()| for more information.
   3413 ---     file   file name
   3414 ---
   3415 --- Refer to |getpos()| for getting information about a specific
   3416 --- mark.
   3417 ---
   3418 --- @param buf? integer?
   3419 --- @return vim.fn.getmarklist.ret.item[]
   3420 function vim.fn.getmarklist(buf) end
   3421 
   3422 --- Returns a |List| with all matches previously defined for the
   3423 --- current window by |matchadd()| and the |:match| commands.
   3424 --- |getmatches()| is useful in combination with |setmatches()|,
   3425 --- as |setmatches()| can restore a list of matches saved by
   3426 --- |getmatches()|.
   3427 --- If {win} is specified, use the window with this number or
   3428 --- window ID instead of the current window.  If {win} is invalid,
   3429 --- an empty list is returned.
   3430 --- Example: >vim
   3431 ---   echo getmatches()
   3432 --- < >
   3433 ---   [{"group": "MyGroup1", "pattern": "TODO",
   3434 ---   "priority": 10, "id": 1}, {"group": "MyGroup2",
   3435 ---   "pattern": "FIXME", "priority": 10, "id": 2}]
   3436 --- < >vim
   3437 ---   let m = getmatches()
   3438 ---   call clearmatches()
   3439 ---   echo getmatches()
   3440 --- < >
   3441 ---   []
   3442 --- < >vim
   3443 ---   call setmatches(m)
   3444 ---   echo getmatches()
   3445 --- < >
   3446 ---   [{"group": "MyGroup1", "pattern": "TODO",
   3447 ---   "priority": 10, "id": 1}, {"group": "MyGroup2",
   3448 ---   "pattern": "FIXME", "priority": 10, "id": 2}]
   3449 --- < >vim
   3450 ---   unlet m
   3451 --- <
   3452 ---
   3453 --- @param win? integer
   3454 --- @return vim.fn.getmatches.ret.item[]
   3455 function vim.fn.getmatches(win) end
   3456 
   3457 --- Returns a |Dictionary| with the last known position of the
   3458 --- mouse.  This can be used in a mapping for a mouse click.  The
   3459 --- items are:
   3460 ---   screenrow  screen row
   3461 ---   screencol  screen column
   3462 ---   winid    Window ID of the click
   3463 ---   winrow    row inside "winid"
   3464 ---   wincol    column inside "winid"
   3465 ---   line    text line inside "winid"
   3466 ---   column    text column inside "winid"
   3467 ---   coladd    offset (in screen columns) from the
   3468 ---       start of the clicked char
   3469 --- All numbers are 1-based.
   3470 ---
   3471 --- If not over a window, e.g. when in the command line, then only
   3472 --- "screenrow" and "screencol" are valid, the others are zero.
   3473 ---
   3474 --- When on the status line below a window or the vertical
   3475 --- separator right of a window, the "line" and "column" values
   3476 --- are zero.
   3477 ---
   3478 --- When the position is after the text then "column" is the
   3479 --- length of the text in bytes plus one.
   3480 ---
   3481 --- If the mouse is over a focusable floating window then that
   3482 --- window is used.
   3483 ---
   3484 --- When using |getchar()| the Vim variables |v:mouse_lnum|,
   3485 --- |v:mouse_col| and |v:mouse_winid| also provide these values.
   3486 ---
   3487 --- @return vim.fn.getmousepos.ret
   3488 function vim.fn.getmousepos() end
   3489 
   3490 --- Return a Number which is the process ID of the Vim process.
   3491 --- This is a unique number, until Vim exits.
   3492 ---
   3493 --- @return integer
   3494 function vim.fn.getpid() end
   3495 
   3496 --- Gets a position, where {expr} is one of:
   3497 ---     .      Cursor position.
   3498 ---     $      Last line in the current buffer.
   3499 ---     'x      Position of mark x (if the mark is not set, 0 is
   3500 ---       returned for all values).
   3501 ---     w0      First line visible in current window (one if the
   3502 ---       display isn't updated, e.g. in silent Ex mode).
   3503 ---     w$      Last line visible in current window (this is one
   3504 ---       less than "w0" if no lines are visible).
   3505 ---     v      End of the current Visual selection (unlike |'<|
   3506 ---       |'>| which give the previous, not current, Visual
   3507 ---       selection), or the cursor position if not in Visual
   3508 ---       mode.
   3509 ---
   3510 ---       To get the current selected region: >vim
   3511 ---         let region = getregionpos(getpos('v'), getpos('.'))
   3512 --- <
   3513 ---       Explanation: in Visual mode "v" and "." complement each
   3514 ---       other.  While "." refers to the cursor position, "v"
   3515 ---       refers to where |v_o| would move the cursor.  So you can
   3516 ---       use "v" and "." together to get the selected region.
   3517 ---
   3518 --- Note that if a mark in another file is used, the line number
   3519 --- applies to that buffer.
   3520 ---
   3521 --- The result is a |List| with four numbers:
   3522 ---     [bufnum, lnum, col, off]
   3523 --- "bufnum" is zero, unless a mark like '0 or 'A is used, then it
   3524 --- is the buffer number of the mark.
   3525 --- "lnum" and "col" are the position in the buffer.  The first
   3526 --- column is 1.
   3527 --- The "off" number is zero, unless 'virtualedit' is used.  Then
   3528 --- it is the offset in screen columns from the start of the
   3529 --- character.  E.g., a position within a <Tab> or after the last
   3530 --- character.
   3531 ---
   3532 --- For getting the cursor position see |getcurpos()|.
   3533 --- The column number in the returned List is the byte position
   3534 --- within the line.  To get the character position in the line,
   3535 --- use |getcharpos()|.
   3536 ---
   3537 --- The visual marks |'<| and |'>| refer to the beginning and end
   3538 --- of the visual selection relative to the buffer.  Note that
   3539 --- this differs from |setpos()|, where they are relative to the
   3540 --- cursor position.
   3541 ---
   3542 --- Note that for '< and '> Visual mode matters: when it is "V"
   3543 --- (visual line mode) the column of '< is zero and the column of
   3544 --- '> is a large number equal to |v:maxcol|.
   3545 --- A very large column number equal to |v:maxcol| can be returned,
   3546 --- in which case it means "after the end of the line".
   3547 --- If {expr} is invalid, returns a list with all zeros.
   3548 ---
   3549 --- This can be used to save and restore the position of a mark: >vim
   3550 ---   let save_a_mark = getpos("'a")
   3551 ---   " ...
   3552 ---   call setpos("'a", save_a_mark)
   3553 --- <
   3554 --- Also see |getcharpos()|, |getcurpos()| and |setpos()|.
   3555 ---
   3556 --- @param expr string
   3557 --- @return [integer, integer, integer, integer]
   3558 function vim.fn.getpos(expr) end
   3559 
   3560 --- Returns a |List| with all the current quickfix errors.  Each
   3561 --- list item is a dictionary with these entries:
   3562 ---   bufnr  number of buffer that has the file name, use
   3563 ---     |bufname()| to get the name
   3564 ---   module  module name
   3565 ---   lnum  line number in the buffer (first line is 1)
   3566 ---   end_lnum
   3567 ---     end of line number if the item is multiline
   3568 ---   col  column number (first column is 1)
   3569 ---   end_col  end of column number if the item has range
   3570 ---   vcol  |TRUE|: "col" is visual column
   3571 ---     |FALSE|: "col" is byte index
   3572 ---   nr  error number
   3573 ---   pattern  search pattern used to locate the error
   3574 ---   text  description of the error
   3575 ---   type  type of the error, 'E', '1', etc.
   3576 ---   valid  |TRUE|: recognized error message
   3577 ---   user_data
   3578 ---     custom data associated with the item, can be
   3579 ---     any type.
   3580 ---
   3581 --- When there is no error list or it's empty, an empty list is
   3582 --- returned.  Quickfix list entries with a non-existing buffer
   3583 --- number are returned with "bufnr" set to zero (Note: some
   3584 --- functions accept buffer number zero for the alternate buffer,
   3585 --- you may need to explicitly check for zero).
   3586 ---
   3587 --- Useful application: Find pattern matches in multiple files and
   3588 --- do something with them: >vim
   3589 ---   vimgrep /theword/jg *.c
   3590 ---   for d in getqflist()
   3591 ---      echo bufname(d.bufnr) ':' d.lnum '=' d.text
   3592 ---   endfor
   3593 --- <
   3594 --- If the optional {what} dictionary argument is supplied, then
   3595 --- returns only the items listed in {what} as a dictionary.  The
   3596 --- following string items are supported in {what}:
   3597 ---   changedtick  get the total number of changes made
   3598 ---       to the list |quickfix-changedtick|
   3599 ---   context  get the |quickfix-context|
   3600 ---   efm  errorformat to use when parsing "lines".  If
   3601 ---     not present, then the 'errorformat' option
   3602 ---     value is used.
   3603 ---   id  get information for the quickfix list with
   3604 ---     |quickfix-ID|; zero means the id for the
   3605 ---     current list or the list specified by "nr"
   3606 ---   idx  get information for the quickfix entry at this
   3607 ---     index in the list specified by "id" or "nr".
   3608 ---     If set to zero, then uses the current entry.
   3609 ---     See |quickfix-index|
   3610 ---   items  quickfix list entries
   3611 ---   lines  parse a list of lines using 'efm' and return
   3612 ---     the resulting entries.  Only a |List| type is
   3613 ---     accepted.  The current quickfix list is not
   3614 ---     modified.  See |quickfix-parse|.
   3615 ---   nr  get information for this quickfix list; zero
   3616 ---     means the current quickfix list and "$" means
   3617 ---     the last quickfix list
   3618 ---   qfbufnr number of the buffer displayed in the quickfix
   3619 ---     window.  Returns 0 if the quickfix buffer is
   3620 ---     not present.  See |quickfix-buffer|.
   3621 ---   size  number of entries in the quickfix list
   3622 ---   title  get the list title |quickfix-title|
   3623 ---   winid  get the quickfix |window-ID|
   3624 ---   all  all of the above quickfix properties
   3625 --- Non-string items in {what} are ignored.  To get the value of a
   3626 --- particular item, set it to zero.
   3627 --- If "nr" is not present then the current quickfix list is used.
   3628 --- If both "nr" and a non-zero "id" are specified, then the list
   3629 --- specified by "id" is used.
   3630 --- To get the number of lists in the quickfix stack, set "nr" to
   3631 --- "$" in {what}.  The "nr" value in the returned dictionary
   3632 --- contains the quickfix stack size.
   3633 --- When "lines" is specified, all the other items except "efm"
   3634 --- are ignored.  The returned dictionary contains the entry
   3635 --- "items" with the list of entries.
   3636 ---
   3637 --- The returned dictionary contains the following entries:
   3638 ---   changedtick  total number of changes made to the
   3639 ---       list |quickfix-changedtick|
   3640 ---   context  quickfix list context.  See |quickfix-context|
   3641 ---     If not present, set to "".
   3642 ---   id  quickfix list ID |quickfix-ID|.  If not
   3643 ---     present, set to 0.
   3644 ---   idx  index of the quickfix entry in the list.  If
   3645 ---     not present, set to 0.
   3646 ---   items  quickfix list entries.  If not present, set to
   3647 ---     an empty list.
   3648 ---   nr  quickfix list number.  If not present, set to
   3649 ---     0
   3650 ---   qfbufnr  number of the buffer displayed in the quickfix
   3651 ---     window.  If not present, set to 0.
   3652 ---   size  number of entries in the quickfix list.  If
   3653 ---     not present, set to 0.
   3654 ---   title  quickfix list title text.  If not present, set
   3655 ---     to "".
   3656 ---   winid  quickfix |window-ID|.  If not present, set to 0
   3657 ---
   3658 --- Examples (See also |getqflist-examples|): >vim
   3659 ---   echo getqflist({'all': 1})
   3660 ---   echo getqflist({'nr': 2, 'title': 1})
   3661 ---   echo getqflist({'lines' : ["F1:10:L10"]})
   3662 --- <
   3663 ---
   3664 --- @param what? table
   3665 --- @return any
   3666 function vim.fn.getqflist(what) end
   3667 
   3668 --- The result is a String, which is the contents of register
   3669 --- {regname}.  Example: >vim
   3670 ---   let cliptext = getreg('*')
   3671 --- <When register {regname} was not set the result is an empty
   3672 --- string.
   3673 --- The {regname} argument must be a string.
   3674 ---
   3675 --- getreg('=') returns the last evaluated value of the expression
   3676 --- register.  (For use in maps.)
   3677 --- getreg('=', 1) returns the expression itself, so that it can
   3678 --- be restored with |setreg()|.  For other registers the extra
   3679 --- argument is ignored, thus you can always give it.
   3680 ---
   3681 --- If {list} is present and |TRUE|, the result type is changed
   3682 --- to |List|.  Each list item is one text line.  Use it if you care
   3683 --- about zero bytes possibly present inside register: without
   3684 --- third argument both NLs and zero bytes are represented as NLs
   3685 --- (see |NL-used-for-Nul|).
   3686 --- When the register was not set an empty list is returned.
   3687 ---
   3688 --- If {regname} is not specified, |v:register| is used.
   3689 ---
   3690 --- @param regname? string
   3691 --- @param expr? any
   3692 --- @param list? nil|false
   3693 --- @return string
   3694 function vim.fn.getreg(regname, expr, list) end
   3695 
   3696 --- @param regname string
   3697 --- @param expr any
   3698 --- @param list true|number|string|table
   3699 --- @return string[]
   3700 function vim.fn.getreg(regname, expr, list) end
   3701 
   3702 --- Returns detailed information about register {regname} as a
   3703 --- Dictionary with the following entries:
   3704 ---   regcontents  List of lines contained in register
   3705 ---       {regname}, like
   3706 ---       getreg({regname}, 1, 1).
   3707 ---   regtype    the type of register {regname}, as in
   3708 ---       |getregtype()|.
   3709 ---   isunnamed  Boolean flag, v:true if this register
   3710 ---       is currently pointed to by the unnamed
   3711 ---       register.
   3712 ---   points_to  for the unnamed register, gives the
   3713 ---       single letter name of the register
   3714 ---       currently pointed to (see |quotequote|).
   3715 ---       For example, after deleting a line
   3716 ---       with `dd`, this field will be "1",
   3717 ---       which is the register that got the
   3718 ---       deleted text.
   3719 ---
   3720 --- The {regname} argument is a string.  If {regname} is invalid
   3721 --- or not set, an empty Dictionary will be returned.
   3722 --- If {regname} is not specified, |v:register| is used.
   3723 --- The returned Dictionary can be passed to |setreg()|.
   3724 ---
   3725 --- @param regname? string
   3726 --- @return table
   3727 function vim.fn.getreginfo(regname) end
   3728 
   3729 --- Returns the list of strings from {pos1} to {pos2} from a
   3730 --- buffer.
   3731 ---
   3732 --- {pos1} and {pos2} must both be |List|s with four numbers.
   3733 --- See |getpos()| for the format of the list.  It's possible
   3734 --- to specify positions from a different buffer, but please
   3735 --- note the limitations at |getregion-notes|.
   3736 ---
   3737 --- The optional argument {opts} is a Dict and supports the
   3738 --- following items:
   3739 ---
   3740 ---   type    Specify the region's selection type.
   3741 ---       See |getregtype()| for possible values,
   3742 ---       except that the width can be omitted
   3743 ---       and an empty string cannot be used.
   3744 ---       (default: "v")
   3745 ---
   3746 ---   exclusive  If |TRUE|, use exclusive selection
   3747 ---       for the end position.
   3748 ---       (default: follow 'selection')
   3749 ---
   3750 --- You can get the last selection type by |visualmode()|.
   3751 --- If Visual mode is active, use |mode()| to get the Visual mode
   3752 --- (e.g., in a |:vmap|).
   3753 --- This function is useful to get text starting and ending in
   3754 --- different columns, such as a |charwise-visual| selection.
   3755 ---
   3756 ---           *getregion-notes*
   3757 --- Note that:
   3758 --- - Order of {pos1} and {pos2} doesn't matter, it will always
   3759 ---   return content from the upper left position to the lower
   3760 ---   right position.
   3761 --- - If 'virtualedit' is enabled and the region is past the end
   3762 ---   of the lines, resulting lines are padded with spaces.
   3763 --- - If the region is blockwise and it starts or ends in the
   3764 ---   middle of a multi-cell character, it is not included but
   3765 ---   its selected part is substituted with spaces.
   3766 --- - If {pos1} and {pos2} are not in the same buffer, an empty
   3767 ---   list is returned.
   3768 --- - {pos1} and {pos2} must belong to a |bufloaded()| buffer.
   3769 --- - It is evaluated in current window context, which makes a
   3770 ---   difference if the buffer is displayed in a window with
   3771 ---   different 'virtualedit' or 'list' values.
   3772 --- - When specifying an exclusive selection and {pos1} and {pos2}
   3773 ---   are equal, the returned list contains a single character as
   3774 ---   if selection is inclusive, to match the behavior of an empty
   3775 ---   exclusive selection in Visual mode.
   3776 ---
   3777 --- Examples: >vim
   3778 ---   xnoremap <CR>
   3779 ---   \ <Cmd>echom getregion(
   3780 ---   \ getpos('v'), getpos('.'), #{ type: mode() })<CR>
   3781 --- <
   3782 ---
   3783 --- @param pos1 [integer, integer, integer, integer]
   3784 --- @param pos2 [integer, integer, integer, integer]
   3785 --- @param opts? {type?:string, exclusive?:boolean}
   3786 --- @return string[]
   3787 function vim.fn.getregion(pos1, pos2, opts) end
   3788 
   3789 --- Same as |getregion()|, but returns a list of positions
   3790 --- describing the buffer text segments bound by {pos1} and
   3791 --- {pos2}.
   3792 --- The segments are a pair of positions for every line: >
   3793 ---   [[{start_pos}, {end_pos}], ...]
   3794 --- <
   3795 --- The position is a |List| with four numbers:
   3796 ---     [bufnum, lnum, col, off]
   3797 --- "bufnum" is the buffer number.
   3798 --- "lnum" and "col" are the position in the buffer.  The first
   3799 --- column is 1.
   3800 --- If the "off" number of a starting position is non-zero, it is
   3801 --- the offset in screen columns from the start of the character.
   3802 --- E.g., a position within a <Tab> or after the last character.
   3803 --- If the "off" number of an ending position is non-zero, it is
   3804 --- the offset of the character's first cell not included in the
   3805 --- selection, otherwise all its cells are included.
   3806 ---
   3807 --- To get the current visual selection: >vim
   3808 ---   let region = getregionpos(getpos('v'), getpos('.'))
   3809 --- <
   3810 --- The {opts} Dict supports the following items:
   3811 ---
   3812 ---   type    See |getregion()|.
   3813 ---
   3814 ---   exclusive  See |getregion()|.
   3815 ---
   3816 ---   eol    If |TRUE|, indicate positions beyond
   3817 ---       the end of a line with "col" values
   3818 ---       one more than the length of the line.
   3819 ---       If |FALSE|, positions are limited
   3820 ---       within their lines, and if a line is
   3821 ---       empty or the selection is entirely
   3822 ---       beyond the end of a line, a "col"
   3823 ---       value of 0 is used for both positions.
   3824 ---       (default: |FALSE|)
   3825 ---
   3826 --- @param pos1 [integer, integer, integer, integer]
   3827 --- @param pos2 [integer, integer, integer, integer]
   3828 --- @param opts? {type?:string, exclusive?:boolean, eol?:boolean}
   3829 --- @return [ [integer, integer, integer, integer], [integer, integer, integer, integer] ][]
   3830 function vim.fn.getregionpos(pos1, pos2, opts) end
   3831 
   3832 --- The result is a String, which is type of register {regname}.
   3833 --- The value will be one of:
   3834 ---     "v"      for |charwise| text
   3835 ---     "V"      for |linewise| text
   3836 ---     "<CTRL-V>{width}"  for |blockwise-visual| text
   3837 ---     ""      for an empty or unknown register
   3838 --- <CTRL-V> is one character with value 0x16.
   3839 --- The {regname} argument is a string.  If {regname} is not
   3840 --- specified, |v:register| is used.
   3841 ---
   3842 --- @param regname? string
   3843 --- @return string
   3844 function vim.fn.getregtype(regname) end
   3845 
   3846 --- Returns a |List| with information about all the sourced Vim
   3847 --- scripts in the order they were sourced, like what
   3848 --- `:scriptnames` shows.
   3849 ---
   3850 --- The optional Dict argument {opts} supports the following
   3851 --- optional items:
   3852 ---     name  Script name match pattern.  If specified,
   3853 ---     and "sid" is not specified, information about
   3854 ---     scripts with a name that match the pattern
   3855 ---     "name" are returned.
   3856 ---     sid    Script ID |<SID>|.  If specified, only
   3857 ---     information about the script with ID "sid" is
   3858 ---     returned and "name" is ignored.
   3859 ---
   3860 --- Each item in the returned List is a |Dict| with the following
   3861 --- items:
   3862 ---     autoload  Always set to FALSE.
   3863 ---     functions   List of script-local function names defined in
   3864 ---     the script.  Present only when a particular
   3865 ---     script is specified using the "sid" item in
   3866 ---     {opts}.
   3867 ---     name  Vim script file name.
   3868 ---     sid    Script ID |<SID>|.
   3869 ---     variables   A dictionary with the script-local variables.
   3870 ---     Present only when a particular script is
   3871 ---     specified using the "sid" item in {opts}.
   3872 ---     Note that this is a copy, the value of
   3873 ---     script-local variables cannot be changed using
   3874 ---     this dictionary.
   3875 ---     version  Vim script version, always 1
   3876 ---
   3877 --- Examples: >vim
   3878 ---   echo getscriptinfo({'name': 'myscript'})
   3879 ---   echo getscriptinfo({'sid': 15})[0].variables
   3880 --- <
   3881 ---
   3882 --- @param opts? table
   3883 --- @return vim.fn.getscriptinfo.ret[]
   3884 function vim.fn.getscriptinfo(opts) end
   3885 
   3886 --- Returns the current stack trace of Vim scripts.
   3887 --- Stack trace is a |List|, of which each item is a |Dictionary|
   3888 --- with the following items:
   3889 ---     funcref  The funcref if the stack is at a function,
   3890 ---     otherwise this item is omitted.
   3891 ---     event  The string of the event description if the
   3892 ---     stack is at an autocmd event, otherwise this
   3893 ---     item is omitted.
   3894 ---     lnum  The line number in the script on the stack.
   3895 ---     filepath  The file path of the script on the stack.
   3896 ---
   3897 --- @return table[]
   3898 function vim.fn.getstacktrace() end
   3899 
   3900 --- If {tabnr} is not specified, then information about all the
   3901 --- tab pages is returned as a |List|.  Each List item is a
   3902 --- |Dictionary|.  Otherwise, {tabnr} specifies the tab page
   3903 --- number and information about that one is returned.  If the tab
   3904 --- page does not exist an empty List is returned.
   3905 ---
   3906 --- Each List item is a |Dictionary| with the following entries:
   3907 ---   tabnr    tab page number.
   3908 ---   variables  a reference to the dictionary with
   3909 ---       tabpage-local variables
   3910 ---   windows    List of |window-ID|s in the tab page.
   3911 ---
   3912 --- @param tabnr? integer
   3913 --- @return any
   3914 function vim.fn.gettabinfo(tabnr) end
   3915 
   3916 --- Get the value of a tab-local variable {varname} in tab page
   3917 --- {tabnr}. |t:var|
   3918 --- Tabs are numbered starting with one.
   3919 --- The {varname} argument is a string.  When {varname} is empty a
   3920 --- dictionary with all tab-local variables is returned.
   3921 --- Note that the name without "t:" must be used.
   3922 --- When the tab or variable doesn't exist {def} or an empty
   3923 --- string is returned, there is no error message.
   3924 ---
   3925 --- @param tabnr integer
   3926 --- @param varname string
   3927 --- @param def? any
   3928 --- @return any
   3929 function vim.fn.gettabvar(tabnr, varname, def) end
   3930 
   3931 --- Get the value of window-local variable {varname} in window
   3932 --- {winnr} in tab page {tabnr}.
   3933 --- The {varname} argument is a string.  When {varname} is empty a
   3934 --- dictionary with all window-local variables is returned.
   3935 --- When {varname} is equal to "&" get the values of all
   3936 --- window-local options in a |Dictionary|.
   3937 --- Otherwise, when {varname} starts with "&" get the value of a
   3938 --- window-local option.
   3939 --- Note that {varname} must be the name without "w:".
   3940 --- Tabs are numbered starting with one.  For the current tabpage
   3941 --- use |getwinvar()|.
   3942 --- {winnr} can be the window number or the |window-ID|.
   3943 --- When {winnr} is zero the current window is used.
   3944 --- This also works for a global option, buffer-local option and
   3945 --- window-local option, but it doesn't work for a global variable
   3946 --- or buffer-local variable.
   3947 --- When the tab, window or variable doesn't exist {def} or an
   3948 --- empty string is returned, there is no error message.
   3949 --- Examples: >vim
   3950 ---   let list_is_on = gettabwinvar(1, 2, '&list')
   3951 ---   echo "myvar = " .. gettabwinvar(3, 1, 'myvar')
   3952 --- <
   3953 --- To obtain all window-local variables use: >vim
   3954 ---   gettabwinvar({tabnr}, {winnr}, '&')
   3955 --- <
   3956 ---
   3957 --- @param tabnr integer
   3958 --- @param winnr integer
   3959 --- @param varname string
   3960 --- @param def? any
   3961 --- @return any
   3962 function vim.fn.gettabwinvar(tabnr, winnr, varname, def) end
   3963 
   3964 --- The result is a Dict, which is the tag stack of window {winnr}.
   3965 --- {winnr} can be the window number or the |window-ID|.
   3966 --- When {winnr} is not specified, the current window is used.
   3967 --- When window {winnr} doesn't exist, an empty Dict is returned.
   3968 ---
   3969 --- The returned dictionary contains the following entries:
   3970 ---   curidx    Current index in the stack.  When at
   3971 ---       top of the stack, set to (length + 1).
   3972 ---       Index of bottom of the stack is 1.
   3973 ---   items    List of items in the stack.  Each item
   3974 ---       is a dictionary containing the
   3975 ---       entries described below.
   3976 ---   length    Number of entries in the stack.
   3977 ---
   3978 --- Each item in the stack is a dictionary with the following
   3979 --- entries:
   3980 ---   bufnr    buffer number of the current jump
   3981 ---   from    cursor position before the tag jump.
   3982 ---       See |getpos()| for the format of the
   3983 ---       returned list.
   3984 ---   matchnr    current matching tag number.  Used
   3985 ---       when multiple matching tags are found
   3986 ---       for a name.
   3987 ---   tagname    name of the tag
   3988 ---
   3989 --- See |tagstack| for more information about the tag stack.
   3990 ---
   3991 --- @param winnr? integer
   3992 --- @return any
   3993 function vim.fn.gettagstack(winnr) end
   3994 
   3995 --- Translate String {text} if possible.
   3996 --- This is mainly for use in the distributed Vim scripts.  When
   3997 --- generating message translations the {text} is extracted by
   3998 --- xgettext, the translator can add the translated message in the
   3999 --- .po file and Vim will lookup the translation when gettext() is
   4000 --- called.
   4001 --- For {text} double quoted strings are preferred, because
   4002 --- xgettext does not understand escaping in single quoted
   4003 --- strings.
   4004 ---
   4005 --- @param text string
   4006 --- @return string
   4007 function vim.fn.gettext(text) end
   4008 
   4009 --- Returns information about windows as a |List| with Dictionaries.
   4010 ---
   4011 --- If {winid} is given Information about the window with that ID
   4012 --- is returned, as a |List| with one item.  If the window does not
   4013 --- exist the result is an empty list.
   4014 ---
   4015 --- Without {winid} information about all the windows in all the
   4016 --- tab pages is returned.
   4017 ---
   4018 --- Each List item is a |Dictionary| with the following entries:
   4019 ---   botline    last complete displayed buffer line
   4020 ---   bufnr    number of buffer in the window
   4021 ---   height    window height (excluding winbar)
   4022 ---   leftcol    first column displayed; only used when
   4023 ---       'wrap' is off
   4024 ---   loclist    1 if showing a location list
   4025 ---   quickfix  1 if quickfix or location list window
   4026 ---   status_height  status lines height (0 or 1)
   4027 ---   tabnr    tab page number
   4028 ---   terminal  1 if a terminal window
   4029 ---   textoff    number of columns occupied by any
   4030 ---       'foldcolumn', 'signcolumn' and line
   4031 ---       number in front of the text
   4032 ---   topline    first displayed buffer line
   4033 ---   variables  a reference to the dictionary with
   4034 ---       window-local variables
   4035 ---   width    window width
   4036 ---   winbar    1 if the window has a toolbar, 0
   4037 ---       otherwise
   4038 ---   wincol    leftmost screen column of the window;
   4039 ---       "col" from |win_screenpos()|
   4040 ---   winid    |window-ID|
   4041 ---   winnr    window number
   4042 ---   winrow    topmost screen line of the window;
   4043 ---       "row" from |win_screenpos()|
   4044 ---
   4045 --- @param winid? integer
   4046 --- @return vim.fn.getwininfo.ret.item[]
   4047 function vim.fn.getwininfo(winid) end
   4048 
   4049 --- The result is a |List| with two numbers, the result of
   4050 --- |getwinposx()| and |getwinposy()| combined:
   4051 ---   [x-pos, y-pos]
   4052 --- {timeout} can be used to specify how long to wait in msec for
   4053 --- a response from the terminal.  When omitted 100 msec is used.
   4054 ---
   4055 --- Use a longer time for a remote terminal.
   4056 --- When using a value less than 10 and no response is received
   4057 --- within that time, a previously reported position is returned,
   4058 --- if available.  This can be used to poll for the position and
   4059 --- do some work in the meantime: >vim
   4060 ---   while 1
   4061 ---     let res = getwinpos(1)
   4062 ---     if res[0] >= 0
   4063 ---       break
   4064 ---     endif
   4065 ---     " Do some work here
   4066 ---   endwhile
   4067 --- <
   4068 ---
   4069 --- @param timeout? integer
   4070 --- @return any
   4071 function vim.fn.getwinpos(timeout) end
   4072 
   4073 --- The result is a Number, which is the X coordinate in pixels of
   4074 --- the left hand side of the GUI Vim window.  The result will be
   4075 --- -1 if the information is not available.
   4076 --- The value can be used with `:winpos`.
   4077 ---
   4078 --- @return integer
   4079 function vim.fn.getwinposx() end
   4080 
   4081 --- The result is a Number, which is the Y coordinate in pixels of
   4082 --- the top of the GUI Vim window.  The result will be -1 if the
   4083 --- information is not available.
   4084 --- The value can be used with `:winpos`.
   4085 ---
   4086 --- @return integer
   4087 function vim.fn.getwinposy() end
   4088 
   4089 --- Like |gettabwinvar()| for the current tabpage.
   4090 --- Examples: >vim
   4091 ---   let list_is_on = getwinvar(2, '&list')
   4092 ---   echo "myvar = " .. getwinvar(1, 'myvar')
   4093 --- <
   4094 ---
   4095 --- @param winnr integer
   4096 --- @param varname string
   4097 --- @param def? any
   4098 --- @return any
   4099 function vim.fn.getwinvar(winnr, varname, def) end
   4100 
   4101 --- Expand the file wildcards in {expr}.  See |wildcards| for the
   4102 --- use of special characters.
   4103 ---
   4104 --- Unless the optional {nosuf} argument is given and is |TRUE|,
   4105 --- the 'suffixes' and 'wildignore' options apply: Names matching
   4106 --- one of the patterns in 'wildignore' will be skipped and
   4107 --- 'suffixes' affect the ordering of matches.
   4108 --- 'wildignorecase' always applies.
   4109 ---
   4110 --- When {list} is present and it is |TRUE| the result is a |List|
   4111 --- with all matching files.  The advantage of using a List is,
   4112 --- you also get filenames containing newlines correctly.
   4113 --- Otherwise the result is a String and when there are several
   4114 --- matches, they are separated by <NL> characters.
   4115 ---
   4116 --- If the expansion fails, the result is an empty String or List.
   4117 ---
   4118 --- You can also use |readdir()| if you need to do complicated
   4119 --- things, such as limiting the number of matches.
   4120 ---
   4121 --- A name for a non-existing file is not included.  A symbolic
   4122 --- link is only included if it points to an existing file.
   4123 --- However, when the {alllinks} argument is present and it is
   4124 --- |TRUE| then all symbolic links are included.
   4125 ---
   4126 --- For most systems backticks can be used to get files names from
   4127 --- any external command.  Example: >vim
   4128 ---   let tagfiles = glob("`find . -name tags -print`")
   4129 ---   let &tags = substitute(tagfiles, "\n", ",", "g")
   4130 --- <The result of the program inside the backticks should be one
   4131 --- item per line.  Spaces inside an item are allowed.
   4132 ---
   4133 --- See |expand()| for expanding special Vim variables.  See
   4134 --- |system()| for getting the raw output of an external command.
   4135 ---
   4136 --- @param expr string
   4137 --- @param nosuf? boolean
   4138 --- @param list? boolean
   4139 --- @param alllinks? boolean
   4140 --- @return any
   4141 function vim.fn.glob(expr, nosuf, list, alllinks) end
   4142 
   4143 --- Convert a file pattern, as used by |glob()|, into a search
   4144 --- pattern.  The result can be used to match with a string that
   4145 --- is a file name.  E.g. >vim
   4146 ---   if filename =~ glob2regpat('Make*.mak')
   4147 ---     " ...
   4148 ---   endif
   4149 --- <This is equivalent to: >vim
   4150 ---   if filename =~ '^Make.*\.mak$'
   4151 ---     " ...
   4152 ---   endif
   4153 --- <When {string} is an empty string the result is "^$", match an
   4154 --- empty string.
   4155 --- Note that the result depends on the system.  On MS-Windows
   4156 --- a backslash usually means a path separator.
   4157 ---
   4158 --- @param string string
   4159 --- @return string
   4160 function vim.fn.glob2regpat(string) end
   4161 
   4162 --- Perform |glob()| for String {expr} on all directories in {path}
   4163 --- and concatenate the results.  Example: >vim
   4164 ---   echo globpath(&rtp, "syntax/c.vim")
   4165 --- <
   4166 --- {path} is a comma-separated list of directory names.  Each
   4167 --- directory name is prepended to {expr} and expanded like with
   4168 --- |glob()|.  A path separator is inserted when needed.
   4169 --- To add a comma inside a directory name escape it with a
   4170 --- backslash.  Note that on MS-Windows a directory may have a
   4171 --- trailing backslash, remove it if you put a comma after it.
   4172 --- If the expansion fails for one of the directories, there is no
   4173 --- error message.
   4174 ---
   4175 --- Unless the optional {nosuf} argument is given and is |TRUE|,
   4176 --- the 'suffixes' and 'wildignore' options apply: Names matching
   4177 --- one of the patterns in 'wildignore' will be skipped and
   4178 --- 'suffixes' affect the ordering of matches.
   4179 ---
   4180 --- When {list} is present and it is |TRUE| the result is a |List|
   4181 --- with all matching files.  The advantage of using a List is,
   4182 --- you also get filenames containing newlines correctly.
   4183 --- Otherwise the result is a String and when there are several
   4184 --- matches, they are separated by <NL> characters.  Example: >vim
   4185 ---   echo globpath(&rtp, "syntax/c.vim", 0, 1)
   4186 --- <
   4187 --- {allinks} is used as with |glob()|.
   4188 ---
   4189 --- The "**" item can be used to search in a directory tree.
   4190 --- For example, to find all "README.txt" files in the directories
   4191 --- in 'runtimepath' and below: >vim
   4192 ---   echo globpath(&rtp, "**/README.txt")
   4193 --- <Upwards search and limiting the depth of "**" is not
   4194 --- supported, thus using 'path' will not always work properly.
   4195 ---
   4196 --- @param path string
   4197 --- @param expr string
   4198 --- @param nosuf? boolean
   4199 --- @param list? boolean
   4200 --- @param allinks? boolean
   4201 --- @return any
   4202 function vim.fn.globpath(path, expr, nosuf, list, allinks) end
   4203 
   4204 --- Returns 1 if {feature} is supported, 0 otherwise.  The
   4205 --- {feature} argument is a feature name like "nvim-0.2.1" or
   4206 --- "win32", see below.  See also |exists()|.
   4207 ---
   4208 --- To get the system name use |vim.uv|.os_uname() in Lua: >lua
   4209 ---   print(vim.uv.os_uname().sysname)
   4210 ---
   4211 --- <If the code has a syntax error then Vimscript may skip the
   4212 --- rest of the line.  Put |:if| and |:endif| on separate lines to
   4213 --- avoid the syntax error: >vim
   4214 ---   if has('feature')
   4215 ---     let x = this_breaks_without_the_feature()
   4216 ---   endif
   4217 --- <
   4218 --- Vim's compile-time feature-names (prefixed with "+") are not
   4219 --- recognized because Nvim is always compiled with all possible
   4220 --- features. |feature-compile|
   4221 ---
   4222 --- Feature names can be:
   4223 --- 1.  Nvim version. For example the "nvim-0.2.1" feature means
   4224 ---     that Nvim is version 0.2.1 or later: >vim
   4225 ---   if has("nvim-0.2.1")
   4226 ---     " ...
   4227 ---   endif
   4228 ---
   4229 --- <2.  Runtime condition or other pseudo-feature. For example the
   4230 ---     "win32" feature checks if the current system is Windows: >vim
   4231 ---   if has("win32")
   4232 ---     " ...
   4233 ---   endif
   4234 --- <          *feature-list*
   4235 ---     List of supported pseudo-feature names:
   4236 ---   acl    |ACL| support.
   4237 ---   bsd    BSD system (not macOS, use "mac" for that).
   4238 ---   clipboard  |clipboard| provider is available.
   4239 ---   fname_case  Case in file names matters (for Darwin and MS-Windows
   4240 ---       this is not present).
   4241 ---   gui_running  Nvim has a GUI.
   4242 ---   hurd    GNU/Hurd system.
   4243 ---   iconv    Can use |iconv()| for conversion.
   4244 ---   linux    Linux system.
   4245 ---   mac    MacOS system.
   4246 ---   nvim    This is Nvim.
   4247 ---   python3    Legacy Vim |python3| interface. |has-python|
   4248 ---   pythonx    Legacy Vim |python_x| interface. |has-pythonx|
   4249 ---   sun    SunOS system.
   4250 ---   ttyin    input is a terminal (tty).
   4251 ---   ttyout    output is a terminal (tty).
   4252 ---   unix    Unix system.
   4253 ---   *vim_starting*  True during |startup|.
   4254 ---   win32    Windows system (32 or 64 bit).
   4255 ---   win64    Windows system (64 bit).
   4256 ---   wsl    WSL (Windows Subsystem for Linux) system.
   4257 ---
   4258 ---           *has-patch*
   4259 --- 3.  Vim patch. For example the "patch123" feature means that
   4260 ---     Vim patch 123 at the current |v:version| was included: >vim
   4261 ---   if v:version > 602 || v:version == 602 && has("patch148")
   4262 ---     " ...
   4263 ---   endif
   4264 ---
   4265 --- <4.  Vim version. For example the "patch-7.4.237" feature means
   4266 ---     that Nvim is Vim-compatible to version 7.4.237 or later. >vim
   4267 ---   if has("patch-7.4.237")
   4268 ---     " ...
   4269 ---   endif
   4270 --- <
   4271 ---
   4272 --- @param feature string
   4273 --- @return 0|1
   4274 function vim.fn.has(feature) end
   4275 
   4276 --- The result is a Number, which is TRUE if |Dictionary| {dict}
   4277 --- has an entry with key {key}.  FALSE otherwise. The {key}
   4278 --- argument is a string.
   4279 ---
   4280 --- @param dict table
   4281 --- @param key string
   4282 --- @return 0|1
   4283 function vim.fn.has_key(dict, key) end
   4284 
   4285 --- The result is a Number, which is 1 when the window has set a
   4286 --- local path via |:lcd| or when {winnr} is -1 and the tabpage
   4287 --- has set a local path via |:tcd|, otherwise 0.
   4288 ---
   4289 --- Tabs and windows are identified by their respective numbers,
   4290 --- 0 means current tab or window. Missing argument implies 0.
   4291 --- Thus the following are equivalent: >vim
   4292 ---   echo haslocaldir()
   4293 ---   echo haslocaldir(0)
   4294 ---   echo haslocaldir(0, 0)
   4295 --- <With {winnr} use that window in the current tabpage.
   4296 --- With {winnr} and {tabnr} use the window in that tabpage.
   4297 --- {winnr} can be the window number or the |window-ID|.
   4298 --- If {winnr} is -1 it is ignored, only the tab is resolved.
   4299 --- Throw error if the arguments are invalid. |E5000| |E5001| |E5002|
   4300 ---
   4301 --- @param winnr? integer
   4302 --- @param tabnr? integer
   4303 --- @return 0|1
   4304 function vim.fn.haslocaldir(winnr, tabnr) end
   4305 
   4306 --- The result is a Number, which is TRUE if there is a mapping
   4307 --- that contains {what} in somewhere in the rhs (what it is
   4308 --- mapped to) and this mapping exists in one of the modes
   4309 --- indicated by {mode}.
   4310 --- The arguments {what} and {mode} are strings.
   4311 --- When {abbr} is there and it is |TRUE| use abbreviations
   4312 --- instead of mappings.  Don't forget to specify Insert and/or
   4313 --- Command-line mode.
   4314 --- Both the global mappings and the mappings local to the current
   4315 --- buffer are checked for a match.
   4316 --- If no matching mapping is found FALSE is returned.
   4317 --- The following characters are recognized in {mode}:
   4318 ---   n  Normal mode
   4319 ---   v  Visual and Select mode
   4320 ---   x  Visual mode
   4321 ---   s  Select mode
   4322 ---   o  Operator-pending mode
   4323 ---   i  Insert mode
   4324 ---   l  Language-Argument ("r", "f", "t", etc.)
   4325 ---   c  Command-line mode
   4326 --- When {mode} is omitted, "nvo" is used.
   4327 ---
   4328 --- This function is useful to check if a mapping already exists
   4329 --- to a function in a Vim script.  Example: >vim
   4330 ---   if !hasmapto('\ABCdoit')
   4331 ---      map <Leader>d \ABCdoit
   4332 ---   endif
   4333 --- <This installs the mapping to "\ABCdoit" only if there isn't
   4334 --- already a mapping to "\ABCdoit".
   4335 ---
   4336 --- @param what any
   4337 --- @param mode? string
   4338 --- @param abbr? boolean
   4339 --- @return 0|1
   4340 function vim.fn.hasmapto(what, mode, abbr) end
   4341 
   4342 --- @deprecated
   4343 --- Obsolete name for |hlID()|.
   4344 ---
   4345 --- @param name string
   4346 --- @return any
   4347 function vim.fn.highlightID(name) end
   4348 
   4349 --- @deprecated
   4350 --- Obsolete name for |hlexists()|.
   4351 ---
   4352 --- @param name string
   4353 --- @return any
   4354 function vim.fn.highlight_exists(name) end
   4355 
   4356 --- Add the String {item} to the history {history} which can be
   4357 --- one of:          *hist-names*
   4358 ---   "cmd"   or ":"    command line history
   4359 ---   "search" or "/"   search pattern history
   4360 ---   "expr"   or "="   typed expression history
   4361 ---   "input"  or "\@"    input line history
   4362 ---   "debug"  or ">"   debug command history
   4363 ---   empty      the current or last used history
   4364 --- The {history} string does not need to be the whole name, one
   4365 --- character is sufficient.
   4366 --- If {item} does already exist in the history, it will be
   4367 --- shifted to become the newest entry.
   4368 --- The result is a Number: TRUE if the operation was successful,
   4369 --- otherwise FALSE is returned.
   4370 ---
   4371 --- Example: >vim
   4372 ---   call histadd("input", strftime("%Y %b %d"))
   4373 ---   let date=input("Enter date: ")
   4374 --- <This function is not available in the |sandbox|.
   4375 ---
   4376 --- @param history string
   4377 --- @param item any
   4378 --- @return 0|1
   4379 function vim.fn.histadd(history, item) end
   4380 
   4381 --- Clear {history}, i.e. delete all its entries.  See |hist-names|
   4382 --- for the possible values of {history}.
   4383 ---
   4384 --- If the parameter {item} evaluates to a String, it is used as a
   4385 --- regular expression.  All entries matching that expression will
   4386 --- be removed from the history (if there are any).
   4387 --- Upper/lowercase must match, unless "\c" is used |/\c|.
   4388 --- If {item} evaluates to a Number, it will be interpreted as
   4389 --- an index, see |:history-indexing|.  The respective entry will
   4390 --- be removed if it exists.
   4391 ---
   4392 --- The result is TRUE for a successful operation, otherwise FALSE
   4393 --- is returned.
   4394 ---
   4395 --- Examples:
   4396 --- Clear expression register history: >vim
   4397 ---   call histdel("expr")
   4398 --- <
   4399 --- Remove all entries starting with "*" from the search history: >vim
   4400 ---   call histdel("/", '^\*')
   4401 --- <
   4402 --- The following three are equivalent: >vim
   4403 ---   call histdel("search", histnr("search"))
   4404 ---   call histdel("search", -1)
   4405 ---   call histdel("search", '^' .. histget("search", -1) .. '$')
   4406 --- <
   4407 --- To delete the last search pattern and use the last-but-one for
   4408 --- the "n" command and 'hlsearch': >vim
   4409 ---   call histdel("search", -1)
   4410 ---   let \@/ = histget("search", -1)
   4411 --- <
   4412 ---
   4413 --- @param history string
   4414 --- @param item? any
   4415 --- @return 0|1
   4416 function vim.fn.histdel(history, item) end
   4417 
   4418 --- The result is a String, the entry with Number {index} from
   4419 --- {history}.  See |hist-names| for the possible values of
   4420 --- {history}, and |:history-indexing| for {index}.  If there is
   4421 --- no such entry, an empty String is returned.  When {index} is
   4422 --- omitted, the most recent item from the history is used.
   4423 ---
   4424 --- Examples:
   4425 --- Redo the second last search from history. >vim
   4426 ---   execute '/' .. histget("search", -2)
   4427 ---
   4428 --- <Define an Ex command ":H {num}" that supports re-execution of
   4429 --- the {num}th entry from the output of |:history|. >vim
   4430 ---   command -nargs=1 H execute histget("cmd", 0+<args>)
   4431 --- <
   4432 ---
   4433 --- @param history string
   4434 --- @param index? integer|string
   4435 --- @return string
   4436 function vim.fn.histget(history, index) end
   4437 
   4438 --- The result is the Number of the current entry in {history}.
   4439 --- See |hist-names| for the possible values of {history}.
   4440 --- If an error occurred, -1 is returned.
   4441 ---
   4442 --- Example: >vim
   4443 ---   let inp_index = histnr("expr")
   4444 --- <
   4445 ---
   4446 --- @param history string
   4447 --- @return integer
   4448 function vim.fn.histnr(history) end
   4449 
   4450 --- The result is a Number, which is the ID of the highlight group
   4451 --- with name {name}.  When the highlight group doesn't exist,
   4452 --- zero is returned.
   4453 --- This can be used to retrieve information about the highlight
   4454 --- group.  For example, to get the background color of the
   4455 --- "Comment" group: >vim
   4456 ---   echo synIDattr(synIDtrans(hlID("Comment")), "bg")
   4457 --- <
   4458 ---
   4459 --- @param name string
   4460 --- @return integer
   4461 function vim.fn.hlID(name) end
   4462 
   4463 --- The result is a Number, which is TRUE if a highlight group
   4464 --- called {name} exists.  This is when the group has been
   4465 --- defined in some way.  Not necessarily when highlighting has
   4466 --- been defined for it, it may also have been used for a syntax
   4467 --- item.
   4468 ---
   4469 --- @param name string
   4470 --- @return 0|1
   4471 function vim.fn.hlexists(name) end
   4472 
   4473 --- The result is a String, which is the name of the machine on
   4474 --- which Vim is currently running.  Machine names greater than
   4475 --- 256 characters long are truncated.
   4476 ---
   4477 --- @return string
   4478 function vim.fn.hostname() end
   4479 
   4480 --- The result is a String, which is the text {string} converted
   4481 --- from encoding {from} to encoding {to}.
   4482 --- When the conversion completely fails an empty string is
   4483 --- returned.  When some characters could not be converted they
   4484 --- are replaced with "?".
   4485 --- The encoding names are whatever the iconv() library function
   4486 --- can accept, see ":!man 3 iconv".
   4487 --- Note that Vim uses UTF-8 for all Unicode encodings, conversion
   4488 --- from/to UCS-2 is automatically changed to use UTF-8.  You
   4489 --- cannot use UCS-2 in a string anyway, because of the NUL bytes.
   4490 ---
   4491 --- @param string string
   4492 --- @param from string
   4493 --- @param to string
   4494 --- @return string
   4495 function vim.fn.iconv(string, from, to) end
   4496 
   4497 --- Returns a |String| which is a unique identifier of the
   4498 --- container type (|List|, |Dict|, |Blob| and |Partial|). It is
   4499 --- guaranteed that for the mentioned types `id(v1) ==# id(v2)`
   4500 --- returns true iff `type(v1) == type(v2) && v1 is v2`.
   4501 --- Note that `v:_null_string`, `v:_null_list`, `v:_null_dict` and
   4502 --- `v:_null_blob` have the same `id()` with different types
   4503 --- because they are internally represented as NULL pointers.
   4504 --- `id()` returns a hexadecimal representation of the pointers to
   4505 --- the containers (i.e. like `0x994a40`), same as `printf("%p",
   4506 --- {expr})`, but it is advised against counting on the exact
   4507 --- format of the return value.
   4508 ---
   4509 --- It is not guaranteed that `id(no_longer_existing_container)`
   4510 --- will not be equal to some other `id()`: new containers may
   4511 --- reuse identifiers of the garbage-collected ones.
   4512 ---
   4513 --- @param expr any
   4514 --- @return string
   4515 function vim.fn.id(expr) end
   4516 
   4517 --- The result is a Number, which is indent of line {lnum} in the
   4518 --- current buffer.  The indent is counted in spaces, the value
   4519 --- of 'tabstop' is relevant.  {lnum} is used just like in
   4520 --- |getline()|.
   4521 --- When {lnum} is invalid -1 is returned.
   4522 ---
   4523 --- To get or set indent of lines in a string, see |vim.text.indent()|.
   4524 ---
   4525 --- @param lnum integer|string
   4526 --- @return integer
   4527 function vim.fn.indent(lnum) end
   4528 
   4529 --- Find {expr} in {object} and return its index.  See
   4530 --- |indexof()| for using a lambda to select the item.
   4531 ---
   4532 --- If {object} is a |List| return the lowest index where the item
   4533 --- has a value equal to {expr}.  There is no automatic
   4534 --- conversion, so the String "4" is different from the Number 4.
   4535 --- And the Number 4 is different from the Float 4.0.  The value
   4536 --- of 'ignorecase' is not used here, case matters as indicated by
   4537 --- the {ic} argument.
   4538 ---
   4539 --- If {object} is a |Blob| return the lowest index where the byte
   4540 --- value is equal to {expr}.
   4541 ---
   4542 --- If {start} is given then start looking at the item with index
   4543 --- {start} (may be negative for an item relative to the end).
   4544 ---
   4545 --- When {ic} is given and it is |TRUE|, ignore case.  Otherwise
   4546 --- case must match.
   4547 ---
   4548 --- -1 is returned when {expr} is not found in {object}.
   4549 --- Example: >vim
   4550 ---   let idx = index(words, "the")
   4551 ---   if index(numbers, 123) >= 0
   4552 ---     " ...
   4553 ---   endif
   4554 --- <
   4555 ---
   4556 --- @param object any
   4557 --- @param expr any
   4558 --- @param start? integer
   4559 --- @param ic? boolean
   4560 --- @return integer
   4561 function vim.fn.index(object, expr, start, ic) end
   4562 
   4563 --- Returns the index of an item in {object} where {expr} is
   4564 --- v:true.  {object} must be a |List| or a |Blob|.
   4565 ---
   4566 --- If {object} is a |List|, evaluate {expr} for each item in the
   4567 --- List until the expression is v:true and return the index of
   4568 --- this item.
   4569 ---
   4570 --- If {object} is a |Blob| evaluate {expr} for each byte in the
   4571 --- Blob until the expression is v:true and return the index of
   4572 --- this byte.
   4573 ---
   4574 --- {expr} must be a |string| or |Funcref|.
   4575 ---
   4576 --- If {expr} is a |string|: If {object} is a |List|, inside
   4577 --- {expr} |v:key| has the index of the current List item and
   4578 --- |v:val| has the value of the item.  If {object} is a |Blob|,
   4579 --- inside {expr} |v:key| has the index of the current byte and
   4580 --- |v:val| has the byte value.
   4581 ---
   4582 --- If {expr} is a |Funcref| it must take two arguments:
   4583 ---   1. the key or the index of the current item.
   4584 ---   2. the value of the current item.
   4585 --- The function must return |TRUE| if the item is found and the
   4586 --- search should stop.
   4587 ---
   4588 --- The optional argument {opts} is a Dict and supports the
   4589 --- following items:
   4590 ---     startidx  start evaluating {expr} at the item with this
   4591 ---     index; may be negative for an item relative to
   4592 ---     the end
   4593 --- Returns -1 when {expr} evaluates to v:false for all the items.
   4594 --- Example: >vim
   4595 ---   let l = [#{n: 10}, #{n: 20}, #{n: 30}]
   4596 ---   echo indexof(l, "v:val.n == 20")
   4597 ---   echo indexof(l, {i, v -> v.n == 30})
   4598 ---   echo indexof(l, "v:val.n == 20", #{startidx: 1})
   4599 --- <
   4600 ---
   4601 --- @param object any
   4602 --- @param expr any
   4603 --- @param opts? table
   4604 --- @return integer
   4605 function vim.fn.indexof(object, expr, opts) end
   4606 
   4607 ---
   4608 --- @param prompt string
   4609 --- @param text? string
   4610 --- @param completion? string
   4611 --- @return string
   4612 function vim.fn.input(prompt, text, completion) end
   4613 
   4614 --- The result is a String, which is whatever the user typed on
   4615 --- the command-line.  The {prompt} argument is either a prompt
   4616 --- string, or a blank string (for no prompt).  A '\n' can be used
   4617 --- in the prompt to start a new line.
   4618 ---
   4619 --- In the second form it accepts a single dictionary with the
   4620 --- following keys, any of which may be omitted:
   4621 ---
   4622 --- Key           Default  Description ~
   4623 --- prompt        ""       Same as {prompt} in the first form.
   4624 --- default       ""       Same as {text} in the first form.
   4625 --- completion    nothing  Same as {completion} in the first form.
   4626 --- cancelreturn  ""       The value returned when the dialog is
   4627 ---                        cancelled.
   4628 --- highlight     nothing  Highlight handler: |Funcref|.
   4629 ---
   4630 --- The highlighting set with |:echohl| is used for the prompt.
   4631 --- The input is entered just like a command-line, with the same
   4632 --- editing commands and mappings.  There is a separate history
   4633 --- for lines typed for input().
   4634 --- Example: >vim
   4635 ---   if input("Coffee or beer? ") == "beer"
   4636 ---     echo "Cheers!"
   4637 ---   endif
   4638 --- <
   4639 --- If the optional {text} argument is present and not empty, this
   4640 --- is used for the default reply, as if the user typed this.
   4641 --- Example: >vim
   4642 ---   let color = input("Color? ", "white")
   4643 ---
   4644 --- <The optional {completion} argument specifies the type of
   4645 --- completion supported for the input.  Without it completion is
   4646 --- not performed.  The supported completion types are the same as
   4647 --- that can be supplied to a user-defined command using the
   4648 --- "-complete=" argument.  Refer to |:command-completion| for
   4649 --- more information.  Example: >vim
   4650 ---   let fname = input("File: ", "", "file")
   4651 ---
   4652 --- <      *input()-highlight* *E5400* *E5402*
   4653 --- The optional `highlight` key allows specifying function which
   4654 --- will be used for highlighting user input.  This function
   4655 --- receives user input as its only argument and must return
   4656 --- a list of 3-tuples [hl_start_col, hl_end_col + 1, hl_group]
   4657 --- where
   4658 ---   hl_start_col is the first highlighted column,
   4659 ---   hl_end_col is the last highlighted column (+ 1!),
   4660 ---   hl_group is |:hi| group used for highlighting.
   4661 ---             *E5403* *E5404* *E5405* *E5406*
   4662 --- Both hl_start_col and hl_end_col + 1 must point to the start
   4663 --- of the multibyte character (highlighting must not break
   4664 --- multibyte characters), hl_end_col + 1 may be equal to the
   4665 --- input length.  Start column must be in range [0, len(input)),
   4666 --- end column must be in range (hl_start_col, len(input)],
   4667 --- sections must be ordered so that next hl_start_col is greater
   4668 --- then or equal to previous hl_end_col.
   4669 ---
   4670 --- Example (try some input with parentheses): >vim
   4671 ---   highlight RBP1 guibg=Red ctermbg=red
   4672 ---   highlight RBP2 guibg=Yellow ctermbg=yellow
   4673 ---   highlight RBP3 guibg=Green ctermbg=green
   4674 ---   highlight RBP4 guibg=Blue ctermbg=blue
   4675 ---   let g:rainbow_levels = 4
   4676 ---   function! RainbowParens(cmdline)
   4677 ---     let ret = []
   4678 ---     let i = 0
   4679 ---     let lvl = 0
   4680 ---     while i < len(a:cmdline)
   4681 ---       if a:cmdline[i] is# '('
   4682 ---         call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)])
   4683 ---         let lvl += 1
   4684 ---       elseif a:cmdline[i] is# ')'
   4685 ---         let lvl -= 1
   4686 ---         call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)])
   4687 ---       endif
   4688 ---       let i += 1
   4689 ---     endwhile
   4690 ---     return ret
   4691 ---   endfunction
   4692 ---   call input({'prompt':'>','highlight':'RainbowParens'})
   4693 --- <
   4694 --- Highlight function is called at least once for each new
   4695 --- displayed input string, before command-line is redrawn.  It is
   4696 --- expected that function is pure for the duration of one input()
   4697 --- call, i.e. it produces the same output for the same input, so
   4698 --- output may be memoized.  Function is run like under |:silent|
   4699 --- modifier. If the function causes any errors, it will be
   4700 --- skipped for the duration of the current input() call.
   4701 ---
   4702 --- Highlighting is disabled if command-line contains arabic
   4703 --- characters.
   4704 ---
   4705 --- NOTE: This function must not be used in a startup file, for
   4706 --- the versions that only run in GUI mode (e.g., the Win32 GUI).
   4707 --- Note: When input() is called from within a mapping it will
   4708 --- consume remaining characters from that mapping, because a
   4709 --- mapping is handled like the characters were typed.
   4710 --- Use |inputsave()| before input() and |inputrestore()|
   4711 --- after input() to avoid that.  Another solution is to avoid
   4712 --- that further characters follow in the mapping, e.g., by using
   4713 --- |:execute| or |:normal|.
   4714 ---
   4715 --- Example with a mapping: >vim
   4716 ---   nmap \x :call GetFoo()<CR>:exe "/" .. Foo<CR>
   4717 ---   function GetFoo()
   4718 ---     call inputsave()
   4719 ---     let g:Foo = input("enter search pattern: ")
   4720 ---     call inputrestore()
   4721 ---   endfunction
   4722 --- <
   4723 ---
   4724 --- @param opts table
   4725 --- @return string
   4726 function vim.fn.input(opts) end
   4727 
   4728 --- @deprecated
   4729 --- Use |input()| instead.
   4730 ---
   4731 --- @param ... any
   4732 --- @return any
   4733 function vim.fn.inputdialog(...) end
   4734 
   4735 --- {textlist} must be a |List| of strings.  This |List| is
   4736 --- displayed, one string per line.  The user will be prompted to
   4737 --- enter a number, which is returned.
   4738 --- The user can also select an item by clicking on it with the
   4739 --- mouse, if the mouse is enabled in the command line ('mouse' is
   4740 --- "a" or includes "c").  For the first string 0 is returned.
   4741 --- When clicking above the first item a negative number is
   4742 --- returned.  When clicking on the prompt one more than the
   4743 --- length of {textlist} is returned.
   4744 --- Make sure {textlist} has less than 'lines' entries, otherwise
   4745 --- it won't work.  It's a good idea to put the entry number at
   4746 --- the start of the string.  And put a prompt in the first item.
   4747 --- Example: >vim
   4748 ---   let color = inputlist(['Select color:', '1. red',
   4749 ---     \ '2. green', '3. blue'])
   4750 --- <
   4751 ---
   4752 --- @param textlist string[]
   4753 --- @return any
   4754 function vim.fn.inputlist(textlist) end
   4755 
   4756 --- Restore typeahead that was saved with a previous |inputsave()|.
   4757 --- Should be called the same number of times |inputsave()| is
   4758 --- called.  Calling it more often is harmless though.
   4759 --- Returns TRUE when there is nothing to restore, FALSE
   4760 --- otherwise.
   4761 ---
   4762 --- @return integer
   4763 function vim.fn.inputrestore() end
   4764 
   4765 --- Preserve typeahead (also from mappings) and clear it, so that
   4766 --- a following prompt gets input from the user.  Should be
   4767 --- followed by a matching |inputrestore()| after the prompt.  Can
   4768 --- be used several times, in which case there must be just as
   4769 --- many |inputrestore()| calls.
   4770 --- Returns TRUE when out of memory, FALSE otherwise.
   4771 ---
   4772 --- @return integer
   4773 function vim.fn.inputsave() end
   4774 
   4775 --- This function acts much like the |input()| function with but
   4776 --- two exceptions:
   4777 --- a) the user's response will be displayed as a sequence of
   4778 --- asterisks ("*") thereby keeping the entry secret, and
   4779 --- b) the user's response will not be recorded on the input
   4780 --- |history| stack.
   4781 --- The result is a String, which is whatever the user actually
   4782 --- typed on the command-line in response to the issued prompt.
   4783 --- NOTE: Command-line completion is not supported.
   4784 ---
   4785 --- @param prompt string
   4786 --- @param text? string
   4787 --- @return string
   4788 function vim.fn.inputsecret(prompt, text) end
   4789 
   4790 --- When {object} is a |List| or a |Blob| insert {item} at the start
   4791 --- of it.
   4792 ---
   4793 --- If {idx} is specified insert {item} before the item with index
   4794 --- {idx}.  If {idx} is zero it goes before the first item, just
   4795 --- like omitting {idx}.  A negative {idx} is also possible, see
   4796 --- |list-index|.  -1 inserts just before the last item.
   4797 ---
   4798 --- Returns the resulting |List| or |Blob|.  Examples: >vim
   4799 ---   let mylist = insert([2, 3, 5], 1)
   4800 ---   call insert(mylist, 4, -1)
   4801 ---   call insert(mylist, 6, len(mylist))
   4802 --- <The last example can be done simpler with |add()|.
   4803 --- Note that when {item} is a |List| it is inserted as a single
   4804 --- item.  Use |extend()| to concatenate |Lists|.
   4805 ---
   4806 --- @param object any
   4807 --- @param item any
   4808 --- @param idx? integer
   4809 --- @return any
   4810 function vim.fn.insert(object, item, idx) end
   4811 
   4812 --- Interrupt script execution.  It works more or less like the
   4813 --- user typing CTRL-C, most commands won't execute and control
   4814 --- returns to the user.  This is useful to abort execution
   4815 --- from lower down, e.g. in an autocommand.  Example: >vim
   4816 --- function s:check_typoname(file)
   4817 ---    if fnamemodify(a:file, ':t') == '['
   4818 ---        echomsg 'Maybe typo'
   4819 ---        call interrupt()
   4820 ---    endif
   4821 --- endfunction
   4822 --- au BufWritePre * call s:check_typoname(expand('<amatch>'))
   4823 --- <
   4824 ---
   4825 --- @return any
   4826 function vim.fn.interrupt() end
   4827 
   4828 --- Bitwise invert.  The argument is converted to a number.  A
   4829 --- List, Dict or Float argument causes an error.  Example: >vim
   4830 ---   let bits = invert(bits)
   4831 --- <
   4832 ---
   4833 --- @param expr integer
   4834 --- @return integer
   4835 function vim.fn.invert(expr) end
   4836 
   4837 --- The result is a Number, which is |TRUE| when {path} is an
   4838 --- absolute path.
   4839 --- On Unix, a path is considered absolute when it starts with
   4840 --- '/'.
   4841 --- On MS-Windows, it is considered absolute when it starts with
   4842 --- an optional drive prefix and is followed by a '\' or '/'.  UNC
   4843 --- paths are always absolute.
   4844 --- Example: >vim
   4845 ---   echo isabsolutepath('/usr/share/')  " 1
   4846 ---   echo isabsolutepath('./foobar')    " 0
   4847 ---   echo isabsolutepath('C:\Windows')  " 1
   4848 ---   echo isabsolutepath('foobar')    " 0
   4849 ---   echo isabsolutepath('\\remote\file')  " 1
   4850 --- <
   4851 ---
   4852 --- @param path string
   4853 --- @return 0|1
   4854 function vim.fn.isabsolutepath(path) end
   4855 
   4856 --- The result is a Number, which is |TRUE| when a directory
   4857 --- with the name {directory} exists.  If {directory} doesn't
   4858 --- exist, or isn't a directory, the result is |FALSE|.  {directory}
   4859 --- is any expression, which is used as a String.
   4860 ---
   4861 --- @param directory string
   4862 --- @return 0|1
   4863 function vim.fn.isdirectory(directory) end
   4864 
   4865 --- Return 1 if {expr} is a positive infinity, or -1 a negative
   4866 --- infinity, otherwise 0. >vim
   4867 ---   echo isinf(1.0 / 0.0)
   4868 --- <  1 >vim
   4869 ---   echo isinf(-1.0 / 0.0)
   4870 --- <  -1
   4871 ---
   4872 --- @param expr number
   4873 --- @return 1|0|-1
   4874 function vim.fn.isinf(expr) end
   4875 
   4876 --- The result is a Number, which is |TRUE| when {expr} is the
   4877 --- name of a locked variable.
   4878 --- The string argument {expr} must be the name of a variable,
   4879 --- |List| item or |Dictionary| entry, not the variable itself!
   4880 --- Example: >vim
   4881 ---   let alist = [0, ['a', 'b'], 2, 3]
   4882 ---   lockvar 1 alist
   4883 ---   echo islocked('alist')    " 1
   4884 ---   echo islocked('alist[1]')  " 0
   4885 ---
   4886 --- <When {expr} is a variable that does not exist you get an error
   4887 --- message.  Use |exists()| to check for existence.
   4888 ---
   4889 --- @param expr any
   4890 --- @return 0|1
   4891 function vim.fn.islocked(expr) end
   4892 
   4893 --- Return |TRUE| if {expr} is a float with value NaN. >vim
   4894 ---   echo isnan(0.0 / 0.0)
   4895 --- <  1
   4896 ---
   4897 --- @param expr number
   4898 --- @return 0|1
   4899 function vim.fn.isnan(expr) end
   4900 
   4901 --- Return a |List| with all key/index and value pairs of {expr}.
   4902 --- Each |List| item is a list with two items:
   4903 --- - for a |Dict|: the key and the value
   4904 --- - for a |List|, |Blob| or |String|: the index and the value
   4905 --- The returned |List| is in arbitrary order for a |Dict|,
   4906 --- otherwise it's in ascending order of the index.
   4907 ---
   4908 --- Also see |keys()| and |values()|.
   4909 ---
   4910 --- Example: >vim
   4911 ---   let mydict = #{a: 'red', b: 'blue'}
   4912 ---   for [key, value] in items(mydict)
   4913 ---      echo $"{key} = {value}"
   4914 ---   endfor
   4915 ---   echo items([1, 2, 3])
   4916 ---   echo items("foobar")
   4917 ---   echo items(0z0102)
   4918 --- <
   4919 ---
   4920 --- @param expr table|string
   4921 --- @return any
   4922 function vim.fn.items(expr) end
   4923 
   4924 --- @deprecated
   4925 --- Obsolete name for |chanclose()|
   4926 ---
   4927 --- @param ... any
   4928 --- @return any
   4929 function vim.fn.jobclose(...) end
   4930 
   4931 --- Return the PID (process id) of |job-id| {job}.
   4932 ---
   4933 --- @param job integer
   4934 --- @return integer
   4935 function vim.fn.jobpid(job) end
   4936 
   4937 --- Resize the pseudo terminal window of |job-id| {job} to {width}
   4938 --- columns and {height} rows.
   4939 --- Fails if the job was not started with `"pty":v:true`.
   4940 ---
   4941 --- @param job integer
   4942 --- @param width integer
   4943 --- @param height integer
   4944 --- @return any
   4945 function vim.fn.jobresize(job, width, height) end
   4946 
   4947 --- @deprecated
   4948 --- Obsolete name for |chansend()|
   4949 ---
   4950 --- @param ... any
   4951 --- @return any
   4952 function vim.fn.jobsend(...) end
   4953 
   4954 --- Note: Prefer |vim.system()| in Lua (unless using `rpc`, `pty`, or `term`).
   4955 ---
   4956 --- Spawns {cmd} as a job.
   4957 --- If {cmd} is a List it runs directly (no 'shell').
   4958 --- If {cmd} is a String it runs in the 'shell', like this: >vim
   4959 ---   call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
   4960 --- <(See |shell-unquoting| for details.)
   4961 ---
   4962 --- Example: start a job and handle its output: >vim
   4963 ---   call jobstart(['nvim', '-h'], {'on_stdout':{j,d,e->append(line('.'),d)}})
   4964 --- <
   4965 --- Example: start a job in a |terminal| connected to the current buffer: >vim
   4966 ---   call jobstart(['nvim', '-h'], {'term':v:true})
   4967 --- <
   4968 --- Returns |job-id| on success, 0 on invalid arguments (or job
   4969 --- table is full), -1 if {cmd}[0] or 'shell' is not executable.
   4970 --- The returned job-id is a valid |channel-id| representing the
   4971 --- job's stdio streams. Use |chansend()| (or |rpcnotify()| and
   4972 --- |rpcrequest()| if "rpc" was enabled) to send data to stdin and
   4973 --- |chanclose()| to close the streams without stopping the job.
   4974 ---
   4975 --- See |job-control| and |RPC|.
   4976 ---
   4977 --- NOTE: on Windows if {cmd} is a List:
   4978 ---   - cmd[0] must be an executable (not a "built-in"). If it is
   4979 ---     in $PATH it can be called by name, without an extension: >vim
   4980 ---       call jobstart(['ping', 'neovim.io'])
   4981 --- <    If it is a full or partial path, extension is required: >vim
   4982 ---       call jobstart(['System32\ping.exe', 'neovim.io'])
   4983 --- <  - {cmd} is collapsed to a string of quoted args as expected
   4984 ---     by CommandLineToArgvW https://msdn.microsoft.com/bb776391
   4985 ---     unless cmd[0] is some form of "cmd.exe".
   4986 ---
   4987 ---           *jobstart-env*
   4988 --- The job environment is initialized as follows:
   4989 ---   $NVIM                is set to |v:servername| of the parent Nvim
   4990 ---   $NVIM_LISTEN_ADDRESS is unset
   4991 ---   $NVIM_LOG_FILE       is unset
   4992 ---   $VIM                 is unset
   4993 ---   $VIMRUNTIME          is unset
   4994 --- You can set these with the `env` option.
   4995 ---
   4996 ---           *jobstart-options*
   4997 --- {opts} is a dictionary with these keys:
   4998 ---   clear_env:  (boolean) `env` defines the job environment
   4999 ---         exactly, instead of merging current environment.
   5000 ---   cwd:        (string, default=|current-directory|) Working
   5001 ---         directory of the job.
   5002 ---   detach:     (boolean) Detach the job process: it will not be
   5003 ---         killed when Nvim exits. If the process exits
   5004 ---         before Nvim, `on_exit` will be invoked.
   5005 ---   env:        (dict) Map of environment variable name:value
   5006 ---         pairs extending (or replace with "clear_env")
   5007 ---         the current environment. |jobstart-env|
   5008 ---   height:     (number) Height of the `pty` terminal.
   5009 ---   |on_exit|:    (function) Callback invoked when the job exits.
   5010 ---   |on_stdout|:  (function) Callback invoked when the job emits
   5011 ---         stdout data.
   5012 ---   |on_stderr|:  (function) Callback invoked when the job emits
   5013 ---         stderr data.
   5014 ---   overlapped: (boolean) Sets FILE_FLAG_OVERLAPPED for the
   5015 ---         stdio passed to the child process. Only on
   5016 ---         MS-Windows; ignored on other platforms.
   5017 ---   pty:        (boolean) Connect the job to a new pseudo
   5018 ---         terminal, and its streams to the master file
   5019 ---         descriptor. `on_stdout` receives all output,
   5020 ---         `on_stderr` is ignored. |terminal-start|
   5021 ---   rpc:        (boolean) Use |msgpack-rpc| to communicate with
   5022 ---         the job over stdio. Then `on_stdout` is ignored,
   5023 ---         but `on_stderr` can still be used.
   5024 ---   stderr_buffered: (boolean) Collect data until EOF (stream closed)
   5025 ---         before invoking `on_stderr`. |channel-buffered|
   5026 ---   stdout_buffered: (boolean) Collect data until EOF (stream
   5027 ---         closed) before invoking `on_stdout`. |channel-buffered|
   5028 ---   stdin:      (string) Either "pipe" (default) to connect the
   5029 ---         job's stdin to a channel or "null" to disconnect
   5030 ---         stdin.
   5031 ---   term:      (boolean) Spawns {cmd} in a new pseudo-terminal session
   5032 ---           connected to the current (unmodified) buffer. Implies "pty".
   5033 ---           Default "height" and "width" are set to the current window
   5034 ---           dimensions. |jobstart()|. Defaults $TERM to "xterm-256color".
   5035 ---   width:      (number) Width of the `pty` terminal.
   5036 ---
   5037 --- {opts} is passed as |self| dictionary to the callback; the
   5038 --- caller may set other keys to pass application-specific data.
   5039 ---
   5040 --- Returns:
   5041 ---   - |channel-id| on success
   5042 ---   - 0 on invalid arguments
   5043 ---   - -1 if {cmd}[0] is not executable.
   5044 --- See also |job-control|, |channel|, |msgpack-rpc|.
   5045 ---
   5046 --- @param cmd string|string[]
   5047 --- @param opts? table
   5048 --- @return integer
   5049 function vim.fn.jobstart(cmd, opts) end
   5050 
   5051 --- Stop |job-id| {id} by sending SIGTERM to the job process. If
   5052 --- the process does not terminate after a timeout then SIGKILL
   5053 --- will be sent. When the job terminates its |on_exit| handler
   5054 --- (if any) will be invoked.
   5055 --- See |job-control|.
   5056 ---
   5057 --- Returns 1 for valid job id, 0 for invalid id, including jobs have
   5058 --- exited or stopped.
   5059 ---
   5060 --- @param id integer
   5061 --- @return integer
   5062 function vim.fn.jobstop(id) end
   5063 
   5064 --- Waits for jobs and their |on_exit| handlers to complete.
   5065 ---
   5066 --- {jobs} is a List of |job-id|s to wait for.
   5067 --- {timeout} is the maximum waiting time in milliseconds. If
   5068 --- omitted or -1, wait forever.
   5069 ---
   5070 --- Timeout of 0 can be used to check the status of a job: >vim
   5071 ---   let running = jobwait([{job-id}], 0)[0] == -1
   5072 --- <
   5073 --- During jobwait() callbacks for jobs not in the {jobs} list may
   5074 --- be invoked. The screen will not redraw unless |:redraw| is
   5075 --- invoked by a callback.
   5076 ---
   5077 --- Returns a list of len({jobs}) integers, where each integer is
   5078 --- the status of the corresponding job:
   5079 ---   Exit-code, if the job exited
   5080 ---   -1 if the timeout was exceeded
   5081 ---   -2 if the job was interrupted (by |CTRL-C|)
   5082 ---   -3 if the job-id is invalid
   5083 ---
   5084 --- @param jobs integer[]
   5085 --- @param timeout? integer
   5086 --- @return integer[]
   5087 function vim.fn.jobwait(jobs, timeout) end
   5088 
   5089 --- Join the items in {list} together into one String.
   5090 --- When {sep} is specified it is put in between the items.  If
   5091 --- {sep} is omitted a single space is used.
   5092 --- Note that {sep} is not added at the end.  You might want to
   5093 --- add it there too: >vim
   5094 ---   let lines = join(mylist, "\n") .. "\n"
   5095 --- <String items are used as-is.  |Lists| and |Dictionaries| are
   5096 --- converted into a string like with |string()|.
   5097 --- The opposite function is |split()|.
   5098 ---
   5099 --- @param list any[]
   5100 --- @param sep? string
   5101 --- @return string
   5102 function vim.fn.join(list, sep) end
   5103 
   5104 --- Convert {expr} from JSON object.  Accepts |readfile()|-style
   5105 --- list as the input, as well as regular string.  May output any
   5106 --- Vim value. In the following cases it will output
   5107 --- |msgpack-special-dict|:
   5108 --- 1. Dictionary contains duplicate key.
   5109 --- 2. String contains NUL byte.  Two special dictionaries: for
   5110 ---    dictionary and for string will be emitted in case string
   5111 ---    with NUL byte was a dictionary key.
   5112 ---
   5113 --- Note: function treats its input as UTF-8 always.  The JSON
   5114 --- standard allows only a few encodings, of which UTF-8 is
   5115 --- recommended and the only one required to be supported.
   5116 --- Non-UTF-8 characters are an error.
   5117 ---
   5118 --- @param expr any
   5119 --- @return any
   5120 function vim.fn.json_decode(expr) end
   5121 
   5122 --- Convert {expr} into a JSON string.  Accepts
   5123 --- |msgpack-special-dict| as the input.  Will not convert
   5124 --- |Funcref|s, mappings with non-string keys (can be created as
   5125 --- |msgpack-special-dict|), values with self-referencing
   5126 --- containers, strings which contain non-UTF-8 characters,
   5127 --- pseudo-UTF-8 strings which contain codepoints reserved for
   5128 --- surrogate pairs (such strings are not valid UTF-8 strings).
   5129 --- Non-printable characters are converted into "\u1234" escapes
   5130 --- or special escapes like "\t", other are dumped as-is.
   5131 --- |Blob|s are converted to arrays of the individual bytes.
   5132 ---
   5133 --- @param expr any
   5134 --- @return string
   5135 function vim.fn.json_encode(expr) end
   5136 
   5137 --- Return a |List| with all the keys of {dict}.  The |List| is in
   5138 --- arbitrary order.  Also see |items()| and |values()|.
   5139 ---
   5140 --- @param dict table
   5141 --- @return string[]
   5142 function vim.fn.keys(dict) end
   5143 
   5144 --- Turn the internal byte representation of keys into a form that
   5145 --- can be used for |:map|.  E.g. >vim
   5146 ---   let xx = "\<C-Home>"
   5147 ---   echo keytrans(xx)
   5148 --- <  <C-Home>
   5149 ---
   5150 --- @param string string
   5151 --- @return string
   5152 function vim.fn.keytrans(string) end
   5153 
   5154 --- @deprecated
   5155 --- Obsolete name for bufnr("$").
   5156 ---
   5157 --- @return any
   5158 function vim.fn.last_buffer_nr() end
   5159 
   5160 --- The result is a Number, which is the length of the argument.
   5161 --- When {expr} is a String or a Number the length in bytes is
   5162 --- used, as with |strlen()|.
   5163 --- When {expr} is a |List| the number of items in the |List| is
   5164 --- returned.
   5165 --- When {expr} is a |Blob| the number of bytes is returned.
   5166 --- When {expr} is a |Dictionary| the number of entries in the
   5167 --- |Dictionary| is returned.
   5168 --- Otherwise an error is given and returns zero.
   5169 ---
   5170 --- @param expr any[]
   5171 --- @return integer
   5172 function vim.fn.len(expr) end
   5173 
   5174 --- Call function {funcname} in the run-time library {libname}
   5175 --- with single argument {argument}.
   5176 --- This is useful to call functions in a library that you
   5177 --- especially made to be used with Vim.  Since only one argument
   5178 --- is possible, calling standard library functions is rather
   5179 --- limited.
   5180 --- The result is the String returned by the function.  If the
   5181 --- function returns NULL, this will appear as an empty string ""
   5182 --- to Vim.
   5183 --- If the function returns a number, use |libcallnr()|!
   5184 --- If {argument} is a number, it is passed to the function as an
   5185 --- int; if {argument} is a string, it is passed as a
   5186 --- null-terminated string.
   5187 ---
   5188 --- libcall() allows you to write your own 'plug-in' extensions to
   5189 --- Vim without having to recompile the program.  It is NOT a
   5190 --- means to call system functions!  If you try to do so Vim will
   5191 --- very probably crash.
   5192 ---
   5193 --- For Win32, the functions you write must be placed in a DLL
   5194 --- and use the normal C calling convention (NOT Pascal which is
   5195 --- used in Windows System DLLs).  The function must take exactly
   5196 --- one parameter, either a character pointer or a long integer,
   5197 --- and must return a character pointer or NULL.  The character
   5198 --- pointer returned must point to memory that will remain valid
   5199 --- after the function has returned (e.g. in static data in the
   5200 --- DLL).  If it points to allocated memory, that memory will
   5201 --- leak away.  Using a static buffer in the function should work,
   5202 --- it's then freed when the DLL is unloaded.
   5203 ---
   5204 --- WARNING: If the function returns a non-valid pointer, Vim may
   5205 --- crash!  This also happens if the function returns a number,
   5206 --- because Vim thinks it's a pointer.
   5207 --- For Win32 systems, {libname} should be the filename of the DLL
   5208 --- without the ".DLL" suffix.  A full path is only required if
   5209 --- the DLL is not in the usual places.
   5210 --- For Unix: When compiling your own plugins, remember that the
   5211 --- object code must be compiled as position-independent ('PIC').
   5212 --- Examples: >vim
   5213 ---   echo libcall("libc.so", "getenv", "HOME")
   5214 --- <
   5215 ---
   5216 --- @param libname string
   5217 --- @param funcname string
   5218 --- @param argument any
   5219 --- @return any
   5220 function vim.fn.libcall(libname, funcname, argument) end
   5221 
   5222 --- Just like |libcall()|, but used for a function that returns an
   5223 --- int instead of a string.
   5224 --- Examples: >vim
   5225 ---   echo libcallnr("/usr/lib/libc.so", "getpid", "")
   5226 ---   call libcallnr("libc.so", "printf", "Hello World!\n")
   5227 ---   call libcallnr("libc.so", "sleep", 10)
   5228 --- <
   5229 ---
   5230 --- @param libname string
   5231 --- @param funcname string
   5232 --- @param argument any
   5233 --- @return any
   5234 function vim.fn.libcallnr(libname, funcname, argument) end
   5235 
   5236 --- See |getpos()| for accepted positions.
   5237 ---
   5238 --- To get the column number use |col()|.  To get both use
   5239 --- |getpos()|.
   5240 ---
   5241 --- With the optional {winid} argument the values are obtained for
   5242 --- that window instead of the current window.
   5243 ---
   5244 --- Returns 0 for invalid values of {expr} and {winid}.
   5245 ---
   5246 --- Examples: >vim
   5247 ---   echo line(".")      " line number of the cursor
   5248 ---   echo line(".", winid)    " idem, in window "winid"
   5249 ---   echo line("'t")      " line number of mark t
   5250 ---   echo line("'" .. marker)  " line number of mark marker
   5251 --- <
   5252 --- To jump to the last known position when opening a file see
   5253 --- |last-position-jump|.
   5254 ---
   5255 --- @param expr string|integer[]
   5256 --- @param winid? integer
   5257 --- @return integer
   5258 function vim.fn.line(expr, winid) end
   5259 
   5260 --- Return the byte count from the start of the buffer for line
   5261 --- {lnum}.  This includes the end-of-line character, depending on
   5262 --- the 'fileformat' option for the current buffer.  The first
   5263 --- line returns 1. UTF-8 encoding is used, 'fileencoding' is
   5264 --- ignored.  This can also be used to get the byte count for the
   5265 --- line just below the last line: >vim
   5266 ---   echo line2byte(line("$") + 1)
   5267 --- <This is the buffer size plus one.  If 'fileencoding' is empty
   5268 --- it is the file size plus one.  {lnum} is used like with
   5269 --- |getline()|.  When {lnum} is invalid -1 is returned.
   5270 --- Also see |byte2line()|, |go| and |:goto|.
   5271 ---
   5272 --- @param lnum integer|string
   5273 --- @return integer
   5274 function vim.fn.line2byte(lnum) end
   5275 
   5276 --- Get the amount of indent for line {lnum} according the lisp
   5277 --- indenting rules, as with 'lisp'.
   5278 --- The indent is counted in spaces, the value of 'tabstop' is
   5279 --- relevant.  {lnum} is used just like in |getline()|.
   5280 --- When {lnum} is invalid, -1 is returned.
   5281 ---
   5282 --- @param lnum integer|string
   5283 --- @return integer
   5284 function vim.fn.lispindent(lnum) end
   5285 
   5286 --- Return a Blob concatenating all the number values in {list}.
   5287 --- Examples: >vim
   5288 ---   echo list2blob([1, 2, 3, 4])  " returns 0z01020304
   5289 ---   echo list2blob([])    " returns 0z
   5290 --- <Returns an empty Blob on error.  If one of the numbers is
   5291 --- negative or more than 255 error *E1239* is given.
   5292 ---
   5293 --- |blob2list()| does the opposite.
   5294 ---
   5295 --- @param list any[]
   5296 --- @return string
   5297 function vim.fn.list2blob(list) end
   5298 
   5299 --- Convert each number in {list} to a character string can
   5300 --- concatenate them all.  Examples: >vim
   5301 ---   echo list2str([32])    " returns " "
   5302 ---   echo list2str([65, 66, 67])  " returns "ABC"
   5303 --- <The same can be done (slowly) with: >vim
   5304 ---   echo join(map(list, {nr, val -> nr2char(val)}), '')
   5305 --- <|str2list()| does the opposite.
   5306 ---
   5307 --- UTF-8 encoding is always used, {utf8} option has no effect,
   5308 --- and exists only for backwards-compatibility.
   5309 --- With UTF-8 composing characters work as expected: >vim
   5310 ---   echo list2str([97, 769])  " returns "á"
   5311 --- <
   5312 --- Returns an empty string on error.
   5313 ---
   5314 --- @param list any[]
   5315 --- @param utf8? boolean
   5316 --- @return string
   5317 function vim.fn.list2str(list, utf8) end
   5318 
   5319 --- Return the current time, measured as seconds since 1st Jan
   5320 --- 1970.  See also |strftime()|, |strptime()| and |getftime()|.
   5321 ---
   5322 --- @return integer
   5323 function vim.fn.localtime() end
   5324 
   5325 --- Return the natural logarithm (base e) of {expr} as a |Float|.
   5326 --- {expr} must evaluate to a |Float| or a |Number| in the range
   5327 --- (0, inf].
   5328 --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
   5329 --- Examples: >vim
   5330 ---   echo log(10)
   5331 --- <  2.302585 >vim
   5332 ---   echo log(exp(5))
   5333 --- <  5.0
   5334 ---
   5335 --- @param expr number
   5336 --- @return number
   5337 function vim.fn.log(expr) end
   5338 
   5339 --- Return the logarithm of Float {expr} to base 10 as a |Float|.
   5340 --- {expr} must evaluate to a |Float| or a |Number|.
   5341 --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
   5342 --- Examples: >vim
   5343 ---   echo log10(1000)
   5344 --- <  3.0 >vim
   5345 ---   echo log10(0.01)
   5346 --- <  -2.0
   5347 ---
   5348 --- @param expr number
   5349 --- @return number
   5350 function vim.fn.log10(expr) end
   5351 
   5352 --- {expr1} must be a |List|, |String|, |Blob| or |Dictionary|.
   5353 --- When {expr1} is a |List| or |Dictionary|, replace each
   5354 --- item in {expr1} with the result of evaluating {expr2}.
   5355 --- For a |Blob| each byte is replaced.
   5356 --- For a |String|, each character, including composing
   5357 --- characters, is replaced.
   5358 --- If the item type changes you may want to use |mapnew()| to
   5359 --- create a new List or Dictionary.
   5360 ---
   5361 --- {expr2} must be a |String| or |Funcref|.
   5362 ---
   5363 --- If {expr2} is a |String|, inside {expr2} |v:val| has the value
   5364 --- of the current item.  For a |Dictionary| |v:key| has the key
   5365 --- of the current item and for a |List| |v:key| has the index of
   5366 --- the current item.  For a |Blob| |v:key| has the index of the
   5367 --- current byte.  For a |String| |v:key| has the index of the
   5368 --- current character.
   5369 --- Example: >vim
   5370 ---   call map(mylist, '"> " .. v:val .. " <"')
   5371 --- <This puts "> " before and " <" after each item in "mylist".
   5372 ---
   5373 --- Note that {expr2} is the result of an expression and is then
   5374 --- used as an expression again.  Often it is good to use a
   5375 --- |literal-string| to avoid having to double backslashes.  You
   5376 --- still have to double ' quotes
   5377 ---
   5378 --- If {expr2} is a |Funcref| it is called with two arguments:
   5379 ---   1. The key or the index of the current item.
   5380 ---   2. the value of the current item.
   5381 --- The function must return the new value of the item.  Example
   5382 --- that changes each value by "key-value": >vim
   5383 ---   func KeyValue(key, val)
   5384 ---     return a:key .. '-' .. a:val
   5385 ---   endfunc
   5386 ---   call map(myDict, function('KeyValue'))
   5387 --- <It is shorter when using a |lambda|: >vim
   5388 ---   call map(myDict, {key, val -> key .. '-' .. val})
   5389 --- <If you do not use "val" you can leave it out: >vim
   5390 ---   call map(myDict, {key -> 'item: ' .. key})
   5391 --- <If you do not use "key" you can use a short name: >vim
   5392 ---   call map(myDict, {_, val -> 'item: ' .. val})
   5393 --- <
   5394 --- The operation is done in-place for a |List| and |Dictionary|.
   5395 --- If you want it to remain unmodified make a copy first: >vim
   5396 ---   let tlist = map(copy(mylist), ' v:val .. "\t"')
   5397 ---
   5398 --- <Returns {expr1}, the |List| or |Dictionary| that was filtered,
   5399 --- or a new |Blob| or |String|.
   5400 --- When an error is encountered while evaluating {expr2} no
   5401 --- further items in {expr1} are processed.
   5402 --- When {expr2} is a Funcref errors inside a function are
   5403 --- ignored, unless it was defined with the "abort" flag.
   5404 ---
   5405 --- @param expr1 string|table|any[]
   5406 --- @param expr2 string|function
   5407 --- @return any
   5408 function vim.fn.map(expr1, expr2) end
   5409 
   5410 --- When {dict} is omitted or zero: Return the rhs of mapping
   5411 --- {name} in mode {mode}.  The returned String has special
   5412 --- characters translated like in the output of the ":map" command
   5413 --- listing.  When {dict} is TRUE a dictionary is returned, see
   5414 --- below.  To get a list of all mappings see |maplist()|.
   5415 ---
   5416 --- When there is no mapping for {name}, an empty String is
   5417 --- returned if {dict} is FALSE, otherwise returns an empty Dict.
   5418 --- When the mapping for {name} is empty, then "<Nop>" is
   5419 --- returned.
   5420 ---
   5421 --- The {name} can have special key names, like in the ":map"
   5422 --- command.
   5423 ---
   5424 --- {mode} can be one of these strings:
   5425 ---   "n"  Normal
   5426 ---   "v"  Visual (including Select)
   5427 ---   "o"  Operator-pending
   5428 ---   "i"  Insert
   5429 ---   "c"  Cmd-line
   5430 ---   "s"  Select
   5431 ---   "x"  Visual
   5432 ---   "l"  langmap |language-mapping|
   5433 ---   "t"  Terminal
   5434 ---   ""  Normal, Visual and Operator-pending
   5435 --- When {mode} is omitted, the modes for "" are used.
   5436 ---
   5437 --- When {abbr} is there and it is |TRUE| use abbreviations
   5438 --- instead of mappings.
   5439 ---
   5440 --- When {dict} is |TRUE|, return a dictionary describing the
   5441 --- mapping, with these items:    *mapping-dict*
   5442 ---   "lhs"       The {lhs} of the mapping as it would be typed
   5443 ---   "lhsraw"   The {lhs} of the mapping as raw bytes
   5444 ---   "lhsrawalt" The {lhs} of the mapping as raw bytes, alternate
   5445 ---         form, only present when it differs from "lhsraw"
   5446 ---   "rhs"       The {rhs} of the mapping as typed.
   5447 ---   "callback" Lua function, if RHS was defined as such.
   5448 ---   "silent"   1 for a |:map-silent| mapping, else 0.
   5449 ---   "noremap"  1 if the {rhs} of the mapping is not remappable.
   5450 ---   "script"   1 if mapping was defined with <script>.
   5451 ---   "expr"     1 for an expression mapping (|:map-<expr>|).
   5452 ---   "buffer"   1 for a buffer local mapping (|:map-local|).
   5453 ---   "mode"     Modes for which the mapping is defined.  In
   5454 ---        addition to the modes mentioned above, these
   5455 ---        characters will be used:
   5456 ---        " "     Normal, Visual and Operator-pending
   5457 ---        "!"     Insert and Commandline mode
   5458 ---          (|mapmode-ic|)
   5459 ---   "sid"       The script local ID, used for <sid> mappings
   5460 ---        (|<SID>|).  Negative for special contexts.
   5461 ---   "scriptversion"  The version of the script, always 1.
   5462 ---   "lnum"     The line number in "sid", zero if unknown.
   5463 ---   "nowait"   Do not wait for other, longer mappings.
   5464 ---        (|:map-<nowait>|).
   5465 ---   "abbr"     True if this is an |abbreviation|.
   5466 ---   "mode_bits" Nvim's internal binary representation of "mode".
   5467 ---        |mapset()| ignores this; only "mode" is used.
   5468 ---        See |maplist()| for usage examples.  The values
   5469 ---        are from src/nvim/state_defs.h and may change in
   5470 ---        the future.
   5471 ---
   5472 --- The dictionary can be used to restore a mapping with
   5473 --- |mapset()|.
   5474 ---
   5475 --- The mappings local to the current buffer are checked first,
   5476 --- then the global mappings.
   5477 --- This function can be used to map a key even when it's already
   5478 --- mapped, and have it do the original mapping too.  Sketch: >vim
   5479 ---   exe 'nnoremap <Tab> ==' .. maparg('<Tab>', 'n')
   5480 --- <
   5481 ---
   5482 --- @param name string
   5483 --- @param mode? string
   5484 --- @param abbr? boolean
   5485 --- @param dict? false
   5486 --- @return string
   5487 function vim.fn.maparg(name, mode, abbr, dict) end
   5488 
   5489 --- @param name string
   5490 --- @param mode string
   5491 --- @param abbr boolean
   5492 --- @param dict true
   5493 --- @return table<string,any>
   5494 function vim.fn.maparg(name, mode, abbr, dict) end
   5495 
   5496 --- Check if there is a mapping that matches with {name} in mode
   5497 --- {mode}.  See |maparg()| for {mode} and special names in
   5498 --- {name}.
   5499 --- When {abbr} is there and it is non-zero use abbreviations
   5500 --- instead of mappings.
   5501 --- A match happens with a mapping that starts with {name} and
   5502 --- with a mapping which is equal to the start of {name}.
   5503 ---
   5504 ---   matches mapping "a"  "ab"  "abc" ~
   5505 ---    mapcheck("a")  yes  yes   yes
   5506 ---    mapcheck("abc")  yes  yes   yes
   5507 ---    mapcheck("ax")  yes  no   no
   5508 ---    mapcheck("b")  no  no   no
   5509 ---
   5510 --- The difference with |maparg()| is that mapcheck() finds a
   5511 --- mapping that matches with {name}, while |maparg()| only finds a
   5512 --- mapping for {name} exactly.
   5513 --- When there is no mapping that starts with {name}, an empty
   5514 --- String is returned.  If there is one, the RHS of that mapping
   5515 --- is returned.  If there are several mappings that start with
   5516 --- {name}, the RHS of one of them is returned.  This will be
   5517 --- "<Nop>" if the RHS is empty.
   5518 --- The mappings local to the current buffer are checked first,
   5519 --- then the global mappings.
   5520 --- This function can be used to check if a mapping can be added
   5521 --- without being ambiguous.  Example: >vim
   5522 ---   if mapcheck("_vv") == ""
   5523 ---      map _vv :set guifont=7x13<CR>
   5524 ---   endif
   5525 --- <This avoids adding the "_vv" mapping when there already is a
   5526 --- mapping for "_v" or for "_vvv".
   5527 ---
   5528 --- @param name string
   5529 --- @param mode? string
   5530 --- @param abbr? boolean
   5531 --- @return any
   5532 function vim.fn.mapcheck(name, mode, abbr) end
   5533 
   5534 --- Returns a |List| of all mappings.  Each List item is a |Dict|,
   5535 --- the same as what is returned by |maparg()|, see
   5536 --- |mapping-dict|.  When {abbr} is there and it is |TRUE| use
   5537 --- abbreviations instead of mappings.
   5538 ---
   5539 --- Example to show all mappings with "MultiMatch" in rhs: >vim
   5540 ---   echo maplist()->filter({_, m ->
   5541 ---     \ match(get(m, 'rhs', ''), 'MultiMatch') >= 0
   5542 ---     \ })
   5543 --- <It can be tricky to find mappings for particular |:map-modes|.
   5544 --- |mapping-dict|'s "mode_bits" can simplify this.  For example,
   5545 --- the mode_bits for Normal, Insert or Command-line modes are
   5546 --- 0x19.  To find all the mappings available in those modes you
   5547 --- can do: >vim
   5548 ---   let saved_maps = []
   5549 ---   for m in maplist()
   5550 ---       if and(m.mode_bits, 0x19) != 0
   5551 ---     eval saved_maps->add(m)
   5552 ---       endif
   5553 ---   endfor
   5554 ---   echo saved_maps->mapnew({_, m -> m.lhs})
   5555 --- <The values of the mode_bits are defined in Nvim's
   5556 --- src/nvim/state_defs.h file and they can be discovered at
   5557 --- runtime using |:map-commands| and "maplist()".  Example: >vim
   5558 ---   omap xyzzy <Nop>
   5559 ---   let op_bit = maplist()->filter(
   5560 ---       \ {_, m -> m.lhs == 'xyzzy'})[0].mode_bits
   5561 ---   ounmap xyzzy
   5562 ---   echo printf("Operator-pending mode bit: 0x%x", op_bit)
   5563 --- <
   5564 ---
   5565 --- @param abbr? 0|1
   5566 --- @return table[]
   5567 function vim.fn.maplist(abbr) end
   5568 
   5569 --- Like |map()| but instead of replacing items in {expr1} a new
   5570 --- List or Dictionary is created and returned.  {expr1} remains
   5571 --- unchanged.  Items can still be changed by {expr2}, if you
   5572 --- don't want that use |deepcopy()| first.
   5573 ---
   5574 --- @param expr1 any
   5575 --- @param expr2 any
   5576 --- @return any
   5577 function vim.fn.mapnew(expr1, expr2) end
   5578 
   5579 --- @param mode string
   5580 --- @param abbr? boolean
   5581 --- @param dict? table<string,any>
   5582 --- @return any
   5583 function vim.fn.mapset(mode, abbr, dict) end
   5584 
   5585 --- Restore a mapping from a dictionary, possibly returned by
   5586 --- |maparg()| or |maplist()|.  A buffer mapping, when dict.buffer
   5587 --- is true, is set on the current buffer; it is up to the caller
   5588 --- to ensure that the intended buffer is the current buffer.
   5589 --- This feature allows copying mappings from one buffer to
   5590 --- another.
   5591 --- The dict.mode value may restore a single mapping that covers
   5592 --- more than one mode, like with mode values of '!', ' ', "nox",
   5593 --- or 'v'. *E1276*
   5594 ---
   5595 --- In the first form, {mode} and {abbr} should be the same as
   5596 --- for the call to |maparg()|. *E460*
   5597 --- {mode} is used to define the mode in which the mapping is set,
   5598 --- not the "mode" entry in {dict}.
   5599 --- Example for saving and restoring a mapping: >vim
   5600 ---   let save_map = maparg('K', 'n', 0, 1)
   5601 ---   nnoremap K somethingelse
   5602 ---   " ...
   5603 ---   call mapset('n', 0, save_map)
   5604 --- <Note that if you are going to replace a map in several modes,
   5605 --- e.g. with `:map!`, you need to save/restore the mapping for
   5606 --- all of them, when they might differ.
   5607 ---
   5608 --- In the second form, with {dict} as the only argument, mode
   5609 --- and abbr are taken from the dict.
   5610 --- Example: >vim
   5611 ---   let save_maps = maplist()->filter(
   5612 ---         \ {_, m -> m.lhs == 'K'})
   5613 ---   nnoremap K somethingelse
   5614 ---   cnoremap K somethingelse2
   5615 ---   " ...
   5616 ---   unmap K
   5617 ---   for d in save_maps
   5618 ---       call mapset(d)
   5619 ---   endfor
   5620 --- <
   5621 ---
   5622 --- @param dict table<string,any>
   5623 --- @return any
   5624 function vim.fn.mapset(dict) end
   5625 
   5626 --- When {expr} is a |List| then this returns the index of the
   5627 --- first item where {pat} matches.  Each item is used as a
   5628 --- String, |Lists| and |Dictionaries| are used as echoed.
   5629 ---
   5630 --- Otherwise, {expr} is used as a String.  The result is a
   5631 --- Number, which gives the index (byte offset) in {expr} where
   5632 --- {pat} matches.
   5633 ---
   5634 --- A match at the first character or |List| item returns zero.
   5635 --- If there is no match -1 is returned.
   5636 ---
   5637 --- For getting submatches see |matchlist()|.
   5638 --- Example: >vim
   5639 ---   echo match("testing", "ing")  " results in 4
   5640 ---   echo match([1, 'x'], '\a')  " results in 1
   5641 --- <See |string-match| for how {pat} is used.
   5642 ---           *strpbrk()*
   5643 --- Vim doesn't have a strpbrk() function.  But you can do: >vim
   5644 ---   let sepidx = match(line, '[.,;: \t]')
   5645 --- <          *strcasestr()*
   5646 --- Vim doesn't have a strcasestr() function.  But you can add
   5647 --- "\c" to the pattern to ignore case: >vim
   5648 ---   let idx = match(haystack, '\cneedle')
   5649 --- <
   5650 --- If {start} is given, the search starts from byte index
   5651 --- {start} in a String or item {start} in a |List|.
   5652 --- The result, however, is still the index counted from the
   5653 --- first character/item.  Example: >vim
   5654 ---   echo match("testing", "ing", 2)
   5655 --- <result is again "4". >vim
   5656 ---   echo match("testing", "ing", 4)
   5657 --- <result is again "4". >vim
   5658 ---   echo match("testing", "t", 2)
   5659 --- <result is "3".
   5660 --- For a String, if {start} > 0 then it is like the string starts
   5661 --- {start} bytes later, thus "^" will match at {start}.  Except
   5662 --- when {count} is given, then it's like matches before the
   5663 --- {start} byte are ignored (this is a bit complicated to keep it
   5664 --- backwards compatible).
   5665 --- For a String, if {start} < 0, it will be set to 0.  For a list
   5666 --- the index is counted from the end.
   5667 --- If {start} is out of range ({start} > strlen({expr}) for a
   5668 --- String or {start} > len({expr}) for a |List|) -1 is returned.
   5669 ---
   5670 --- When {count} is given use the {count}th match.  When a match
   5671 --- is found in a String the search for the next one starts one
   5672 --- character further.  Thus this example results in 1: >vim
   5673 ---   echo match("testing", "..", 0, 2)
   5674 --- <In a |List| the search continues in the next item.
   5675 --- Note that when {count} is added the way {start} works changes,
   5676 --- see above.
   5677 ---
   5678 ---         *match-pattern*
   5679 --- See |pattern| for the patterns that are accepted.
   5680 --- The 'ignorecase' option is used to set the ignore-caseness of
   5681 --- the pattern.  'smartcase' is NOT used.  The matching is always
   5682 --- done like 'magic' is set and 'cpoptions' is empty.
   5683 --- Note that a match at the start is preferred, thus when the
   5684 --- pattern is using "*" (any number of matches) it tends to find
   5685 --- zero matches at the start instead of a number of matches
   5686 --- further down in the text.
   5687 ---
   5688 --- @param expr string|any[]
   5689 --- @param pat string
   5690 --- @param start? integer
   5691 --- @param count? integer
   5692 --- @return integer
   5693 function vim.fn.match(expr, pat, start, count) end
   5694 
   5695 --- Defines a pattern to be highlighted in the current window (a
   5696 --- "match").  It will be highlighted with {group}.  Returns an
   5697 --- identification number (ID), which can be used to delete the
   5698 --- match using |matchdelete()|.  The ID is bound to the window.
   5699 --- Matching is case sensitive and magic, unless case sensitivity
   5700 --- or magicness are explicitly overridden in {pattern}.  The
   5701 --- 'magic', 'smartcase' and 'ignorecase' options are not used.
   5702 --- The "Conceal" value is special, it causes the match to be
   5703 --- concealed.
   5704 ---
   5705 --- The optional {priority} argument assigns a priority to the
   5706 --- match.  A match with a high priority will have its
   5707 --- highlighting overrule that of a match with a lower priority.
   5708 --- A priority is specified as an integer (negative numbers are no
   5709 --- exception).  If the {priority} argument is not specified, the
   5710 --- default priority is 10.  The priority of 'hlsearch' is zero,
   5711 --- hence all matches with a priority greater than zero will
   5712 --- overrule it.  Syntax highlighting (see 'syntax') is a separate
   5713 --- mechanism, and regardless of the chosen priority a match will
   5714 --- always overrule syntax highlighting.
   5715 ---
   5716 --- The optional {id} argument allows the request for a specific
   5717 --- match ID.  If a specified ID is already taken, an error
   5718 --- message will appear and the match will not be added.  An ID
   5719 --- is specified as a positive integer (zero excluded).  IDs 1, 2
   5720 --- and 3 are reserved for |:match|, |:2match| and |:3match|,
   5721 --- respectively.  3 is reserved for use by the |matchparen|
   5722 --- plugin.
   5723 --- If the {id} argument is not specified or -1, |matchadd()|
   5724 --- automatically chooses a free ID, which is at least 1000.
   5725 ---
   5726 --- The optional {dict} argument allows for further custom
   5727 --- values.  Currently this is used to specify a match specific
   5728 --- conceal character that will be shown for |hl-Conceal|
   5729 --- highlighted matches.  The dict can have the following members:
   5730 ---
   5731 ---   conceal      Special character to show instead of the
   5732 ---         match (only for |hl-Conceal| highlighted
   5733 ---         matches, see |:syn-cchar|)
   5734 ---   window      Instead of the current window use the
   5735 ---         window with this number or window ID.
   5736 ---
   5737 --- The number of matches is not limited, as it is the case with
   5738 --- the |:match| commands.
   5739 ---
   5740 --- Returns -1 on error.
   5741 ---
   5742 --- Example: >vim
   5743 ---   highlight MyGroup ctermbg=green guibg=green
   5744 ---   let m = matchadd("MyGroup", "TODO")
   5745 --- <Deletion of the pattern: >vim
   5746 ---   call matchdelete(m)
   5747 ---
   5748 --- <A list of matches defined by |matchadd()| and |:match| are
   5749 --- available from |getmatches()|.  All matches can be deleted in
   5750 --- one operation by |clearmatches()|.
   5751 ---
   5752 --- @param group integer|string
   5753 --- @param pattern string
   5754 --- @param priority? integer
   5755 --- @param id? integer
   5756 --- @param dict? table
   5757 --- @return integer
   5758 function vim.fn.matchadd(group, pattern, priority, id, dict) end
   5759 
   5760 --- Same as |matchadd()|, but requires a list of positions {pos}
   5761 --- instead of a pattern.  This command is faster than |matchadd()|
   5762 --- because it does not handle regular expressions and it sets
   5763 --- buffer line boundaries to redraw screen.  It is supposed to be
   5764 --- used when fast match additions and deletions are required, for
   5765 --- example to highlight matching parentheses.
   5766 ---           *E5030* *E5031*
   5767 --- {pos} is a list of positions.  Each position can be one of
   5768 --- these:
   5769 --- - A number.  This whole line will be highlighted.  The first
   5770 ---   line has number 1.
   5771 --- - A list with one number, e.g., [23].  The whole line with
   5772 ---   this number will be highlighted.
   5773 --- - A list with two numbers, e.g., [23, 11].  The first number
   5774 ---   is the line number, the second one is the column number
   5775 ---   (first column is 1, the value must correspond to the byte
   5776 ---   index as |col()| would return).  The character at this
   5777 ---   position will be highlighted.
   5778 --- - A list with three numbers, e.g., [23, 11, 3].  As above, but
   5779 ---   the third number gives the length of the highlight in bytes.
   5780 ---
   5781 --- Entries with zero and negative line numbers are silently
   5782 --- ignored, as well as entries with negative column numbers and
   5783 --- lengths.
   5784 ---
   5785 --- Returns -1 on error.
   5786 ---
   5787 --- Example: >vim
   5788 ---   highlight MyGroup ctermbg=green guibg=green
   5789 ---   let m = matchaddpos("MyGroup", [[23, 24], 34])
   5790 --- <Deletion of the pattern: >vim
   5791 ---   call matchdelete(m)
   5792 ---
   5793 --- <Matches added by |matchaddpos()| are returned by
   5794 --- |getmatches()|.
   5795 ---
   5796 --- @param group integer|string
   5797 --- @param pos any[]
   5798 --- @param priority? integer
   5799 --- @param id? integer
   5800 --- @param dict? table
   5801 --- @return integer|table
   5802 function vim.fn.matchaddpos(group, pos, priority, id, dict) end
   5803 
   5804 --- Selects the {nr} match item, as set with a |:match|,
   5805 --- |:2match| or |:3match| command.
   5806 --- Return a |List| with two elements:
   5807 ---   The name of the highlight group used
   5808 ---   The pattern used.
   5809 --- When {nr} is not 1, 2 or 3 returns an empty |List|.
   5810 --- When there is no match item set returns ['', ''].
   5811 --- This is useful to save and restore a |:match|.
   5812 --- Highlighting matches using the |:match| commands are limited
   5813 --- to three matches.  |matchadd()| does not have this limitation.
   5814 ---
   5815 --- @param nr integer
   5816 --- @return string[]
   5817 function vim.fn.matcharg(nr) end
   5818 
   5819 --- Returns the |List| of matches in lines from {lnum} to {end} in
   5820 --- buffer {buf} where {pat} matches.
   5821 ---
   5822 --- {lnum} and {end} can either be a line number or the string "$"
   5823 --- to refer to the last line in {buf}.
   5824 ---
   5825 --- The {dict} argument supports following items:
   5826 ---     submatches  include submatch information (|/\(|)
   5827 ---
   5828 --- For each match, a |Dict| with the following items is returned:
   5829 ---     byteidx  starting byte index of the match
   5830 ---     lnum  line number where there is a match
   5831 ---     text  matched string
   5832 --- Note that there can be multiple matches in a single line.
   5833 ---
   5834 --- This function works only for loaded buffers.  First call
   5835 --- |bufload()| if needed.
   5836 ---
   5837 --- See |match-pattern| for information about the effect of some
   5838 --- option settings on the pattern.
   5839 ---
   5840 --- When {buf} is not a valid buffer, the buffer is not loaded or
   5841 --- {lnum} or {end} is not valid then an error is given and an
   5842 --- empty |List| is returned.
   5843 ---
   5844 --- Examples: >vim
   5845 ---     " Assuming line 3 in buffer 5 contains "a"
   5846 ---     echo matchbufline(5, '\<\k\+\>', 3, 3)
   5847 --- <    `[{'lnum': 3, 'byteidx': 0, 'text': 'a'}]` >vim
   5848 ---     " Assuming line 4 in buffer 10 contains "tik tok"
   5849 ---     echo matchbufline(10, '\<\k\+\>', 1, 4)
   5850 --- <    `[{'lnum': 4, 'byteidx': 0, 'text': 'tik'}, {'lnum': 4, 'byteidx': 4, 'text': 'tok'}]`
   5851 ---
   5852 --- If {submatch} is present and is v:true, then submatches like
   5853 --- "\1", "\2", etc. are also returned.  Example: >vim
   5854 ---     " Assuming line 2 in buffer 2 contains "acd"
   5855 ---     echo matchbufline(2, '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2, 2
   5856 ---         \ {'submatches': v:true})
   5857 --- <    `[{'lnum': 2, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]`
   5858 --- The "submatches" List always contains 9 items.  If a submatch
   5859 --- is not found, then an empty string is returned for that
   5860 --- submatch.
   5861 ---
   5862 --- @param buf string|integer
   5863 --- @param pat string
   5864 --- @param lnum string|integer
   5865 --- @param end_ string|integer
   5866 --- @param dict? table
   5867 --- @return string[]
   5868 function vim.fn.matchbufline(buf, pat, lnum, end_, dict) end
   5869 
   5870 --- Deletes a match with ID {id} previously defined by |matchadd()|
   5871 --- or one of the |:match| commands.  Returns 0 if successful,
   5872 --- otherwise -1.  See example for |matchadd()|.  All matches can
   5873 --- be deleted in one operation by |clearmatches()|.
   5874 --- If {win} is specified, use the window with this number or
   5875 --- window ID instead of the current window.
   5876 ---
   5877 --- @param id integer
   5878 --- @param win? integer
   5879 --- @return any
   5880 function vim.fn.matchdelete(id, win) end
   5881 
   5882 --- Same as |match()|, but return the index of first character
   5883 --- after the match.  Example: >vim
   5884 ---   echo matchend("testing", "ing")
   5885 --- <results in "7".
   5886 ---           *strspn()* *strcspn()*
   5887 --- Vim doesn't have a strspn() or strcspn() function, but you can
   5888 --- do it with matchend(): >vim
   5889 ---   let span = matchend(line, '[a-zA-Z]')
   5890 ---   let span = matchend(line, '[^a-zA-Z]')
   5891 --- <Except that -1 is returned when there are no matches.
   5892 ---
   5893 --- The {start}, if given, has the same meaning as for |match()|. >vim
   5894 ---   echo matchend("testing", "ing", 2)
   5895 --- <results in "7". >vim
   5896 ---   echo matchend("testing", "ing", 5)
   5897 --- <result is "-1".
   5898 --- When {expr} is a |List| the result is equal to |match()|.
   5899 ---
   5900 --- @param expr any
   5901 --- @param pat string
   5902 --- @param start? integer
   5903 --- @param count? integer
   5904 --- @return integer
   5905 function vim.fn.matchend(expr, pat, start, count) end
   5906 
   5907 --- If {list} is a list of strings, then returns a |List| with all
   5908 --- the strings in {list} that fuzzy match {str}.  The strings in
   5909 --- the returned list are sorted based on the matching score.
   5910 ---
   5911 --- The optional {dict} argument always supports the following
   5912 --- items:
   5913 ---     matchseq  When this item is present return only matches
   5914 ---     that contain the characters in {str} in the
   5915 ---     given sequence.
   5916 ---     limit  Maximum number of matches in {list} to be
   5917 ---     returned.  Zero means no limit.
   5918 ---
   5919 --- If {list} is a list of dictionaries, then the optional {dict}
   5920 --- argument supports the following additional items:
   5921 ---     key    Key of the item which is fuzzy matched against
   5922 ---     {str}.  The value of this item should be a
   5923 ---     string.
   5924 ---     text_cb  |Funcref| that will be called for every item
   5925 ---     in {list} to get the text for fuzzy matching.
   5926 ---     This should accept a dictionary item as the
   5927 ---     argument and return the text for that item to
   5928 ---     use for fuzzy matching.
   5929 ---
   5930 --- {str} is treated as a literal string and regular expression
   5931 --- matching is NOT supported.  The maximum supported {str} length
   5932 --- is 256.
   5933 ---
   5934 --- When {str} has multiple words each separated by white space,
   5935 --- then the list of strings that have all the words is returned.
   5936 ---
   5937 --- If there are no matching strings or there is an error, then an
   5938 --- empty list is returned.  If length of {str} is greater than
   5939 --- 256, then returns an empty list.
   5940 ---
   5941 --- When {limit} is given, matchfuzzy() will find up to this
   5942 --- number of matches in {list} and return them in sorted order.
   5943 ---
   5944 --- Refer to |fuzzy-matching| for more information about fuzzy
   5945 --- matching strings.
   5946 ---
   5947 --- Example: >vim
   5948 ---    echo matchfuzzy(["clay", "crow"], "cay")
   5949 --- <results in ["clay"]. >vim
   5950 ---    echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl")
   5951 --- <results in a list of buffer names fuzzy matching "ndl". >vim
   5952 ---    echo getbufinfo()->matchfuzzy("ndl", {'key' : 'name'})
   5953 --- <results in a list of buffer information dicts with buffer
   5954 --- names fuzzy matching "ndl". >vim
   5955 ---    echo getbufinfo()->matchfuzzy("spl",
   5956 ---         \ {'text_cb' : {v -> v.name}})
   5957 --- <results in a list of buffer information dicts with buffer
   5958 --- names fuzzy matching "spl". >vim
   5959 ---    echo v:oldfiles->matchfuzzy("test")
   5960 --- <results in a list of file names fuzzy matching "test". >vim
   5961 ---    let l = readfile("buffer.c")->matchfuzzy("str")
   5962 --- <results in a list of lines in "buffer.c" fuzzy matching "str". >vim
   5963 ---    echo ['one two', 'two one']->matchfuzzy('two one')
   5964 --- <results in `['two one', 'one two']` . >vim
   5965 ---    echo ['one two', 'two one']->matchfuzzy('two one',
   5966 ---         \ {'matchseq': 1})
   5967 --- <results in `['two one']`.
   5968 ---
   5969 --- @param list any[]
   5970 --- @param str string
   5971 --- @param dict? table
   5972 --- @return table
   5973 function vim.fn.matchfuzzy(list, str, dict) end
   5974 
   5975 --- Same as |matchfuzzy()|, but returns the list of matched
   5976 --- strings, the list of character positions where characters
   5977 --- in {str} matches and a list of matching scores.  You can
   5978 --- use |byteidx()| to convert a character position to a byte
   5979 --- position.
   5980 ---
   5981 --- If {str} matches multiple times in a string, then only the
   5982 --- positions for the best match is returned.
   5983 ---
   5984 --- If there are no matching strings or there is an error, then a
   5985 --- list with three empty list items is returned.
   5986 ---
   5987 --- Example: >vim
   5988 ---   echo matchfuzzypos(['testing'], 'tsg')
   5989 --- <results in [["testing"], [[0, 2, 6]], [99]] >vim
   5990 ---   echo matchfuzzypos(['clay', 'lacy'], 'la')
   5991 --- <results in [["lacy", "clay"], [[0, 1], [1, 2]], [153, 133]] >vim
   5992 ---   echo [{'text': 'hello', 'id' : 10}]
   5993 ---     \ ->matchfuzzypos('ll', {'key' : 'text'})
   5994 --- <results in `[[{"id": 10, "text": "hello"}], [[2, 3]], [127]]`
   5995 ---
   5996 --- @param list any[]
   5997 --- @param str string
   5998 --- @param dict? table
   5999 --- @return table
   6000 function vim.fn.matchfuzzypos(list, str, dict) end
   6001 
   6002 --- Same as |match()|, but return a |List|.  The first item in the
   6003 --- list is the matched string, same as what |matchstr()| would
   6004 --- return.  Following items are submatches, like "\1", "\2", etc.
   6005 --- in |:substitute|.  When an optional submatch didn't match an
   6006 --- empty string is used.  Example: >vim
   6007 ---   echo matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)')
   6008 --- <Results in: ['acd', 'a', '', 'c', 'd', '', '', '', '', '']
   6009 --- When there is no match an empty list is returned.
   6010 ---
   6011 --- You can pass in a List, but that is not very useful.
   6012 ---
   6013 --- @param expr any
   6014 --- @param pat string
   6015 --- @param start? integer
   6016 --- @param count? integer
   6017 --- @return string[]
   6018 function vim.fn.matchlist(expr, pat, start, count) end
   6019 
   6020 --- Same as |match()|, but return the matched string.  Example: >vim
   6021 ---   echo matchstr("testing", "ing")
   6022 --- <results in "ing".
   6023 --- When there is no match "" is returned.
   6024 --- The {start}, if given, has the same meaning as for |match()|. >vim
   6025 ---   echo matchstr("testing", "ing", 2)
   6026 --- <results in "ing". >vim
   6027 ---   echo matchstr("testing", "ing", 5)
   6028 --- <result is "".
   6029 --- When {expr} is a |List| then the matching item is returned.
   6030 --- The type isn't changed, it's not necessarily a String.
   6031 ---
   6032 --- @param expr any
   6033 --- @param pat string
   6034 --- @param start? integer
   6035 --- @param count? integer
   6036 --- @return string
   6037 function vim.fn.matchstr(expr, pat, start, count) end
   6038 
   6039 --- Returns the |List| of matches in {list} where {pat} matches.
   6040 --- {list} is a |List| of strings.  {pat} is matched against each
   6041 --- string in {list}.
   6042 ---
   6043 --- The {dict} argument supports following items:
   6044 ---     submatches  include submatch information (|/\(|)
   6045 ---
   6046 --- For each match, a |Dict| with the following items is returned:
   6047 ---     byteidx  starting byte index of the match.
   6048 ---     idx    index in {list} of the match.
   6049 ---     text  matched string
   6050 ---     submatches  a List of submatches.  Present only if
   6051 ---     "submatches" is set to v:true in {dict}.
   6052 ---
   6053 --- See |match-pattern| for information about the effect of some
   6054 --- option settings on the pattern.
   6055 ---
   6056 --- Example: >vim
   6057 ---     echo matchstrlist(['tik tok'], '\<\k\+\>')
   6058 --- <    `[{'idx': 0, 'byteidx': 0, 'text': 'tik'}, {'idx': 0, 'byteidx': 4, 'text': 'tok'}]` >vim
   6059 ---     echo matchstrlist(['a', 'b'], '\<\k\+\>')
   6060 --- <    `[{'idx': 0, 'byteidx': 0, 'text': 'a'}, {'idx': 1, 'byteidx': 0, 'text': 'b'}]`
   6061 ---
   6062 --- If "submatches" is present and is v:true, then submatches like
   6063 --- "\1", "\2", etc. are also returned.  Example: >vim
   6064 ---     echo matchstrlist(['acd'], '\(a\)\?\(b\)\?\(c\)\?\(.*\)',
   6065 ---         \ #{submatches: v:true})
   6066 --- <    `[{'idx': 0, 'byteidx': 0, 'text': 'acd', 'submatches': ['a', '', 'c', 'd', '', '', '', '', '']}]`
   6067 --- The "submatches" List always contains 9 items.  If a submatch
   6068 --- is not found, then an empty string is returned for that
   6069 --- submatch.
   6070 ---
   6071 --- @param list string[]
   6072 --- @param pat string
   6073 --- @param dict? table
   6074 --- @return string[]
   6075 function vim.fn.matchstrlist(list, pat, dict) end
   6076 
   6077 --- Same as |matchstr()|, but return the matched string, the start
   6078 --- position and the end position of the match.  Example: >vim
   6079 ---   echo matchstrpos("testing", "ing")
   6080 --- <results in ["ing", 4, 7].
   6081 --- When there is no match ["", -1, -1] is returned.
   6082 --- The {start}, if given, has the same meaning as for |match()|. >vim
   6083 ---   echo matchstrpos("testing", "ing", 2)
   6084 --- <results in ["ing", 4, 7]. >vim
   6085 ---   echo matchstrpos("testing", "ing", 5)
   6086 --- <result is ["", -1, -1].
   6087 --- When {expr} is a |List| then the matching item, the index
   6088 --- of first item where {pat} matches, the start position and the
   6089 --- end position of the match are returned. >vim
   6090 ---   echo matchstrpos([1, '__x'], '\a')
   6091 --- <result is ["x", 1, 2, 3].
   6092 --- The type isn't changed, it's not necessarily a String.
   6093 ---
   6094 --- @param expr any
   6095 --- @param pat string
   6096 --- @param start? integer
   6097 --- @param count? integer
   6098 --- @return table
   6099 function vim.fn.matchstrpos(expr, pat, start, count) end
   6100 
   6101 --- Return the maximum value of all items in {expr}.  Example: >vim
   6102 ---   echo max([apples, pears, oranges])
   6103 ---
   6104 --- <{expr} can be a |List| or a |Dictionary|.  For a Dictionary,
   6105 --- it returns the maximum of all values in the Dictionary.
   6106 --- If {expr} is neither a List nor a Dictionary, or one of the
   6107 --- items in {expr} cannot be used as a Number this results in
   6108 --- an error.  An empty |List| or |Dictionary| results in zero.
   6109 ---
   6110 --- @param expr any
   6111 --- @return number
   6112 function vim.fn.max(expr) end
   6113 
   6114 --- Returns a |List| of |Dictionaries| describing |menus| (defined
   6115 --- by |:menu|, |:amenu|, …), including |hidden-menus|.
   6116 ---
   6117 --- {path} matches a menu by name, or all menus if {path} is an
   6118 --- empty string.  Example: >vim
   6119 ---   echo menu_get('File','')
   6120 ---   echo menu_get('')
   6121 --- <
   6122 --- {modes} is a string of zero or more modes (see |maparg()| or
   6123 --- |creating-menus| for the list of modes). "a" means "all".
   6124 ---
   6125 --- Example: >vim
   6126 ---   nnoremenu &Test.Test inormal
   6127 ---   inoremenu Test.Test insert
   6128 ---   vnoremenu Test.Test x
   6129 ---   echo menu_get("")
   6130 ---
   6131 --- <returns something like this: >
   6132 ---
   6133 ---   [ {
   6134 ---     "hidden": 0,
   6135 ---     "name": "Test",
   6136 ---     "priority": 500,
   6137 ---     "shortcut": 84,
   6138 ---     "submenus": [ {
   6139 ---       "hidden": 0,
   6140 ---       "mappings": {
   6141 ---         i": {
   6142 ---     "enabled": 1,
   6143 ---     "noremap": 1,
   6144 ---     "rhs": "insert",
   6145 ---     "sid": 1,
   6146 ---     "silent": 0
   6147 ---         },
   6148 ---         n": { ... },
   6149 ---         s": { ... },
   6150 ---         v": { ... }
   6151 ---       },
   6152 ---       "name": "Test",
   6153 ---       "priority": 500,
   6154 ---       "shortcut": 0
   6155 ---     } ]
   6156 ---   } ]
   6157 --- <
   6158 ---
   6159 --- @param path string
   6160 --- @param modes? string
   6161 --- @return any
   6162 function vim.fn.menu_get(path, modes) end
   6163 
   6164 --- Return information about the specified menu {name} in
   6165 --- mode {mode}.  The menu name should be specified without the
   6166 --- shortcut character ('&').  If {name} is "", then the top-level
   6167 --- menu names are returned.
   6168 ---
   6169 --- {mode} can be one of these strings:
   6170 ---   "n"  Normal
   6171 ---   "v"  Visual (including Select)
   6172 ---   "o"  Operator-pending
   6173 ---   "i"  Insert
   6174 ---   "c"  Cmd-line
   6175 ---   "s"  Select
   6176 ---   "x"  Visual
   6177 ---   "t"  Terminal-Job
   6178 ---   ""  Normal, Visual and Operator-pending
   6179 ---   "!"  Insert and Cmd-line
   6180 --- When {mode} is omitted, the modes for "" are used.
   6181 ---
   6182 --- Returns a |Dictionary| containing the following items:
   6183 ---   accel    menu item accelerator text |menu-text|
   6184 ---   display  display name (name without '&')
   6185 ---   enabled  v:true if this menu item is enabled
   6186 ---     Refer to |:menu-enable|
   6187 ---   icon    name of the icon file (for toolbar)
   6188 ---     |toolbar-icon|
   6189 ---   iconidx  index of a built-in icon
   6190 ---   modes    modes for which the menu is defined.  In
   6191 ---     addition to the modes mentioned above, these
   6192 ---     characters will be used:
   6193 ---     " "  Normal, Visual and Operator-pending
   6194 ---   name    menu item name.
   6195 ---   noremenu  v:true if the {rhs} of the menu item is not
   6196 ---     remappable else v:false.
   6197 ---   priority  menu order priority |menu-priority|
   6198 ---   rhs    right-hand-side of the menu item.  The
   6199 ---     returned string has special characters
   6200 ---     translated like in the output of the ":menu"
   6201 ---     command listing.  When the {rhs} of a menu
   6202 ---     item is empty, then "<Nop>" is returned.
   6203 ---   script  v:true if script-local remapping of {rhs} is
   6204 ---     allowed else v:false.  See |:menu-script|.
   6205 ---   shortcut  shortcut key (character after '&' in
   6206 ---     the menu name) |menu-shortcut|
   6207 ---   silent  v:true if the menu item is created
   6208 ---     with <silent> argument |:menu-silent|
   6209 ---   submenus  |List| containing the names of
   6210 ---     all the submenus.  Present only if the menu
   6211 ---     item has submenus.
   6212 ---
   6213 --- Returns an empty dictionary if the menu item is not found.
   6214 ---
   6215 --- Examples: >vim
   6216 ---   echo menu_info('Edit.Cut')
   6217 ---   echo menu_info('File.Save', 'n')
   6218 ---
   6219 ---   " Display the entire menu hierarchy in a buffer
   6220 ---   func ShowMenu(name, pfx)
   6221 ---     let m = menu_info(a:name)
   6222 ---     call append(line('$'), a:pfx .. m.display)
   6223 ---     for child in m->get('submenus', [])
   6224 ---       call ShowMenu(a:name .. '.' .. escape(child, '.'),
   6225 ---           \ a:pfx .. '    ')
   6226 ---     endfor
   6227 ---   endfunc
   6228 ---   new
   6229 ---   for topmenu in menu_info('').submenus
   6230 ---     call ShowMenu(topmenu, '')
   6231 ---   endfor
   6232 --- <
   6233 ---
   6234 --- @param name string
   6235 --- @param mode? string
   6236 --- @return any
   6237 function vim.fn.menu_info(name, mode) end
   6238 
   6239 --- Return the minimum value of all items in {expr}. Example: >vim
   6240 ---   echo min([apples, pears, oranges])
   6241 ---
   6242 --- <{expr} can be a |List| or a |Dictionary|.  For a Dictionary,
   6243 --- it returns the minimum of all values in the Dictionary.
   6244 --- If {expr} is neither a List nor a Dictionary, or one of the
   6245 --- items in {expr} cannot be used as a Number this results in
   6246 --- an error.  An empty |List| or |Dictionary| results in zero.
   6247 ---
   6248 --- @param expr any
   6249 --- @return number
   6250 function vim.fn.min(expr) end
   6251 
   6252 --- Create directory {name}.
   6253 ---
   6254 --- When {flags} is present it must be a string.  An empty string
   6255 --- has no effect.
   6256 ---
   6257 --- {flags} can contain these character flags:
   6258 ---  "p"  intermediate directories will be created as necessary
   6259 ---  "D"  {name} will be deleted at the end of the current
   6260 ---   function, but not recursively |:defer|
   6261 ---  "R"  {name} will be deleted recursively at the end of the
   6262 ---   current function |:defer|
   6263 ---
   6264 --- Note that when {name} has more than one part and "p" is used
   6265 --- some directories may already exist.  Only the first one that
   6266 --- is created and what it contains is scheduled to be deleted.
   6267 --- E.g. when using: >vim
   6268 ---   call mkdir('subdir/tmp/autoload', 'pR')
   6269 --- <and "subdir" already exists then "subdir/tmp" will be
   6270 --- scheduled for deletion, like with: >vim
   6271 ---   defer delete('subdir/tmp', 'rf')
   6272 --- <
   6273 --- If {prot} is given it is used to set the protection bits of
   6274 --- the new directory.  The default is 0o755 (rwxr-xr-x: r/w for
   6275 --- the user, readable for others).  Use 0o700 to make it
   6276 --- unreadable for others.  This is used for the newly created
   6277 --- directories.  Note: umask is applied to {prot} (on Unix).
   6278 --- Example: >vim
   6279 ---   call mkdir($HOME .. "/tmp/foo/bar", "p", 0o700)
   6280 ---
   6281 --- <This function is not available in the |sandbox|.
   6282 ---
   6283 --- If you try to create an existing directory with {flags} set to
   6284 --- "p" mkdir() will silently exit.
   6285 ---
   6286 --- The function result is a Number, which is TRUE if the call was
   6287 --- successful or FALSE if the directory creation failed or partly
   6288 --- failed.
   6289 ---
   6290 --- @param name string
   6291 --- @param flags? string
   6292 --- @param prot? string
   6293 --- @return integer
   6294 function vim.fn.mkdir(name, flags, prot) end
   6295 
   6296 --- Return a string that indicates the current mode.
   6297 --- If {expr} is supplied and it evaluates to a non-zero Number or
   6298 --- a non-empty String (|non-zero-arg|), then the full mode is
   6299 --- returned, otherwise only the first letter is returned.
   6300 --- Also see |state()|.
   6301 ---
   6302 ---    n      Normal
   6303 ---    no      Operator-pending
   6304 ---    nov      Operator-pending (forced charwise |o_v|)
   6305 ---    noV      Operator-pending (forced linewise |o_V|)
   6306 ---    noCTRL-V Operator-pending (forced blockwise |o_CTRL-V|)
   6307 ---     CTRL-V is one character
   6308 ---    niI      Normal using |i_CTRL-O| in |Insert-mode|
   6309 ---    niR      Normal using |i_CTRL-O| in |Replace-mode|
   6310 ---    niV      Normal using |i_CTRL-O| in |Virtual-Replace-mode|
   6311 ---    nt      Normal in |terminal-emulator| (insert goes to
   6312 ---     Terminal mode)
   6313 ---    ntT      Normal using |t_CTRL-\_CTRL-O| in |Terminal-mode|
   6314 ---    v      Visual by character
   6315 ---    vs      Visual by character using |v_CTRL-O| in Select mode
   6316 ---    V      Visual by line
   6317 ---    Vs      Visual by line using |v_CTRL-O| in Select mode
   6318 ---    CTRL-V   Visual blockwise
   6319 ---    CTRL-Vs  Visual blockwise using |v_CTRL-O| in Select mode
   6320 ---    s      Select by character
   6321 ---    S      Select by line
   6322 ---    CTRL-S   Select blockwise
   6323 ---    i      Insert
   6324 ---    ic      Insert mode completion |compl-generic|
   6325 ---    ix      Insert mode |i_CTRL-X| completion
   6326 ---    R      Replace |R|
   6327 ---    Rc      Replace mode completion |compl-generic|
   6328 ---    Rx      Replace mode |i_CTRL-X| completion
   6329 ---    Rv      Virtual Replace |gR|
   6330 ---    Rvc      Virtual Replace mode completion |compl-generic|
   6331 ---    Rvx      Virtual Replace mode |i_CTRL-X| completion
   6332 ---    c      Command-line editing
   6333 ---    cr      Command-line editing overstrike mode |c_<Insert>|
   6334 ---    cv      Vim Ex mode |gQ|
   6335 ---    cvr      Vim Ex mode while in overstrike mode |c_<Insert>|
   6336 ---    r      Hit-enter prompt
   6337 ---    rm      The -- more -- prompt
   6338 ---    r?      A |:confirm| query of some sort
   6339 ---    !      Shell or external command is executing
   6340 ---    t      Terminal mode: keys go to the job
   6341 ---
   6342 --- This is useful in the 'statusline' option or RPC calls. In
   6343 --- most other places it always returns "c" or "n".
   6344 --- Note that in the future more modes and more specific modes may
   6345 --- be added.  It's better not to compare the whole string but
   6346 --- only the leading character(s).
   6347 --- Also see |visualmode()|.
   6348 ---
   6349 --- @param expr? any
   6350 --- @return any
   6351 function vim.fn.mode(expr) end
   6352 
   6353 --- Convert a list of Vimscript objects to msgpack. Returned value is a
   6354 --- |readfile()|-style list. When {type} contains "B", a |Blob| is
   6355 --- returned instead. Example: >vim
   6356 ---   call writefile(msgpackdump([{}]), 'fname.mpack', 'b')
   6357 --- <or, using a |Blob|: >vim
   6358 ---   call writefile(msgpackdump([{}], 'B'), 'fname.mpack')
   6359 --- <
   6360 --- This will write the single 0x80 byte to a `fname.mpack` file
   6361 --- (dictionary with zero items is represented by 0x80 byte in
   6362 --- messagepack).
   6363 ---
   6364 --- Limitations:        *E5004* *E5005*
   6365 --- 1. |Funcref|s cannot be dumped.
   6366 --- 2. Containers that reference themselves cannot be dumped.
   6367 --- 3. Dictionary keys are always dumped as STR strings.
   6368 --- 4. Other strings and |Blob|s are always dumped as BIN strings.
   6369 --- 5. Points 3. and 4. do not apply to |msgpack-special-dict|s.
   6370 ---
   6371 --- @param list any
   6372 --- @param type? any
   6373 --- @return any
   6374 function vim.fn.msgpackdump(list, type) end
   6375 
   6376 --- Convert a |readfile()|-style list or a |Blob| to a list of
   6377 --- Vimscript objects.
   6378 --- Example: >vim
   6379 ---   let fname = expand('~/.config/nvim/shada/main.shada')
   6380 ---   let mpack = readfile(fname, 'b')
   6381 ---   let shada_objects = msgpackparse(mpack)
   6382 --- <This will read ~/.config/nvim/shada/main.shada file to
   6383 --- `shada_objects` list.
   6384 ---
   6385 --- Limitations:
   6386 --- 1. Mapping ordering is not preserved unless messagepack
   6387 ---    mapping is dumped using generic mapping
   6388 ---    (|msgpack-special-map|).
   6389 --- 2. Since the parser aims to preserve all data untouched
   6390 ---    (except for 1.) some strings are parsed to
   6391 ---    |msgpack-special-dict| format which is not convenient to
   6392 ---    use.
   6393 ---           *msgpack-special-dict*
   6394 --- Some messagepack strings may be parsed to special
   6395 --- dictionaries. Special dictionaries are dictionaries which
   6396 ---
   6397 --- 1. Contain exactly two keys: `_TYPE` and `_VAL`.
   6398 --- 2. `_TYPE` key is one of the types found in |v:msgpack_types|
   6399 ---    variable.
   6400 --- 3. Value for `_VAL` has the following format (Key column
   6401 ---    contains name of the key from |v:msgpack_types|):
   6402 ---
   6403 --- Key  Value ~
   6404 --- nil  Zero, ignored when dumping.  Not returned by
   6405 ---   |msgpackparse()| since |v:null| was introduced.
   6406 --- boolean  One or zero.  When dumping it is only checked that
   6407 ---   value is a |Number|.  Not returned by |msgpackparse()|
   6408 ---   since |v:true| and |v:false| were introduced.
   6409 --- integer  |List| with four numbers: sign (-1 or 1), highest two
   6410 ---   bits, number with bits from 62nd to 31st, lowest 31
   6411 ---   bits. I.e. to get actual number one will need to use
   6412 ---   code like >
   6413 ---     _VAL[0] * ((_VAL[1] << 62)
   6414 ---                & (_VAL[2] << 31)
   6415 ---                & _VAL[3])
   6416 --- <  Special dictionary with this type will appear in
   6417 ---   |msgpackparse()| output under one of the following
   6418 ---   circumstances:
   6419 ---   1. |Number| is 32-bit and value is either above
   6420 ---      INT32_MAX or below INT32_MIN.
   6421 ---   2. |Number| is 64-bit and value is above INT64_MAX. It
   6422 ---      cannot possibly be below INT64_MIN because msgpack
   6423 ---      C parser does not support such values.
   6424 --- float  |Float|. This value cannot possibly appear in
   6425 ---   |msgpackparse()| output.
   6426 --- string  |String|, or |Blob| if binary string contains zero
   6427 ---   byte. This value cannot appear in |msgpackparse()|
   6428 ---   output since blobs were introduced.
   6429 --- array  |List|. This value cannot appear in |msgpackparse()|
   6430 ---   output.
   6431 ---           *msgpack-special-map*
   6432 --- map  |List| of |List|s with two items (key and value) each.
   6433 ---   This value will appear in |msgpackparse()| output if
   6434 ---   parsed mapping contains one of the following keys:
   6435 ---   1. Any key that is not a string (including keys which
   6436 ---      are binary strings).
   6437 ---   2. String with NUL byte inside.
   6438 ---   3. Duplicate key.
   6439 --- ext  |List| with two values: first is a signed integer
   6440 ---   representing extension type. Second is
   6441 ---   |readfile()|-style list of strings.
   6442 ---
   6443 --- @param data any
   6444 --- @return any
   6445 function vim.fn.msgpackparse(data) end
   6446 
   6447 --- Return the line number of the first line at or below {lnum}
   6448 --- that is not blank.  Example: >vim
   6449 ---   if getline(nextnonblank(1)) =~ "Java" | endif
   6450 --- <When {lnum} is invalid or there is no non-blank line at or
   6451 --- below it, zero is returned.
   6452 --- {lnum} is used like with |getline()|.
   6453 --- See also |prevnonblank()|.
   6454 ---
   6455 --- @param lnum integer|string
   6456 --- @return integer
   6457 function vim.fn.nextnonblank(lnum) end
   6458 
   6459 --- Return a string with a single character, which has the number
   6460 --- value {expr}.  Examples: >vim
   6461 ---   echo nr2char(64)    " returns '\@'
   6462 ---   echo nr2char(32)    " returns ' '
   6463 --- <Example for "utf-8": >vim
   6464 ---   echo nr2char(300)    " returns I with bow character
   6465 --- <
   6466 --- UTF-8 encoding is always used, {utf8} option has no effect,
   6467 --- and exists only for backwards-compatibility.
   6468 --- Note that a NUL character in the file is specified with
   6469 --- nr2char(10), because NULs are represented with newline
   6470 --- characters.  nr2char(0) is a real NUL and terminates the
   6471 --- string, thus results in an empty string.
   6472 ---
   6473 --- @param expr integer
   6474 --- @param utf8? boolean
   6475 --- @return string
   6476 function vim.fn.nr2char(expr, utf8) end
   6477 
   6478 --- Bitwise OR on the two arguments.  The arguments are converted
   6479 --- to a number.  A List, Dict or Float argument causes an error.
   6480 --- Also see `and()` and `xor()`.
   6481 --- Example: >vim
   6482 ---   let bits = or(bits, 0x80)
   6483 ---
   6484 --- <Rationale: The reason this is a function and not using the "|"
   6485 --- character like many languages, is that Vi has always used "|"
   6486 --- to separate commands.  In many places it would not be clear if
   6487 --- "|" is an operator or a command separator.
   6488 ---
   6489 --- @param expr number
   6490 --- @param expr1 number
   6491 --- @return any
   6492 vim.fn['or'] = function(expr, expr1) end
   6493 
   6494 --- Shorten directory names in the path {path} and return the
   6495 --- result.  The tail, the file name, is kept as-is.  The other
   6496 --- components in the path are reduced to {len} letters in length.
   6497 --- If {len} is omitted or smaller than 1 then 1 is used (single
   6498 --- letters).  Leading '~' and '.' characters are kept.  Examples: >vim
   6499 ---   echo pathshorten('~/.config/nvim/autoload/file1.vim')
   6500 --- <  ~/.c/n/a/file1.vim ~
   6501 --- >vim
   6502 ---   echo pathshorten('~/.config/nvim/autoload/file2.vim', 2)
   6503 --- <  ~/.co/nv/au/file2.vim ~
   6504 --- It doesn't matter if the path exists or not.
   6505 --- Returns an empty string on error.
   6506 ---
   6507 --- @param path string
   6508 --- @param len? integer
   6509 --- @return string
   6510 function vim.fn.pathshorten(path, len) end
   6511 
   6512 --- Evaluate |perl| expression {expr} and return its result
   6513 --- converted to Vim data structures.
   6514 --- Numbers and strings are returned as they are (strings are
   6515 --- copied though).
   6516 --- Lists are represented as Vim |List| type.
   6517 --- Dictionaries are represented as Vim |Dictionary| type,
   6518 --- non-string keys result in error.
   6519 ---
   6520 --- Note: If you want an array or hash, {expr} must return a
   6521 --- reference to it.
   6522 --- Example: >vim
   6523 ---   echo perleval('[1 .. 4]')
   6524 --- <  [1, 2, 3, 4]
   6525 ---
   6526 --- @param expr any
   6527 --- @return any
   6528 function vim.fn.perleval(expr) end
   6529 
   6530 --- Return the power of {x} to the exponent {y} as a |Float|.
   6531 --- {x} and {y} must evaluate to a |Float| or a |Number|.
   6532 --- Returns 0.0 if {x} or {y} is not a |Float| or a |Number|.
   6533 --- Examples: >vim
   6534 ---   echo pow(3, 3)
   6535 --- <  27.0 >vim
   6536 ---   echo pow(2, 16)
   6537 --- <  65536.0 >vim
   6538 ---   echo pow(32, 0.20)
   6539 --- <  2.0
   6540 ---
   6541 --- @param x number
   6542 --- @param y number
   6543 --- @return number
   6544 function vim.fn.pow(x, y) end
   6545 
   6546 --- Returns non-zero if text has been inserted after the cursor
   6547 --- because "preinsert" is present in 'completeopt', or because
   6548 --- "longest" is present in 'completeopt' while 'autocomplete'
   6549 --- is active.  Otherwise returns zero.
   6550 ---
   6551 --- @return number
   6552 function vim.fn.preinserted() end
   6553 
   6554 --- Return the line number of the first line at or above {lnum}
   6555 --- that is not blank.  Example: >vim
   6556 ---   let ind = indent(prevnonblank(v:lnum - 1))
   6557 --- <When {lnum} is invalid or there is no non-blank line at or
   6558 --- above it, zero is returned.
   6559 --- {lnum} is used like with |getline()|.
   6560 --- Also see |nextnonblank()|.
   6561 ---
   6562 --- @param lnum integer|string
   6563 --- @return integer
   6564 function vim.fn.prevnonblank(lnum) end
   6565 
   6566 --- Return a String with {fmt}, where "%" items are replaced by
   6567 --- the formatted form of their respective arguments.  Example: >vim
   6568 ---   echo printf("%4d: E%d %.30s", lnum, errno, msg)
   6569 --- <May result in:
   6570 ---   "  99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~
   6571 ---
   6572 --- When used as a |method| the base is passed as the second
   6573 --- argument: >vim
   6574 ---   Compute()->printf("result: %d")
   6575 --- <
   6576 --- You can use `call()` to pass the items as a list.
   6577 ---
   6578 --- Often used items are:
   6579 ---   %s  string
   6580 ---   %6S  string right-aligned in 6 display cells
   6581 ---   %6s  string right-aligned in 6 bytes
   6582 ---   %.9s  string truncated to 9 bytes
   6583 ---   %c  single byte
   6584 ---   %d  decimal number
   6585 ---   %5d  decimal number padded with spaces to 5 characters
   6586 ---   %b  binary number
   6587 ---   %08b  binary number padded with zeros to at least 8 characters
   6588 ---   %B  binary number using upper case letters
   6589 ---   %x  hex number
   6590 ---   %04x  hex number padded with zeros to at least 4 characters
   6591 ---   %X  hex number using upper case letters
   6592 ---   %o  octal number
   6593 ---   %f  floating point number as 12.23, inf, -inf or nan
   6594 ---   %F  floating point number as 12.23, INF, -INF or NAN
   6595 ---   %e  floating point number as 1.23e3, inf, -inf or nan
   6596 ---   %E  floating point number as 1.23E3, INF, -INF or NAN
   6597 ---   %g  floating point number, as %f or %e depending on value
   6598 ---   %G  floating point number, as %F or %E depending on value
   6599 ---   %%  the % character itself
   6600 ---   %p  representation of the pointer to the container
   6601 ---
   6602 --- Conversion specifications start with '%' and end with the
   6603 --- conversion type.  All other characters are copied unchanged to
   6604 --- the result.
   6605 ---
   6606 --- The "%" starts a conversion specification.  The following
   6607 --- arguments appear in sequence:
   6608 ---
   6609 ---   % [pos-argument] [flags] [field-width] [.precision] type
   6610 ---
   6611 --- pos-argument
   6612 ---   At most one positional argument specifier.  These take
   6613 ---   the form {n$}, where n is >= 1.
   6614 ---
   6615 --- flags
   6616 ---   Zero or more of the following flags:
   6617 ---
   6618 ---     #        The value should be converted to an "alternate
   6619 ---         form".  For c, d, and s conversions, this option
   6620 ---         has no effect.  For o conversions, the precision
   6621 ---         of the number is increased to force the first
   6622 ---         character of the output string to a zero (except
   6623 ---         if a zero value is printed with an explicit
   6624 ---         precision of zero).
   6625 ---         For x and X conversions, a non-zero result has
   6626 ---         the string "0x" (or "0X" for X conversions)
   6627 ---         prepended to it.
   6628 ---
   6629 ---     0 (zero)  Zero padding.  For all conversions the converted
   6630 ---         value is padded on the left with zeros rather
   6631 ---         than blanks.  If a precision is given with a
   6632 ---         numeric conversion (d, o, x, and X), the 0 flag
   6633 ---         is ignored.
   6634 ---
   6635 ---     -        A negative field width flag; the converted value
   6636 ---         is to be left adjusted on the field boundary.
   6637 ---         The converted value is padded on the right with
   6638 ---         blanks, rather than on the left with blanks or
   6639 ---         zeros.  A - overrides a 0 if both are given.
   6640 ---
   6641 ---     ' ' (space)  A blank should be left before a positive
   6642 ---         number produced by a signed conversion (d).
   6643 ---
   6644 ---     +        A sign must always be placed before a number
   6645 ---         produced by a signed conversion.  A + overrides
   6646 ---         a space if both are used.
   6647 ---
   6648 --- field-width
   6649 ---   An optional decimal digit string specifying a minimum
   6650 ---   field width.  If the converted value has fewer bytes
   6651 ---   than the field width, it will be padded with spaces on
   6652 ---   the left (or right, if the left-adjustment flag has
   6653 ---   been given) to fill out the field width.  For the S
   6654 ---   conversion the count is in cells.
   6655 ---
   6656 --- .precision
   6657 ---   An optional precision, in the form of a period '.'
   6658 ---   followed by an optional digit string.  If the digit
   6659 ---   string is omitted, the precision is taken as zero.
   6660 ---   This gives the minimum number of digits to appear for
   6661 ---   d, o, x, and X conversions, the maximum number of
   6662 ---   bytes to be printed from a string for s conversions,
   6663 ---   or the maximum number of cells to be printed from a
   6664 ---   string for S conversions.
   6665 ---   For floating point it is the number of digits after
   6666 ---   the decimal point.
   6667 ---
   6668 --- type
   6669 ---   A character that specifies the type of conversion to
   6670 ---   be applied, see below.
   6671 ---
   6672 --- A field width or precision, or both, may be indicated by an
   6673 --- asterisk "*" instead of a digit string.  In this case, a
   6674 --- Number argument supplies the field width or precision.  A
   6675 --- negative field width is treated as a left adjustment flag
   6676 --- followed by a positive field width; a negative precision is
   6677 --- treated as though it were missing.  Example: >vim
   6678 ---   echo printf("%d: %.*s", nr, width, line)
   6679 --- <This limits the length of the text used from "line" to
   6680 --- "width" bytes.
   6681 ---
   6682 --- If the argument to be formatted is specified using a
   6683 --- positional argument specifier, and a '*' is used to indicate
   6684 --- that a number argument is to be used to specify the width or
   6685 --- precision, the argument(s) to be used must also be specified
   6686 --- using a {n$} positional argument specifier.  See |printf-$|.
   6687 ---
   6688 --- The conversion specifiers and their meanings are:
   6689 ---
   6690 ---     *printf-d* *printf-b* *printf-B* *printf-o* *printf-x* *printf-X*
   6691 --- dbBoxX  The Number argument is converted to signed decimal (d),
   6692 ---   unsigned binary (b and B), unsigned octal (o), or
   6693 ---   unsigned hexadecimal (x and X) notation.  The letters
   6694 ---   "abcdef" are used for x conversions; the letters
   6695 ---   "ABCDEF" are used for X conversions.  The precision, if
   6696 ---   any, gives the minimum number of digits that must
   6697 ---   appear; if the converted value requires fewer digits, it
   6698 ---   is padded on the left with zeros.  In no case does a
   6699 ---   non-existent or small field width cause truncation of a
   6700 ---   numeric field; if the result of a conversion is wider
   6701 ---   than the field width, the field is expanded to contain
   6702 ---   the conversion result.
   6703 ---   The 'h' modifier indicates the argument is 16 bits.
   6704 ---   The 'l' modifier indicates the argument is a long
   6705 ---   integer.  The size will be 32 bits or 64 bits
   6706 ---   depending on your platform.
   6707 ---   The "ll" modifier indicates the argument is 64 bits.
   6708 ---   The b and B conversion specifiers never take a width
   6709 ---   modifier and always assume their argument is a 64 bit
   6710 ---   integer.
   6711 ---   Generally, these modifiers are not useful.  They are
   6712 ---   ignored when type is known from the argument.
   6713 ---
   6714 --- i  alias for d
   6715 --- D  alias for ld
   6716 --- U  alias for lu
   6717 --- O  alias for lo
   6718 ---
   6719 ---           *printf-c*
   6720 --- c  The Number argument is converted to a byte, and the
   6721 ---   resulting character is written.
   6722 ---
   6723 ---           *printf-s*
   6724 --- s  The text of the String argument is used.  If a
   6725 ---   precision is specified, no more bytes than the number
   6726 ---   specified are used.
   6727 ---   If the argument is not a String type, it is
   6728 ---   automatically converted to text with the same format
   6729 ---   as ":echo".
   6730 ---           *printf-S*
   6731 --- S  The text of the String argument is used.  If a
   6732 ---   precision is specified, no more display cells than the
   6733 ---   number specified are used.
   6734 ---
   6735 ---           *printf-f* *E807*
   6736 --- f F  The Float argument is converted into a string of the
   6737 ---   form 123.456.  The precision specifies the number of
   6738 ---   digits after the decimal point.  When the precision is
   6739 ---   zero the decimal point is omitted.  When the precision
   6740 ---   is not specified 6 is used.  A really big number
   6741 ---   (out of range or dividing by zero) results in "inf"
   6742 ---    or "-inf" with %f (INF or -INF with %F).
   6743 ---    "0.0 / 0.0" results in "nan" with %f (NAN with %F).
   6744 ---   Example: >vim
   6745 ---     echo printf("%.2f", 12.115)
   6746 --- <    12.12
   6747 ---   Note that roundoff depends on the system libraries.
   6748 ---   Use |round()| when in doubt.
   6749 ---
   6750 ---           *printf-e* *printf-E*
   6751 --- e E  The Float argument is converted into a string of the
   6752 ---   form 1.234e+03 or 1.234E+03 when using 'E'.  The
   6753 ---   precision specifies the number of digits after the
   6754 ---   decimal point, like with 'f'.
   6755 ---
   6756 ---           *printf-g* *printf-G*
   6757 --- g G  The Float argument is converted like with 'f' if the
   6758 ---   value is between 0.001 (inclusive) and 10000000.0
   6759 ---   (exclusive).  Otherwise 'e' is used for 'g' and 'E'
   6760 ---   for 'G'.  When no precision is specified superfluous
   6761 ---   zeroes and '+' signs are removed, except for the zero
   6762 ---   immediately after the decimal point.  Thus 10000000.0
   6763 ---   results in 1.0e7.
   6764 ---
   6765 ---           *printf-%*
   6766 --- %  A '%' is written.  No argument is converted.  The
   6767 ---   complete conversion specification is "%%".
   6768 ---
   6769 --- When a Number argument is expected a String argument is also
   6770 --- accepted and automatically converted.
   6771 --- When a Float or String argument is expected a Number argument
   6772 --- is also accepted and automatically converted.
   6773 --- Any other argument type results in an error message.
   6774 ---
   6775 ---           *E766* *E767*
   6776 --- The number of {exprN} arguments must exactly match the number
   6777 --- of "%" items.  If there are not sufficient or too many
   6778 --- arguments an error is given.  Up to 18 arguments can be used.
   6779 ---
   6780 ---           *printf-$*
   6781 --- In certain languages, error and informative messages are
   6782 --- more readable when the order of words is different from the
   6783 --- corresponding message in English.  To accommodate translations
   6784 --- having a different word order, positional arguments may be
   6785 --- used to indicate this.  For instance: >vim
   6786 ---
   6787 ---     #, c-format
   6788 ---     msgid "%s returning %s"
   6789 ---     msgstr "waarde %2$s komt terug van %1$s"
   6790 --- <
   6791 --- In this example, the sentence has its 2 string arguments
   6792 --- reversed in the output. >vim
   6793 ---
   6794 ---     echo printf(
   6795 ---   "In The Netherlands, vim's creator's name is: %1$s %2$s",
   6796 ---   "Bram", "Moolenaar")
   6797 --- <    In The Netherlands, vim's creator's name is: Bram Moolenaar >vim
   6798 ---
   6799 ---     echo printf(
   6800 ---   "In Belgium, vim's creator's name is: %2$s %1$s",
   6801 ---   "Bram", "Moolenaar")
   6802 --- <    In Belgium, vim's creator's name is: Moolenaar Bram
   6803 ---
   6804 --- Width (and precision) can be specified using the '*'
   6805 --- specifier.  In this case, you must specify the field width
   6806 --- position in the argument list. >vim
   6807 ---
   6808 ---     echo printf("%1$*2$.*3$d", 1, 2, 3)
   6809 --- <    001 >vim
   6810 ---     echo printf("%2$*3$.*1$d", 1, 2, 3)
   6811 --- <      2 >vim
   6812 ---     echo printf("%3$*1$.*2$d", 1, 2, 3)
   6813 --- <    03 >vim
   6814 ---     echo printf("%1$*2$.*3$g", 1.4142, 2, 3)
   6815 --- <    1.414
   6816 ---
   6817 --- You can mix specifying the width and/or precision directly
   6818 --- and via positional arguments: >vim
   6819 ---
   6820 ---     echo printf("%1$4.*2$f", 1.4142135, 6)
   6821 --- <    1.414214 >vim
   6822 ---     echo printf("%1$*2$.4f", 1.4142135, 6)
   6823 --- <    1.4142 >vim
   6824 ---     echo printf("%1$*2$.*3$f", 1.4142135, 6, 2)
   6825 --- <      1.41
   6826 ---
   6827 --- You will get an overflow error |E1510|, when the field-width
   6828 --- or precision will result in a string longer than 1 MB
   6829 --- (1024*1024 = 1048576) chars.
   6830 ---
   6831 ---           *E1500*
   6832 --- You cannot mix positional and non-positional arguments: >vim
   6833 ---     echo printf("%s%1$s", "One", "Two")
   6834 ---     " E1500: Cannot mix positional and non-positional arguments:
   6835 ---     " %s%1$s
   6836 --- <
   6837 ---           *E1501*
   6838 --- You cannot skip a positional argument in a format string: >vim
   6839 ---     echo printf("%3$s%1$s", "One", "Two", "Three")
   6840 ---     " E1501: format argument 2 unused in $-style format:
   6841 ---     " %3$s%1$s
   6842 --- <
   6843 ---           *E1502*
   6844 --- You can re-use a [field-width] (or [precision]) argument: >vim
   6845 ---     echo printf("%1$d at width %2$d is: %1$0*2$d", 1, 2)
   6846 ---     " 1 at width 2 is: 01
   6847 --- <
   6848 --- However, you can't use it as a different type: >vim
   6849 ---     echo printf("%1$d at width %2$ld is: %1$0*2$d", 1, 2)
   6850 ---     " E1502: Positional argument 2 used as field width reused as
   6851 ---     " different type: long int/int
   6852 --- <
   6853 ---           *E1503*
   6854 --- When a positional argument is used, but not the correct number
   6855 --- or arguments is given, an error is raised: >vim
   6856 ---     echo printf("%1$d at width %2$d is: %1$0*2$.*3$d", 1, 2)
   6857 ---     " E1503: Positional argument 3 out of bounds: %1$d at width
   6858 ---     " %2$d is: %1$0*2$.*3$d
   6859 --- <
   6860 --- Only the first error is reported: >vim
   6861 ---     echo printf("%1$0*2$.*3$d %4$d", 1, 2)
   6862 ---     " E1503: Positional argument 3 out of bounds: %1$0*2$.*3$d
   6863 ---     " %4$d
   6864 --- <
   6865 ---           *E1504*
   6866 --- A positional argument can be used more than once: >vim
   6867 ---     echo printf("%1$s %2$s %1$s", "One", "Two")
   6868 ---     " One Two One
   6869 --- <
   6870 --- However, you can't use a different type the second time: >vim
   6871 ---     echo printf("%1$s %2$s %1$d", "One", "Two")
   6872 ---     " E1504: Positional argument 1 type used inconsistently:
   6873 ---     " int/string
   6874 --- <
   6875 ---           *E1505*
   6876 --- Various other errors that lead to a format string being
   6877 --- wrongly formatted lead to: >vim
   6878 ---     echo printf("%1$d at width %2$d is: %01$*2$.3$d", 1, 2)
   6879 ---     " E1505: Invalid format specifier: %1$d at width %2$d is:
   6880 ---     " %01$*2$.3$d
   6881 --- <
   6882 ---           *E1507*
   6883 --- This internal error indicates that the logic to parse a
   6884 --- positional format argument ran into a problem that couldn't be
   6885 --- otherwise reported.  Please file a bug against Vim if you run
   6886 --- into this, copying the exact format string and parameters that
   6887 --- were used.
   6888 ---
   6889 --- @param fmt string
   6890 --- @param expr1? any
   6891 --- @return string
   6892 function vim.fn.printf(fmt, expr1) end
   6893 
   6894 --- Gets the current user-input in |prompt-buffer| {buf} without invoking
   6895 --- prompt_callback. {buf} can be a buffer name or number.
   6896 ---
   6897 --- If the buffer doesn't exist or isn't a prompt buffer, an empty
   6898 --- string is returned.
   6899 ---
   6900 --- @param buf integer|string
   6901 --- @return any
   6902 function vim.fn.prompt_getinput(buf) end
   6903 
   6904 --- Returns the effective prompt text for buffer {buf}.  {buf} can
   6905 --- be a buffer name or number.  See |prompt-buffer|.
   6906 ---
   6907 --- If the buffer doesn't exist or isn't a prompt buffer, an empty
   6908 --- string is returned.
   6909 ---
   6910 --- @param buf integer|string
   6911 --- @return any
   6912 function vim.fn.prompt_getprompt(buf) end
   6913 
   6914 --- Set prompt callback for buffer {buf} to {expr}.  When {expr}
   6915 --- is an empty string the callback is removed.  This has only
   6916 --- effect if {buf} has 'buftype' set to "prompt".
   6917 ---
   6918 --- The callback is invoked when pressing Enter.  The current
   6919 --- buffer will always be the prompt buffer.  A new line for a
   6920 --- prompt is added before invoking the callback, thus the prompt
   6921 --- for which the callback was invoked will be in the last but one
   6922 --- line.
   6923 --- If the callback wants to add text to the buffer, it must
   6924 --- insert it above the last line, since that is where the current
   6925 --- prompt is.  This can also be done asynchronously.
   6926 --- The callback is invoked with one argument, which is the text
   6927 --- that was entered at the prompt.  This can be an empty string
   6928 --- if the user only typed Enter.
   6929 --- Example: >vim
   6930 ---    func s:TextEntered(text)
   6931 ---      if a:text == 'exit' || a:text == 'quit'
   6932 ---        stopinsert
   6933 ---        " Reset 'modified' to allow the buffer to be closed.
   6934 ---        " We assume there is nothing useful to be saved.
   6935 ---        set nomodified
   6936 ---        close
   6937 ---      else
   6938 ---        " Do something useful with "a:text".  In this example
   6939 ---        " we just repeat it.
   6940 ---        call append(line('$') - 1, 'Entered: "' .. a:text .. '"')
   6941 ---      endif
   6942 ---    endfunc
   6943 ---    call prompt_setcallback(bufnr(), function('s:TextEntered'))
   6944 --- <
   6945 ---
   6946 --- @param buf integer|string
   6947 --- @param expr string|function
   6948 --- @return any
   6949 function vim.fn.prompt_setcallback(buf, expr) end
   6950 
   6951 --- Set a callback for buffer {buf} to {expr}.  When {expr} is an
   6952 --- empty string the callback is removed.  This has only effect if
   6953 --- {buf} has 'buftype' set to "prompt".
   6954 ---
   6955 --- This callback will be invoked when pressing CTRL-C in Insert
   6956 --- mode.  Without setting a callback Vim will exit Insert mode,
   6957 --- as in any buffer.
   6958 ---
   6959 --- @param buf integer|string
   6960 --- @param expr string|function
   6961 --- @return any
   6962 function vim.fn.prompt_setinterrupt(buf, expr) end
   6963 
   6964 --- Set prompt for buffer {buf} to {text}.  You most likely want
   6965 --- {text} to end in a space.
   6966 --- The result is only visible if {buf} has 'buftype' set to
   6967 --- "prompt".  Example: >vim
   6968 ---   call prompt_setprompt(bufnr(''), 'command: ')
   6969 --- <
   6970 ---
   6971 --- @param buf integer|string
   6972 --- @param text string
   6973 --- @return any
   6974 function vim.fn.prompt_setprompt(buf, text) end
   6975 
   6976 --- If the popup menu (see |ins-completion-menu|) is not visible,
   6977 --- returns an empty |Dictionary|, otherwise, returns a
   6978 --- |Dictionary| with the following keys:
   6979 ---   height    nr of items visible
   6980 ---   width    screen cells
   6981 ---   row    top screen row (0 first row)
   6982 ---   col    leftmost screen column (0 first col)
   6983 ---   size    total nr of items
   6984 ---   scrollbar  |TRUE| if scrollbar is visible
   6985 ---
   6986 --- The values are the same as in |v:event| during |CompleteChanged|.
   6987 ---
   6988 --- @return any
   6989 function vim.fn.pum_getpos() end
   6990 
   6991 --- Returns non-zero when the popup menu is visible, zero
   6992 --- otherwise.  See |ins-completion-menu|.
   6993 --- This can be used to avoid some things that would remove the
   6994 --- popup menu.
   6995 ---
   6996 --- @return any
   6997 function vim.fn.pumvisible() end
   6998 
   6999 --- Evaluate Python expression {expr} and return its result
   7000 --- converted to Vim data structures.
   7001 --- Numbers and strings are returned as they are (strings are
   7002 --- copied though, Unicode strings are additionally converted to
   7003 --- UTF-8).
   7004 --- Lists are represented as Vim |List| type.
   7005 --- Dictionaries are represented as Vim |Dictionary| type with
   7006 --- keys converted to strings.
   7007 ---
   7008 --- @param expr any
   7009 --- @return any
   7010 function vim.fn.py3eval(expr) end
   7011 
   7012 --- Evaluate Python expression {expr} and return its result
   7013 --- converted to Vim data structures.
   7014 --- Numbers and strings are returned as they are (strings are
   7015 --- copied though).
   7016 --- Lists are represented as Vim |List| type.
   7017 --- Dictionaries are represented as Vim |Dictionary| type,
   7018 --- non-string keys result in error.
   7019 ---
   7020 --- @param expr any
   7021 --- @return any
   7022 function vim.fn.pyeval(expr) end
   7023 
   7024 --- Evaluate Python expression {expr} and return its result
   7025 --- converted to Vim data structures.
   7026 --- Uses Python 2 or 3, see |python_x| and 'pyxversion'.
   7027 --- See also: |pyeval()|, |py3eval()|
   7028 ---
   7029 --- @param expr any
   7030 --- @return any
   7031 function vim.fn.pyxeval(expr) end
   7032 
   7033 --- Return a pseudo-random Number generated with an xoshiro128**
   7034 --- algorithm using seed {expr}.  The returned number is 32 bits,
   7035 --- also on 64 bits systems, for consistency.
   7036 --- {expr} can be initialized by |srand()| and will be updated by
   7037 --- rand().  If {expr} is omitted, an internal seed value is used
   7038 --- and updated.
   7039 --- Returns -1 if {expr} is invalid.
   7040 ---
   7041 --- Examples: >vim
   7042 ---   echo rand()
   7043 ---   let seed = srand()
   7044 ---   echo rand(seed)
   7045 ---   echo rand(seed) % 16  " random number 0 - 15
   7046 --- <
   7047 ---
   7048 --- @param expr? number
   7049 --- @return any
   7050 function vim.fn.rand(expr) end
   7051 
   7052 --- Returns a |List| with Numbers:
   7053 --- - If only {expr} is specified: [0, 1, ..., {expr} - 1]
   7054 --- - If {max} is specified: [{expr}, {expr} + 1, ..., {max}]
   7055 --- - If {stride} is specified: [{expr}, {expr} + {stride}, ...,
   7056 ---   {max}] (increasing {expr} with {stride} each time, not
   7057 ---   producing a value past {max}).
   7058 --- When the maximum is one before the start the result is an
   7059 --- empty list.  When the maximum is more than one before the
   7060 --- start this is an error.
   7061 --- Examples: >vim
   7062 ---   echo range(4)    " [0, 1, 2, 3]
   7063 ---   echo range(2, 4)  " [2, 3, 4]
   7064 ---   echo range(2, 9, 3)  " [2, 5, 8]
   7065 ---   echo range(2, -2, -1)  " [2, 1, 0, -1, -2]
   7066 ---   echo range(0)    " []
   7067 ---   echo range(2, 0)  " error!
   7068 --- <
   7069 ---
   7070 --- @param expr any
   7071 --- @param max? integer
   7072 --- @param stride? integer
   7073 --- @return any
   7074 function vim.fn.range(expr, max, stride) end
   7075 
   7076 --- Read file {fname} in binary mode and return a |Blob|.
   7077 --- If {offset} is specified, read the file from the specified
   7078 --- offset.  If it is a negative value, it is used as an offset
   7079 --- from the end of the file.  E.g., to read the last 12 bytes: >vim
   7080 ---   echo readblob('file.bin', -12)
   7081 --- <If {size} is specified, only the specified size will be read.
   7082 --- E.g. to read the first 100 bytes of a file: >vim
   7083 ---   echo readblob('file.bin', 0, 100)
   7084 --- <If {size} is -1 or omitted, the whole data starting from
   7085 --- {offset} will be read.
   7086 --- This can be also used to read the data from a character device
   7087 --- on Unix when {size} is explicitly set.  Only if the device
   7088 --- supports seeking {offset} can be used.  Otherwise it should be
   7089 --- zero.  E.g. to read 10 bytes from a serial console: >vim
   7090 ---   echo readblob('/dev/ttyS0', 0, 10)
   7091 --- <When the file can't be opened an error message is given and
   7092 --- the result is an empty |Blob|.
   7093 --- When the offset is beyond the end of the file the result is an
   7094 --- empty blob.
   7095 --- When trying to read more bytes than are available the result
   7096 --- is truncated.
   7097 --- Also see |readfile()| and |writefile()|.
   7098 ---
   7099 --- @param fname string
   7100 --- @param offset? integer
   7101 --- @param size? integer
   7102 --- @return any
   7103 function vim.fn.readblob(fname, offset, size) end
   7104 
   7105 --- Return a list with file and directory names in {directory}.
   7106 --- You can also use |glob()| if you don't need to do complicated
   7107 --- things, such as limiting the number of matches.
   7108 ---
   7109 --- When {expr} is omitted all entries are included.
   7110 --- When {expr} is given, it is evaluated to check what to do:
   7111 ---   If {expr} results in -1 then no further entries will
   7112 ---   be handled.
   7113 ---   If {expr} results in 0 then this entry will not be
   7114 ---   added to the list.
   7115 ---   If {expr} results in 1 then this entry will be added
   7116 ---   to the list.
   7117 --- Each time {expr} is evaluated |v:val| is set to the entry name.
   7118 --- When {expr} is a function the name is passed as the argument.
   7119 --- For example, to get a list of files ending in ".txt": >vim
   7120 ---   echo readdir(dirname, {n -> n =~ '.txt$'})
   7121 --- <To skip hidden and backup files: >vim
   7122 ---   echo readdir(dirname, {n -> n !~ '^\.\|\~$'})
   7123 ---
   7124 --- <If you want to get a directory tree: >vim
   7125 ---   function! s:tree(dir)
   7126 ---       return {a:dir : map(readdir(a:dir),
   7127 ---       \ {_, x -> isdirectory(x) ?
   7128 ---       \          {x : s:tree(a:dir .. '/' .. x)} : x})}
   7129 ---   endfunction
   7130 ---   echo s:tree(".")
   7131 --- <
   7132 --- Returns an empty List on error.
   7133 ---
   7134 --- @param directory string
   7135 --- @param expr? integer
   7136 --- @return any
   7137 function vim.fn.readdir(directory, expr) end
   7138 
   7139 --- Read file {fname} and return a |List|, each line of the file
   7140 --- as an item.  Lines are broken at NL characters.  Macintosh
   7141 --- files separated with CR will result in a single long line
   7142 --- (unless a NL appears somewhere).
   7143 --- All NUL characters are replaced with a NL character.
   7144 --- When {type} contains "b" binary mode is used:
   7145 --- - When the last line ends in a NL an extra empty list item is
   7146 ---   added.
   7147 --- - No CR characters are removed.
   7148 --- Otherwise:
   7149 --- - CR characters that appear before a NL are removed.
   7150 --- - Whether the last line ends in a NL or not does not matter.
   7151 --- - Any UTF-8 byte order mark is removed from the text.
   7152 --- When {max} is given this specifies the maximum number of lines
   7153 --- to be read.  Useful if you only want to check the first ten
   7154 --- lines of a file: >vim
   7155 ---   for line in readfile(fname, '', 10)
   7156 ---     if line =~ 'Date' | echo line | endif
   7157 ---   endfor
   7158 --- <When {max} is negative -{max} lines from the end of the file
   7159 --- are returned, or as many as there are.
   7160 --- When {max} is zero the result is an empty list.
   7161 --- Note that without {max} the whole file is read into memory.
   7162 --- Also note that there is no recognition of encoding.  Read a
   7163 --- file into a buffer if you need to.
   7164 --- Deprecated (use |readblob()| instead): When {type} contains
   7165 --- "B" a |Blob| is returned with the binary data of the file
   7166 --- unmodified.
   7167 --- When the file can't be opened an error message is given and
   7168 --- the result is an empty list.
   7169 --- Also see |writefile()|.
   7170 ---
   7171 --- @param fname string
   7172 --- @param type? string
   7173 --- @param max? integer
   7174 --- @return string[]
   7175 function vim.fn.readfile(fname, type, max) end
   7176 
   7177 --- {func} is called for every item in {object}, which can be a
   7178 --- |String|, |List| or a |Blob|.  {func} is called with two
   7179 --- arguments: the result so far and current item.  After
   7180 --- processing all items the result is returned.
   7181 ---
   7182 --- {initial} is the initial result.  When omitted, the first item
   7183 --- in {object} is used and {func} is first called for the second
   7184 --- item.  If {initial} is not given and {object} is empty no
   7185 --- result can be computed, an E998 error is given.
   7186 ---
   7187 --- Examples: >vim
   7188 ---   echo reduce([1, 3, 5], { acc, val -> acc + val })
   7189 ---   echo reduce(['x', 'y'], { acc, val -> acc .. val }, 'a')
   7190 ---   echo reduce(0z1122, { acc, val -> 2 * acc + val })
   7191 ---   echo reduce('xyz', { acc, val -> acc .. ',' .. val })
   7192 --- <
   7193 ---
   7194 --- @generic T
   7195 --- @param object any
   7196 --- @param func fun(accumulator: T, current: any): any
   7197 --- @param initial? any
   7198 --- @return T
   7199 function vim.fn.reduce(object, func, initial) end
   7200 
   7201 --- Returns the single letter name of the register being executed.
   7202 --- Returns an empty string when no register is being executed.
   7203 --- See |\@|.
   7204 ---
   7205 --- @return any
   7206 function vim.fn.reg_executing() end
   7207 
   7208 --- Returns the single letter name of the last recorded register.
   7209 --- Returns an empty string when nothing was recorded yet.
   7210 --- See |q| and |Q|.
   7211 ---
   7212 --- @return any
   7213 function vim.fn.reg_recorded() end
   7214 
   7215 --- Returns the single letter name of the register being recorded.
   7216 --- Returns an empty string when not recording.  See |q|.
   7217 ---
   7218 --- @return any
   7219 function vim.fn.reg_recording() end
   7220 
   7221 --- @return any
   7222 function vim.fn.reltime() end
   7223 
   7224 --- @param start? any
   7225 --- @return any
   7226 function vim.fn.reltime(start) end
   7227 
   7228 --- Return an item that represents a time value.  The item is a
   7229 --- list with items that depend on the system.
   7230 --- The item can be passed to |reltimestr()| to convert it to a
   7231 --- string or |reltimefloat()| to convert to a Float.
   7232 ---
   7233 --- Without an argument it returns the current "relative time", an
   7234 --- implementation-defined value meaningful only when used as an
   7235 --- argument to |reltime()|, |reltimestr()| and |reltimefloat()|.
   7236 ---
   7237 --- With one argument it returns the time passed since the time
   7238 --- specified in the argument.
   7239 --- With two arguments it returns the time passed between {start}
   7240 --- and {end}.
   7241 ---
   7242 --- The {start} and {end} arguments must be values returned by
   7243 --- reltime().  Returns zero on error.
   7244 ---
   7245 --- Note: |localtime()| returns the current (non-relative) time.
   7246 ---
   7247 --- @param start? any
   7248 --- @param end_? any
   7249 --- @return any
   7250 function vim.fn.reltime(start, end_) end
   7251 
   7252 --- Return a Float that represents the time value of {time}.
   7253 --- Unit of time is seconds.
   7254 --- Example:
   7255 ---   let start = reltime()
   7256 ---   call MyFunction()
   7257 ---   let seconds = reltimefloat(reltime(start))
   7258 --- See the note of |reltimestr()| about overhead.
   7259 --- Also see |profiling|.
   7260 --- If there is an error an empty string is returned
   7261 ---
   7262 --- @param time any
   7263 --- @return any
   7264 function vim.fn.reltimefloat(time) end
   7265 
   7266 --- Return a String that represents the time value of {time}.
   7267 --- This is the number of seconds, a dot and the number of
   7268 --- microseconds.  Example: >vim
   7269 ---   let start = reltime()
   7270 ---   call MyFunction()
   7271 ---   echo reltimestr(reltime(start))
   7272 --- <Note that overhead for the commands will be added to the time.
   7273 --- Leading spaces are used to make the string align nicely.  You
   7274 --- can use |split()| to remove it. >vim
   7275 ---   echo split(reltimestr(reltime(start)))[0]
   7276 --- <Also see |profiling|.
   7277 --- If there is an error an empty string is returned
   7278 ---
   7279 --- @param time any
   7280 --- @return any
   7281 function vim.fn.reltimestr(time) end
   7282 
   7283 --- @param list any
   7284 --- @param idx integer
   7285 --- @return any
   7286 function vim.fn.remove(list, idx) end
   7287 
   7288 --- Without {end}: Remove the item at {idx} from |List| {list} and
   7289 --- return the item.
   7290 --- With {end}: Remove items from {idx} to {end} (inclusive) and
   7291 --- return a |List| with these items.  When {idx} points to the same
   7292 --- item as {end} a list with one item is returned.  When {end}
   7293 --- points to an item before {idx} this is an error.
   7294 --- See |list-index| for possible values of {idx} and {end}.
   7295 --- Returns zero on error.
   7296 --- Example: >vim
   7297 ---   echo "last item: " .. remove(mylist, -1)
   7298 ---   call remove(mylist, 0, 9)
   7299 --- <
   7300 --- Use |delete()| to remove a file.
   7301 ---
   7302 --- @param list any[]
   7303 --- @param idx integer
   7304 --- @param end_? integer
   7305 --- @return any
   7306 function vim.fn.remove(list, idx, end_) end
   7307 
   7308 --- @param blob any
   7309 --- @param idx integer
   7310 --- @return any
   7311 function vim.fn.remove(blob, idx) end
   7312 
   7313 --- Without {end}: Remove the byte at {idx} from |Blob| {blob} and
   7314 --- return the byte.
   7315 --- With {end}: Remove bytes from {idx} to {end} (inclusive) and
   7316 --- return a |Blob| with these bytes.  When {idx} points to the same
   7317 --- byte as {end} a |Blob| with one byte is returned.  When {end}
   7318 --- points to a byte before {idx} this is an error.
   7319 --- Returns zero on error.
   7320 --- Example: >vim
   7321 ---   echo "last byte: " .. remove(myblob, -1)
   7322 ---   call remove(mylist, 0, 9)
   7323 --- <
   7324 ---
   7325 --- @param blob any
   7326 --- @param idx integer
   7327 --- @param end_? integer
   7328 --- @return any
   7329 function vim.fn.remove(blob, idx, end_) end
   7330 
   7331 --- Remove the entry from {dict} with key {key} and return it.
   7332 --- Example: >vim
   7333 ---   echo "removed " .. remove(dict, "one")
   7334 --- <If there is no {key} in {dict} this is an error.
   7335 --- Returns zero on error.
   7336 ---
   7337 --- @param dict any
   7338 --- @param key string
   7339 --- @return any
   7340 function vim.fn.remove(dict, key) end
   7341 
   7342 --- Rename the file by the name {from} to the name {to}.  This
   7343 --- should also work to move files across file systems.  The
   7344 --- result is a Number, which is 0 if the file was renamed
   7345 --- successfully, and non-zero when the renaming failed.
   7346 --- NOTE: If {to} exists it is overwritten without warning.
   7347 --- This function is not available in the |sandbox|.
   7348 ---
   7349 --- @param from string
   7350 --- @param to string
   7351 --- @return integer
   7352 function vim.fn.rename(from, to) end
   7353 
   7354 --- Repeat {expr} {count} times and return the concatenated
   7355 --- result.  Example: >vim
   7356 ---   let separator = repeat('-', 80)
   7357 --- <When {count} is zero or negative the result is empty.
   7358 --- When {expr} is a |List| or a |Blob| the result is {expr}
   7359 --- concatenated {count} times.  Example: >vim
   7360 ---   let longlist = repeat(['a', 'b'], 3)
   7361 --- <Results in ['a', 'b', 'a', 'b', 'a', 'b'].
   7362 ---
   7363 --- @param expr any
   7364 --- @param count integer
   7365 --- @return any
   7366 vim.fn['repeat'] = function(expr, count) end
   7367 
   7368 --- On MS-Windows, when {filename} is a shortcut (a .lnk file),
   7369 --- returns the path the shortcut points to in a simplified form.
   7370 --- On Unix, repeat resolving symbolic links in all path
   7371 --- components of {filename} and return the simplified result.
   7372 --- To cope with link cycles, resolving of symbolic links is
   7373 --- stopped after 100 iterations.
   7374 --- On other systems, return the simplified {filename}.
   7375 --- The simplification step is done as by |simplify()|.
   7376 --- resolve() keeps a leading path component specifying the
   7377 --- current directory (provided the result is still a relative
   7378 --- path name) and also keeps a trailing path separator.
   7379 ---
   7380 --- @param filename string
   7381 --- @return string
   7382 function vim.fn.resolve(filename) end
   7383 
   7384 --- Reverse the order of items in {object}.  {object} can be a
   7385 --- |List|, a |Blob| or a |String|.  For a List and a Blob the
   7386 --- items are reversed in-place and {object} is returned.
   7387 --- For a String a new String is returned.
   7388 --- Returns zero if {object} is not a List, Blob or a String.
   7389 --- If you want a List or Blob to remain unmodified make a copy
   7390 --- first: >vim
   7391 ---   let revlist = reverse(copy(mylist))
   7392 --- <
   7393 ---
   7394 --- @generic T
   7395 --- @param object T[]
   7396 --- @return T[]
   7397 function vim.fn.reverse(object) end
   7398 
   7399 --- Round off {expr} to the nearest integral value and return it
   7400 --- as a |Float|.  If {expr} lies halfway between two integral
   7401 --- values, then use the larger one (away from zero).
   7402 --- {expr} must evaluate to a |Float| or a |Number|.
   7403 --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
   7404 --- Examples: >vim
   7405 ---   echo round(0.456)
   7406 --- <  0.0  >vim
   7407 ---   echo round(4.5)
   7408 --- <  5.0 >vim
   7409 ---   echo round(-4.5)
   7410 --- <  -5.0
   7411 ---
   7412 --- @param expr number
   7413 --- @return number
   7414 function vim.fn.round(expr) end
   7415 
   7416 --- Sends {event} to {channel} via |RPC| and returns immediately.
   7417 --- If {channel} is 0, the event is broadcast to all channels.
   7418 --- Example: >vim
   7419 ---   au VimLeave call rpcnotify(0, "leaving")
   7420 --- <
   7421 ---
   7422 --- @param channel integer
   7423 --- @param event string
   7424 --- @param ... any
   7425 --- @return integer
   7426 function vim.fn.rpcnotify(channel, event, ...) end
   7427 
   7428 --- Sends a request to {channel} to invoke {method} via
   7429 --- |RPC| and blocks until a response is received.
   7430 --- Example: >vim
   7431 ---   let result = rpcrequest(rpc_chan, "func", 1, 2, 3)
   7432 --- <
   7433 ---
   7434 --- @param channel integer
   7435 --- @param method string
   7436 --- @param ... any
   7437 --- @return any
   7438 function vim.fn.rpcrequest(channel, method, ...) end
   7439 
   7440 --- @deprecated
   7441 --- Deprecated. Replace  >vim
   7442 ---   let id = rpcstart('prog', ['arg1', 'arg2'])
   7443 --- <with >vim
   7444 ---   let id = jobstart(['prog', 'arg1', 'arg2'], {'rpc': v:true})
   7445 --- <
   7446 ---
   7447 --- @param prog string
   7448 --- @param argv? any
   7449 --- @return any
   7450 function vim.fn.rpcstart(prog, argv) end
   7451 
   7452 --- @deprecated
   7453 --- Use |jobstop()| instead to stop any job, or
   7454 --- `chanclose(id, "rpc")` to close RPC communication
   7455 --- without stopping the job. Use chanclose(id) to close
   7456 --- any socket.
   7457 ---
   7458 --- @param ... any
   7459 --- @return any
   7460 function vim.fn.rpcstop(...) end
   7461 
   7462 --- Evaluate Ruby expression {expr} and return its result
   7463 --- converted to Vim data structures.
   7464 --- Numbers, floats and strings are returned as they are (strings
   7465 --- are copied though).
   7466 --- Arrays are represented as Vim |List| type.
   7467 --- Hashes are represented as Vim |Dictionary| type.
   7468 --- Other objects are represented as strings resulted from their
   7469 --- "Object#to_s" method.
   7470 ---
   7471 --- @param expr any
   7472 --- @return any
   7473 function vim.fn.rubyeval(expr) end
   7474 
   7475 --- Like |screenchar()|, but return the attribute.  This is a rather
   7476 --- arbitrary number that can only be used to compare to the
   7477 --- attribute at other positions.
   7478 --- Returns -1 when row or col is out of range.
   7479 ---
   7480 --- @param row integer
   7481 --- @param col integer
   7482 --- @return integer
   7483 function vim.fn.screenattr(row, col) end
   7484 
   7485 --- The result is a Number, which is the character at position
   7486 --- [row, col] on the screen.  This works for every possible
   7487 --- screen position, also status lines, window separators and the
   7488 --- command line.  The top left position is row one, column one
   7489 --- The character excludes composing characters.  For double-byte
   7490 --- encodings it may only be the first byte.
   7491 --- This is mainly to be used for testing.
   7492 --- Returns -1 when row or col is out of range.
   7493 ---
   7494 --- @param row integer
   7495 --- @param col integer
   7496 --- @return integer
   7497 function vim.fn.screenchar(row, col) end
   7498 
   7499 --- The result is a |List| of Numbers.  The first number is the same
   7500 --- as what |screenchar()| returns.  Further numbers are
   7501 --- composing characters on top of the base character.
   7502 --- This is mainly to be used for testing.
   7503 --- Returns an empty List when row or col is out of range.
   7504 ---
   7505 --- @param row integer
   7506 --- @param col integer
   7507 --- @return integer[]
   7508 function vim.fn.screenchars(row, col) end
   7509 
   7510 --- The result is a Number, which is the current screen column of
   7511 --- the cursor.  The leftmost column has number 1.
   7512 --- This function is mainly used for testing.
   7513 ---
   7514 --- Note: Always returns the current screen column, thus if used
   7515 --- in a command (e.g. ":echo screencol()") it will return the
   7516 --- column inside the command line, which is 1 when the command is
   7517 --- executed.  To get the cursor position in the file use one of
   7518 --- the following mappings: >vim
   7519 ---   nnoremap <expr> GG ":echom " .. screencol() .. "\n"
   7520 ---   nnoremap <silent> GG :echom screencol()<CR>
   7521 ---   noremap GG <Cmd>echom screencol()<CR>
   7522 --- <
   7523 ---
   7524 --- @return integer[]
   7525 function vim.fn.screencol() end
   7526 
   7527 --- The result is a Dict with the screen position of the text
   7528 --- character in window {winid} at buffer line {lnum} and column
   7529 --- {col}.  {col} is a one-based byte index.
   7530 --- The Dict has these members:
   7531 ---   row  screen row
   7532 ---   col  first screen column
   7533 ---   endcol  last screen column
   7534 ---   curscol  cursor screen column
   7535 --- If the specified position is not visible, all values are zero.
   7536 --- The "endcol" value differs from "col" when the character
   7537 --- occupies more than one screen cell.  E.g. for a Tab "col" can
   7538 --- be 1 and "endcol" can be 8.
   7539 --- The "curscol" value is where the cursor would be placed.  For
   7540 --- a Tab it would be the same as "endcol", while for a double
   7541 --- width character it would be the same as "col".
   7542 --- The |conceal| feature is ignored here, the column numbers are
   7543 --- as if 'conceallevel' is zero.  You can set the cursor to the
   7544 --- right position and use |screencol()| to get the value with
   7545 --- |conceal| taken into account.
   7546 --- If the position is in a closed fold the screen position of the
   7547 --- first character is returned, {col} is not used.
   7548 --- Returns an empty Dict if {winid} is invalid.
   7549 ---
   7550 --- @param winid integer
   7551 --- @param lnum integer
   7552 --- @param col integer
   7553 --- @return any
   7554 function vim.fn.screenpos(winid, lnum, col) end
   7555 
   7556 --- The result is a Number, which is the current screen row of the
   7557 --- cursor.  The top line has number one.
   7558 --- This function is mainly used for testing.
   7559 --- Alternatively you can use |winline()|.
   7560 ---
   7561 --- Note: Same restrictions as with |screencol()|.
   7562 ---
   7563 --- @return integer
   7564 function vim.fn.screenrow() end
   7565 
   7566 --- The result is a String that contains the base character and
   7567 --- any composing characters at position [row, col] on the screen.
   7568 --- This is like |screenchars()| but returning a String with the
   7569 --- characters.
   7570 --- This is mainly to be used for testing.
   7571 --- Returns an empty String when row or col is out of range.
   7572 ---
   7573 --- @param row integer
   7574 --- @param col integer
   7575 --- @return string
   7576 function vim.fn.screenstring(row, col) end
   7577 
   7578 --- Search for regexp pattern {pattern}.  The search starts at the
   7579 --- cursor position (you can use |cursor()| to set it).
   7580 ---
   7581 --- When a match has been found its line number is returned.
   7582 --- If there is no match a 0 is returned and the cursor doesn't
   7583 --- move.  No error message is given.
   7584 --- To get the matched string, use |matchbufline()|.
   7585 ---
   7586 --- {flags} is a String, which can contain these character flags:
   7587 --- 'b'  search Backward instead of forward
   7588 --- 'c'  accept a match at the Cursor position
   7589 --- 'e'  move to the End of the match
   7590 --- 'n'  do Not move the cursor
   7591 --- 'p'  return number of matching sub-Pattern (see below)
   7592 --- 's'  Set the ' mark at the previous location of the cursor
   7593 --- 'w'  Wrap around the end of the file
   7594 --- 'W'  don't Wrap around the end of the file
   7595 --- 'z'  start searching at the cursor column instead of Zero
   7596 --- If neither 'w' or 'W' is given, the 'wrapscan' option applies.
   7597 ---
   7598 --- If the 's' flag is supplied, the ' mark is set, only if the
   7599 --- cursor is moved.  The 's' flag cannot be combined with the 'n'
   7600 --- flag.
   7601 ---
   7602 --- 'ignorecase', 'smartcase' and 'magic' are used.
   7603 ---
   7604 --- When the 'z' flag is not given, forward searching always
   7605 --- starts in column zero and then matches before the cursor are
   7606 --- skipped.  When the 'c' flag is present in 'cpo' the next
   7607 --- search starts after the match.  Without the 'c' flag the next
   7608 --- search starts one column after the start of the match.  This
   7609 --- matters for overlapping matches.  See |cpo-c|.  You can also
   7610 --- insert "\ze" to change where the match ends, see  |/\ze|.
   7611 ---
   7612 --- When searching backwards and the 'z' flag is given then the
   7613 --- search starts in column zero, thus no match in the current
   7614 --- line will be found (unless wrapping around the end of the
   7615 --- file).
   7616 ---
   7617 --- When the {stopline} argument is given then the search stops
   7618 --- after searching this line.  This is useful to restrict the
   7619 --- search to a range of lines.  Examples: >vim
   7620 ---   let match = search('(', 'b', line("w0"))
   7621 ---   let end = search('END', '', line("w$"))
   7622 --- <When {stopline} is used and it is not zero this also implies
   7623 --- that the search does not wrap around the end of the file.
   7624 --- A zero value is equal to not giving the argument.
   7625 ---
   7626 --- When the {timeout} argument is given the search stops when
   7627 --- more than this many milliseconds have passed.  Thus when
   7628 --- {timeout} is 500 the search stops after half a second.
   7629 --- The value must not be negative.  A zero value is like not
   7630 --- giving the argument.
   7631 ---
   7632 --- Note: the timeout is only considered when searching, not
   7633 --- while evaluating the {skip} expression.
   7634 ---
   7635 --- If the {skip} expression is given it is evaluated with the
   7636 --- cursor positioned on the start of a match.  If it evaluates to
   7637 --- non-zero this match is skipped.  This can be used, for
   7638 --- example, to skip a match in a comment or a string.
   7639 --- {skip} can be a string, which is evaluated as an expression, a
   7640 --- function reference or a lambda.
   7641 --- When {skip} is omitted or empty, every match is accepted.
   7642 --- When evaluating {skip} causes an error the search is aborted
   7643 --- and -1 returned.
   7644 ---           *search()-sub-match*
   7645 --- With the 'p' flag the returned value is one more than the
   7646 --- first sub-match in \(\).  One if none of them matched but the
   7647 --- whole pattern did match.
   7648 --- To get the column number too use |searchpos()|.
   7649 ---
   7650 --- The cursor will be positioned at the match, unless the 'n'
   7651 --- flag is used.
   7652 ---
   7653 --- Example (goes over all files in the argument list): >vim
   7654 ---     let n = 1
   7655 ---     while n <= argc()      " loop over all files in arglist
   7656 ---       exe "argument " .. n
   7657 ---       " start at the last char in the file and wrap for the
   7658 ---       " first search to find match at start of file
   7659 ---       normal G$
   7660 ---       let flags = "w"
   7661 ---       while search("foo", flags) > 0
   7662 ---         s/foo/bar/g
   7663 ---         let flags = "W"
   7664 ---       endwhile
   7665 ---       update        " write the file if modified
   7666 ---       let n = n + 1
   7667 ---     endwhile
   7668 --- <
   7669 --- Example for using some flags: >vim
   7670 ---     echo search('\<if\|\(else\)\|\(endif\)', 'ncpe')
   7671 --- <This will search for the keywords "if", "else", and "endif"
   7672 --- under or after the cursor.  Because of the 'p' flag, it
   7673 --- returns 1, 2, or 3 depending on which keyword is found, or 0
   7674 --- if the search fails.  With the cursor on the first word of the
   7675 --- line:
   7676 ---     if (foo == 0) | let foo = foo + 1 | endif ~
   7677 --- the function returns 1.  Without the 'c' flag, the function
   7678 --- finds the "endif" and returns 3.  The same thing happens
   7679 --- without the 'e' flag if the cursor is on the "f" of "if".
   7680 --- The 'n' flag tells the function not to move the cursor.
   7681 ---
   7682 --- @param pattern string
   7683 --- @param flags? string
   7684 --- @param stopline? integer
   7685 --- @param timeout? integer
   7686 --- @param skip? string|function
   7687 --- @return integer
   7688 function vim.fn.search(pattern, flags, stopline, timeout, skip) end
   7689 
   7690 --- Get or update the last search count, like what is displayed
   7691 --- without the "S" flag in 'shortmess'.  This works even if
   7692 --- 'shortmess' does contain the "S" flag.
   7693 ---
   7694 --- This returns a |Dictionary|.  The dictionary is empty if the
   7695 --- previous pattern was not set and "pattern" was not specified.
   7696 ---
   7697 ---   key    type    meaning ~
   7698 ---   current  |Number|  current position of match;
   7699 ---         0 if the cursor position is
   7700 ---         before the first match
   7701 ---   exact_match  |Boolean|  1 if "current" is matched on
   7702 ---         "pos", otherwise 0
   7703 ---   total    |Number|  total count of matches found
   7704 ---   incomplete  |Number|  0: search was fully completed
   7705 ---         1: recomputing was timed out
   7706 ---         2: max count exceeded
   7707 ---
   7708 --- For {options} see further down.
   7709 ---
   7710 --- To get the last search count when |n| or |N| was pressed, call
   7711 --- this function with `recompute: 0` .  This sometimes returns
   7712 --- wrong information because of 'maxsearchcount'.
   7713 --- If the count exceeded 'maxsearchcount', the result must be
   7714 --- 'maxsearchcount' + 1.  If you want to get correct information,
   7715 --- specify `recompute: 1`: >vim
   7716 ---
   7717 ---   " result == 'maxsearchcount' + 1 when many matches
   7718 ---   let result = searchcount(#{recompute: 0})
   7719 ---
   7720 ---   " Below returns correct result (recompute defaults
   7721 ---   " to 1)
   7722 ---   let result = searchcount()
   7723 --- <
   7724 --- The function is useful to add the count to 'statusline': >vim
   7725 ---   function! LastSearchCount() abort
   7726 ---     let result = searchcount(#{recompute: 0})
   7727 ---     if empty(result)
   7728 ---       return ''
   7729 ---     endif
   7730 ---     if result.incomplete ==# 1     " timed out
   7731 ---       return printf(' /%s [?/??]', \@/)
   7732 ---     elseif result.incomplete ==# 2 " max count exceeded
   7733 ---       if result.total > result.maxcount &&
   7734 ---       \  result.current > result.maxcount
   7735 ---         return printf(' /%s [>%d/>%d]', \@/,
   7736 ---         \             result.current, result.total)
   7737 ---       elseif result.total > result.maxcount
   7738 ---         return printf(' /%s [%d/>%d]', \@/,
   7739 ---         \             result.current, result.total)
   7740 ---       endif
   7741 ---     endif
   7742 ---     return printf(' /%s [%d/%d]', \@/,
   7743 ---     \             result.current, result.total)
   7744 ---   endfunction
   7745 ---   let &statusline ..= '%{LastSearchCount()}'
   7746 ---
   7747 ---   " Or if you want to show the count only when
   7748 ---   " 'hlsearch' was on
   7749 ---   " let &statusline ..=
   7750 ---   " \   '%{v:hlsearch ? LastSearchCount() : ""}'
   7751 --- <
   7752 --- You can also update the search count, which can be useful in a
   7753 --- |CursorMoved| or |CursorMovedI| autocommand: >vim
   7754 ---
   7755 ---   autocmd CursorMoved,CursorMovedI *
   7756 ---     \ let s:searchcount_timer = timer_start(
   7757 ---     \   200, function('s:update_searchcount'))
   7758 ---   function! s:update_searchcount(timer) abort
   7759 ---     if a:timer ==# s:searchcount_timer
   7760 ---       call searchcount(#{
   7761 ---       \ recompute: 1, maxcount: 0, timeout: 100})
   7762 ---       redrawstatus
   7763 ---     endif
   7764 ---   endfunction
   7765 --- <
   7766 --- This can also be used to count matched texts with specified
   7767 --- pattern in the current buffer using "pattern":  >vim
   7768 ---
   7769 ---   " Count '\<foo\>' in this buffer
   7770 ---   " (Note that it also updates search count)
   7771 ---   let result = searchcount(#{pattern: '\<foo\>'})
   7772 ---
   7773 ---   " To restore old search count by old pattern,
   7774 ---   " search again
   7775 ---   call searchcount()
   7776 --- <
   7777 --- {options} must be a |Dictionary|.  It can contain:
   7778 ---   key    type    meaning ~
   7779 ---   recompute  |Boolean|  if |TRUE|, recompute the count
   7780 ---         like |n| or |N| was executed.
   7781 ---         otherwise returns the last
   7782 ---         computed result (when |n| or
   7783 ---         |N| was used when "S" is not
   7784 ---         in 'shortmess', or this
   7785 ---         function was called).
   7786 ---         (default: |TRUE|)
   7787 ---   pattern  |String|  recompute if this was given
   7788 ---         and different with |\@/|.
   7789 ---         this works as same as the
   7790 ---         below command is executed
   7791 ---         before calling this function >vim
   7792 ---           let \@/ = pattern
   7793 --- <        (default: |\@/|)
   7794 ---   timeout  |Number|  0 or negative number is no
   7795 ---         timeout. timeout milliseconds
   7796 ---         for recomputing the result
   7797 ---         (default: 0)
   7798 ---   maxcount  |Number|  0 or negative number is no
   7799 ---         limit. max count of matched
   7800 ---         text while recomputing the
   7801 ---         result.  if search exceeded
   7802 ---         total count, "total" value
   7803 ---         becomes `maxcount + 1`
   7804 ---         (default: 'maxsearchcount')
   7805 ---   pos    |List|    `[lnum, col, off]` value
   7806 ---         when recomputing the result.
   7807 ---         this changes "current" result
   7808 ---         value. see |cursor()|, |getpos()|
   7809 ---         (default: cursor's position)
   7810 ---
   7811 --- @param options? table
   7812 --- @return any
   7813 function vim.fn.searchcount(options) end
   7814 
   7815 --- Search for the declaration of {name}.
   7816 ---
   7817 --- With a non-zero {global} argument it works like |gD|, find
   7818 --- first match in the file.  Otherwise it works like |gd|, find
   7819 --- first match in the function.
   7820 ---
   7821 --- With a non-zero {thisblock} argument matches in a {} block
   7822 --- that ends before the cursor position are ignored.  Avoids
   7823 --- finding variable declarations only valid in another scope.
   7824 ---
   7825 --- Moves the cursor to the found match.
   7826 --- Returns zero for success, non-zero for failure.
   7827 --- Example: >vim
   7828 ---   if searchdecl('myvar') == 0
   7829 ---      echo getline('.')
   7830 ---   endif
   7831 --- <
   7832 ---
   7833 --- @param name string
   7834 --- @param global? boolean
   7835 --- @param thisblock? boolean
   7836 --- @return any
   7837 function vim.fn.searchdecl(name, global, thisblock) end
   7838 
   7839 --- Search for the match of a nested start-end pair.  This can be
   7840 --- used to find the "endif" that matches an "if", while other
   7841 --- if/endif pairs in between are ignored.
   7842 --- The search starts at the cursor.  The default is to search
   7843 --- forward, include 'b' in {flags} to search backward.
   7844 --- If a match is found, the cursor is positioned at it and the
   7845 --- line number is returned.  If no match is found 0 or -1 is
   7846 --- returned and the cursor doesn't move.  No error message is
   7847 --- given.
   7848 ---
   7849 --- {start}, {middle} and {end} are patterns, see |pattern|.  They
   7850 --- must not contain \( \) pairs.  Use of \%( \) is allowed.  When
   7851 --- {middle} is not empty, it is found when searching from either
   7852 --- direction, but only when not in a nested start-end pair.  A
   7853 --- typical use is: >vim
   7854 ---   echo searchpair('\<if\>', '\<else\>', '\<endif\>')
   7855 --- <By leaving {middle} empty the "else" is skipped.
   7856 ---
   7857 --- {flags} 'b', 'c', 'n', 's', 'w' and 'W' are used like with
   7858 --- |search()|.  Additionally:
   7859 --- 'r'  Repeat until no more matches found; will find the
   7860 ---   outer pair.  Implies the 'W' flag.
   7861 --- 'm'  Return number of matches instead of line number with
   7862 ---   the match; will be > 1 when 'r' is used.
   7863 --- Note: it's nearly always a good idea to use the 'W' flag, to
   7864 --- avoid wrapping around the end of the file.
   7865 ---
   7866 --- When a match for {start}, {middle} or {end} is found, the
   7867 --- {skip} expression is evaluated with the cursor positioned on
   7868 --- the start of the match.  It should return non-zero if this
   7869 --- match is to be skipped.  E.g., because it is inside a comment
   7870 --- or a string.
   7871 --- When {skip} is omitted or empty, every match is accepted.
   7872 --- When evaluating {skip} causes an error the search is aborted
   7873 --- and -1 returned.
   7874 --- {skip} can be a string, a lambda, a funcref or a partial.
   7875 --- Anything else makes the function fail.
   7876 ---
   7877 --- For {stopline} and {timeout} see |search()|.
   7878 ---
   7879 --- The value of 'ignorecase' is used.  'magic' is ignored, the
   7880 --- patterns are used like it's on.
   7881 ---
   7882 --- The search starts exactly at the cursor.  A match with
   7883 --- {start}, {middle} or {end} at the next character, in the
   7884 --- direction of searching, is the first one found.  Example: >vim
   7885 ---   if 1
   7886 ---     if 2
   7887 ---     endif 2
   7888 ---   endif 1
   7889 --- <When starting at the "if 2", with the cursor on the "i", and
   7890 --- searching forwards, the "endif 2" is found.  When starting on
   7891 --- the character just before the "if 2", the "endif 1" will be
   7892 --- found.  That's because the "if 2" will be found first, and
   7893 --- then this is considered to be a nested if/endif from "if 2" to
   7894 --- "endif 2".
   7895 --- When searching backwards and {end} is more than one character,
   7896 --- it may be useful to put "\zs" at the end of the pattern, so
   7897 --- that when the cursor is inside a match with the end it finds
   7898 --- the matching start.
   7899 ---
   7900 --- Example, to find the "endif" command in a Vim script: >vim
   7901 ---
   7902 ---   echo searchpair('\<if\>', '\<el\%[seif]\>', '\<en\%[dif]\>', 'W',
   7903 ---   \ 'getline(".") =~ "^\\s*\""')
   7904 ---
   7905 --- <The cursor must be at or after the "if" for which a match is
   7906 --- to be found.  Note that single-quote strings are used to avoid
   7907 --- having to double the backslashes.  The skip expression only
   7908 --- catches comments at the start of a line, not after a command.
   7909 --- Also, a word "en" or "if" halfway through a line is considered
   7910 --- a match.
   7911 --- Another example, to search for the matching "{" of a "}": >vim
   7912 ---
   7913 ---   echo searchpair('{', '', '}', 'bW')
   7914 ---
   7915 --- <This works when the cursor is at or before the "}" for which a
   7916 --- match is to be found.  To reject matches that syntax
   7917 --- highlighting recognized as strings: >vim
   7918 ---
   7919 ---   echo searchpair('{', '', '}', 'bW',
   7920 ---        \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"')
   7921 --- <
   7922 ---
   7923 --- @param start string
   7924 --- @param middle string
   7925 --- @param end_ string
   7926 --- @param flags? string
   7927 --- @param skip? string|function
   7928 --- @param stopline? integer
   7929 --- @param timeout? integer
   7930 --- @return integer
   7931 function vim.fn.searchpair(start, middle, end_, flags, skip, stopline, timeout) end
   7932 
   7933 --- Same as |searchpair()|, but returns a |List| with the line and
   7934 --- column position of the match.  The first element of the |List|
   7935 --- is the line number and the second element is the byte index of
   7936 --- the column position of the match.  If no match is found,
   7937 --- returns [0, 0]. >vim
   7938 ---
   7939 ---   let [lnum,col] = searchpairpos('{', '', '}', 'n')
   7940 --- <
   7941 --- See |match-parens| for a bigger and more useful example.
   7942 ---
   7943 --- @param start string
   7944 --- @param middle string
   7945 --- @param end_ string
   7946 --- @param flags? string
   7947 --- @param skip? string|function
   7948 --- @param stopline? integer
   7949 --- @param timeout? integer
   7950 --- @return [integer, integer]
   7951 function vim.fn.searchpairpos(start, middle, end_, flags, skip, stopline, timeout) end
   7952 
   7953 --- Same as |search()|, but returns a |List| with the line and
   7954 --- column position of the match.  The first element of the |List|
   7955 --- is the line number and the second element is the byte index of
   7956 --- the column position of the match.  If no match is found,
   7957 --- returns [0, 0].
   7958 --- Example: >vim
   7959 ---   let [lnum, col] = searchpos('mypattern', 'n')
   7960 ---
   7961 --- <When the 'p' flag is given then there is an extra item with
   7962 --- the sub-pattern match number |search()-sub-match|.  Example: >vim
   7963 ---   let [lnum, col, submatch] = searchpos('\(\l\)\|\(\u\)', 'np')
   7964 --- <In this example "submatch" is 2 when a lowercase letter is
   7965 --- found |/\l|, 3 when an uppercase letter is found |/\u|.
   7966 ---
   7967 --- @param pattern string
   7968 --- @param flags? string
   7969 --- @param stopline? integer
   7970 --- @param timeout? integer
   7971 --- @param skip? string|function
   7972 --- @return any
   7973 function vim.fn.searchpos(pattern, flags, stopline, timeout, skip) end
   7974 
   7975 --- Returns a list of server addresses, or empty if all servers
   7976 --- were stopped. |serverstart()| |serverstop()|
   7977 ---
   7978 --- The optional argument {opts} is a Dict and supports the following items:
   7979 ---
   7980 ---   peer  : If |TRUE|, servers not started by |serverstart()|
   7981 ---           will also be returned. (default: |FALSE|)
   7982 ---           Not supported on Windows yet.
   7983 ---
   7984 --- Example: >vim
   7985 ---   echo serverlist()
   7986 --- <
   7987 ---
   7988 --- @param opts? table
   7989 --- @return string[]
   7990 function vim.fn.serverlist(opts) end
   7991 
   7992 --- Opens a socket or named pipe at {address} and listens for
   7993 --- |RPC| messages. Clients can send |API| commands to the
   7994 --- returned address to control Nvim.
   7995 ---
   7996 --- Returns the address string (which may differ from the
   7997 --- {address} argument, see below).
   7998 ---
   7999 --- - If {address} has a colon (":") it is a TCP/IPv4/IPv6 address
   8000 ---   where the last ":" separates host and port (empty or zero
   8001 ---   assigns a random port).
   8002 --- - Else {address} is the path to a named pipe (except on Windows).
   8003 ---   - If {address} has no slashes ("/") it is treated as the
   8004 ---     "name" part of a generated path in this format: >vim
   8005 ---   stdpath("run").."/{name}.{pid}.{counter}"
   8006 --- <  - If {address} is omitted the name is "nvim". >vim
   8007 ---   echo serverstart()
   8008 --- < >
   8009 ---   => /tmp/nvim.bram/oknANW/nvim.15430.5
   8010 --- <
   8011 --- Example bash command to list all Nvim servers: >bash
   8012 ---   ls ${XDG_RUNTIME_DIR:-${TMPDIR}nvim.${USER}}/*/nvim.*.0
   8013 ---
   8014 --- <Example named pipe: >vim
   8015 ---   if has('win32')
   8016 ---     echo serverstart('\\.\pipe\nvim-pipe-1234')
   8017 ---   else
   8018 ---     echo serverstart('nvim.sock')
   8019 ---   endif
   8020 --- <
   8021 --- Example TCP/IP address: >vim
   8022 ---   echo serverstart('::1:12345')
   8023 --- <
   8024 ---
   8025 --- @param address? string
   8026 --- @return string
   8027 function vim.fn.serverstart(address) end
   8028 
   8029 --- Closes the pipe or socket at {address}.
   8030 --- Returns TRUE if {address} is valid, else FALSE.
   8031 --- If |v:servername| is stopped it is set to the next available
   8032 --- address in |serverlist()|.
   8033 ---
   8034 --- @param address string
   8035 --- @return integer
   8036 function vim.fn.serverstop(address) end
   8037 
   8038 --- Set line {lnum} to {text} in buffer {buf}.  This works like
   8039 --- |setline()| for the specified buffer.
   8040 ---
   8041 --- This function works only for loaded buffers.  First call
   8042 --- |bufload()| if needed.
   8043 ---
   8044 --- To insert lines use |appendbufline()|.
   8045 ---
   8046 --- {text} can be a string to set one line, or a List of strings
   8047 --- to set multiple lines.  If the List extends below the last
   8048 --- line then those lines are added.  If the List is empty then
   8049 --- nothing is changed and zero is returned.
   8050 ---
   8051 --- For the use of {buf}, see |bufname()| above.
   8052 ---
   8053 --- {lnum} is used like with |setline()|.
   8054 --- Use "$" to refer to the last line in buffer {buf}.
   8055 --- When {lnum} is just below the last line the {text} will be
   8056 --- added below the last line.
   8057 --- On success 0 is returned, on failure 1 is returned.
   8058 ---
   8059 --- If {buf} is not a valid buffer or {lnum} is not valid, an
   8060 --- error message is given.
   8061 ---
   8062 --- @param buf integer|string
   8063 --- @param lnum integer
   8064 --- @param text string|string[]
   8065 --- @return integer
   8066 function vim.fn.setbufline(buf, lnum, text) end
   8067 
   8068 --- Set option or local variable {varname} in buffer {buf} to
   8069 --- {val}.
   8070 --- This also works for a global or local window option, but it
   8071 --- doesn't work for a global or local window variable.
   8072 --- For a local window option the global value is unchanged.
   8073 --- For the use of {buf}, see |bufname()| above.
   8074 --- The {varname} argument is a string.
   8075 --- Note that the variable name without "b:" must be used.
   8076 --- Examples: >vim
   8077 ---   call setbufvar(1, "&mod", 1)
   8078 ---   call setbufvar("todo", "myvar", "foobar")
   8079 --- <This function is not available in the |sandbox|.
   8080 ---
   8081 --- @param buf integer|string
   8082 --- @param varname string
   8083 --- @param val any
   8084 --- @return any
   8085 function vim.fn.setbufvar(buf, varname, val) end
   8086 
   8087 --- Specify overrides for cell widths of character ranges.  This
   8088 --- tells Vim how wide characters are when displayed in the
   8089 --- terminal, counted in screen cells.  The values override
   8090 --- 'ambiwidth'.  Example: >vim
   8091 ---    call setcellwidths([
   8092 ---     \ [0x111, 0x111, 1],
   8093 ---     \ [0x2194, 0x2199, 2],
   8094 ---     \ ])
   8095 ---
   8096 --- <The {list} argument is a List of Lists with each three
   8097 --- numbers: [{low}, {high}, {width}].  *E1109* *E1110*
   8098 --- {low} and {high} can be the same, in which case this refers to
   8099 --- one character.  Otherwise it is the range of characters from
   8100 --- {low} to {high} (inclusive).    *E1111* *E1114*
   8101 --- Only characters with value 0x80 and higher can be used.
   8102 ---
   8103 --- {width} must be either 1 or 2, indicating the character width
   8104 --- in screen cells.      *E1112*
   8105 --- An error is given if the argument is invalid, also when a
   8106 --- range overlaps with another.    *E1113*
   8107 ---
   8108 --- If the new value causes 'fillchars' or 'listchars' to become
   8109 --- invalid it is rejected and an error is given.
   8110 ---
   8111 --- To clear the overrides pass an empty {list}: >vim
   8112 ---    call setcellwidths([])
   8113 ---
   8114 --- <You can use the script $VIMRUNTIME/scripts/emoji_list.lua to see
   8115 --- the effect for known emoji characters.  Move the cursor
   8116 --- through the text to check if the cell widths of your terminal
   8117 --- match with what Vim knows about each emoji.  If it doesn't
   8118 --- look right you need to adjust the {list} argument.
   8119 ---
   8120 --- @param list any[]
   8121 --- @return any
   8122 function vim.fn.setcellwidths(list) end
   8123 
   8124 --- Same as |setpos()| but uses the specified column number as the
   8125 --- character index instead of the byte index in the line.
   8126 ---
   8127 --- Example:
   8128 --- With the text "여보세요" in line 8: >vim
   8129 ---   call setcharpos('.', [0, 8, 4, 0])
   8130 --- <positions the cursor on the fourth character '요'. >vim
   8131 ---   call setpos('.', [0, 8, 4, 0])
   8132 --- <positions the cursor on the second character '보'.
   8133 ---
   8134 --- @param expr string
   8135 --- @param list integer[]
   8136 --- @return any
   8137 function vim.fn.setcharpos(expr, list) end
   8138 
   8139 --- Set the current character search information to {dict},
   8140 --- which contains one or more of the following entries:
   8141 ---
   8142 ---     char  character which will be used for a subsequent
   8143 ---     |,| or |;| command; an empty string clears the
   8144 ---     character search
   8145 ---     forward  direction of character search; 1 for forward,
   8146 ---     0 for backward
   8147 ---     until  type of character search; 1 for a |t| or |T|
   8148 ---     character search, 0 for an |f| or |F|
   8149 ---     character search
   8150 ---
   8151 --- This can be useful to save/restore a user's character search
   8152 --- from a script: >vim
   8153 ---   let prevsearch = getcharsearch()
   8154 ---   " Perform a command which clobbers user's search
   8155 ---   call setcharsearch(prevsearch)
   8156 --- <Also see |getcharsearch()|.
   8157 ---
   8158 --- @param dict { char?: string, forward?: 1|0, until?: 1|0 }
   8159 --- @return any
   8160 function vim.fn.setcharsearch(dict) end
   8161 
   8162 --- Set the command line to {str} and set the cursor position to
   8163 --- {pos}.
   8164 --- If {pos} is omitted, the cursor is positioned after the text.
   8165 --- Returns 0 when successful, 1 when not editing the command
   8166 --- line.
   8167 ---
   8168 --- @param str string
   8169 --- @param pos? integer
   8170 --- @return integer
   8171 function vim.fn.setcmdline(str, pos) end
   8172 
   8173 --- Set the cursor position in the command line to byte position
   8174 --- {pos}.  The first position is 1.
   8175 --- Use |getcmdpos()| to obtain the current position.
   8176 --- Only works while editing the command line, thus you must use
   8177 --- |c_CTRL-\_e|, |c_CTRL-R_=| or |c_CTRL-R_CTRL-R| with '='.  For
   8178 --- |c_CTRL-\_e| and |c_CTRL-R_CTRL-R| with '=' the position is
   8179 --- set after the command line is set to the expression.  For
   8180 --- |c_CTRL-R_=| it is set after evaluating the expression but
   8181 --- before inserting the resulting text.
   8182 --- When the number is too big the cursor is put at the end of the
   8183 --- line.  A number smaller than one has undefined results.
   8184 --- Returns 0 when successful, 1 when not editing the command
   8185 --- line.
   8186 ---
   8187 --- @param pos integer
   8188 --- @return any
   8189 function vim.fn.setcmdpos(pos) end
   8190 
   8191 --- @param lnum integer|string
   8192 --- @param col? integer
   8193 --- @param off? integer
   8194 --- @return any
   8195 function vim.fn.setcursorcharpos(lnum, col, off) end
   8196 
   8197 --- Same as |cursor()| but uses the specified column number as the
   8198 --- character index instead of the byte index in the line.
   8199 ---
   8200 --- Example:
   8201 --- With the text "여보세요" in line 4: >vim
   8202 ---   call setcursorcharpos(4, 3)
   8203 --- <positions the cursor on the third character '세'. >vim
   8204 ---   call cursor(4, 3)
   8205 --- <positions the cursor on the first character '여'.
   8206 ---
   8207 --- Returns 0 when the position could be set, -1 otherwise.
   8208 ---
   8209 --- @param list integer[]
   8210 --- @return any
   8211 function vim.fn.setcursorcharpos(list) end
   8212 
   8213 --- Set environment variable {name} to {val}.  Example: >vim
   8214 ---   call setenv('HOME', '/home/myhome')
   8215 ---
   8216 --- <When {val} is |v:null| the environment variable is deleted.
   8217 --- See also |expr-env|.
   8218 ---
   8219 --- @param name string
   8220 --- @param val string
   8221 --- @return any
   8222 function vim.fn.setenv(name, val) end
   8223 
   8224 --- Set the file permissions for {fname} to {mode}.
   8225 --- {mode} must be a string with 9 characters.  It is of the form
   8226 --- "rwxrwxrwx", where each group of "rwx" flags represent, in
   8227 --- turn, the permissions of the owner of the file, the group the
   8228 --- file belongs to, and other users.  A '-' character means the
   8229 --- permission is off, any other character means on.  Multi-byte
   8230 --- characters are not supported.
   8231 ---
   8232 --- For example "rw-r-----" means read-write for the user,
   8233 --- readable by the group, not accessible by others.  "xx-x-----"
   8234 --- would do the same thing.
   8235 ---
   8236 --- Returns non-zero for success, zero for failure.
   8237 ---
   8238 --- To read permissions see |getfperm()|.
   8239 ---
   8240 --- @param fname string
   8241 --- @param mode string
   8242 --- @return any
   8243 function vim.fn.setfperm(fname, mode) end
   8244 
   8245 --- Set line {lnum} of the current buffer to {text}.  To insert
   8246 --- lines use |append()|.  To set lines in another buffer use
   8247 --- |setbufline()|.
   8248 ---
   8249 --- {lnum} is used like with |getline()|.
   8250 --- When {lnum} is just below the last line the {text} will be
   8251 --- added below the last line.
   8252 --- {text} can be any type or a List of any type, each item is
   8253 --- converted to a String.  When {text} is an empty List then
   8254 --- nothing is changed and FALSE is returned.
   8255 ---
   8256 --- If this succeeds, FALSE is returned.  If this fails (most
   8257 --- likely because {lnum} is invalid) TRUE is returned.
   8258 ---
   8259 --- Example: >vim
   8260 ---   call setline(5, strftime("%c"))
   8261 ---
   8262 --- <When {text} is a |List| then line {lnum} and following lines
   8263 --- will be set to the items in the list.  Example: >vim
   8264 ---   call setline(5, ['aaa', 'bbb', 'ccc'])
   8265 --- <This is equivalent to: >vim
   8266 ---   for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']]
   8267 ---     call setline(n, l)
   8268 ---   endfor
   8269 ---
   8270 --- <Note: The '[ and '] marks are not set.
   8271 ---
   8272 --- @param lnum integer|string
   8273 --- @param text any
   8274 --- @return any
   8275 function vim.fn.setline(lnum, text) end
   8276 
   8277 --- Create or replace or add to the location list for window {nr}.
   8278 --- {nr} can be the window number or the |window-ID|.
   8279 --- When {nr} is zero the current window is used.
   8280 ---
   8281 --- For a location list window, the displayed location list is
   8282 --- modified.  For an invalid window number {nr}, -1 is returned.
   8283 --- Otherwise, same as |setqflist()|.
   8284 --- Also see |location-list|.
   8285 ---
   8286 --- For {action} see |setqflist-action|.
   8287 ---
   8288 --- If the optional {what} dictionary argument is supplied, then
   8289 --- only the items listed in {what} are set.  Refer to |setqflist()|
   8290 --- for the list of supported keys in {what}.
   8291 ---
   8292 --- @param nr integer
   8293 --- @param list vim.quickfix.entry[]
   8294 --- @param action? string
   8295 --- @param what? vim.fn.setqflist.what
   8296 --- @return any
   8297 function vim.fn.setloclist(nr, list, action, what) end
   8298 
   8299 --- Restores a list of matches saved by |getmatches()| for the
   8300 --- current window.  Returns 0 if successful, otherwise -1.  All
   8301 --- current matches are cleared before the list is restored.  See
   8302 --- example for |getmatches()|.
   8303 --- If {win} is specified, use the window with this number or
   8304 --- window ID instead of the current window.
   8305 ---
   8306 --- @param list vim.fn.getmatches.ret.item[]
   8307 --- @param win? integer
   8308 --- @return any
   8309 function vim.fn.setmatches(list, win) end
   8310 
   8311 --- Set the position for String {expr}.  Possible values:
   8312 ---   .  the cursor
   8313 ---   'x  mark x
   8314 ---
   8315 --- {list} must be a |List| with four or five numbers:
   8316 ---     [bufnum, lnum, col, off]
   8317 ---     [bufnum, lnum, col, off, curswant]
   8318 ---
   8319 --- "bufnum" is the buffer number.  Zero can be used for the
   8320 --- current buffer.  When setting an uppercase mark "bufnum" is
   8321 --- used for the mark position.  For other marks it specifies the
   8322 --- buffer to set the mark in.  You can use the |bufnr()| function
   8323 --- to turn a file name into a buffer number.
   8324 --- For setting the cursor and the ' mark "bufnum" is ignored,
   8325 --- since these are associated with a window, not a buffer.
   8326 --- Does not change the jumplist.
   8327 ---
   8328 --- "lnum" and "col" are the position in the buffer.  The first
   8329 --- column is 1.  Use a zero "lnum" to delete a mark.  If "col" is
   8330 --- smaller than 1 then 1 is used.  To use the character count
   8331 --- instead of the byte count, use |setcharpos()|.
   8332 ---
   8333 --- The "off" number is only used when 'virtualedit' is set.  Then
   8334 --- it is the offset in screen columns from the start of the
   8335 --- character.  E.g., a position within a <Tab> or after the last
   8336 --- character.
   8337 ---
   8338 --- The "curswant" number is only used when setting the cursor
   8339 --- position.  It sets the preferred column for when moving the
   8340 --- cursor vertically.  When the "curswant" number is missing the
   8341 --- preferred column is not set.  When it is present and setting a
   8342 --- mark position it is not used.
   8343 ---
   8344 --- Note that for |'<| and |'>| changing the line number may
   8345 --- result in the marks to be effectively swapped, so that |'<| is
   8346 --- always before |'>|.
   8347 ---
   8348 --- The visual marks |'<| and |'>| refer to the beginning and end
   8349 --- of the visual selection relative to the cursor position.
   8350 --- Note that this differs from |getpos()|, where they are
   8351 --- relative to the buffer.
   8352 ---
   8353 --- Returns 0 when the position could be set, -1 otherwise.
   8354 --- An error message is given if {expr} is invalid.
   8355 ---
   8356 --- Also see |setcharpos()|, |getpos()| and |getcurpos()|.
   8357 ---
   8358 --- This does not restore the preferred column for moving
   8359 --- vertically; if you set the cursor position with this, |j| and
   8360 --- |k| motions will jump to previous columns!  Use |cursor()| to
   8361 --- also set the preferred column.  Also see the "curswant" key in
   8362 --- |winrestview()|.
   8363 ---
   8364 --- @param expr string
   8365 --- @param list integer[]
   8366 --- @return any
   8367 function vim.fn.setpos(expr, list) end
   8368 
   8369 --- Create or replace or add to the quickfix list.
   8370 ---
   8371 --- If the optional {what} dictionary argument is supplied, then
   8372 --- only the items listed in {what} are set.  The first {list}
   8373 --- argument is ignored.  See below for the supported items in
   8374 --- {what}.
   8375 ---           *setqflist-what*
   8376 --- When {what} is not present, the items in {list} are used.
   8377 --- Each item must be a dictionary.  Non-dictionary items in
   8378 --- {list} are ignored.  Each dictionary item can contain the
   8379 --- following entries:
   8380 ---
   8381 ---     bufnr  buffer number; must be the number of a valid
   8382 ---     buffer
   8383 ---     filename  name of a file; only used when "bufnr" is not
   8384 ---     present or it is invalid.
   8385 ---     module  name of a module; if given it will be used in
   8386 ---     quickfix error window instead of the filename.
   8387 ---     lnum  line number in the file
   8388 ---     end_lnum  end of lines, if the item spans multiple lines
   8389 ---     pattern  search pattern used to locate the error
   8390 ---     col    column number
   8391 ---     vcol  when non-zero: "col" is visual column
   8392 ---     when zero: "col" is byte index
   8393 ---     end_col  end column, if the item spans multiple columns
   8394 ---     nr    error number
   8395 ---     text  description of the error
   8396 ---     type  single-character error type, 'E', 'W', etc.
   8397 ---     valid  recognized error message
   8398 ---     user_data
   8399 ---     custom data associated with the item, can be
   8400 ---     any type.
   8401 ---
   8402 --- The "col", "vcol", "nr", "type" and "text" entries are
   8403 --- optional.  Either "lnum" or "pattern" entry can be used to
   8404 --- locate a matching error line.
   8405 --- If the "filename" and "bufnr" entries are not present or
   8406 --- neither the "lnum" or "pattern" entries are present, then the
   8407 --- item will not be handled as an error line.
   8408 --- If both "pattern" and "lnum" are present then "pattern" will
   8409 --- be used.
   8410 --- If the "valid" entry is not supplied, then the valid flag is
   8411 --- set when "bufnr" is a valid buffer or "filename" exists.
   8412 --- If you supply an empty {list}, the quickfix list will be
   8413 --- cleared.
   8414 --- Note that the list is not exactly the same as what
   8415 --- |getqflist()| returns.
   8416 ---
   8417 --- {action} values:    *setqflist-action* *E927*
   8418 --- 'a'  The items from {list} are added to the existing
   8419 ---   quickfix list.  If there is no existing list, then a
   8420 ---   new list is created.
   8421 ---
   8422 --- 'r'  The items from the current quickfix list are replaced
   8423 ---   with the items from {list}.  This can also be used to
   8424 ---   clear the list: >vim
   8425 ---     call setqflist([], 'r')
   8426 --- <
   8427 --- 'u'  Like 'r', but tries to preserve the current selection
   8428 ---   in the quickfix list.
   8429 --- 'f'  All the quickfix lists in the quickfix stack are
   8430 ---   freed.
   8431 ---
   8432 --- If {action} is not present or is set to ' ', then a new list
   8433 --- is created.  The new quickfix list is added after the current
   8434 --- quickfix list in the stack and all the following lists are
   8435 --- freed.  To add a new quickfix list at the end of the stack,
   8436 --- set "nr" in {what} to "$".
   8437 ---
   8438 --- The following items can be specified in dictionary {what}:
   8439 ---     context  quickfix list context.  See |quickfix-context|
   8440 ---     efm    errorformat to use when parsing text from
   8441 ---     "lines".  If this is not present, then the
   8442 ---     'errorformat' option value is used.
   8443 ---     See |quickfix-parse|
   8444 ---     id    quickfix list identifier |quickfix-ID|
   8445 ---     idx    index of the current entry in the quickfix
   8446 ---     list specified by "id" or "nr".  If set to
   8447 ---     '$', then the last entry in the list is set as
   8448 ---     the current entry.  See |quickfix-index|
   8449 ---     items  list of quickfix entries.  Same as the {list}
   8450 ---     argument.
   8451 ---     lines  use 'errorformat' to parse a list of lines and
   8452 ---     add the resulting entries to the quickfix list
   8453 ---     {nr} or {id}.  Only a |List| value is supported.
   8454 ---     See |quickfix-parse|
   8455 ---     nr    list number in the quickfix stack; zero
   8456 ---     means the current quickfix list and "$" means
   8457 ---     the last quickfix list.
   8458 ---     quickfixtextfunc
   8459 ---     function to get the text to display in the
   8460 ---     quickfix window.  The value can be the name of
   8461 ---     a function or a funcref or a lambda.  Refer to
   8462 ---     |quickfix-window-function| for an explanation
   8463 ---     of how to write the function and an example.
   8464 ---     title  quickfix list title text.  See |quickfix-title|
   8465 --- Unsupported keys in {what} are ignored.
   8466 --- If the "nr" item is not present, then the current quickfix
   8467 --- list is modified.  When creating a new quickfix list, "nr" can
   8468 --- be set to a value one greater than the quickfix stack size.
   8469 --- When modifying a quickfix list, to guarantee that the correct
   8470 --- list is modified, "id" should be used instead of "nr" to
   8471 --- specify the list.
   8472 ---
   8473 --- Examples (See also |setqflist-examples|): >vim
   8474 ---    call setqflist([], 'r', {'title': 'My search'})
   8475 ---    call setqflist([], 'r', {'nr': 2, 'title': 'Errors'})
   8476 ---    call setqflist([], 'a', {'id':qfid, 'lines':["F1:10:L10"]})
   8477 --- <
   8478 --- Returns zero for success, -1 for failure.
   8479 ---
   8480 --- This function can be used to create a quickfix list
   8481 --- independent of the 'errorformat' setting.  Use a command like
   8482 --- `:cc 1` to jump to the first position.
   8483 ---
   8484 --- @param list vim.quickfix.entry[]
   8485 --- @param action? string
   8486 --- @param what? vim.fn.setqflist.what
   8487 --- @return integer
   8488 function vim.fn.setqflist(list, action, what) end
   8489 
   8490 --- Set the register {regname} to {value}.
   8491 --- If {regname} is "" or "\@", the unnamed register '"' is used.
   8492 --- The {regname} argument is a string.
   8493 ---
   8494 --- {value} may be any value returned by |getreg()| or
   8495 --- |getreginfo()|, including a |List| or |Dict|.
   8496 --- If {options} contains "a" or {regname} is upper case,
   8497 --- then the value is appended.
   8498 ---
   8499 --- {options} can also contain a register type specification:
   8500 ---     "c" or "v"        |charwise| mode
   8501 ---     "l" or "V"        |linewise| mode
   8502 ---     "b" or "<CTRL-V>" |blockwise-visual| mode
   8503 --- If a number immediately follows "b" or "<CTRL-V>" then this is
   8504 --- used as the width of the selection - if it is not specified
   8505 --- then the width of the block is set to the number of characters
   8506 --- in the longest line (counting a <Tab> as 1 character).
   8507 --- If {options} contains "u" or '"', then the unnamed register is
   8508 --- set to point to register {regname}.
   8509 ---
   8510 --- If {options} contains no register settings, then the default
   8511 --- is to use character mode unless {value} ends in a <NL> for
   8512 --- string {value} and linewise mode for list {value}.  Blockwise
   8513 --- mode is never selected automatically.
   8514 --- Returns zero for success, non-zero for failure.
   8515 ---
   8516 ---           *E883*
   8517 --- Note: you may not use |List| containing more than one item to
   8518 ---       set search and expression registers.  Lists containing
   8519 ---       no items act like empty strings.
   8520 ---
   8521 --- Examples: >vim
   8522 ---   call setreg(v:register, \@*)
   8523 ---   call setreg('*', \@%, 'ac')
   8524 ---   call setreg('a', "1\n2\n3", 'b5')
   8525 ---   call setreg('"', { 'points_to': 'a'})
   8526 ---
   8527 --- <This example shows using the functions to save and restore a
   8528 --- register: >vim
   8529 ---   let var_a = getreginfo()
   8530 ---   call setreg('a', var_a)
   8531 --- <or: >vim
   8532 ---   let var_a = getreg('a', 1, 1)
   8533 ---   let var_amode = getregtype('a')
   8534 ---   " ....
   8535 ---   call setreg('a', var_a, var_amode)
   8536 --- <Note: you may not reliably restore register value
   8537 --- without using the third argument to |getreg()| as without it
   8538 --- newlines are represented as newlines AND Nul bytes are
   8539 --- represented as newlines as well, see |NL-used-for-Nul|.
   8540 ---
   8541 --- You can also change the type of a register by appending
   8542 --- nothing: >vim
   8543 ---   call setreg('a', '', 'al')
   8544 --- <
   8545 ---
   8546 --- @param regname string
   8547 --- @param value any
   8548 --- @param options? string
   8549 --- @return any
   8550 function vim.fn.setreg(regname, value, options) end
   8551 
   8552 --- Set tab-local variable {varname} to {val} in tab page {tabnr}.
   8553 --- |t:var|
   8554 --- The {varname} argument is a string.
   8555 --- Note that the variable name without "t:" must be used.
   8556 --- Tabs are numbered starting with one.
   8557 --- This function is not available in the |sandbox|.
   8558 ---
   8559 --- @param tabnr integer
   8560 --- @param varname string
   8561 --- @param val any
   8562 --- @return any
   8563 function vim.fn.settabvar(tabnr, varname, val) end
   8564 
   8565 --- Set option or local variable {varname} in window {winnr} to
   8566 --- {val}.
   8567 --- Tabs are numbered starting with one.  For the current tabpage
   8568 --- use |setwinvar()|.
   8569 --- {winnr} can be the window number or the |window-ID|.
   8570 --- When {winnr} is zero the current window is used.
   8571 --- This also works for a global or local buffer option, but it
   8572 --- doesn't work for a global or local buffer variable.
   8573 --- For a local buffer option the global value is unchanged.
   8574 --- Note that the variable name without "w:" must be used.
   8575 --- Examples: >vim
   8576 ---   call settabwinvar(1, 1, "&list", 0)
   8577 ---   call settabwinvar(3, 2, "myvar", "foobar")
   8578 --- <This function is not available in the |sandbox|.
   8579 ---
   8580 --- @param tabnr integer
   8581 --- @param winnr integer
   8582 --- @param varname string
   8583 --- @param val any
   8584 --- @return any
   8585 function vim.fn.settabwinvar(tabnr, winnr, varname, val) end
   8586 
   8587 --- Modify the tag stack of the window {nr} using {dict}.
   8588 --- {nr} can be the window number or the |window-ID|.
   8589 ---
   8590 --- For a list of supported items in {dict}, refer to
   8591 --- |gettagstack()|.  "curidx" takes effect before changing the tag
   8592 --- stack.
   8593 ---           *E962*
   8594 --- How the tag stack is modified depends on the {action}
   8595 --- argument:
   8596 --- - If {action} is not present or is set to 'r', then the tag
   8597 ---   stack is replaced.
   8598 --- - If {action} is set to 'a', then new entries from {dict} are
   8599 ---   pushed (added) onto the tag stack.
   8600 --- - If {action} is set to 't', then all the entries from the
   8601 ---   current entry in the tag stack or "curidx" in {dict} are
   8602 ---   removed and then new entries are pushed to the stack.
   8603 ---
   8604 --- The current index is set to one after the length of the tag
   8605 --- stack after the modification.
   8606 ---
   8607 --- Returns zero for success, -1 for failure.
   8608 ---
   8609 --- Examples (for more examples see |tagstack-examples|):
   8610 ---     Empty the tag stack of window 3: >vim
   8611 ---   call settagstack(3, {'items' : []})
   8612 ---
   8613 --- <    Save and restore the tag stack: >vim
   8614 ---   let stack = gettagstack(1003)
   8615 ---   " do something else
   8616 ---   call settagstack(1003, stack)
   8617 ---   unlet stack
   8618 --- <
   8619 ---
   8620 --- @param nr integer
   8621 --- @param dict any
   8622 --- @param action? string
   8623 --- @return any
   8624 function vim.fn.settagstack(nr, dict, action) end
   8625 
   8626 --- Like |settabwinvar()| for the current tab page.
   8627 --- Examples: >vim
   8628 ---   call setwinvar(1, "&list", 0)
   8629 ---   call setwinvar(2, "myvar", "foobar")
   8630 --- <
   8631 ---
   8632 --- @param nr integer
   8633 --- @param varname string
   8634 --- @param val any
   8635 --- @return any
   8636 function vim.fn.setwinvar(nr, varname, val) end
   8637 
   8638 --- Returns a String with 64 hex characters, which is the SHA256
   8639 --- checksum of {expr}.
   8640 --- {expr} is a String or a Blob.
   8641 ---
   8642 --- @param expr string
   8643 --- @return string
   8644 function vim.fn.sha256(expr) end
   8645 
   8646 --- Escape {string} for use as a shell command argument.
   8647 ---
   8648 --- On Windows when 'shellslash' is not set, encloses {string} in
   8649 --- double-quotes and doubles all double-quotes within {string}.
   8650 --- Otherwise encloses {string} in single-quotes and replaces all
   8651 --- "'" with "'\''".
   8652 ---
   8653 --- The {special} argument adds additional escaping of keywords
   8654 --- used in Vim commands. If it is a |non-zero-arg|:
   8655 --- - Special items such as "!", "%", "#" and "<cword>" (as listed
   8656 ---   in |expand()|) will be preceded by a backslash.
   8657 ---   The backslash will be removed again by the |:!| command.
   8658 --- - The <NL> character is escaped.
   8659 ---
   8660 --- If 'shell' contains "csh" in the tail:
   8661 --- - The "!" character will be escaped. This is because csh and
   8662 ---   tcsh use "!" for history replacement even in single-quotes.
   8663 --- - The <NL> character is escaped (twice if {special} is
   8664 ---   a |non-zero-arg|).
   8665 ---
   8666 --- If 'shell' contains "fish" in the tail, the "\" character will
   8667 --- be escaped because in fish it is used as an escape character
   8668 --- inside single quotes.
   8669 ---
   8670 --- Example of use with a |:!| command: >vim
   8671 ---     exe '!dir ' .. shellescape(expand('<cfile>'), 1)
   8672 --- <This results in a directory listing for the file under the
   8673 --- cursor.  Example of use with |system()|: >vim
   8674 ---     call system("chmod +w -- " .. shellescape(expand("%")))
   8675 --- <See also |::S|.
   8676 ---
   8677 --- @param string string
   8678 --- @param special? boolean
   8679 --- @return string
   8680 function vim.fn.shellescape(string, special) end
   8681 
   8682 --- Returns the effective value of 'shiftwidth'.  This is the
   8683 --- 'shiftwidth' value unless it is zero, in which case it is the
   8684 --- 'tabstop' value.  To be backwards compatible in indent
   8685 --- plugins, use this: >vim
   8686 ---   if exists('*shiftwidth')
   8687 ---     func s:sw()
   8688 ---       return shiftwidth()
   8689 ---     endfunc
   8690 ---   else
   8691 ---     func s:sw()
   8692 ---       return &sw
   8693 ---     endfunc
   8694 ---   endif
   8695 --- <And then use s:sw() instead of &sw.
   8696 ---
   8697 --- for which to return the 'shiftwidth' value.  This matters for
   8698 --- the 'vartabstop' feature.  If the 'vartabstop' setting is
   8699 --- enabled and no {col} argument is given, column 1 will be
   8700 --- assumed.
   8701 ---
   8702 --- @param col? integer
   8703 --- @return integer
   8704 function vim.fn.shiftwidth(col) end
   8705 
   8706 --- @param name string
   8707 --- @param dict? vim.fn.sign_define.dict
   8708 --- @return 0|-1
   8709 function vim.fn.sign_define(name, dict) end
   8710 
   8711 --- Define a new sign named {name} or modify the attributes of an
   8712 --- existing sign.  This is similar to the |:sign-define| command.
   8713 ---
   8714 --- Prefix {name} with a unique text to avoid name collisions.
   8715 --- There is no {group} like with placing signs.
   8716 ---
   8717 --- The {name} can be a String or a Number.  The optional {dict}
   8718 --- argument specifies the sign attributes.  The following values
   8719 --- are supported:
   8720 ---    icon    full path to the bitmap file for the sign.
   8721 ---    linehl  highlight group used for the whole line the
   8722 ---     sign is placed in.
   8723 ---    priority  default priority value of the sign
   8724 ---    numhl  highlight group used for the line number where
   8725 ---     the sign is placed.
   8726 ---    text    text that is displayed when there is no icon
   8727 ---     or the GUI is not being used.
   8728 ---    texthl  highlight group used for the text item
   8729 ---    culhl  highlight group used for the text item when
   8730 ---     the cursor is on the same line as the sign and
   8731 ---     'cursorline' is enabled.
   8732 ---
   8733 --- If the sign named {name} already exists, then the attributes
   8734 --- of the sign are updated.
   8735 ---
   8736 --- The one argument {list} can be used to define a list of signs.
   8737 --- Each list item is a dictionary with the above items in {dict}
   8738 --- and a "name" item for the sign name.
   8739 ---
   8740 --- Returns 0 on success and -1 on failure.  When the one argument
   8741 --- {list} is used, then returns a List of values one for each
   8742 --- defined sign.
   8743 ---
   8744 --- Examples: >vim
   8745 ---   call sign_define("mySign", {
   8746 ---     \ "text" : "=>",
   8747 ---     \ "texthl" : "Error",
   8748 ---     \ "linehl" : "Search"})
   8749 ---   call sign_define([
   8750 ---     \ {'name' : 'sign1',
   8751 ---     \  'text' : '=>'},
   8752 ---     \ {'name' : 'sign2',
   8753 ---     \  'text' : '!!'}
   8754 ---     \ ])
   8755 --- <
   8756 ---
   8757 --- @param list vim.fn.sign_define.dict[]
   8758 --- @return (0|-1)[]
   8759 function vim.fn.sign_define(list) end
   8760 
   8761 --- Get a list of defined signs and their attributes.
   8762 --- This is similar to the |:sign-list| command.
   8763 ---
   8764 --- If the {name} is not supplied, then a list of all the defined
   8765 --- signs is returned.  Otherwise the attribute of the specified
   8766 --- sign is returned.
   8767 ---
   8768 --- Each list item in the returned value is a dictionary with the
   8769 --- following entries:
   8770 ---    icon    full path to the bitmap file of the sign
   8771 ---    linehl  highlight group used for the whole line the
   8772 ---     sign is placed in; not present if not set.
   8773 ---    name    name of the sign
   8774 ---    priority  default priority value of the sign
   8775 ---    numhl  highlight group used for the line number where
   8776 ---     the sign is placed; not present if not set.
   8777 ---    text    text that is displayed when there is no icon
   8778 ---     or the GUI is not being used.
   8779 ---    texthl  highlight group used for the text item; not
   8780 ---     present if not set.
   8781 ---    culhl  highlight group used for the text item when
   8782 ---     the cursor is on the same line as the sign and
   8783 ---     'cursorline' is enabled; not present if not
   8784 ---     set.
   8785 ---
   8786 --- Returns an empty List if there are no signs and when {name} is
   8787 --- not found.
   8788 ---
   8789 --- Examples: >vim
   8790 ---   " Get a list of all the defined signs
   8791 ---   echo sign_getdefined()
   8792 ---
   8793 ---   " Get the attribute of the sign named mySign
   8794 ---   echo sign_getdefined("mySign")
   8795 --- <
   8796 ---
   8797 --- @param name? string
   8798 --- @return vim.fn.sign_getdefined.ret.item[]
   8799 function vim.fn.sign_getdefined(name) end
   8800 
   8801 --- Return a list of signs placed in a buffer or all the buffers.
   8802 --- This is similar to the |:sign-place-list| command.
   8803 ---
   8804 --- If the optional buffer name {buf} is specified, then only the
   8805 --- list of signs placed in that buffer is returned.  For the use
   8806 --- of {buf}, see |bufname()|.  The optional {dict} can contain
   8807 --- the following entries:
   8808 ---    group  select only signs in this group
   8809 ---    id    select sign with this identifier
   8810 ---    lnum    select signs placed in this line.  For the use
   8811 ---     of {lnum}, see |line()|.
   8812 --- If {group} is "*", then signs in all the groups including the
   8813 --- global group are returned.  If {group} is not supplied or is
   8814 --- an empty string, then only signs in the global group are
   8815 --- returned.  If no arguments are supplied, then signs in the
   8816 --- global group placed in all the buffers are returned.
   8817 --- See |sign-group|.
   8818 ---
   8819 --- Each list item in the returned value is a dictionary with the
   8820 --- following entries:
   8821 ---   bufnr  number of the buffer with the sign
   8822 ---   signs  list of signs placed in {bufnr}.  Each list
   8823 ---     item is a dictionary with the below listed
   8824 ---     entries
   8825 ---
   8826 --- The dictionary for each sign contains the following entries:
   8827 ---   group   sign group.  Set to '' for the global group.
   8828 ---   id   identifier of the sign
   8829 ---   lnum   line number where the sign is placed
   8830 ---   name   name of the defined sign
   8831 ---   priority sign priority
   8832 ---
   8833 --- The returned signs in a buffer are ordered by their line
   8834 --- number and priority.
   8835 ---
   8836 --- Returns an empty list on failure or if there are no placed
   8837 --- signs.
   8838 ---
   8839 --- Examples: >vim
   8840 ---   " Get a List of signs placed in eval.c in the
   8841 ---   " global group
   8842 ---   echo sign_getplaced("eval.c")
   8843 ---
   8844 ---   " Get a List of signs in group 'g1' placed in eval.c
   8845 ---   echo sign_getplaced("eval.c", {'group' : 'g1'})
   8846 ---
   8847 ---   " Get a List of signs placed at line 10 in eval.c
   8848 ---   echo sign_getplaced("eval.c", {'lnum' : 10})
   8849 ---
   8850 ---   " Get sign with identifier 10 placed in a.py
   8851 ---   echo sign_getplaced("a.py", {'id' : 10})
   8852 ---
   8853 ---   " Get sign with id 20 in group 'g1' placed in a.py
   8854 ---   echo sign_getplaced("a.py", {'group' : 'g1',
   8855 ---           \  'id' : 20})
   8856 ---
   8857 ---   " Get a List of all the placed signs
   8858 ---   echo sign_getplaced()
   8859 --- <
   8860 ---
   8861 --- @param buf? integer|string
   8862 --- @param dict? vim.fn.sign_getplaced.dict
   8863 --- @return vim.fn.sign_getplaced.ret.item[]
   8864 function vim.fn.sign_getplaced(buf, dict) end
   8865 
   8866 --- Open the buffer {buf} or jump to the window that contains
   8867 --- {buf} and position the cursor at sign {id} in group {group}.
   8868 --- This is similar to the |:sign-jump| command.
   8869 ---
   8870 --- If {group} is an empty string, then the global group is used.
   8871 --- For the use of {buf}, see |bufname()|.
   8872 ---
   8873 --- Returns the line number of the sign.  Returns -1 if the
   8874 --- arguments are invalid.
   8875 ---
   8876 --- Example: >vim
   8877 ---   " Jump to sign 10 in the current buffer
   8878 ---   call sign_jump(10, '', '')
   8879 --- <
   8880 ---
   8881 --- @param id integer
   8882 --- @param group string
   8883 --- @param buf integer|string
   8884 --- @return integer
   8885 function vim.fn.sign_jump(id, group, buf) end
   8886 
   8887 --- Place the sign defined as {name} at line {lnum} in file or
   8888 --- buffer {buf} and assign {id} and {group} to sign.  This is
   8889 --- similar to the |:sign-place| command.
   8890 ---
   8891 --- If the sign identifier {id} is zero, then a new identifier is
   8892 --- allocated.  Otherwise the specified number is used.  {group}
   8893 --- is the sign group name.  To use the global sign group, use an
   8894 --- empty string.  {group} functions as a namespace for {id}, thus
   8895 --- two groups can use the same IDs.  Refer to |sign-identifier|
   8896 --- and |sign-group| for more information.
   8897 ---
   8898 --- {name} refers to a defined sign.
   8899 --- {buf} refers to a buffer name or number.  For the accepted
   8900 --- values, see |bufname()|.
   8901 ---
   8902 --- The optional {dict} argument supports the following entries:
   8903 ---   lnum    line number in the file or buffer
   8904 ---       {buf} where the sign is to be placed.
   8905 ---       For the accepted values, see |line()|.
   8906 ---   priority  priority of the sign.  See
   8907 ---       |sign-priority| for more information.
   8908 ---
   8909 --- If the optional {dict} is not specified, then it modifies the
   8910 --- placed sign {id} in group {group} to use the defined sign
   8911 --- {name}.
   8912 ---
   8913 --- Returns the sign identifier on success and -1 on failure.
   8914 ---
   8915 --- Examples: >vim
   8916 ---   " Place a sign named sign1 with id 5 at line 20 in
   8917 ---   " buffer json.c
   8918 ---   call sign_place(5, '', 'sign1', 'json.c',
   8919 ---           \ {'lnum' : 20})
   8920 ---
   8921 ---   " Updates sign 5 in buffer json.c to use sign2
   8922 ---   call sign_place(5, '', 'sign2', 'json.c')
   8923 ---
   8924 ---   " Place a sign named sign3 at line 30 in
   8925 ---   " buffer json.c with a new identifier
   8926 ---   let id = sign_place(0, '', 'sign3', 'json.c',
   8927 ---           \ {'lnum' : 30})
   8928 ---
   8929 ---   " Place a sign named sign4 with id 10 in group 'g3'
   8930 ---   " at line 40 in buffer json.c with priority 90
   8931 ---   call sign_place(10, 'g3', 'sign4', 'json.c',
   8932 ---       \ {'lnum' : 40, 'priority' : 90})
   8933 --- <
   8934 ---
   8935 --- @param id integer
   8936 --- @param group string
   8937 --- @param name string
   8938 --- @param buf integer|string
   8939 --- @param dict? vim.fn.sign_place.dict
   8940 --- @return integer
   8941 function vim.fn.sign_place(id, group, name, buf, dict) end
   8942 
   8943 --- Place one or more signs.  This is similar to the
   8944 --- |sign_place()| function.  The {list} argument specifies the
   8945 --- List of signs to place.  Each list item is a dict with the
   8946 --- following sign attributes:
   8947 ---     buffer  Buffer name or number.  For the accepted
   8948 ---     values, see |bufname()|.
   8949 ---     group  Sign group.  {group} functions as a namespace
   8950 ---     for {id}, thus two groups can use the same
   8951 ---     IDs.  If not specified or set to an empty
   8952 ---     string, then the global group is used.   See
   8953 ---     |sign-group| for more information.
   8954 ---     id    Sign identifier.  If not specified or zero,
   8955 ---     then a new unique identifier is allocated.
   8956 ---     Otherwise the specified number is used.  See
   8957 ---     |sign-identifier| for more information.
   8958 ---     lnum  Line number in the buffer where the sign is to
   8959 ---     be placed.  For the accepted values, see
   8960 ---     |line()|.
   8961 ---     name  Name of the sign to place.  See |sign_define()|
   8962 ---     for more information.
   8963 ---     priority  Priority of the sign.  When multiple signs are
   8964 ---     placed on a line, the sign with the highest
   8965 ---     priority is used.  If not specified, the
   8966 ---     default value of 10 is used, unless specified
   8967 ---     otherwise by the sign definition.  See
   8968 ---     |sign-priority| for more information.
   8969 ---
   8970 --- If {id} refers to an existing sign, then the existing sign is
   8971 --- modified to use the specified {name} and/or {priority}.
   8972 ---
   8973 --- Returns a List of sign identifiers.  If failed to place a
   8974 --- sign, the corresponding list item is set to -1.
   8975 ---
   8976 --- Examples: >vim
   8977 ---   " Place sign s1 with id 5 at line 20 and id 10 at line
   8978 ---   " 30 in buffer a.c
   8979 ---   let [n1, n2] = sign_placelist([
   8980 ---     \ {'id' : 5,
   8981 ---     \  'name' : 's1',
   8982 ---     \  'buffer' : 'a.c',
   8983 ---     \  'lnum' : 20},
   8984 ---     \ {'id' : 10,
   8985 ---     \  'name' : 's1',
   8986 ---     \  'buffer' : 'a.c',
   8987 ---     \  'lnum' : 30}
   8988 ---     \ ])
   8989 ---
   8990 ---   " Place sign s1 in buffer a.c at line 40 and 50
   8991 ---   " with auto-generated identifiers
   8992 ---   let [n1, n2] = sign_placelist([
   8993 ---     \ {'name' : 's1',
   8994 ---     \  'buffer' : 'a.c',
   8995 ---     \  'lnum' : 40},
   8996 ---     \ {'name' : 's1',
   8997 ---     \  'buffer' : 'a.c',
   8998 ---     \  'lnum' : 50}
   8999 ---     \ ])
   9000 --- <
   9001 ---
   9002 --- @param list vim.fn.sign_placelist.list.item[]
   9003 --- @return integer[]
   9004 function vim.fn.sign_placelist(list) end
   9005 
   9006 --- @param name? string
   9007 --- @return 0|-1
   9008 function vim.fn.sign_undefine(name) end
   9009 
   9010 --- Deletes a previously defined sign {name}.  This is similar to
   9011 --- the |:sign-undefine| command.  If {name} is not supplied, then
   9012 --- deletes all the defined signs.
   9013 ---
   9014 --- The one argument {list} can be used to undefine a list of
   9015 --- signs.  Each list item is the name of a sign.
   9016 ---
   9017 --- Returns 0 on success and -1 on failure.  For the one argument
   9018 --- {list} call, returns a list of values one for each undefined
   9019 --- sign.
   9020 ---
   9021 --- Examples: >vim
   9022 ---   " Delete a sign named mySign
   9023 ---   call sign_undefine("mySign")
   9024 ---
   9025 ---   " Delete signs 'sign1' and 'sign2'
   9026 ---   call sign_undefine(["sign1", "sign2"])
   9027 ---
   9028 ---   " Delete all the signs
   9029 ---   call sign_undefine()
   9030 --- <
   9031 ---
   9032 --- @param list? string[]
   9033 --- @return integer[]
   9034 function vim.fn.sign_undefine(list) end
   9035 
   9036 --- Remove a previously placed sign in one or more buffers.  This
   9037 --- is similar to the |:sign-unplace| command.
   9038 ---
   9039 --- {group} is the sign group name.  To use the global sign group,
   9040 --- use an empty string.  If {group} is set to "*", then all the
   9041 --- groups including the global group are used.
   9042 --- The signs in {group} are selected based on the entries in
   9043 --- {dict}.  The following optional entries in {dict} are
   9044 --- supported:
   9045 ---   buffer  buffer name or number.  See |bufname()|.
   9046 ---   id  sign identifier
   9047 --- If {dict} is not supplied, then all the signs in {group} are
   9048 --- removed.
   9049 ---
   9050 --- Returns 0 on success and -1 on failure.
   9051 ---
   9052 --- Examples: >vim
   9053 ---   " Remove sign 10 from buffer a.vim
   9054 ---   call sign_unplace('', {'buffer' : "a.vim", 'id' : 10})
   9055 ---
   9056 ---   " Remove sign 20 in group 'g1' from buffer 3
   9057 ---   call sign_unplace('g1', {'buffer' : 3, 'id' : 20})
   9058 ---
   9059 ---   " Remove all the signs in group 'g2' from buffer 10
   9060 ---   call sign_unplace('g2', {'buffer' : 10})
   9061 ---
   9062 ---   " Remove sign 30 in group 'g3' from all the buffers
   9063 ---   call sign_unplace('g3', {'id' : 30})
   9064 ---
   9065 ---   " Remove all the signs placed in buffer 5
   9066 ---   call sign_unplace('*', {'buffer' : 5})
   9067 ---
   9068 ---   " Remove the signs in group 'g4' from all the buffers
   9069 ---   call sign_unplace('g4')
   9070 ---
   9071 ---   " Remove sign 40 from all the buffers
   9072 ---   call sign_unplace('*', {'id' : 40})
   9073 ---
   9074 ---   " Remove all the placed signs from all the buffers
   9075 ---   call sign_unplace('*')
   9076 --- <
   9077 ---
   9078 --- @param group string
   9079 --- @param dict? vim.fn.sign_unplace.dict
   9080 --- @return 0|-1
   9081 function vim.fn.sign_unplace(group, dict) end
   9082 
   9083 --- Remove previously placed signs from one or more buffers.  This
   9084 --- is similar to the |sign_unplace()| function.
   9085 ---
   9086 --- The {list} argument specifies the List of signs to remove.
   9087 --- Each list item is a dict with the following sign attributes:
   9088 ---     buffer  buffer name or number.  For the accepted
   9089 ---     values, see |bufname()|.  If not specified,
   9090 ---     then the specified sign is removed from all
   9091 ---     the buffers.
   9092 ---     group  sign group name.  If not specified or set to an
   9093 ---     empty string, then the global sign group is
   9094 ---     used.  If set to "*", then all the groups
   9095 ---     including the global group are used.
   9096 ---     id    sign identifier.  If not specified, then all
   9097 ---     the signs in the specified group are removed.
   9098 ---
   9099 --- Returns a List where an entry is set to 0 if the corresponding
   9100 --- sign was successfully removed or -1 on failure.
   9101 ---
   9102 --- Example: >vim
   9103 ---   " Remove sign with id 10 from buffer a.vim and sign
   9104 ---   " with id 20 from buffer b.vim
   9105 ---   call sign_unplacelist([
   9106 ---     \ {'id' : 10, 'buffer' : "a.vim"},
   9107 ---     \ {'id' : 20, 'buffer' : 'b.vim'},
   9108 ---     \ ])
   9109 --- <
   9110 ---
   9111 --- @param list vim.fn.sign_unplacelist.list.item
   9112 --- @return (0|-1)[]
   9113 function vim.fn.sign_unplacelist(list) end
   9114 
   9115 --- Simplify the file name as much as possible without changing
   9116 --- the meaning.  Shortcuts (on MS-Windows) or symbolic links (on
   9117 --- Unix) are not resolved.  If the first path component in
   9118 --- {filename} designates the current directory, this will be
   9119 --- valid for the result as well.  A trailing path separator is
   9120 --- not removed either.  On Unix "//path" is unchanged, but
   9121 --- "///path" is simplified to "/path" (this follows the Posix
   9122 --- standard).
   9123 --- Example: >vim
   9124 ---   simplify("./dir/.././/file/") == "./file/"
   9125 --- <Note: The combination "dir/.." is only removed if "dir" is
   9126 --- a searchable directory or does not exist.  On Unix, it is also
   9127 --- removed when "dir" is a symbolic link within the same
   9128 --- directory.  In order to resolve all the involved symbolic
   9129 --- links before simplifying the path name, use |resolve()|.
   9130 ---
   9131 --- @param filename string
   9132 --- @return string
   9133 function vim.fn.simplify(filename) end
   9134 
   9135 --- Return the sine of {expr}, measured in radians, as a |Float|.
   9136 --- {expr} must evaluate to a |Float| or a |Number|.
   9137 --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
   9138 --- Examples: >vim
   9139 ---   echo sin(100)
   9140 --- <  -0.506366 >vim
   9141 ---   echo sin(-4.01)
   9142 --- <  0.763301
   9143 ---
   9144 --- @param expr number
   9145 --- @return number
   9146 function vim.fn.sin(expr) end
   9147 
   9148 --- Return the hyperbolic sine of {expr} as a |Float| in the range
   9149 --- [-inf, inf].
   9150 --- {expr} must evaluate to a |Float| or a |Number|.
   9151 --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
   9152 --- Examples: >vim
   9153 ---   echo sinh(0.5)
   9154 --- <  0.521095 >vim
   9155 ---   echo sinh(-0.9)
   9156 --- <  -1.026517
   9157 ---
   9158 --- @param expr number
   9159 --- @return any
   9160 function vim.fn.sinh(expr) end
   9161 
   9162 --- Similar to using a |slice| "expr[start : end]", but "end" is
   9163 --- used exclusive.  And for a string the indexes are used as
   9164 --- character indexes instead of byte indexes.
   9165 --- Also, composing characters are treated as a part of the
   9166 --- preceding base character.
   9167 --- When {end} is omitted the slice continues to the last item.
   9168 --- When {end} is -1 the last item is omitted.
   9169 --- Returns an empty value if {start} or {end} are invalid.
   9170 ---
   9171 --- @param expr any
   9172 --- @param start integer
   9173 --- @param end_? integer
   9174 --- @return any
   9175 function vim.fn.slice(expr, start, end_) end
   9176 
   9177 --- Connect a socket to an address. If {mode} is "pipe" then
   9178 --- {address} should be the path of a local domain socket (on
   9179 --- unix) or named pipe (on Windows). If {mode} is "tcp" then
   9180 --- {address} should be of the form "host:port" where the host
   9181 --- should be an ip address or host name, and port the port
   9182 --- number.
   9183 ---
   9184 --- For "pipe" mode, see |luv-pipe-handle|. For "tcp" mode, see
   9185 --- |luv-tcp-handle|.
   9186 ---
   9187 --- Returns a |channel| ID. Close the socket with |chanclose()|.
   9188 --- Use |chansend()| to send data over a bytes socket, and
   9189 --- |rpcrequest()| and |rpcnotify()| to communicate with a RPC
   9190 --- socket.
   9191 ---
   9192 --- {opts} is an optional dictionary with these keys:
   9193 ---   |on_data| : callback invoked when data was read from socket
   9194 ---   data_buffered : read socket data in |channel-buffered| mode.
   9195 ---   rpc     : If set, |msgpack-rpc| will be used to communicate
   9196 ---       over the socket.
   9197 --- Returns:
   9198 ---   - The channel ID on success (greater than zero)
   9199 ---   - 0 on invalid arguments or connection failure.
   9200 ---
   9201 --- @param mode string
   9202 --- @param address string
   9203 --- @param opts? table
   9204 --- @return any
   9205 function vim.fn.sockconnect(mode, address, opts) end
   9206 
   9207 --- Sort the items in {list} in-place.  Returns {list}.
   9208 ---
   9209 --- If you want a list to remain unmodified make a copy first: >vim
   9210 ---   let sortedlist = sort(copy(mylist))
   9211 ---
   9212 --- <When {how} is omitted or is a string, then sort() uses the
   9213 --- string representation of each item to sort on.  Numbers sort
   9214 --- after Strings, |Lists| after Numbers.  For sorting text in the
   9215 --- current buffer use |:sort|.
   9216 ---
   9217 --- When {how} is given and it is 'i' then case is ignored.
   9218 --- For backwards compatibility, the value one can be used to
   9219 --- ignore case.  Zero means to not ignore case.
   9220 ---
   9221 --- When {how} is given and it is 'l' then the current collation
   9222 --- locale is used for ordering.  Implementation details:
   9223 --- strcoll() is used to compare strings.  See |:language| to check
   9224 --- or set the collation locale.  |v:collate| can also be used to
   9225 --- check the current locale.  Sorting using the locale typically
   9226 --- ignores case.  Example: >vim
   9227 ---   " ö is sorted similarly to o with English locale.
   9228 ---   language collate en_US.UTF8
   9229 ---   echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l')
   9230 --- <  ['n', 'o', 'O', 'ö', 'p', 'z'] ~
   9231 --- >vim
   9232 ---   " ö is sorted after z with Swedish locale.
   9233 ---   language collate sv_SE.UTF8
   9234 ---   echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l')
   9235 --- <  ['n', 'o', 'O', 'p', 'z', 'ö'] ~
   9236 --- This does not work properly on Mac.
   9237 ---
   9238 --- When {how} is given and it is 'n' then all items will be
   9239 --- sorted numerical (Implementation detail: this uses the
   9240 --- strtod() function to parse numbers, Strings, Lists, Dicts and
   9241 --- Funcrefs will be considered as being 0).
   9242 ---
   9243 --- When {how} is given and it is 'N' then all items will be
   9244 --- sorted numerical.  This is like 'n' but a string containing
   9245 --- digits will be used as the number they represent.
   9246 ---
   9247 --- When {how} is given and it is 'f' then all items will be
   9248 --- sorted numerical.  All values must be a Number or a Float.
   9249 ---
   9250 --- When {how} is a |Funcref| or a function name, this function
   9251 --- is called to compare items.  The function is invoked with two
   9252 --- items as argument and must return zero if they are equal, 1 or
   9253 --- bigger if the first one sorts after the second one, -1 or
   9254 --- smaller if the first one sorts before the second one.
   9255 ---
   9256 --- {dict} is for functions with the "dict" attribute.  It will be
   9257 --- used to set the local variable "self". |Dictionary-function|
   9258 ---
   9259 --- The sort is stable, items which compare equal (as number or as
   9260 --- string) will keep their relative position.  E.g., when sorting
   9261 --- on numbers, text strings will sort next to each other, in the
   9262 --- same order as they were originally.
   9263 ---
   9264 ---
   9265 --- Example: >vim
   9266 ---   func MyCompare(i1, i2)
   9267 ---      return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1
   9268 ---   endfunc
   9269 ---   eval mylist->sort("MyCompare")
   9270 --- <A shorter compare version for this specific simple case, which
   9271 --- ignores overflow: >vim
   9272 ---   func MyCompare(i1, i2)
   9273 ---      return a:i1 - a:i2
   9274 ---   endfunc
   9275 --- <For a simple expression you can use a lambda: >vim
   9276 ---   eval mylist->sort({i1, i2 -> i1 - i2})
   9277 --- <
   9278 ---
   9279 --- @generic T
   9280 --- @param list T[]
   9281 --- @param how? string|function
   9282 --- @param dict? any
   9283 --- @return T[]
   9284 function vim.fn.sort(list, how, dict) end
   9285 
   9286 --- Return the sound-folded equivalent of {word}.  Uses the first
   9287 --- language in 'spelllang' for the current window that supports
   9288 --- soundfolding.  'spell' must be set.  When no sound folding is
   9289 --- possible the {word} is returned unmodified.
   9290 --- This can be used for making spelling suggestions.  Note that
   9291 --- the method can be quite slow.
   9292 ---
   9293 --- @param word string
   9294 --- @return string
   9295 function vim.fn.soundfold(word) end
   9296 
   9297 --- Without argument: The result is the badly spelled word under
   9298 --- or after the cursor.  The cursor is moved to the start of the
   9299 --- bad word.  When no bad word is found in the cursor line the
   9300 --- result is an empty string and the cursor doesn't move.
   9301 ---
   9302 --- With argument: The result is the first word in {sentence} that
   9303 --- is badly spelled.  If there are no spelling mistakes the
   9304 --- result is an empty string.
   9305 ---
   9306 --- The return value is a list with two items:
   9307 --- - The badly spelled word or an empty string.
   9308 --- - The type of the spelling error:
   9309 ---   "bad"    spelling mistake
   9310 ---   "rare"    rare word
   9311 ---   "local"    word only valid in another region
   9312 ---   "caps"    word should start with Capital
   9313 --- Example: >vim
   9314 ---   echo spellbadword("the quik brown fox")
   9315 --- <  ['quik', 'bad'] ~
   9316 ---
   9317 --- The spelling information for the current window and the value
   9318 --- of 'spelllang' are used.
   9319 ---
   9320 --- @param sentence? string
   9321 --- @return any
   9322 function vim.fn.spellbadword(sentence) end
   9323 
   9324 --- Return a |List| with spelling suggestions to replace {word}.
   9325 --- When {max} is given up to this number of suggestions are
   9326 --- returned.  Otherwise up to 25 suggestions are returned.
   9327 ---
   9328 --- When the {capital} argument is given and it's non-zero only
   9329 --- suggestions with a leading capital will be given.  Use this
   9330 --- after a match with 'spellcapcheck'.
   9331 ---
   9332 --- {word} can be a badly spelled word followed by other text.
   9333 --- This allows for joining two words that were split.  The
   9334 --- suggestions also include the following text, thus you can
   9335 --- replace a line.
   9336 ---
   9337 --- {word} may also be a good word.  Similar words will then be
   9338 --- returned.  {word} itself is not included in the suggestions,
   9339 --- although it may appear capitalized.
   9340 ---
   9341 --- The spelling information for the current window is used.  The
   9342 --- values of 'spelllang' and 'spellsuggest' are used.
   9343 ---
   9344 --- @param word string
   9345 --- @param max? integer
   9346 --- @param capital? boolean
   9347 --- @return string[]
   9348 function vim.fn.spellsuggest(word, max, capital) end
   9349 
   9350 --- Make a |List| out of {string}.  When {pattern} is omitted or
   9351 --- empty each white space separated sequence of characters
   9352 --- becomes an item.
   9353 --- Otherwise the string is split where {pattern} matches,
   9354 --- removing the matched characters.  'ignorecase' is not used
   9355 --- here, add \c to ignore case. |/\c|
   9356 --- When the first or last item is empty it is omitted, unless the
   9357 --- {keepempty} argument is given and it's non-zero.
   9358 --- Other empty items are kept when {pattern} matches at least one
   9359 --- character or when {keepempty} is non-zero.
   9360 --- Example: >vim
   9361 ---   let words = split(getline('.'), '\W\+')
   9362 --- <To split a string in individual characters: >vim
   9363 ---   for c in split(mystring, '\zs') | endfor
   9364 --- <If you want to keep the separator you can also use '\zs' at
   9365 --- the end of the pattern: >vim
   9366 ---   echo split('abc:def:ghi', ':\zs')
   9367 --- < >
   9368 ---   ['abc:', 'def:', 'ghi']
   9369 --- <
   9370 --- Splitting a table where the first element can be empty: >vim
   9371 ---   let items = split(line, ':', 1)
   9372 --- <The opposite function is |join()|.
   9373 ---
   9374 --- @param string string
   9375 --- @param pattern? string
   9376 --- @param keepempty? boolean
   9377 --- @return string[]
   9378 function vim.fn.split(string, pattern, keepempty) end
   9379 
   9380 --- Return the non-negative square root of Float {expr} as a
   9381 --- |Float|.
   9382 --- {expr} must evaluate to a |Float| or a |Number|.  When {expr}
   9383 --- is negative the result is NaN (Not a Number).  Returns 0.0 if
   9384 --- {expr} is not a |Float| or a |Number|.
   9385 --- Examples: >vim
   9386 ---   echo sqrt(100)
   9387 --- <  10.0 >vim
   9388 ---   echo sqrt(-4.01)
   9389 --- <  str2float("nan")
   9390 --- NaN may be different, it depends on system libraries.
   9391 ---
   9392 --- @param expr number
   9393 --- @return any
   9394 function vim.fn.sqrt(expr) end
   9395 
   9396 --- Initialize seed used by |rand()|:
   9397 --- - If {expr} is not given, seed values are initialized by
   9398 ---   reading from /dev/urandom, if possible, or using time(NULL)
   9399 ---   a.k.a. epoch time otherwise; this only has second accuracy.
   9400 --- - If {expr} is given it must be a Number.  It is used to
   9401 ---   initialize the seed values.  This is useful for testing or
   9402 ---   when a predictable sequence is intended.
   9403 ---
   9404 --- Examples: >vim
   9405 ---   let seed = srand()
   9406 ---   let seed = srand(userinput)
   9407 ---   echo rand(seed)
   9408 --- <
   9409 ---
   9410 --- @param expr? number
   9411 --- @return any
   9412 function vim.fn.srand(expr) end
   9413 
   9414 --- Return a string which contains characters indicating the
   9415 --- current state.  Mostly useful in callbacks that want to do
   9416 --- work that may not always be safe.  Roughly this works like:
   9417 --- - callback uses state() to check if work is safe to do.
   9418 ---   Yes: then do it right away.
   9419 ---   No:  add to work queue and add a |SafeState| autocommand.
   9420 --- - When SafeState is triggered and executes your autocommand,
   9421 ---   check with `state()` if the work can be done now, and if yes
   9422 ---   remove it from the queue and execute.
   9423 ---   Remove the autocommand if the queue is now empty.
   9424 --- Also see |mode()|.
   9425 ---
   9426 --- When {what} is given only characters in this string will be
   9427 --- added.  E.g, this checks if the screen has scrolled: >vim
   9428 ---   if state('s') == ''
   9429 ---      " screen has not scrolled
   9430 --- <
   9431 --- These characters indicate the state, generally indicating that
   9432 --- something is busy:
   9433 ---     m  halfway a mapping, :normal command, |feedkeys()| or
   9434 ---   stuffed command
   9435 ---     o  operator pending, e.g. after |d|
   9436 ---     a  Insert mode autocomplete active
   9437 ---     x  executing an autocommand
   9438 ---     S  not triggering SafeState, e.g. after |f| or a count
   9439 ---     c  callback invoked, including timer (repeats for
   9440 ---   recursiveness up to "ccc")
   9441 ---     s  screen has scrolled for messages
   9442 ---
   9443 --- @param what? string
   9444 --- @return any
   9445 function vim.fn.state(what) end
   9446 
   9447 --- With |--headless| this opens stdin and stdout as a |channel|.
   9448 --- May be called only once. See |channel-stdio|. stderr is not
   9449 --- handled by this function, see |v:stderr|.
   9450 ---
   9451 --- Close the stdio handles with |chanclose()|. Use |chansend()|
   9452 --- to send data to stdout, and |rpcrequest()| and |rpcnotify()|
   9453 --- to communicate over RPC.
   9454 ---
   9455 --- {opts} is a dictionary with these keys:
   9456 ---   |on_stdin| : callback invoked when stdin is written to.
   9457 ---   on_print : callback invoked when Nvim needs to print a
   9458 ---        message, with the message (whose type is string)
   9459 ---        as sole argument.
   9460 ---   stdin_buffered : read stdin in |channel-buffered| mode.
   9461 ---   rpc      : If set, |msgpack-rpc| will be used to communicate
   9462 ---        over stdio
   9463 --- Returns:
   9464 ---   - |channel-id| on success (value is always 1)
   9465 ---   - 0 on invalid arguments
   9466 ---
   9467 --- @param opts table
   9468 --- @return any
   9469 function vim.fn.stdioopen(opts) end
   9470 
   9471 --- Returns |standard-path| locations of various default files and
   9472 --- directories. The locations are driven by |base-directories|
   9473 --- which you can configure via |$NVIM_APPNAME| or the `$XDG_…`
   9474 --- environment variables.
   9475 ---
   9476 --- {what}       Type    Description ~
   9477 --- cache        String  Cache directory: arbitrary temporary
   9478 ---                      storage for plugins, etc.
   9479 --- config       String  User configuration directory. |init.vim|
   9480 ---                      is stored here.
   9481 --- config_dirs  List    Other configuration directories.
   9482 --- data         String  User data directory.
   9483 --- data_dirs    List    Other data directories.
   9484 --- log          String  Logs directory (for use by plugins too).
   9485 --- run          String  Run directory: temporary, local storage
   9486 ---          for sockets, named pipes, etc.
   9487 --- state        String  Session state: storage for backupdir,
   9488 ---          file drafts, |shada|, swap, undo, 'viewdir'.
   9489 ---
   9490 --- Example: >vim
   9491 ---   echo stdpath("config")
   9492 --- <
   9493 ---
   9494 --- @param what 'cache'|'config'|'config_dirs'|'data'|'data_dirs'|'log'|'run'|'state'
   9495 --- @return string|string[]
   9496 function vim.fn.stdpath(what) end
   9497 
   9498 --- @param what 'cache'|'config'|'data'|'log'|'run'|'state'
   9499 --- @return string
   9500 function vim.fn.stdpath(what) end
   9501 
   9502 --- @param what 'config_dirs'|'data_dirs'
   9503 --- @return string[]
   9504 function vim.fn.stdpath(what) end
   9505 
   9506 --- Convert String {string} to a Float.  This mostly works the
   9507 --- same as when using a floating point number in an expression,
   9508 --- see |floating-point-format|.  But it's a bit more permissive.
   9509 --- E.g., "1e40" is accepted, while in an expression you need to
   9510 --- write "1.0e40".  The hexadecimal form "0x123" is also
   9511 --- accepted, but not others, like binary or octal.
   9512 --- When {quoted} is present and non-zero then embedded single
   9513 --- quotes before the dot are ignored, thus "1'000.0" is a
   9514 --- thousand.
   9515 --- Text after the number is silently ignored.
   9516 --- The decimal point is always '.', no matter what the locale is
   9517 --- set to.  A comma ends the number: "12,345.67" is converted to
   9518 --- 12.0.  You can strip out thousands separators with
   9519 --- |substitute()|: >vim
   9520 ---   let f = str2float(substitute(text, ',', '', 'g'))
   9521 --- <
   9522 --- Returns 0.0 if the conversion fails.
   9523 ---
   9524 --- @param string string
   9525 --- @param quoted? boolean
   9526 --- @return any
   9527 function vim.fn.str2float(string, quoted) end
   9528 
   9529 --- Return a list containing the number values which represent
   9530 --- each character in String {string}.  Examples: >vim
   9531 ---   echo str2list(" ")    " returns [32]
   9532 ---   echo str2list("ABC")    " returns [65, 66, 67]
   9533 --- <|list2str()| does the opposite.
   9534 ---
   9535 --- UTF-8 encoding is always used, {utf8} option has no effect,
   9536 --- and exists only for backwards-compatibility.
   9537 --- With UTF-8 composing characters are handled properly: >vim
   9538 ---   echo str2list("á")    " returns [97, 769]
   9539 --- <
   9540 ---
   9541 --- @param string string
   9542 --- @param utf8? boolean
   9543 --- @return any
   9544 function vim.fn.str2list(string, utf8) end
   9545 
   9546 --- Convert string {string} to a number.
   9547 --- {base} is the conversion base, it can be 2, 8, 10 or 16.
   9548 --- When {quoted} is present and non-zero then embedded single
   9549 --- quotes are ignored, thus "1'000'000" is a million.
   9550 ---
   9551 --- When {base} is omitted base 10 is used.  This also means that
   9552 --- a leading zero doesn't cause octal conversion to be used, as
   9553 --- with the default String to Number conversion.  Example: >vim
   9554 ---   let nr = str2nr('0123')
   9555 --- <
   9556 --- When {base} is 16 a leading "0x" or "0X" is ignored.  With a
   9557 --- different base the result will be zero. Similarly, when
   9558 --- {base} is 8 a leading "0", "0o" or "0O" is ignored, and when
   9559 --- {base} is 2 a leading "0b" or "0B" is ignored.
   9560 --- Text after the number is silently ignored.
   9561 ---
   9562 --- Returns 0 if {string} is empty or on error.
   9563 ---
   9564 --- @param string string
   9565 --- @param base? integer
   9566 --- @return any
   9567 function vim.fn.str2nr(string, base) end
   9568 
   9569 --- The result is a Number, which is the number of characters
   9570 --- in String {string}.  Composing characters are ignored.
   9571 --- |strchars()| can count the number of characters, counting
   9572 --- composing characters separately.
   9573 ---
   9574 --- Returns 0 if {string} is empty or on error.
   9575 ---
   9576 --- Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
   9577 ---
   9578 --- @param string string
   9579 --- @return integer
   9580 function vim.fn.strcharlen(string) end
   9581 
   9582 --- Like |strpart()| but using character index and length instead
   9583 --- of byte index and length.
   9584 --- When {skipcc} is omitted or zero, composing characters are
   9585 --- counted separately.
   9586 --- When {skipcc} set to 1, composing characters are treated as a
   9587 --- part of the preceding base character, similar to |slice()|.
   9588 --- When a character index is used where a character does not
   9589 --- exist it is omitted and counted as one character.  For
   9590 --- example: >vim
   9591 ---   echo strcharpart('abc', -1, 2)
   9592 --- <results in 'a'.
   9593 ---
   9594 --- Returns an empty string on error.
   9595 ---
   9596 --- @param src string
   9597 --- @param start integer
   9598 --- @param len? integer
   9599 --- @param skipcc? 0|1|boolean
   9600 --- @return string
   9601 function vim.fn.strcharpart(src, start, len, skipcc) end
   9602 
   9603 --- The result is a Number, which is the number of characters
   9604 --- in String {string}.
   9605 --- When {skipcc} is omitted or zero, composing characters are
   9606 --- counted separately.
   9607 --- When {skipcc} set to 1, composing characters are ignored.
   9608 --- |strcharlen()| always does this.
   9609 ---
   9610 --- Returns zero on error.
   9611 ---
   9612 --- Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
   9613 ---
   9614 --- {skipcc} is only available after 7.4.755.  For backward
   9615 --- compatibility, you can define a wrapper function: >vim
   9616 ---     if has("patch-7.4.755")
   9617 ---       function s:strchars(str, skipcc)
   9618 ---   return strchars(a:str, a:skipcc)
   9619 ---       endfunction
   9620 ---     else
   9621 ---       function s:strchars(str, skipcc)
   9622 ---   if a:skipcc
   9623 ---     return strlen(substitute(a:str, ".", "x", "g"))
   9624 ---   else
   9625 ---     return strchars(a:str)
   9626 ---   endif
   9627 ---       endfunction
   9628 ---     endif
   9629 --- <
   9630 ---
   9631 --- @param string string
   9632 --- @param skipcc? 0|1|boolean
   9633 --- @return integer
   9634 function vim.fn.strchars(string, skipcc) end
   9635 
   9636 --- The result is a Number, which is the number of display cells
   9637 --- String {string} occupies on the screen when it starts at {col}
   9638 --- (first column is zero).  When {col} is omitted zero is used.
   9639 --- Otherwise it is the screen column where to start.  This
   9640 --- matters for Tab characters.
   9641 --- The option settings of the current window are used.  This
   9642 --- matters for anything that's displayed differently, such as
   9643 --- 'tabstop' and 'display'.
   9644 --- When {string} contains characters with East Asian Width Class
   9645 --- Ambiguous, this function's return value depends on
   9646 --- 'ambiwidth'.
   9647 --- Returns zero on error.
   9648 --- Also see |strlen()|, |strwidth()| and |strchars()|.
   9649 ---
   9650 --- @param string string
   9651 --- @param col? integer
   9652 --- @return integer
   9653 function vim.fn.strdisplaywidth(string, col) end
   9654 
   9655 --- The result is a String, which is a formatted date and time, as
   9656 --- specified by the {format} string.  The given {time} is used,
   9657 --- or the current time if no time is given.  The accepted
   9658 --- {format} depends on your system, thus this is not portable!
   9659 --- See the manual page of the C function strftime() for the
   9660 --- format.  The maximum length of the result is 80 characters.
   9661 --- See also |localtime()|, |getftime()| and |strptime()|.
   9662 --- The language can be changed with the |:language| command.
   9663 --- Examples: >vim
   9664 ---   echo strftime("%c")       " Sun Apr 27 11:49:23 1997
   9665 ---   echo strftime("%Y %b %d %X")     " 1997 Apr 27 11:53:25
   9666 ---   echo strftime("%y%m%d %T")     " 970427 11:53:55
   9667 ---   echo strftime("%H:%M")       " 11:55
   9668 ---   echo strftime("%c", getftime("file.c"))
   9669 ---            " Show mod time of file.c.
   9670 --- <
   9671 ---
   9672 --- @param format string
   9673 --- @param time? number
   9674 --- @return string
   9675 function vim.fn.strftime(format, time) end
   9676 
   9677 --- Get a Number corresponding to the character at {index} in
   9678 --- {str}.  This uses a zero-based character index, not a byte
   9679 --- index.  Composing characters are considered separate
   9680 --- characters here.  Use |nr2char()| to convert the Number to a
   9681 --- String.
   9682 --- Returns -1 if {index} is invalid.
   9683 --- Also see |strcharpart()| and |strchars()|.
   9684 ---
   9685 --- @param str string
   9686 --- @param index integer
   9687 --- @return integer
   9688 function vim.fn.strgetchar(str, index) end
   9689 
   9690 --- The result is a Number, which gives the byte index in
   9691 --- {haystack} of the first occurrence of the String {needle}.
   9692 --- If {start} is specified, the search starts at index {start}.
   9693 --- This can be used to find a second match: >vim
   9694 ---   let colon1 = stridx(line, ":")
   9695 ---   let colon2 = stridx(line, ":", colon1 + 1)
   9696 --- <The search is done case-sensitive.
   9697 --- For pattern searches use |match()|.
   9698 --- -1 is returned if the {needle} does not occur in {haystack}.
   9699 --- See also |strridx()|.
   9700 --- Examples: >vim
   9701 ---   echo stridx("An Example", "Example")     " 3
   9702 ---   echo stridx("Starting point", "Start")   " 0
   9703 ---   echo stridx("Starting point", "start")   " -1
   9704 --- <          *strstr()* *strchr()*
   9705 --- stridx() works similar to the C function strstr().  When used
   9706 --- with a single character it works similar to strchr().
   9707 ---
   9708 --- @param haystack string
   9709 --- @param needle string
   9710 --- @param start? integer
   9711 --- @return integer
   9712 function vim.fn.stridx(haystack, needle, start) end
   9713 
   9714 --- Return {expr} converted to a String.  If {expr} is a Number,
   9715 --- Float, String, Blob or a composition of them, then the result
   9716 --- can be parsed back with |eval()|.
   9717 ---   {expr} type  result ~
   9718 ---   String    'string'
   9719 ---   Number    123
   9720 ---   Float    123.123456 or 1.123456e8 or
   9721 ---       `str2float('inf')`
   9722 ---   Funcref    `function('name')`
   9723 ---   Blob    0z00112233.44556677.8899
   9724 ---   List    [item, item]
   9725 ---   Dictionary  `{key: value, key: value}`
   9726 --- Note that in String values the ' character is doubled.
   9727 --- Also see |strtrans()|.
   9728 --- Note 2: Output format is mostly compatible with YAML, except
   9729 --- for infinite and NaN floating-point values representations
   9730 --- which use |str2float()|.  Strings are also dumped literally,
   9731 --- only single quote is escaped, which does not allow using YAML
   9732 --- for parsing back binary strings.  |eval()| should always work
   9733 --- for strings and floats though, and this is the only official
   9734 --- method.  Use |msgpackdump()| or |json_encode()| if you need to
   9735 --- share data with other applications.
   9736 ---
   9737 --- @param expr any
   9738 --- @return string
   9739 function vim.fn.string(expr) end
   9740 
   9741 --- The result is a Number, which is the length of the String
   9742 --- {string} in bytes.
   9743 --- If the argument is a Number it is first converted to a String.
   9744 --- For other types an error is given and zero is returned.
   9745 --- If you want to count the number of multibyte characters use
   9746 --- |strchars()|.
   9747 --- Also see |len()|, |strdisplaywidth()| and |strwidth()|.
   9748 ---
   9749 --- @param string string
   9750 --- @return integer
   9751 function vim.fn.strlen(string) end
   9752 
   9753 --- The result is a String, which is part of {src}, starting from
   9754 --- byte {start}, with the byte length {len}.
   9755 --- When {chars} is present and TRUE then {len} is the number of
   9756 --- characters positions (composing characters are not counted
   9757 --- separately, thus "1" means one base character and any
   9758 --- following composing characters).
   9759 --- To count {start} as characters instead of bytes use
   9760 --- |strcharpart()|.
   9761 ---
   9762 --- When bytes are selected which do not exist, this doesn't
   9763 --- result in an error, the bytes are simply omitted.
   9764 --- If {len} is missing, the copy continues from {start} till the
   9765 --- end of the {src}. >vim
   9766 ---   echo strpart("abcdefg", 3, 2)    " returns 'de'
   9767 ---   echo strpart("abcdefg", -2, 4)   " returns 'ab'
   9768 ---   echo strpart("abcdefg", 5, 4)    " returns 'fg'
   9769 ---   echo strpart("abcdefg", 3)   " returns 'defg'
   9770 ---
   9771 --- <Note: To get the first character, {start} must be 0.  For
   9772 --- example, to get the character under the cursor: >vim
   9773 ---   strpart(getline("."), col(".") - 1, 1, v:true)
   9774 --- <
   9775 --- Returns an empty string on error.
   9776 ---
   9777 --- @param src string
   9778 --- @param start integer
   9779 --- @param len? integer
   9780 --- @param chars? 0|1
   9781 --- @return string
   9782 function vim.fn.strpart(src, start, len, chars) end
   9783 
   9784 --- The result is a Number, which is a unix timestamp representing
   9785 --- the date and time in {timestring}, which is expected to match
   9786 --- the format specified in {format}.
   9787 ---
   9788 --- The accepted {format} depends on your system, thus this is not
   9789 --- portable!  See the manual page of the C function strptime()
   9790 --- for the format.  Especially avoid "%c".  The value of $TZ also
   9791 --- matters.
   9792 ---
   9793 --- If the {timestring} cannot be parsed with {format} zero is
   9794 --- returned.  If you do not know the format of {timestring} you
   9795 --- can try different {format} values until you get a non-zero
   9796 --- result.
   9797 ---
   9798 --- See also |strftime()|.
   9799 --- Examples: >vim
   9800 ---   echo strptime("%Y %b %d %X", "1997 Apr 27 11:49:23")
   9801 --- <  862156163 >vim
   9802 ---   echo strftime("%c", strptime("%y%m%d %T", "970427 11:53:55"))
   9803 --- <  Sun Apr 27 11:53:55 1997 >vim
   9804 ---   echo strftime("%c", strptime("%Y%m%d%H%M%S", "19970427115355") + 3600)
   9805 --- <  Sun Apr 27 12:53:55 1997
   9806 ---
   9807 --- @param format string
   9808 --- @param timestring string
   9809 --- @return integer
   9810 function vim.fn.strptime(format, timestring) end
   9811 
   9812 --- The result is a Number, which gives the byte index in
   9813 --- {haystack} of the last occurrence of the String {needle}.
   9814 --- When {start} is specified, matches beyond this index are
   9815 --- ignored.  This can be used to find a match before a previous
   9816 --- match: >vim
   9817 ---   let lastcomma = strridx(line, ",")
   9818 ---   let comma2 = strridx(line, ",", lastcomma - 1)
   9819 --- <The search is done case-sensitive.
   9820 --- For pattern searches use |match()|.
   9821 --- -1 is returned if the {needle} does not occur in {haystack}.
   9822 --- If the {needle} is empty the length of {haystack} is returned.
   9823 --- See also |stridx()|.  Examples: >vim
   9824 ---   echo strridx("an angry armadillo", "an")       3
   9825 --- <          *strrchr()*
   9826 --- When used with a single character it works similar to the C
   9827 --- function strrchr().
   9828 ---
   9829 --- @param haystack string
   9830 --- @param needle string
   9831 --- @param start? integer
   9832 --- @return integer
   9833 function vim.fn.strridx(haystack, needle, start) end
   9834 
   9835 --- The result is a String, which is {string} with all unprintable
   9836 --- characters translated into printable characters 'isprint'.
   9837 --- Like they are shown in a window.  Example: >vim
   9838 ---   echo strtrans(\@a)
   9839 --- <This displays a newline in register a as "^\@" instead of
   9840 --- starting a new line.
   9841 ---
   9842 --- Returns an empty string on error.
   9843 ---
   9844 --- @param string string
   9845 --- @return string
   9846 function vim.fn.strtrans(string) end
   9847 
   9848 --- The result is a Number, which is the number of UTF-16 code
   9849 --- units in String {string} (after converting it to UTF-16).
   9850 ---
   9851 --- When {countcc} is TRUE, composing characters are counted
   9852 --- separately.
   9853 --- When {countcc} is omitted or FALSE, composing characters are
   9854 --- ignored.
   9855 ---
   9856 --- Returns zero on error.
   9857 ---
   9858 --- Also see |strlen()| and |strcharlen()|.
   9859 --- Examples: >vim
   9860 ---     echo strutf16len('a')    " returns 1
   9861 ---     echo strutf16len('©')    " returns 1
   9862 ---     echo strutf16len('😊')    " returns 2
   9863 ---     echo strutf16len('ą́')    " returns 1
   9864 ---     echo strutf16len('ą́', v:true)  " returns 3
   9865 --- <
   9866 ---
   9867 --- @param string string
   9868 --- @param countcc? 0|1
   9869 --- @return integer
   9870 function vim.fn.strutf16len(string, countcc) end
   9871 
   9872 --- The result is a Number, which is the number of display cells
   9873 --- String {string} occupies.  A Tab character is counted as one
   9874 --- cell, alternatively use |strdisplaywidth()|.
   9875 --- When {string} contains characters with East Asian Width Class
   9876 --- Ambiguous, this function's return value depends on
   9877 --- 'ambiwidth'.
   9878 --- Returns zero on error.
   9879 --- Also see |strlen()|, |strdisplaywidth()| and |strchars()|.
   9880 ---
   9881 --- @param string string
   9882 --- @return integer
   9883 function vim.fn.strwidth(string) end
   9884 
   9885 --- Only for an expression in a |:substitute| command or
   9886 --- |substitute()| function.
   9887 --- Returns the {nr}th submatch of the matched text.  When {nr}
   9888 --- is 0 the whole matched text is returned.
   9889 --- Note that a NL in the string can stand for a line break of a
   9890 --- multi-line match or a NUL character in the text.
   9891 --- Also see |sub-replace-expression|.
   9892 ---
   9893 --- If {list} is present and non-zero then submatch() returns
   9894 --- a list of strings, similar to |getline()| with two arguments.
   9895 --- NL characters in the text represent NUL characters in the
   9896 --- text.
   9897 --- Only returns more than one item for |:substitute|, inside
   9898 --- |substitute()| this list will always contain one or zero
   9899 --- items, since there are no real line breaks.
   9900 ---
   9901 --- When |substitute()| is used recursively only the submatches in
   9902 --- the current (deepest) call can be obtained.
   9903 ---
   9904 --- Returns an empty string or list on error.
   9905 ---
   9906 --- Examples: >vim
   9907 ---   s/\d\+/\=submatch(0) + 1/
   9908 ---   echo substitute(text, '\d\+', '\=submatch(0) + 1', '')
   9909 --- <This finds the first number in the line and adds one to it.
   9910 --- A line break is included as a newline character.
   9911 ---
   9912 --- @param nr integer
   9913 --- @param list? nil
   9914 --- @return string
   9915 function vim.fn.submatch(nr, list) end
   9916 
   9917 --- @param nr integer
   9918 --- @param list integer
   9919 --- @return string|string[]
   9920 function vim.fn.submatch(nr, list) end
   9921 
   9922 --- The result is a String, which is a copy of {string}, in which
   9923 --- the first match of {pat} is replaced with {sub}.
   9924 --- When {flags} is "g", all matches of {pat} in {string} are
   9925 --- replaced.  Otherwise {flags} should be "".
   9926 ---
   9927 --- This works like the ":substitute" command (without any flags).
   9928 --- But the matching with {pat} is always done like the 'magic'
   9929 --- option is set and 'cpoptions' is empty (to make scripts
   9930 --- portable).  'ignorecase' is still relevant, use |/\c| or |/\C|
   9931 --- if you want to ignore or match case and ignore 'ignorecase'.
   9932 --- 'smartcase' is not used.  See |string-match| for how {pat} is
   9933 --- used.
   9934 ---
   9935 --- A "~" in {sub} is not replaced with the previous {sub}.
   9936 --- Note that some codes in {sub} have a special meaning
   9937 --- |sub-replace-special|.  For example, to replace something with
   9938 --- "\n" (two characters), use "\\\\n" or '\\n'.
   9939 ---
   9940 --- When {pat} does not match in {string}, {string} is returned
   9941 --- unmodified.
   9942 ---
   9943 --- Example: >vim
   9944 ---   let &path = substitute(&path, ",\\=[^,]*$", "", "")
   9945 --- <This removes the last component of the 'path' option. >vim
   9946 ---   echo substitute("testing", ".*", "\\U\\0", "")
   9947 --- <results in "TESTING".
   9948 ---
   9949 --- When {sub} starts with "\=", the remainder is interpreted as
   9950 --- an expression.  See |sub-replace-expression|.  Example: >vim
   9951 ---   echo substitute(s, '%\(\x\x\)',
   9952 ---      \ '\=nr2char("0x" .. submatch(1))', 'g')
   9953 ---
   9954 --- <When {sub} is a Funcref that function is called, with one
   9955 --- optional argument.  Example: >vim
   9956 ---    echo substitute(s, '%\(\x\x\)', SubNr, 'g')
   9957 --- <The optional argument is a list which contains the whole
   9958 --- matched string and up to nine submatches, like what
   9959 --- |submatch()| returns.  Example: >vim
   9960 ---    echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g')
   9961 ---
   9962 --- <Returns an empty string on error.
   9963 ---
   9964 --- @param string string
   9965 --- @param pat string
   9966 --- @param sub string
   9967 --- @param flags string
   9968 --- @return string
   9969 function vim.fn.substitute(string, pat, sub, flags) end
   9970 
   9971 --- Returns a list of swap file names, like what "vim -r" shows.
   9972 --- See the |-r| command argument.  The 'directory' option is used
   9973 --- for the directories to inspect.  If you only want to get a
   9974 --- list of swap files in the current directory then temporarily
   9975 --- set 'directory' to a dot: >vim
   9976 ---   let save_dir = &directory
   9977 ---   let &directory = '.'
   9978 ---   let swapfiles = swapfilelist()
   9979 ---   let &directory = save_dir
   9980 --- <
   9981 ---
   9982 --- @return string[]
   9983 function vim.fn.swapfilelist() end
   9984 
   9985 --- The result is a dictionary, which holds information about the
   9986 --- swapfile {fname}.  The available fields are:
   9987 ---   version Vim version
   9988 ---   user  user name
   9989 ---   host  host name
   9990 ---   fname  original file name
   9991 ---   pid  PID of the Nvim process that created the swap
   9992 ---     file, or zero if not running.
   9993 ---   mtime  last modification time in seconds
   9994 ---   inode  Optional: INODE number of the file
   9995 ---   dirty  1 if file was modified, 0 if not
   9996 --- In case of failure an "error" item is added with the reason:
   9997 ---   Cannot open file: file not found or in accessible
   9998 ---   Cannot read file: cannot read first block
   9999 ---   Not a swap file: does not contain correct block ID
  10000 ---   Magic number mismatch: Info in first block is invalid
  10001 ---
  10002 --- @param fname string
  10003 --- @return any
  10004 function vim.fn.swapinfo(fname) end
  10005 
  10006 --- The result is the swap file path of the buffer {buf}.
  10007 --- For the use of {buf}, see |bufname()| above.
  10008 --- If buffer {buf} is the current buffer, the result is equal to
  10009 --- |:swapname| (unless there is no swap file).
  10010 --- If buffer {buf} has no swap file, returns an empty string.
  10011 ---
  10012 --- @param buf integer|string
  10013 --- @return string
  10014 function vim.fn.swapname(buf) end
  10015 
  10016 --- The result is a Number, which is the syntax ID at the position
  10017 --- {lnum} and {col} in the current window.
  10018 --- The syntax ID can be used with |synIDattr()| and
  10019 --- |synIDtrans()| to obtain syntax information about text.
  10020 ---
  10021 --- {col} is 1 for the leftmost column, {lnum} is 1 for the first
  10022 --- line.  'synmaxcol' applies, in a longer line zero is returned.
  10023 --- Note that when the position is after the last character,
  10024 --- that's where the cursor can be in Insert mode, synID() returns
  10025 --- zero.  {lnum} is used like with |getline()|.
  10026 ---
  10027 --- When {trans} is |TRUE|, transparent items are reduced to the
  10028 --- item that they reveal.  This is useful when wanting to know
  10029 --- the effective color.  When {trans} is |FALSE|, the transparent
  10030 --- item is returned.  This is useful when wanting to know which
  10031 --- syntax item is effective (e.g. inside parens).
  10032 --- Warning: This function can be very slow.  Best speed is
  10033 --- obtained by going through the file in forward direction.
  10034 ---
  10035 --- Returns zero on error.
  10036 ---
  10037 --- Example (echoes the name of the syntax item under the cursor): >vim
  10038 ---   echo synIDattr(synID(line("."), col("."), 1), "name")
  10039 --- <
  10040 ---
  10041 --- @param lnum integer|string
  10042 --- @param col integer
  10043 --- @param trans 0|1
  10044 --- @return integer
  10045 function vim.fn.synID(lnum, col, trans) end
  10046 
  10047 --- The result is a String, which is the {what} attribute of
  10048 --- syntax ID {synID}.  This can be used to obtain information
  10049 --- about a syntax item.
  10050 --- {mode} can be "gui" or "cterm", to get the attributes
  10051 --- for that mode.  When {mode} is omitted, or an invalid value is
  10052 --- used, the attributes for the currently active highlighting are
  10053 --- used (GUI or cterm).
  10054 --- Use |synIDtrans()| to follow linked highlight groups.
  10055 --- {what}    result
  10056 --- "name"    the name of the syntax item
  10057 --- "fg"    foreground color (GUI: color name used to set
  10058 ---     the color, cterm: color number as a string,
  10059 ---     term: empty string)
  10060 --- "bg"    background color (as with "fg")
  10061 --- "font"    font name (only available in the GUI)
  10062 ---     |highlight-font|
  10063 --- "sp"    special color (as with "fg") |guisp|
  10064 --- "fg#"    like "fg", but for the GUI and the GUI is
  10065 ---     running the name in "#RRGGBB" form
  10066 --- "bg#"    like "fg#" for "bg"
  10067 --- "sp#"    like "fg#" for "sp"
  10068 --- "bold"    "1" if bold
  10069 --- "italic"  "1" if italic
  10070 --- "reverse"  "1" if reverse
  10071 --- "inverse"  "1" if inverse (= reverse)
  10072 --- "standout"  "1" if standout
  10073 --- "underline"  "1" if underlined
  10074 --- "undercurl"  "1" if undercurled
  10075 --- "underdouble"  "1" if double underlined
  10076 --- "underdotted"  "1" if dotted underlined
  10077 --- "underdashed"  "1" if dashed underlined
  10078 --- "strikethrough"  "1" if struckthrough
  10079 --- "altfont"  "1" if alternative font
  10080 --- "nocombine"  "1" if nocombine
  10081 --- "dim"  "1" if half-bright/dimmed
  10082 --- "blink"  "1" if blinking
  10083 --- "conceal"  "1" if concealed
  10084 --- "overline"  "1" if overlined
  10085 ---
  10086 --- Returns an empty string on error.
  10087 ---
  10088 --- Example (echoes the color of the syntax item under the
  10089 --- cursor): >vim
  10090 ---   echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg")
  10091 --- <
  10092 --- Can also be used as a |method|: >vim
  10093 ---   echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
  10094 --- <
  10095 ---
  10096 --- @param synID integer
  10097 --- @param what string
  10098 --- @param mode? string
  10099 --- @return string
  10100 function vim.fn.synIDattr(synID, what, mode) end
  10101 
  10102 --- The result is a Number, which is the translated syntax ID of
  10103 --- {synID}.  This is the syntax group ID of what is being used to
  10104 --- highlight the character.  Highlight links given with
  10105 --- ":highlight link" are followed.
  10106 ---
  10107 --- Returns zero on error.
  10108 ---
  10109 --- @param synID integer
  10110 --- @return integer
  10111 function vim.fn.synIDtrans(synID) end
  10112 
  10113 --- The result is a |List| with three items:
  10114 --- 1. The first item in the list is 0 if the character at the
  10115 ---    position {lnum} and {col} is not part of a concealable
  10116 ---    region, 1 if it is.  {lnum} is used like with |getline()|.
  10117 --- 2. The second item in the list is a string.  If the first item
  10118 ---    is 1, the second item contains the text which will be
  10119 ---    displayed in place of the concealed text, depending on the
  10120 ---    current setting of 'conceallevel' and 'listchars'.
  10121 --- 3. The third and final item in the list is a number
  10122 ---    representing the specific syntax region matched in the
  10123 ---    line.  When the character is not concealed the value is
  10124 ---    zero.  This allows detection of the beginning of a new
  10125 ---    concealable region if there are two consecutive regions
  10126 ---    with the same replacement character.  For an example, if
  10127 ---    the text is "123456" and both "23" and "45" are concealed
  10128 ---    and replaced by the character "X", then:
  10129 ---   call      returns ~
  10130 ---   synconcealed(lnum, 1)   [0, '', 0]
  10131 ---   synconcealed(lnum, 2)   [1, 'X', 1]
  10132 ---   synconcealed(lnum, 3)   [1, 'X', 1]
  10133 ---   synconcealed(lnum, 4)   [1, 'X', 2]
  10134 ---   synconcealed(lnum, 5)   [1, 'X', 2]
  10135 ---   synconcealed(lnum, 6)   [0, '', 0]
  10136 ---
  10137 --- Note: Doesn't consider |matchadd()| highlighting items,
  10138 --- since syntax and matching highlighting are two different
  10139 --- mechanisms |syntax-vs-match|.
  10140 ---
  10141 --- @param lnum integer|string
  10142 --- @param col integer
  10143 --- @return [integer, string, integer]
  10144 function vim.fn.synconcealed(lnum, col) end
  10145 
  10146 --- Return a |List|, which is the stack of syntax items at the
  10147 --- position {lnum} and {col} in the current window.  {lnum} is
  10148 --- used like with |getline()|.  Each item in the List is an ID
  10149 --- like what |synID()| returns.
  10150 --- The first item in the List is the outer region, following are
  10151 --- items contained in that one.  The last one is what |synID()|
  10152 --- returns, unless not the whole item is highlighted or it is a
  10153 --- transparent item.
  10154 --- This function is useful for debugging a syntax file.
  10155 --- Example that shows the syntax stack under the cursor: >vim
  10156 ---   for id in synstack(line("."), col("."))
  10157 ---      echo synIDattr(id, "name")
  10158 ---   endfor
  10159 --- <When the position specified with {lnum} and {col} is invalid
  10160 --- an empty list is returned.  The position just after the last
  10161 --- character in a line and the first column in an empty line are
  10162 --- valid positions.
  10163 ---
  10164 --- @param lnum integer|string
  10165 --- @param col integer
  10166 --- @return integer[]
  10167 function vim.fn.synstack(lnum, col) end
  10168 
  10169 --- Note: Prefer |vim.system()| in Lua.
  10170 ---
  10171 --- Gets the output of {cmd} as a |string| (|systemlist()| returns
  10172 --- a |List|) and sets |v:shell_error| to the error code.
  10173 --- {cmd} is treated as in |jobstart()|:
  10174 --- If {cmd} is a List it runs directly (no 'shell').
  10175 --- If {cmd} is a String it runs in the 'shell', like this: >vim
  10176 ---   call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
  10177 ---
  10178 --- <Not to be used for interactive commands.
  10179 ---
  10180 --- Result is a String, filtered to avoid platform-specific quirks:
  10181 --- - <CR><NL> is replaced with <NL>
  10182 --- - NUL characters are replaced with SOH (0x01)
  10183 ---
  10184 --- Example: >vim
  10185 ---     echo system(['ls', expand('%:h')])
  10186 ---
  10187 --- <If {input} is a string it is written to a pipe and passed as
  10188 --- stdin to the command.  The string is written as-is, line
  10189 --- separators are not changed.
  10190 --- If {input} is a |List| it is written to the pipe as
  10191 --- |writefile()| does with {binary} set to "b" (i.e. with
  10192 --- a newline between each list item, and newlines inside list
  10193 --- items converted to NULs).
  10194 --- When {input} is given and is a valid buffer id, the content of
  10195 --- the buffer is written to the file line by line, each line
  10196 --- terminated by NL (and NUL where the text has NL).
  10197 ---             *E5677*
  10198 --- Note: system() cannot write to or read from backgrounded ("&")
  10199 --- shell commands, e.g.: >vim
  10200 ---     echo system("cat - &", "foo")
  10201 --- <which is equivalent to: >
  10202 ---     $ echo foo | bash -c 'cat - &'
  10203 --- <The pipes are disconnected (unless overridden by shell
  10204 --- redirection syntax) before input can reach it. Use
  10205 --- |jobstart()| instead.
  10206 ---
  10207 --- Note: Use |shellescape()| or |::S| with |expand()| or
  10208 --- |fnamemodify()| to escape special characters in a command
  10209 --- argument. 'shellquote' and 'shellxquote' must be properly
  10210 --- configured. Example: >vim
  10211 ---     echo system('ls '..shellescape(expand('%:h')))
  10212 ---     echo system('ls '..expand('%:h:S'))
  10213 ---
  10214 --- <Unlike ":!cmd" there is no automatic check for changed files.
  10215 --- Use |:checktime| to force a check.
  10216 ---
  10217 --- @param cmd string|string[]
  10218 --- @param input? string|string[]|integer
  10219 --- @return string
  10220 function vim.fn.system(cmd, input) end
  10221 
  10222 --- Same as |system()|, but returns a |List| with lines (parts of
  10223 --- output separated by NL) with NULs transformed into NLs.
  10224 --- Output is the same as |readfile()| will output with {binary}
  10225 --- argument set to "b", except that a final newline is not
  10226 --- preserved, unless {keepempty} is non-zero.
  10227 --- Note that on MS-Windows you may get trailing CR characters.
  10228 ---
  10229 --- To see the difference between "echo hello" and "echo -n hello"
  10230 --- use |system()| and |split()|: >vim
  10231 ---   echo split(system('echo hello'), '\n', 1)
  10232 --- <
  10233 --- Returns an empty string on error.
  10234 ---
  10235 --- @param cmd string|string[]
  10236 --- @param input? string|string[]|integer
  10237 --- @param keepempty? integer
  10238 --- @return string[]
  10239 function vim.fn.systemlist(cmd, input, keepempty) end
  10240 
  10241 --- The result is a |List|, where each item is the number of the
  10242 --- buffer associated with each window in the current tab page.
  10243 --- {arg} specifies the number of the tab page to be used.  When
  10244 --- omitted the current tab page is used.
  10245 --- When {arg} is invalid the number zero is returned.
  10246 --- To get a list of all buffers in all tabs use this: >vim
  10247 ---   let buflist = []
  10248 ---   for i in range(tabpagenr('$'))
  10249 ---      call extend(buflist, tabpagebuflist(i + 1))
  10250 ---   endfor
  10251 --- <Note that a buffer may appear in more than one window.
  10252 ---
  10253 --- @param arg? integer
  10254 --- @return any
  10255 function vim.fn.tabpagebuflist(arg) end
  10256 
  10257 --- The result is a Number, which is the number of the current
  10258 --- tab page.  The first tab page has number 1.
  10259 ---
  10260 --- The optional argument {arg} supports the following values:
  10261 ---   $  the number of the last tab page (the tab page
  10262 ---     count).
  10263 ---   #  the number of the last accessed tab page
  10264 ---     (where |g<Tab>| goes to).  If there is no
  10265 ---     previous tab page, 0 is returned.
  10266 --- The number can be used with the |:tab| command.
  10267 ---
  10268 --- Returns zero on error.
  10269 ---
  10270 --- @param arg? '$'|'#'
  10271 --- @return integer
  10272 function vim.fn.tabpagenr(arg) end
  10273 
  10274 --- Like |winnr()| but for tab page {tabarg}.
  10275 --- {tabarg} specifies the number of tab page to be used.
  10276 --- {arg} is used like with |winnr()|:
  10277 --- - When omitted the current window number is returned.  This is
  10278 ---   the window which will be used when going to this tab page.
  10279 --- - When "$" the number of windows is returned.
  10280 --- - When "#" the previous window nr is returned.
  10281 --- Useful examples: >vim
  10282 ---     tabpagewinnr(1)      " current window of tab page 1
  10283 ---     tabpagewinnr(4, '$')    " number of windows in tab page 4
  10284 --- <When {tabarg} is invalid zero is returned.
  10285 ---
  10286 --- @param tabarg integer
  10287 --- @param arg? '$'|'#'
  10288 --- @return integer
  10289 function vim.fn.tabpagewinnr(tabarg, arg) end
  10290 
  10291 --- Returns a |List| with the file names used to search for tags
  10292 --- for the current buffer.  This is the 'tags' option expanded.
  10293 ---
  10294 --- @return string[]
  10295 function vim.fn.tagfiles() end
  10296 
  10297 --- Returns a |List| of tags matching the regular expression {expr}.
  10298 ---
  10299 --- If {filename} is passed it is used to prioritize the results
  10300 --- in the same way that |:tselect| does.  See |tag-priority|.
  10301 --- {filename} should be the full path of the file.
  10302 ---
  10303 --- Each list item is a dictionary with at least the following
  10304 --- entries:
  10305 ---   name    Name of the tag.
  10306 ---   filename  Name of the file where the tag is
  10307 ---       defined.  It is either relative to the
  10308 ---       current directory or a full path.
  10309 ---   cmd    Ex command used to locate the tag in
  10310 ---       the file.
  10311 ---   kind    Type of the tag.  The value for this
  10312 ---       entry depends on the language specific
  10313 ---       kind values.  Only available when
  10314 ---       using a tags file generated by
  10315 ---       Universal/Exuberant ctags or hdrtag.
  10316 ---   static    A file specific tag.  Refer to
  10317 ---       |static-tag| for more information.
  10318 --- More entries may be present, depending on the content of the
  10319 --- tags file: access, implementation, inherits and signature.
  10320 --- Refer to the ctags documentation for information about these
  10321 --- fields.  For C code the fields "struct", "class" and "enum"
  10322 --- may appear, they give the name of the entity the tag is
  10323 --- contained in.
  10324 ---
  10325 --- The ex-command "cmd" can be either an ex search pattern, a
  10326 --- line number or a line number followed by a byte number.
  10327 ---
  10328 --- If there are no matching tags, then an empty list is returned.
  10329 ---
  10330 --- To get an exact tag match, the anchors '^' and '$' should be
  10331 --- used in {expr}.  This also make the function work faster.
  10332 --- Refer to |tag-regexp| for more information about the tag
  10333 --- search regular expression pattern.
  10334 ---
  10335 --- Refer to 'tags' for information about how the tags file is
  10336 --- located by Vim.  Refer to |tags-file-format| for the format of
  10337 --- the tags file generated by the different ctags tools.
  10338 ---
  10339 --- @param expr any
  10340 --- @param filename? string
  10341 --- @return any
  10342 function vim.fn.taglist(expr, filename) end
  10343 
  10344 --- Return the tangent of {expr}, measured in radians, as a |Float|
  10345 --- in the range [-inf, inf].
  10346 --- {expr} must evaluate to a |Float| or a |Number|.
  10347 --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
  10348 --- Examples: >vim
  10349 ---   echo tan(10)
  10350 --- <  0.648361 >vim
  10351 ---   echo tan(-4.01)
  10352 --- <  -1.181502
  10353 ---
  10354 --- @param expr number
  10355 --- @return number
  10356 function vim.fn.tan(expr) end
  10357 
  10358 --- Return the hyperbolic tangent of {expr} as a |Float| in the
  10359 --- range [-1, 1].
  10360 --- {expr} must evaluate to a |Float| or a |Number|.
  10361 --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
  10362 --- Examples: >vim
  10363 ---   echo tanh(0.5)
  10364 --- <  0.462117 >vim
  10365 ---   echo tanh(-1)
  10366 --- <  -0.761594
  10367 ---
  10368 --- @param expr number
  10369 --- @return number
  10370 function vim.fn.tanh(expr) end
  10371 
  10372 --- Generates a (non-existent) filename located in the Nvim root
  10373 --- |tempdir|. Scripts can use the filename as a temporary file.
  10374 --- Example: >vim
  10375 ---   let tmpfile = tempname()
  10376 ---   exe "redir > " .. tmpfile
  10377 --- <
  10378 ---
  10379 --- @return string
  10380 function vim.fn.tempname() end
  10381 
  10382 --- @deprecated
  10383 --- Use |jobstart()| with `{term: v:true}` instead.
  10384 ---
  10385 --- @param cmd string|string[]
  10386 --- @param opts? table
  10387 --- @return integer
  10388 function vim.fn.termopen(cmd, opts) end
  10389 
  10390 --- Return a list with information about timers.
  10391 --- When {id} is given only information about this timer is
  10392 --- returned.  When timer {id} does not exist an empty list is
  10393 --- returned.
  10394 --- When {id} is omitted information about all timers is returned.
  10395 ---
  10396 --- For each timer the information is stored in a |Dictionary| with
  10397 --- these items:
  10398 ---     "id"      the timer ID
  10399 ---     "time"      time the timer was started with
  10400 ---     "repeat"      number of times the timer will still fire;
  10401 ---         -1 means forever
  10402 ---     "callback"      the callback
  10403 ---
  10404 --- @param id? integer
  10405 --- @return any
  10406 function vim.fn.timer_info(id) end
  10407 
  10408 --- Pause or unpause a timer.  A paused timer does not invoke its
  10409 --- callback when its time expires.  Unpausing a timer may cause
  10410 --- the callback to be invoked almost immediately if enough time
  10411 --- has passed.
  10412 ---
  10413 --- Pausing a timer is useful to avoid the callback to be called
  10414 --- for a short time.
  10415 ---
  10416 --- If {paused} evaluates to a non-zero Number or a non-empty
  10417 --- String, then the timer is paused, otherwise it is unpaused.
  10418 --- See |non-zero-arg|.
  10419 ---
  10420 --- @param timer integer
  10421 --- @param paused boolean
  10422 --- @return any
  10423 function vim.fn.timer_pause(timer, paused) end
  10424 
  10425 --- Create a timer and return the timer ID.
  10426 ---
  10427 --- {time} is the waiting time in milliseconds.  This is the
  10428 --- minimum time before invoking the callback.  When the system is
  10429 --- busy or Vim is not waiting for input the time will be longer.
  10430 --- Zero can be used to execute the callback when Vim is back in
  10431 --- the main loop.
  10432 ---
  10433 --- {callback} is the function to call.  It can be the name of a
  10434 --- function or a |Funcref|.  It is called with one argument, which
  10435 --- is the timer ID.  The callback is only invoked when Vim is
  10436 --- waiting for input.
  10437 ---
  10438 --- {options} is a dictionary.  Supported entries:
  10439 ---    "repeat"  Number of times to repeat the callback.
  10440 ---     -1 means forever.  Default is 1.
  10441 ---     If the timer causes an error three times in a
  10442 ---     row the repeat is cancelled.
  10443 ---
  10444 --- Returns -1 on error.
  10445 ---
  10446 --- Example: >vim
  10447 ---   func MyHandler(timer)
  10448 ---     echo 'Handler called'
  10449 ---   endfunc
  10450 ---   let timer = timer_start(500, 'MyHandler',
  10451 ---     \ {'repeat': 3})
  10452 --- <This invokes MyHandler() three times at 500 msec intervals.
  10453 ---
  10454 --- @param time number
  10455 --- @param callback string|function
  10456 --- @param options? table
  10457 --- @return any
  10458 function vim.fn.timer_start(time, callback, options) end
  10459 
  10460 --- Stop a timer.  The timer callback will no longer be invoked.
  10461 --- {timer} is an ID returned by |timer_start()|, thus it must be a
  10462 --- Number.  If {timer} does not exist there is no error.
  10463 ---
  10464 --- @param timer integer
  10465 --- @return any
  10466 function vim.fn.timer_stop(timer) end
  10467 
  10468 --- Stop all timers.  The timer callbacks will no longer be
  10469 --- invoked.  Useful if some timers is misbehaving.  If there are
  10470 --- no timers there is no error.
  10471 ---
  10472 --- @return any
  10473 function vim.fn.timer_stopall() end
  10474 
  10475 --- The result is a copy of the String given, with all uppercase
  10476 --- characters turned into lowercase (just like applying |gu| to
  10477 --- the string).  Returns an empty string on error.
  10478 ---
  10479 --- @param expr string
  10480 --- @return string
  10481 function vim.fn.tolower(expr) end
  10482 
  10483 --- The result is a copy of the String given, with all lowercase
  10484 --- characters turned into uppercase (just like applying |gU| to
  10485 --- the string).  Returns an empty string on error.
  10486 ---
  10487 --- @param expr string
  10488 --- @return string
  10489 function vim.fn.toupper(expr) end
  10490 
  10491 --- The result is a copy of the {src} string with all characters
  10492 --- which appear in {fromstr} replaced by the character in that
  10493 --- position in the {tostr} string.  Thus the first character in
  10494 --- {fromstr} is translated into the first character in {tostr}
  10495 --- and so on.  Exactly like the unix "tr" command.
  10496 --- This code also deals with multibyte characters properly.
  10497 ---
  10498 --- Returns an empty string on error.
  10499 ---
  10500 --- Examples: >vim
  10501 ---   echo tr("hello there", "ht", "HT")
  10502 --- <returns "Hello THere" >vim
  10503 ---   echo tr("<blob>", "<>", "{}")
  10504 --- <returns "{blob}"
  10505 ---
  10506 --- @param src string
  10507 --- @param fromstr string
  10508 --- @param tostr string
  10509 --- @return string
  10510 function vim.fn.tr(src, fromstr, tostr) end
  10511 
  10512 --- Return {text} as a String where any character in {mask} is
  10513 --- removed from the beginning and/or end of {text}.
  10514 ---
  10515 --- If {mask} is not given, or is an empty string, {mask} is all
  10516 --- characters up to 0x20, which includes Tab, space, NL and CR,
  10517 --- plus the non-breaking space character 0xa0.
  10518 ---
  10519 --- The optional {dir} argument specifies where to remove the
  10520 --- characters:
  10521 ---   0  remove from the beginning and end of {text}
  10522 ---   1  remove only at the beginning of {text}
  10523 ---   2  remove only at the end of {text}
  10524 --- When omitted both ends are trimmed.
  10525 ---
  10526 --- This function deals with multibyte characters properly.
  10527 --- Returns an empty string on error.
  10528 ---
  10529 --- Examples: >vim
  10530 ---   echo trim("   some text ")
  10531 --- <returns "some text" >vim
  10532 ---   echo trim("  \r\t\t\r RESERVE \t\n\x0B\xA0") .. "_TAIL"
  10533 --- <returns "RESERVE_TAIL" >vim
  10534 ---   echo trim("rm<Xrm<>X>rrm", "rm<>")
  10535 --- <returns "Xrm<>X" (characters in the middle are not removed) >vim
  10536 ---   echo trim("  vim  ", " ", 2)
  10537 --- <returns "  vim"
  10538 ---
  10539 --- @param text string
  10540 --- @param mask? string
  10541 --- @param dir? 0|1|2
  10542 --- @return string
  10543 function vim.fn.trim(text, mask, dir) end
  10544 
  10545 --- Return the largest integral value with magnitude less than or
  10546 --- equal to {expr} as a |Float| (truncate towards zero).
  10547 --- {expr} must evaluate to a |Float| or a |Number|.
  10548 --- Returns 0.0 if {expr} is not a |Float| or a |Number|.
  10549 --- Examples: >vim
  10550 ---   echo trunc(1.456)
  10551 --- <  1.0  >vim
  10552 ---   echo trunc(-5.456)
  10553 --- <  -5.0  >vim
  10554 ---   echo trunc(4.0)
  10555 --- <  4.0
  10556 ---
  10557 --- @param expr number
  10558 --- @return integer
  10559 function vim.fn.trunc(expr) end
  10560 
  10561 --- The result is a Number representing the type of {expr}.
  10562 --- Instead of using the number directly, it is better to use the
  10563 --- v:t_ variable that has the value:
  10564 ---   Number:      0  |v:t_number|
  10565 ---   String:      1  |v:t_string|
  10566 ---   Funcref:    2  |v:t_func|
  10567 ---   List:      3  |v:t_list|
  10568 ---   Dictionary: 4  |v:t_dict|
  10569 ---   Float:      5  |v:t_float|
  10570 ---   Boolean:    6  |v:t_bool| (|v:false| and |v:true|)
  10571 ---   Null:      7  (|v:null|)
  10572 ---   Blob:     10  |v:t_blob|
  10573 --- For backward compatibility, this method can be used: >vim
  10574 ---   if type(myvar) == type(0) | endif
  10575 ---   if type(myvar) == type("") | endif
  10576 ---   if type(myvar) == type(function("tr")) | endif
  10577 ---   if type(myvar) == type([]) | endif
  10578 ---   if type(myvar) == type({}) | endif
  10579 ---   if type(myvar) == type(0.0) | endif
  10580 ---   if type(myvar) == type(v:true) | endif
  10581 --- <In place of checking for |v:null| type it is better to check
  10582 --- for |v:null| directly as it is the only value of this type: >vim
  10583 ---   if myvar is v:null | endif
  10584 --- <To check if the v:t_ variables exist use this: >vim
  10585 ---   if exists('v:t_number') | endif
  10586 --- <
  10587 ---
  10588 --- @param expr any
  10589 --- @return integer
  10590 function vim.fn.type(expr) end
  10591 
  10592 --- Return the name of the undo file that would be used for a file
  10593 --- with name {name} when writing.  This uses the 'undodir'
  10594 --- option, finding directories that exist.  It does not check if
  10595 --- the undo file exists.
  10596 --- {name} is always expanded to the full path, since that is what
  10597 --- is used internally.
  10598 --- If {name} is empty undofile() returns an empty string, since a
  10599 --- buffer without a file name will not write an undo file.
  10600 --- Useful in combination with |:wundo| and |:rundo|.
  10601 ---
  10602 --- @param name string
  10603 --- @return string
  10604 function vim.fn.undofile(name) end
  10605 
  10606 --- Return the current state of the undo tree for the current
  10607 --- buffer, or for a specific buffer if {buf} is given.  The
  10608 --- result is a dictionary with the following items:
  10609 ---   "seq_last"  The highest undo sequence number used.
  10610 ---   "seq_cur"  The sequence number of the current position in
  10611 ---     the undo tree.  This differs from "seq_last"
  10612 ---     when some changes were undone.
  10613 ---   "time_cur"  Time last used for |:earlier| and related
  10614 ---     commands.  Use |strftime()| to convert to
  10615 ---     something readable.
  10616 ---   "save_last"  Number of the last file write.  Zero when no
  10617 ---     write yet.
  10618 ---   "save_cur"  Number of the current position in the undo
  10619 ---     tree.
  10620 ---   "synced"  Non-zero when the last undo block was synced.
  10621 ---     This happens when waiting from input from the
  10622 ---     user.  See |undo-blocks|.
  10623 ---   "entries"  A list of dictionaries with information about
  10624 ---     undo blocks.
  10625 ---
  10626 --- The first item in the "entries" list is the oldest undo item.
  10627 --- Each List item is a |Dictionary| with these items:
  10628 ---   "seq"    Undo sequence number.  Same as what appears in
  10629 ---     |:undolist|.
  10630 ---   "time"  Timestamp when the change happened.  Use
  10631 ---     |strftime()| to convert to something readable.
  10632 ---   "newhead"  Only appears in the item that is the last one
  10633 ---     that was added.  This marks the last change
  10634 ---     and where further changes will be added.
  10635 ---   "curhead"  Only appears in the item that is the last one
  10636 ---     that was undone.  This marks the current
  10637 ---     position in the undo tree, the block that will
  10638 ---     be used by a redo command.  When nothing was
  10639 ---     undone after the last change this item will
  10640 ---     not appear anywhere.
  10641 ---   "save"  Only appears on the last block before a file
  10642 ---     write.  The number is the write count.  The
  10643 ---     first write has number 1, the last one the
  10644 ---     "save_last" mentioned above.
  10645 ---   "alt"    Alternate entry.  This is again a List of undo
  10646 ---     blocks.  Each item may again have an "alt"
  10647 ---     item.
  10648 ---
  10649 --- @param buf? integer|string
  10650 --- @return vim.fn.undotree.ret
  10651 function vim.fn.undotree(buf) end
  10652 
  10653 --- Note: Prefer |vim.list.unique()| in Lua.
  10654 ---
  10655 --- Remove second and succeeding copies of repeated adjacent
  10656 --- {list} items in-place.  Returns {list}.  If you want a list
  10657 --- to remain unmodified make a copy first: >vim
  10658 ---   let newlist = uniq(copy(mylist))
  10659 --- <The default compare function uses the string representation of
  10660 --- each item.  For the use of {func} and {dict} see |sort()|.
  10661 --- For deduplicating text in the current buffer see |:uniq|.
  10662 ---
  10663 --- Returns zero if {list} is not a |List|.
  10664 ---
  10665 --- @param list any
  10666 --- @param func? any
  10667 --- @param dict? any
  10668 --- @return any[]|0
  10669 function vim.fn.uniq(list, func, dict) end
  10670 
  10671 --- Same as |charidx()| but returns the UTF-16 code unit index of
  10672 --- the byte at {idx} in {string} (after converting it to UTF-16).
  10673 ---
  10674 --- When {charidx} is present and TRUE, {idx} is used as the
  10675 --- character index in the String {string} instead of as the byte
  10676 --- index.
  10677 --- An {idx} in the middle of a UTF-8 sequence is rounded
  10678 --- downwards to the beginning of that sequence.
  10679 ---
  10680 --- Returns -1 if the arguments are invalid or if there are less
  10681 --- than {idx} bytes in {string}.  If there are exactly {idx}
  10682 --- bytes, the length of the string in UTF-16 code units is
  10683 --- returned.
  10684 ---
  10685 --- See |byteidx()| and |byteidxcomp()| for getting the byte index
  10686 --- from the UTF-16 index and |charidx()| for getting the
  10687 --- character index from the UTF-16 index.
  10688 --- Refer to |string-offset-encoding| for more information.
  10689 --- Examples: >vim
  10690 ---   echo utf16idx('a😊😊', 3)  " returns 2
  10691 ---   echo utf16idx('a😊😊', 7)  " returns 4
  10692 ---   echo utf16idx('a😊😊', 1, 0, 1)  " returns 2
  10693 ---   echo utf16idx('a😊😊', 2, 0, 1)  " returns 4
  10694 ---   echo utf16idx('aą́c', 6)    " returns 2
  10695 ---   echo utf16idx('aą́c', 6, 1)  " returns 4
  10696 ---   echo utf16idx('a😊😊', 9)  " returns -1
  10697 --- <
  10698 ---
  10699 --- @param string string
  10700 --- @param idx integer
  10701 --- @param countcc? boolean
  10702 --- @param charidx? boolean
  10703 --- @return integer
  10704 function vim.fn.utf16idx(string, idx, countcc, charidx) end
  10705 
  10706 --- Return a |List| with all the values of {dict}.  The |List| is
  10707 --- in arbitrary order.  Also see |items()| and |keys()|.
  10708 --- Returns zero if {dict} is not a |Dict|.
  10709 ---
  10710 --- @param dict any
  10711 --- @return any
  10712 function vim.fn.values(dict) end
  10713 
  10714 --- The result is a Number, which is the screen column of the file
  10715 --- position given with {expr}.  That is, the total number of
  10716 --- screen cells occupied by the part of the line until the end of
  10717 --- the character at that position.  When there is a <Tab> at the
  10718 --- position, the returned Number will be the column at the end of
  10719 --- the <Tab>.  For example, for a <Tab> in column 1, with 'ts'
  10720 --- set to 8, it returns 8.  |conceal| is ignored.
  10721 --- For the byte position use |col()|.
  10722 ---
  10723 --- For the use of {expr} see |getpos()| and |col()|.
  10724 --- When {expr} is "$", it means the end of the cursor line, so
  10725 --- the result is the number of cells in the cursor line plus one.
  10726 ---
  10727 --- When 'virtualedit' is used {expr} can be [lnum, col, off],
  10728 --- where "off" is the offset in screen columns from the start of
  10729 --- the character.  E.g., a position within a <Tab> or after the
  10730 --- last character.  When "off" is omitted zero is used.  When
  10731 --- Virtual editing is active in the current mode, a position
  10732 --- beyond the end of the line can be returned.  Also see
  10733 --- 'virtualedit'
  10734 ---
  10735 --- If {list} is present and non-zero then virtcol() returns a
  10736 --- List with the first and last screen position occupied by the
  10737 --- character.
  10738 ---
  10739 --- With the optional {winid} argument the values are obtained for
  10740 --- that window instead of the current window.
  10741 ---
  10742 --- Note that only marks in the current file can be used.
  10743 --- Examples: >vim
  10744 ---   " With text "foo^Lbar" and cursor on the "^L":
  10745 ---
  10746 ---   echo virtcol(".")  " returns 5
  10747 ---   echo virtcol(".", 1)  " returns [4, 5]
  10748 ---   echo virtcol("$")  " returns 9
  10749 ---
  10750 ---   " With text "    there", with 't at 'h':
  10751 ---
  10752 ---   echo virtcol("'t")  " returns 6
  10753 --- <
  10754 --- The first column is 1.  0 or [0, 0] is returned for an error.
  10755 ---
  10756 --- A more advanced example that echoes the maximum length of
  10757 --- all lines: >vim
  10758 ---     echo max(map(range(1, line('$')), "virtcol([v:val, '$'])"))
  10759 --- <
  10760 ---
  10761 --- @param expr string|any[]
  10762 --- @param list? boolean
  10763 --- @param winid? integer
  10764 --- @return integer|[integer, integer]
  10765 function vim.fn.virtcol(expr, list, winid) end
  10766 
  10767 --- The result is a Number, which is the byte index of the
  10768 --- character in window {winid} at buffer line {lnum} and virtual
  10769 --- column {col}.
  10770 ---
  10771 --- If buffer line {lnum} is an empty line, 0 is returned.
  10772 ---
  10773 --- If {col} is greater than the last virtual column in line
  10774 --- {lnum}, then the byte index of the character at the last
  10775 --- virtual column is returned.
  10776 ---
  10777 --- For a multi-byte character, the column number of the first
  10778 --- byte in the character is returned.
  10779 ---
  10780 --- The {winid} argument can be the window number or the
  10781 --- |window-ID|.  If this is zero, then the current window is used.
  10782 ---
  10783 --- Returns -1 if the window {winid} doesn't exist or the buffer
  10784 --- line {lnum} or virtual column {col} is invalid.
  10785 ---
  10786 --- See also |screenpos()|, |virtcol()| and |col()|.
  10787 ---
  10788 --- @param winid integer
  10789 --- @param lnum integer
  10790 --- @param col integer
  10791 --- @return integer
  10792 function vim.fn.virtcol2col(winid, lnum, col) end
  10793 
  10794 --- The result is a String, which describes the last Visual mode
  10795 --- used in the current buffer.  Initially it returns an empty
  10796 --- string, but once Visual mode has been used, it returns "v",
  10797 --- "V", or "<CTRL-V>" (a single CTRL-V character) for
  10798 --- character-wise, line-wise, or block-wise Visual mode
  10799 --- respectively.
  10800 --- Example: >vim
  10801 ---   exe "normal " .. visualmode()
  10802 --- <This enters the same Visual mode as before.  It is also useful
  10803 --- in scripts if you wish to act differently depending on the
  10804 --- Visual mode that was used.
  10805 --- If Visual mode is active, use |mode()| to get the Visual mode
  10806 --- (e.g., in a |:vmap|).
  10807 --- If {expr} is supplied and it evaluates to a non-zero Number or
  10808 --- a non-empty String, then the Visual mode will be cleared and
  10809 --- the old value is returned.  See |non-zero-arg|.
  10810 ---
  10811 --- @param expr? boolean
  10812 --- @return string
  10813 function vim.fn.visualmode(expr) end
  10814 
  10815 --- Waits until {condition} evaluates to |TRUE|, where {condition}
  10816 --- is a |Funcref| or |string| containing an expression.
  10817 ---
  10818 --- {timeout} is the maximum waiting time in milliseconds, -1
  10819 --- means forever.
  10820 ---
  10821 --- Condition is evaluated on user events, internal events, and
  10822 --- every {interval} milliseconds (default: 200).
  10823 ---
  10824 --- Returns a status integer:
  10825 ---   0 if the condition was satisfied before timeout
  10826 ---   -1 if the timeout was exceeded
  10827 ---   -2 if the function was interrupted (by |CTRL-C|)
  10828 ---   -3 if an error occurred
  10829 ---
  10830 --- @param timeout integer
  10831 --- @param condition any
  10832 --- @param interval? number
  10833 --- @return any
  10834 function vim.fn.wait(timeout, condition, interval) end
  10835 
  10836 --- Returns |TRUE| when the wildmenu is active and |FALSE|
  10837 --- otherwise.  See 'wildmenu' and 'wildmode'.
  10838 --- This can be used in mappings to handle the 'wildcharm' option
  10839 --- gracefully.  (Makes only sense with |mapmode-c| mappings).
  10840 ---
  10841 --- For example to make <c-j> work like <down> in wildmode, use: >vim
  10842 ---     cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>"
  10843 --- <
  10844 --- (Note: this needs the 'wildcharm' option set appropriately).
  10845 ---
  10846 --- @return any
  10847 function vim.fn.wildmenumode() end
  10848 
  10849 --- Start wildcard expansion in the command-line, using the
  10850 --- behavior defined by the 'wildmode' and 'wildoptions' settings.
  10851 ---
  10852 --- This function also enables completion in search patterns such
  10853 --- as |/|, |?|, |:s|, |:g|, |:v| and |:vimgrep|.
  10854 ---
  10855 --- Unlike pressing 'wildchar' manually, this function does not
  10856 --- produce a beep when no matches are found and generally
  10857 --- operates more quietly.  This makes it suitable for triggering
  10858 --- completion automatically.
  10859 ---
  10860 --- Note: After navigating command-line history, the first call to
  10861 --- wildtrigger() is a no-op; a second call is needed to start
  10862 --- expansion.  This is to support history navigation in
  10863 --- command-line autocompletion.
  10864 ---
  10865 --- See |cmdline-autocompletion|.
  10866 ---
  10867 --- Return value is always 0.
  10868 ---
  10869 --- @return number
  10870 function vim.fn.wildtrigger() end
  10871 
  10872 --- Like `execute()` but in the context of window {id}.
  10873 --- The window will temporarily be made the current window,
  10874 --- without triggering autocommands or changing directory.  When
  10875 --- executing {command} autocommands will be triggered, this may
  10876 --- have unexpected side effects.  Use `:noautocmd` if needed.
  10877 --- Example: >vim
  10878 ---   call win_execute(winid, 'syntax enable')
  10879 --- <Doing the same with `setwinvar()` would not trigger
  10880 --- autocommands and not actually show syntax highlighting.
  10881 ---
  10882 --- When window {id} does not exist then no error is given and
  10883 --- an empty string is returned.
  10884 ---
  10885 --- @param id integer
  10886 --- @param command string
  10887 --- @param silent? boolean
  10888 --- @return any
  10889 function vim.fn.win_execute(id, command, silent) end
  10890 
  10891 --- Returns a |List| with |window-ID|s for windows that contain
  10892 --- buffer {bufnr}.  When there is none the list is empty.
  10893 ---
  10894 --- @param bufnr integer
  10895 --- @return integer[]
  10896 function vim.fn.win_findbuf(bufnr) end
  10897 
  10898 --- Get the |window-ID| for the specified window.
  10899 --- When {win} is missing use the current window.
  10900 --- With {win} this is the window number.  The top window has
  10901 --- number 1.
  10902 --- Without {tab} use the current tab, otherwise the tab with
  10903 --- number {tab}.  The first tab has number one.
  10904 --- Return zero if the window cannot be found.
  10905 ---
  10906 --- @param win? integer
  10907 --- @param tab? integer
  10908 --- @return integer
  10909 function vim.fn.win_getid(win, tab) end
  10910 
  10911 --- Return the type of the window:
  10912 ---   "autocmd"  autocommand window.  Temporary window
  10913 ---       used to execute autocommands.
  10914 ---   "command"  command-line window |cmdwin|
  10915 ---   (empty)    normal window
  10916 ---   "loclist"  |location-list-window|
  10917 ---   "popup"    floating window |api-floatwin|
  10918 ---   "preview"  preview window |preview-window|
  10919 ---   "quickfix"  |quickfix-window|
  10920 ---   "unknown"  window {nr} not found
  10921 ---
  10922 --- When {nr} is omitted return the type of the current window.
  10923 --- When {nr} is given return the type of this window by number or
  10924 --- |window-ID|.
  10925 ---
  10926 --- Also see the 'buftype' option.
  10927 ---
  10928 --- @param nr? integer
  10929 --- @return 'autocmd'|'command'|''|'loclist'|'popup'|'preview'|'quickfix'|'unknown'
  10930 function vim.fn.win_gettype(nr) end
  10931 
  10932 --- Go to window with ID {expr}.  This may also change the current
  10933 --- tabpage.
  10934 --- Return TRUE if successful, FALSE if the window cannot be
  10935 --- found.
  10936 ---
  10937 --- @param expr integer
  10938 --- @return 0|1
  10939 function vim.fn.win_gotoid(expr) end
  10940 
  10941 --- Return a list with the tab number and window number of window
  10942 --- with ID {expr}: [tabnr, winnr].
  10943 --- Return [0, 0] if the window cannot be found.
  10944 ---
  10945 --- @param expr integer
  10946 --- @return any
  10947 function vim.fn.win_id2tabwin(expr) end
  10948 
  10949 --- Return the window number of window with ID {expr}.
  10950 --- Return 0 if the window cannot be found in the current tabpage.
  10951 ---
  10952 --- @param expr integer
  10953 --- @return integer
  10954 function vim.fn.win_id2win(expr) end
  10955 
  10956 --- Move window {nr}'s vertical separator (i.e., the right border)
  10957 --- by {offset} columns, as if being dragged by the mouse.  {nr}
  10958 --- can be a window number or |window-ID|.  A positive {offset}
  10959 --- moves right and a negative {offset} moves left.  Moving a
  10960 --- window's vertical separator will change the width of the
  10961 --- window and the width of other windows adjacent to the vertical
  10962 --- separator.  The magnitude of movement may be smaller than
  10963 --- specified (e.g., as a consequence of maintaining
  10964 --- 'winminwidth').  Returns TRUE if the window can be found and
  10965 --- FALSE otherwise.
  10966 --- This will fail for the rightmost window and a full-width
  10967 --- window, since it has no separator on the right.
  10968 --- Only works for the current tab page. *E1308*
  10969 ---
  10970 --- @param nr integer
  10971 --- @param offset integer
  10972 --- @return any
  10973 function vim.fn.win_move_separator(nr, offset) end
  10974 
  10975 --- Move window {nr}'s status line (i.e., the bottom border) by
  10976 --- {offset} rows, as if being dragged by the mouse.  {nr} can be
  10977 --- a window number or |window-ID|.  A positive {offset} moves
  10978 --- down and a negative {offset} moves up.  Moving a window's
  10979 --- status line will change the height of the window and the
  10980 --- height of other windows adjacent to the status line. The
  10981 --- magnitude of movement may be smaller than specified (e.g., as
  10982 --- a consequence of maintaining 'winminheight'). Returns TRUE if
  10983 --- the window can be found and FALSE otherwise.
  10984 --- Only works for the current tab page.
  10985 ---
  10986 --- @param nr integer
  10987 --- @param offset integer
  10988 --- @return any
  10989 function vim.fn.win_move_statusline(nr, offset) end
  10990 
  10991 --- Return the screen position of window {nr} as a list with two
  10992 --- numbers: [row, col].  The first window always has position
  10993 --- [1, 1], unless there is a tabline, then it is [2, 1].
  10994 --- {nr} can be the window number or the |window-ID|.  Use zero
  10995 --- for the current window.
  10996 --- Returns [0, 0] if the window cannot be found.
  10997 ---
  10998 --- @param nr integer
  10999 --- @return any
  11000 function vim.fn.win_screenpos(nr) end
  11001 
  11002 --- Temporarily switch to window {target}, then move window {nr}
  11003 --- to a new split adjacent to {target}.
  11004 --- Unlike commands such as |:split|, no new windows are created
  11005 --- (the |window-ID| of window {nr} is unchanged after the move).
  11006 ---
  11007 --- Both {nr} and {target} can be window numbers or |window-ID|s.
  11008 --- Both must be in the current tab page.
  11009 ---
  11010 --- Returns zero for success, non-zero for failure.
  11011 ---
  11012 --- {options} is a |Dictionary| with the following optional entries:
  11013 ---   "vertical"  When TRUE, the split is created vertically,
  11014 ---     like with |:vsplit|.
  11015 ---   "rightbelow"  When TRUE, the split is made below or to the
  11016 ---     right (if vertical).  When FALSE, it is done
  11017 ---     above or to the left (if vertical).  When not
  11018 ---     present, the values of 'splitbelow' and
  11019 ---     'splitright' are used.
  11020 ---
  11021 --- @param nr integer
  11022 --- @param target integer
  11023 --- @param options? table
  11024 --- @return any
  11025 function vim.fn.win_splitmove(nr, target, options) end
  11026 
  11027 --- The result is a Number, which is the number of the buffer
  11028 --- associated with window {nr}.  {nr} can be the window number or
  11029 --- the |window-ID|.
  11030 --- When {nr} is zero, the number of the buffer in the current
  11031 --- window is returned.
  11032 --- When window {nr} doesn't exist, -1 is returned.
  11033 --- Example: >vim
  11034 ---   echo "The file in the current window is " .. bufname(winbufnr(0))
  11035 --- <
  11036 ---
  11037 --- @param nr integer
  11038 --- @return integer
  11039 function vim.fn.winbufnr(nr) end
  11040 
  11041 --- The result is a Number, which is the virtual column of the
  11042 --- cursor in the window.  This is counting screen cells from the
  11043 --- left side of the window.  The leftmost column is one.
  11044 ---
  11045 --- @return integer
  11046 function vim.fn.wincol() end
  11047 
  11048 --- The result is a String.  For MS-Windows it indicates the OS
  11049 --- version.  E.g, Windows 10 is "10.0", Windows 8 is "6.2",
  11050 --- Windows XP is "5.1".  For non-MS-Windows systems the result is
  11051 --- an empty string.
  11052 ---
  11053 --- @return string
  11054 function vim.fn.windowsversion() end
  11055 
  11056 --- Gets the height of |window-ID| {nr} (zero for "current
  11057 --- window"), excluding any 'winbar' and 'statusline'. Returns -1
  11058 --- if window {nr} doesn't exist. An existing window always has
  11059 --- a height of zero or more.
  11060 ---
  11061 --- Examples: >vim
  11062 ---   echo "Current window has " .. winheight(0) .. " lines."
  11063 --- <
  11064 ---
  11065 --- @param nr integer
  11066 --- @return integer
  11067 function vim.fn.winheight(nr) end
  11068 
  11069 --- The result is a nested List containing the layout of windows
  11070 --- in a tabpage.
  11071 ---
  11072 --- Without {tabnr} use the current tabpage, otherwise the tabpage
  11073 --- with number {tabnr}.  If the tabpage {tabnr} is not found,
  11074 --- returns an empty list.
  11075 ---
  11076 --- For a leaf window, it returns: >
  11077 ---   ["leaf", {winid}]
  11078 --- <
  11079 --- For horizontally split windows, which form a column, it
  11080 --- returns: >
  11081 ---   ["col", [{nested list of windows}]]
  11082 --- <For vertically split windows, which form a row, it returns: >
  11083 ---   ["row", [{nested list of windows}]]
  11084 --- <
  11085 --- Example: >vim
  11086 ---   " Only one window in the tab page
  11087 ---   echo winlayout()
  11088 --- < >
  11089 ---   ['leaf', 1000]
  11090 --- < >vim
  11091 ---   " Two horizontally split windows
  11092 ---   echo winlayout()
  11093 --- < >
  11094 ---   ['col', [['leaf', 1000], ['leaf', 1001]]]
  11095 --- < >vim
  11096 ---   " The second tab page, with three horizontally split
  11097 ---   " windows, with two vertically split windows in the
  11098 ---   " middle window
  11099 ---   echo winlayout(2)
  11100 --- < >
  11101 ---   ['col', [['leaf', 1002], ['row', [['leaf', 1003],
  11102 ---           ['leaf', 1001]]], ['leaf', 1000]]]
  11103 --- <
  11104 ---
  11105 --- @param tabnr? integer
  11106 --- @return vim.fn.winlayout.ret
  11107 function vim.fn.winlayout(tabnr) end
  11108 
  11109 --- The result is a Number, which is the screen line of the cursor
  11110 --- in the window.  This is counting screen lines from the top of
  11111 --- the window.  The first line is one.
  11112 --- If the cursor was moved the view on the file will be updated
  11113 --- first, this may cause a scroll.
  11114 ---
  11115 --- @return integer
  11116 function vim.fn.winline() end
  11117 
  11118 --- The result is a Number, which is the number of the current
  11119 --- window.  The top window has number 1.
  11120 --- Returns zero for a hidden or non |focusable| window, unless
  11121 --- it is the current window.
  11122 ---
  11123 --- The optional argument {arg} supports the following values:
  11124 ---   $  the number of the last window (the window
  11125 ---     count).
  11126 ---   #  the number of the last accessed window (where
  11127 ---     |CTRL-W_p| goes to).  If there is no previous
  11128 ---     window or it is in another tab page 0 is
  11129 ---     returned.  May refer to the current window in
  11130 ---     some cases (e.g. when evaluating 'statusline'
  11131 ---     expressions).
  11132 ---   {N}j  the number of the Nth window below the
  11133 ---     current window (where |CTRL-W_j| goes to).
  11134 ---   {N}k  the number of the Nth window above the current
  11135 ---     window (where |CTRL-W_k| goes to).
  11136 ---   {N}h  the number of the Nth window left of the
  11137 ---     current window (where |CTRL-W_h| goes to).
  11138 ---   {N}l  the number of the Nth window right of the
  11139 ---     current window (where |CTRL-W_l| goes to).
  11140 --- The number can be used with |CTRL-W_w| and ":wincmd w"
  11141 --- |:wincmd|.
  11142 --- When {arg} is invalid an error is given and zero is returned.
  11143 --- Also see |tabpagewinnr()| and |win_getid()|.
  11144 --- Examples: >vim
  11145 ---   let window_count = winnr('$')
  11146 ---   let prev_window = winnr('#')
  11147 ---   let wnum = winnr('3k')
  11148 --- <
  11149 ---
  11150 --- @param arg? string|integer
  11151 --- @return integer
  11152 function vim.fn.winnr(arg) end
  11153 
  11154 --- Returns a sequence of |:resize| commands that should restore
  11155 --- the current window sizes.  Only works properly when no windows
  11156 --- are opened or closed and the current window and tab page is
  11157 --- unchanged.
  11158 --- Example: >vim
  11159 ---   let cmd = winrestcmd()
  11160 ---   call MessWithWindowSizes()
  11161 ---   exe cmd
  11162 --- <
  11163 ---
  11164 --- @return string
  11165 function vim.fn.winrestcmd() end
  11166 
  11167 --- Uses the |Dictionary| returned by |winsaveview()| to restore
  11168 --- the view of the current window.
  11169 --- Note: The {dict} does not have to contain all values, that are
  11170 --- returned by |winsaveview()|.  If values are missing, those
  11171 --- settings won't be restored.  So you can use: >vim
  11172 ---     call winrestview({'curswant': 4})
  11173 --- <
  11174 --- This will only set the curswant value (the column the cursor
  11175 --- wants to move on vertical movements) of the cursor to column 5
  11176 --- (yes, that is 5), while all other settings will remain the
  11177 --- same.  This is useful, if you set the cursor position
  11178 --- manually.
  11179 ---
  11180 --- If you have changed the values the result is unpredictable.
  11181 --- If the window size changed the result won't be the same.
  11182 ---
  11183 --- @param dict vim.fn.winrestview.dict
  11184 --- @return any
  11185 function vim.fn.winrestview(dict) end
  11186 
  11187 --- Returns a |Dictionary| that contains information to restore
  11188 --- the view of the current window.  Use |winrestview()| to
  11189 --- restore the view.
  11190 --- This is useful if you have a mapping that jumps around in the
  11191 --- buffer and you want to go back to the original view.
  11192 --- This does not save fold information.  Use the 'foldenable'
  11193 --- option to temporarily switch off folding, so that folds are
  11194 --- not opened when moving around.  This may have side effects.
  11195 --- The return value includes:
  11196 ---   lnum    cursor line number
  11197 ---   col    cursor column (Note: the first column
  11198 ---       zero, as opposed to what |getcurpos()|
  11199 ---       returns)
  11200 ---   coladd    cursor column offset for 'virtualedit'
  11201 ---   curswant  column for vertical movement (Note:
  11202 ---       the first column is zero, as opposed
  11203 ---       to what |getcurpos()| returns).  After
  11204 ---       |$| command it will be a very large
  11205 ---       number equal to |v:maxcol|.
  11206 ---   topline    first line in the window
  11207 ---   topfill    filler lines, only in diff mode
  11208 ---   leftcol    first column displayed; only used when
  11209 ---       'wrap' is off
  11210 ---   skipcol    columns skipped
  11211 --- Note that no option values are saved.
  11212 ---
  11213 --- @return vim.fn.winsaveview.ret
  11214 function vim.fn.winsaveview() end
  11215 
  11216 --- Gets the width of |window-ID| {nr} (zero for "current
  11217 --- window"), including columns (|sign-column|, 'statuscolumn',
  11218 --- etc.). Returns -1 if window {nr} doesn't exist. An existing
  11219 --- window always has a width of zero or more.
  11220 ---
  11221 --- Example: >vim
  11222 ---   echo "Current window has " .. winwidth(0) .. " columns."
  11223 ---   if winwidth(0) <= 50
  11224 ---     50 wincmd |
  11225 ---   endif
  11226 --- <
  11227 --- To get the buffer "viewport", use |getwininfo()|: >vim
  11228 ---     :echo getwininfo(win_getid())[0].width - getwininfo(win_getid())[0].textoff
  11229 --- <
  11230 --- To get the Nvim screen size, see the 'columns' option.
  11231 ---
  11232 --- @param nr integer
  11233 --- @return integer
  11234 function vim.fn.winwidth(nr) end
  11235 
  11236 --- The result is a dictionary of byte/chars/word statistics for
  11237 --- the current buffer.  This is the same info as provided by
  11238 --- |g_CTRL-G|
  11239 --- The return value includes:
  11240 ---   bytes    Number of bytes in the buffer
  11241 ---   chars    Number of chars in the buffer
  11242 ---   words    Number of words in the buffer
  11243 ---   cursor_bytes    Number of bytes before cursor position
  11244 ---       (not in Visual mode)
  11245 ---   cursor_chars    Number of chars before cursor position
  11246 ---       (not in Visual mode)
  11247 ---   cursor_words    Number of words before cursor position
  11248 ---       (not in Visual mode)
  11249 ---   visual_bytes    Number of bytes visually selected
  11250 ---       (only in Visual mode)
  11251 ---   visual_chars    Number of chars visually selected
  11252 ---       (only in Visual mode)
  11253 ---   visual_words    Number of words visually selected
  11254 ---       (only in Visual mode)
  11255 ---
  11256 --- @return any
  11257 function vim.fn.wordcount() end
  11258 
  11259 --- When {object} is a |List| write it to file {fname}.  Each list
  11260 --- item is separated with a NL.  Each list item must be a String
  11261 --- or Number.
  11262 --- All NL characters are replaced with a NUL character.
  11263 --- Inserting CR characters needs to be done before passing {list}
  11264 --- to writefile().
  11265 ---
  11266 --- When {object} is a |Blob| write the bytes to file {fname}
  11267 --- unmodified, also when binary mode is not specified.
  11268 ---
  11269 --- {flags} must be a String.  These characters are recognized:
  11270 ---
  11271 --- 'b'  Binary mode is used: There will not be a NL after the
  11272 ---      last list item.  An empty item at the end does cause the
  11273 ---      last line in the file to end in a NL.
  11274 ---
  11275 --- 'a'  Append mode is used, lines are appended to the file: >vim
  11276 ---   call writefile(["foo"], "event.log", "a")
  11277 ---   call writefile(["bar"], "event.log", "a")
  11278 --- <
  11279 --- 'D'  Delete the file when the current function ends.  This
  11280 ---      works like: >vim
  11281 ---   defer delete({fname})
  11282 --- <     Fails when not in a function.  Also see |:defer|.
  11283 ---
  11284 --- 's'  fsync() is called after writing the file.  This flushes
  11285 ---      the file to disk, if possible.  This takes more time but
  11286 ---      avoids losing the file if the system crashes.
  11287 ---
  11288 --- 'S'  fsync() is not called, even when 'fsync' is set.
  11289 ---
  11290 ---      When {flags} does not contain "S" or "s" then fsync() is
  11291 ---      called if the 'fsync' option is set.
  11292 ---
  11293 --- An existing file is overwritten, if possible.
  11294 ---
  11295 --- When the write fails -1 is returned, otherwise 0.  There is an
  11296 --- error message if the file can't be created or when writing
  11297 --- fails.
  11298 ---
  11299 --- Also see |readfile()|.
  11300 --- To copy a file byte for byte: >vim
  11301 ---   let fl = readfile("foo", "b")
  11302 ---   call writefile(fl, "foocopy", "b")
  11303 --- <
  11304 ---
  11305 --- @param object any
  11306 --- @param fname string
  11307 --- @param flags? string
  11308 --- @return any
  11309 function vim.fn.writefile(object, fname, flags) end
  11310 
  11311 --- Bitwise XOR on the two arguments.  The arguments are converted
  11312 --- to a number.  A List, Dict or Float argument causes an error.
  11313 --- Also see `and()` and `or()`.
  11314 --- Example: >vim
  11315 ---   let bits = xor(bits, 0x80)
  11316 --- <
  11317 ---
  11318 --- @param expr integer
  11319 --- @param expr1 integer
  11320 --- @return integer
  11321 function vim.fn.xor(expr, expr1) end