api.lua 107 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556
  1. --- @meta _
  2. -- THIS FILE IS GENERATED
  3. -- DO NOT EDIT
  4. error('Cannot require a meta file')
  5. --- This file embeds vimdoc as the function descriptions
  6. --- so ignore any doc related errors.
  7. --- @diagnostic disable: undefined-doc-name,luadoc-miss-symbol
  8. vim.api = {}
  9. --- @private
  10. --- @param buffer integer
  11. --- @param keys boolean
  12. --- @param dot boolean
  13. --- @return string
  14. function vim.api.nvim__buf_debug_extmarks(buffer, keys, dot) end
  15. --- @private
  16. --- @param buffer integer
  17. --- @return table<string,any>
  18. function vim.api.nvim__buf_stats(buffer) end
  19. --- @private
  20. --- EXPERIMENTAL: this API may change in the future.
  21. ---
  22. --- Sets info for the completion item at the given index. If the info text was shown in a window,
  23. --- returns the window and buffer ids, or empty dict if not shown.
  24. ---
  25. --- @param index integer Completion candidate index
  26. --- @param opts vim.api.keyset.complete_set Optional parameters.
  27. --- - info: (string) info text.
  28. --- @return table<string,any> # Dict containing these keys:
  29. --- - winid: (number) floating window id
  30. --- - bufnr: (number) buffer id in floating window
  31. function vim.api.nvim__complete_set(index, opts) end
  32. --- @private
  33. --- @return string
  34. function vim.api.nvim__get_lib_dir() end
  35. --- @private
  36. --- Find files in runtime directories
  37. ---
  38. --- @param pat any[] pattern of files to search for
  39. --- @param all boolean whether to return all matches or only the first
  40. --- @param opts vim.api.keyset.runtime is_lua: only search Lua subdirs
  41. --- @return string[] # list of absolute paths to the found files
  42. function vim.api.nvim__get_runtime(pat, all, opts) end
  43. --- @private
  44. --- Returns object given as argument.
  45. ---
  46. --- This API function is used for testing. One should not rely on its presence
  47. --- in plugins.
  48. ---
  49. --- @param obj any Object to return.
  50. --- @return any # its argument.
  51. function vim.api.nvim__id(obj) end
  52. --- @private
  53. --- Returns array given as argument.
  54. ---
  55. --- This API function is used for testing. One should not rely on its presence
  56. --- in plugins.
  57. ---
  58. --- @param arr any[] Array to return.
  59. --- @return any[] # its argument.
  60. function vim.api.nvim__id_array(arr) end
  61. --- @private
  62. --- Returns dict given as argument.
  63. ---
  64. --- This API function is used for testing. One should not rely on its presence
  65. --- in plugins.
  66. ---
  67. --- @param dct table<string,any> Dict to return.
  68. --- @return table<string,any> # its argument.
  69. function vim.api.nvim__id_dict(dct) end
  70. --- @private
  71. --- Returns floating-point value given as argument.
  72. ---
  73. --- This API function is used for testing. One should not rely on its presence
  74. --- in plugins.
  75. ---
  76. --- @param flt number Value to return.
  77. --- @return number # its argument.
  78. function vim.api.nvim__id_float(flt) end
  79. --- @private
  80. --- NB: if your UI doesn't use hlstate, this will not return hlstate first time.
  81. --- @param grid integer
  82. --- @param row integer
  83. --- @param col integer
  84. --- @return any[]
  85. function vim.api.nvim__inspect_cell(grid, row, col) end
  86. --- @private
  87. --- For testing. The condition in schar_cache_clear_if_full is hard to
  88. --- reach, so this function can be used to force a cache clear in a test.
  89. function vim.api.nvim__invalidate_glyph_cache() end
  90. --- @private
  91. --- EXPERIMENTAL: this API will change in the future.
  92. ---
  93. --- Get the properties for namespace
  94. ---
  95. --- @param ns_id integer Namespace
  96. --- @return vim.api.keyset.ns_opts # Map defining the namespace properties, see |nvim__ns_set()|
  97. function vim.api.nvim__ns_get(ns_id) end
  98. --- @private
  99. --- EXPERIMENTAL: this API will change in the future.
  100. ---
  101. --- Set some properties for namespace
  102. ---
  103. --- @param ns_id integer Namespace
  104. --- @param opts vim.api.keyset.ns_opts Optional parameters to set:
  105. --- - wins: a list of windows to be scoped in
  106. function vim.api.nvim__ns_set(ns_id, opts) end
  107. --- @private
  108. --- EXPERIMENTAL: this API may change in the future.
  109. ---
  110. --- Instruct Nvim to redraw various components.
  111. ---
  112. ---
  113. --- @see `:help :redraw`
  114. --- @param opts vim.api.keyset.redraw Optional parameters.
  115. --- - win: Target a specific `window-ID` as described below.
  116. --- - buf: Target a specific buffer number as described below.
  117. --- - flush: Update the screen with pending updates.
  118. --- - valid: When present mark `win`, `buf`, or all windows for
  119. --- redraw. When `true`, only redraw changed lines (useful for
  120. --- decoration providers). When `false`, forcefully redraw.
  121. --- - range: Redraw a range in `buf`, the buffer in `win` or the
  122. --- current buffer (useful for decoration providers). Expects a
  123. --- tuple `[first, last]` with the first and last line number
  124. --- of the range, 0-based end-exclusive `api-indexing`.
  125. --- - cursor: Immediately update cursor position on the screen in
  126. --- `win` or the current window.
  127. --- - statuscolumn: Redraw the 'statuscolumn' in `buf`, `win` or
  128. --- all windows.
  129. --- - statusline: Redraw the 'statusline' in `buf`, `win` or all
  130. --- windows.
  131. --- - winbar: Redraw the 'winbar' in `buf`, `win` or all windows.
  132. --- - tabline: Redraw the 'tabline'.
  133. function vim.api.nvim__redraw(opts) end
  134. --- @private
  135. --- @return any[]
  136. function vim.api.nvim__runtime_inspect() end
  137. --- @private
  138. --- @param path string
  139. function vim.api.nvim__screenshot(path) end
  140. --- @private
  141. --- Gets internal stats.
  142. ---
  143. --- @return table<string,any> # Map of various internal stats.
  144. function vim.api.nvim__stats() end
  145. --- @private
  146. --- @param str string
  147. --- @return any
  148. function vim.api.nvim__unpack(str) end
  149. --- @deprecated
  150. --- @param buffer integer
  151. --- @param ns_id integer
  152. --- @param hl_group string
  153. --- @param line integer
  154. --- @param col_start integer
  155. --- @param col_end integer
  156. --- @return integer
  157. function vim.api.nvim_buf_add_highlight(buffer, ns_id, hl_group, line, col_start, col_end) end
  158. --- Activates buffer-update events on a channel, or as Lua callbacks.
  159. ---
  160. --- Example (Lua): capture buffer updates in a global `events` variable
  161. --- (use "vim.print(events)" to see its contents):
  162. ---
  163. --- ```lua
  164. --- events = {}
  165. --- vim.api.nvim_buf_attach(0, false, {
  166. --- on_lines = function(...)
  167. --- table.insert(events, {...})
  168. --- end,
  169. --- })
  170. --- ```
  171. ---
  172. ---
  173. --- @see vim.api.nvim_buf_detach
  174. --- @see `:help api-buffer-updates-lua`
  175. --- @param buffer integer Buffer handle, or 0 for current buffer
  176. --- @param send_buffer boolean True if the initial notification should contain the
  177. --- whole buffer: first notification will be `nvim_buf_lines_event`.
  178. --- Else the first notification will be `nvim_buf_changedtick_event`.
  179. --- Not for Lua callbacks.
  180. --- @param opts vim.api.keyset.buf_attach Optional parameters.
  181. --- - on_lines: Lua callback invoked on change.
  182. --- Return a truthy value (not `false` or `nil`) to detach. Args:
  183. --- - the string "lines"
  184. --- - buffer handle
  185. --- - b:changedtick
  186. --- - first line that changed (zero-indexed)
  187. --- - last line that was changed
  188. --- - last line in the updated range
  189. --- - byte count of previous contents
  190. --- - deleted_codepoints (if `utf_sizes` is true)
  191. --- - deleted_codeunits (if `utf_sizes` is true)
  192. --- - on_bytes: Lua callback invoked on change.
  193. --- This callback receives more granular information about the
  194. --- change compared to on_lines.
  195. --- Return a truthy value (not `false` or `nil`) to detach. Args:
  196. --- - the string "bytes"
  197. --- - buffer handle
  198. --- - b:changedtick
  199. --- - start row of the changed text (zero-indexed)
  200. --- - start column of the changed text
  201. --- - byte offset of the changed text (from the start of
  202. --- the buffer)
  203. --- - old end row of the changed text (offset from start row)
  204. --- - old end column of the changed text
  205. --- (if old end row = 0, offset from start column)
  206. --- - old end byte length of the changed text
  207. --- - new end row of the changed text (offset from start row)
  208. --- - new end column of the changed text
  209. --- (if new end row = 0, offset from start column)
  210. --- - new end byte length of the changed text
  211. --- - on_changedtick: Lua callback invoked on changedtick
  212. --- increment without text change. Args:
  213. --- - the string "changedtick"
  214. --- - buffer handle
  215. --- - b:changedtick
  216. --- - on_detach: Lua callback invoked on detach. Args:
  217. --- - the string "detach"
  218. --- - buffer handle
  219. --- - on_reload: Lua callback invoked on reload. The entire buffer
  220. --- content should be considered changed. Args:
  221. --- - the string "reload"
  222. --- - buffer handle
  223. --- - utf_sizes: include UTF-32 and UTF-16 size of the replaced
  224. --- region, as args to `on_lines`.
  225. --- - preview: also attach to command preview (i.e. 'inccommand')
  226. --- events.
  227. --- @return boolean # False if attach failed (invalid parameter, or buffer isn't loaded);
  228. --- otherwise True. TODO: LUA_API_NO_EVAL
  229. function vim.api.nvim_buf_attach(buffer, send_buffer, opts) end
  230. --- Call a function with buffer as temporary current buffer.
  231. ---
  232. --- This temporarily switches current buffer to "buffer".
  233. --- If the current window already shows "buffer", the window is not switched.
  234. --- If a window inside the current tabpage (including a float) already shows the
  235. --- buffer, then one of those windows will be set as current window temporarily.
  236. --- Otherwise a temporary scratch window (called the "autocmd window" for
  237. --- historical reasons) will be used.
  238. ---
  239. --- This is useful e.g. to call Vimscript functions that only work with the
  240. --- current buffer/window currently, like `jobstart(…, {'term': v:true})`.
  241. ---
  242. --- @param buffer integer Buffer handle, or 0 for current buffer
  243. --- @param fun function Function to call inside the buffer (currently Lua callable
  244. --- only)
  245. --- @return any # Return value of function.
  246. function vim.api.nvim_buf_call(buffer, fun) end
  247. --- @deprecated
  248. --- @param buffer integer
  249. --- @param ns_id integer
  250. --- @param line_start integer
  251. --- @param line_end integer
  252. function vim.api.nvim_buf_clear_highlight(buffer, ns_id, line_start, line_end) end
  253. --- Clears `namespace`d objects (highlights, `extmarks`, virtual text) from
  254. --- a region.
  255. ---
  256. --- Lines are 0-indexed. `api-indexing` To clear the namespace in the entire
  257. --- buffer, specify line_start=0 and line_end=-1.
  258. ---
  259. --- @param buffer integer Buffer handle, or 0 for current buffer
  260. --- @param ns_id integer Namespace to clear, or -1 to clear all namespaces.
  261. --- @param line_start integer Start of range of lines to clear
  262. --- @param line_end integer End of range of lines to clear (exclusive) or -1 to clear
  263. --- to end of buffer.
  264. function vim.api.nvim_buf_clear_namespace(buffer, ns_id, line_start, line_end) end
  265. --- Creates a buffer-local command `user-commands`.
  266. ---
  267. --- @see vim.api.nvim_create_user_command
  268. --- @param buffer integer Buffer handle, or 0 for current buffer.
  269. --- @param name string
  270. --- @param command any
  271. --- @param opts vim.api.keyset.user_command
  272. function vim.api.nvim_buf_create_user_command(buffer, name, command, opts) end
  273. --- Removes an `extmark`.
  274. ---
  275. --- @param buffer integer Buffer handle, or 0 for current buffer
  276. --- @param ns_id integer Namespace id from `nvim_create_namespace()`
  277. --- @param id integer Extmark id
  278. --- @return boolean # true if the extmark was found, else false
  279. function vim.api.nvim_buf_del_extmark(buffer, ns_id, id) end
  280. --- Unmaps a buffer-local `mapping` for the given mode.
  281. ---
  282. ---
  283. --- @see vim.api.nvim_del_keymap
  284. --- @param buffer integer Buffer handle, or 0 for current buffer
  285. --- @param mode string
  286. --- @param lhs string
  287. function vim.api.nvim_buf_del_keymap(buffer, mode, lhs) end
  288. --- Deletes a named mark in the buffer. See `mark-motions`.
  289. ---
  290. --- Note:
  291. --- only deletes marks set in the buffer, if the mark is not set
  292. --- in the buffer it will return false.
  293. ---
  294. --- @see vim.api.nvim_buf_set_mark
  295. --- @see vim.api.nvim_del_mark
  296. --- @param buffer integer Buffer to set the mark on
  297. --- @param name string Mark name
  298. --- @return boolean # true if the mark was deleted, else false.
  299. function vim.api.nvim_buf_del_mark(buffer, name) end
  300. --- Delete a buffer-local user-defined command.
  301. ---
  302. --- Only commands created with `:command-buffer` or
  303. --- `nvim_buf_create_user_command()` can be deleted with this function.
  304. ---
  305. --- @param buffer integer Buffer handle, or 0 for current buffer.
  306. --- @param name string Name of the command to delete.
  307. function vim.api.nvim_buf_del_user_command(buffer, name) end
  308. --- Removes a buffer-scoped (b:) variable
  309. ---
  310. --- @param buffer integer Buffer handle, or 0 for current buffer
  311. --- @param name string Variable name
  312. function vim.api.nvim_buf_del_var(buffer, name) end
  313. --- Deletes the buffer. See `:bwipeout`
  314. ---
  315. --- @param buffer integer Buffer handle, or 0 for current buffer
  316. --- @param opts vim.api.keyset.buf_delete Optional parameters. Keys:
  317. --- - force: Force deletion and ignore unsaved changes.
  318. --- - unload: Unloaded only, do not delete. See `:bunload`
  319. function vim.api.nvim_buf_delete(buffer, opts) end
  320. --- Gets a changed tick of a buffer
  321. ---
  322. --- @param buffer integer Buffer handle, or 0 for current buffer
  323. --- @return integer # `b:changedtick` value.
  324. function vim.api.nvim_buf_get_changedtick(buffer) end
  325. --- Gets a map of buffer-local `user-commands`.
  326. ---
  327. --- @param buffer integer Buffer handle, or 0 for current buffer
  328. --- @param opts vim.api.keyset.get_commands Optional parameters. Currently not used.
  329. --- @return table<string,any> # Map of maps describing commands.
  330. function vim.api.nvim_buf_get_commands(buffer, opts) end
  331. --- Gets the position (0-indexed) of an `extmark`.
  332. ---
  333. --- @param buffer integer Buffer handle, or 0 for current buffer
  334. --- @param ns_id integer Namespace id from `nvim_create_namespace()`
  335. --- @param id integer Extmark id
  336. --- @param opts vim.api.keyset.get_extmark Optional parameters. Keys:
  337. --- - details: Whether to include the details dict
  338. --- - hl_name: Whether to include highlight group name instead of id, true if omitted
  339. --- @return vim.api.keyset.get_extmark_item_by_id # 0-indexed (row, col) tuple or empty list () if extmark id was
  340. --- absent
  341. function vim.api.nvim_buf_get_extmark_by_id(buffer, ns_id, id, opts) end
  342. --- Gets `extmarks` in "traversal order" from a `charwise` region defined by
  343. --- buffer positions (inclusive, 0-indexed `api-indexing`).
  344. ---
  345. --- Region can be given as (row,col) tuples, or valid extmark ids (whose
  346. --- positions define the bounds). 0 and -1 are understood as (0,0) and (-1,-1)
  347. --- respectively, thus the following are equivalent:
  348. ---
  349. --- ```lua
  350. --- vim.api.nvim_buf_get_extmarks(0, my_ns, 0, -1, {})
  351. --- vim.api.nvim_buf_get_extmarks(0, my_ns, {0,0}, {-1,-1}, {})
  352. --- ```
  353. ---
  354. --- If `end` is less than `start`, traversal works backwards. (Useful
  355. --- with `limit`, to get the first marks prior to a given position.)
  356. ---
  357. --- Note: when using extmark ranges (marks with a end_row/end_col position)
  358. --- the `overlap` option might be useful. Otherwise only the start position
  359. --- of an extmark will be considered.
  360. ---
  361. --- Note: legacy signs placed through the `:sign` commands are implemented
  362. --- as extmarks and will show up here. Their details array will contain a
  363. --- `sign_name` field.
  364. ---
  365. --- Example:
  366. ---
  367. --- ```lua
  368. --- local api = vim.api
  369. --- local pos = api.nvim_win_get_cursor(0)
  370. --- local ns = api.nvim_create_namespace('my-plugin')
  371. --- -- Create new extmark at line 1, column 1.
  372. --- local m1 = api.nvim_buf_set_extmark(0, ns, 0, 0, {})
  373. --- -- Create new extmark at line 3, column 1.
  374. --- local m2 = api.nvim_buf_set_extmark(0, ns, 2, 0, {})
  375. --- -- Get extmarks only from line 3.
  376. --- local ms = api.nvim_buf_get_extmarks(0, ns, {2,0}, {2,0}, {})
  377. --- -- Get all marks in this buffer + namespace.
  378. --- local all = api.nvim_buf_get_extmarks(0, ns, 0, -1, {})
  379. --- vim.print(ms)
  380. --- ```
  381. ---
  382. --- @param buffer integer Buffer handle, or 0 for current buffer
  383. --- @param ns_id integer Namespace id from `nvim_create_namespace()` or -1 for all namespaces
  384. --- @param start any Start of range: a 0-indexed (row, col) or valid extmark id
  385. --- (whose position defines the bound). `api-indexing`
  386. --- @param end_ any End of range (inclusive): a 0-indexed (row, col) or valid
  387. --- extmark id (whose position defines the bound). `api-indexing`
  388. --- @param opts vim.api.keyset.get_extmarks Optional parameters. Keys:
  389. --- - limit: Maximum number of marks to return
  390. --- - details: Whether to include the details dict
  391. --- - hl_name: Whether to include highlight group name instead of id, true if omitted
  392. --- - overlap: Also include marks which overlap the range, even if
  393. --- their start position is less than `start`
  394. --- - type: Filter marks by type: "highlight", "sign", "virt_text" and "virt_lines"
  395. --- @return vim.api.keyset.get_extmark_item[] # List of `[extmark_id, row, col]` tuples in "traversal order".
  396. function vim.api.nvim_buf_get_extmarks(buffer, ns_id, start, end_, opts) end
  397. --- Gets a list of buffer-local `mapping` definitions.
  398. ---
  399. --- @param buffer integer Buffer handle, or 0 for current buffer
  400. --- @param mode string Mode short-name ("n", "i", "v", ...)
  401. --- @return vim.api.keyset.get_keymap[] # Array of |maparg()|-like dictionaries describing mappings.
  402. --- The "buffer" key holds the associated buffer handle.
  403. function vim.api.nvim_buf_get_keymap(buffer, mode) end
  404. --- Gets a line-range from the buffer.
  405. ---
  406. --- Indexing is zero-based, end-exclusive. Negative indices are interpreted
  407. --- as length+1+index: -1 refers to the index past the end. So to get the
  408. --- last element use start=-2 and end=-1.
  409. ---
  410. --- Out-of-bounds indices are clamped to the nearest valid value, unless
  411. --- `strict_indexing` is set.
  412. ---
  413. --- @param buffer integer Buffer handle, or 0 for current buffer
  414. --- @param start integer First line index
  415. --- @param end_ integer Last line index, exclusive
  416. --- @param strict_indexing boolean Whether out-of-bounds should be an error.
  417. --- @return string[] # Array of lines, or empty array for unloaded buffer.
  418. function vim.api.nvim_buf_get_lines(buffer, start, end_, strict_indexing) end
  419. --- Returns a `(row,col)` tuple representing the position of the named mark.
  420. --- "End of line" column position is returned as `v:maxcol` (big number).
  421. --- See `mark-motions`.
  422. ---
  423. --- Marks are (1,0)-indexed. `api-indexing`
  424. ---
  425. --- @see vim.api.nvim_buf_set_mark
  426. --- @see vim.api.nvim_buf_del_mark
  427. --- @param buffer integer Buffer handle, or 0 for current buffer
  428. --- @param name string Mark name
  429. --- @return integer[] # (row, col) tuple, (0, 0) if the mark is not set, or is an
  430. --- uppercase/file mark set in another buffer.
  431. function vim.api.nvim_buf_get_mark(buffer, name) end
  432. --- Gets the full file name for the buffer
  433. ---
  434. --- @param buffer integer Buffer handle, or 0 for current buffer
  435. --- @return string # Buffer name
  436. function vim.api.nvim_buf_get_name(buffer) end
  437. --- @deprecated
  438. --- @param buffer integer
  439. --- @return integer
  440. function vim.api.nvim_buf_get_number(buffer) end
  441. --- Returns the byte offset of a line (0-indexed). `api-indexing`
  442. ---
  443. --- Line 1 (index=0) has offset 0. UTF-8 bytes are counted. EOL is one byte.
  444. --- 'fileformat' and 'fileencoding' are ignored. The line index just after the
  445. --- last line gives the total byte-count of the buffer. A final EOL byte is
  446. --- counted if it would be written, see 'eol'.
  447. ---
  448. --- Unlike `line2byte()`, throws error for out-of-bounds indexing.
  449. --- Returns -1 for unloaded buffer.
  450. ---
  451. --- @param buffer integer Buffer handle, or 0 for current buffer
  452. --- @param index integer Line index
  453. --- @return integer # Integer byte offset, or -1 for unloaded buffer.
  454. function vim.api.nvim_buf_get_offset(buffer, index) end
  455. --- @deprecated
  456. --- @param buffer integer
  457. --- @param name string
  458. --- @return any
  459. function vim.api.nvim_buf_get_option(buffer, name) end
  460. --- Gets a range from the buffer.
  461. ---
  462. --- This differs from `nvim_buf_get_lines()` in that it allows retrieving only
  463. --- portions of a line.
  464. ---
  465. --- Indexing is zero-based. Row indices are end-inclusive, and column indices
  466. --- are end-exclusive.
  467. ---
  468. --- Prefer `nvim_buf_get_lines()` when retrieving entire lines.
  469. ---
  470. --- @param buffer integer Buffer handle, or 0 for current buffer
  471. --- @param start_row integer First line index
  472. --- @param start_col integer Starting column (byte offset) on first line
  473. --- @param end_row integer Last line index, inclusive
  474. --- @param end_col integer Ending column (byte offset) on last line, exclusive
  475. --- @param opts vim.api.keyset.empty Optional parameters. Currently unused.
  476. --- @return string[] # Array of lines, or empty array for unloaded buffer.
  477. function vim.api.nvim_buf_get_text(buffer, start_row, start_col, end_row, end_col, opts) end
  478. --- Gets a buffer-scoped (b:) variable.
  479. ---
  480. --- @param buffer integer Buffer handle, or 0 for current buffer
  481. --- @param name string Variable name
  482. --- @return any # Variable value
  483. function vim.api.nvim_buf_get_var(buffer, name) end
  484. --- Checks if a buffer is valid and loaded. See `api-buffer` for more info
  485. --- about unloaded buffers.
  486. ---
  487. --- @param buffer integer Buffer handle, or 0 for current buffer
  488. --- @return boolean # true if the buffer is valid and loaded, false otherwise.
  489. function vim.api.nvim_buf_is_loaded(buffer) end
  490. --- Checks if a buffer is valid.
  491. ---
  492. --- Note:
  493. --- Even if a buffer is valid it may have been unloaded. See |api-buffer|
  494. --- for more info about unloaded buffers.
  495. ---
  496. ---
  497. --- @param buffer integer Buffer handle, or 0 for current buffer
  498. --- @return boolean # true if the buffer is valid, false otherwise.
  499. function vim.api.nvim_buf_is_valid(buffer) end
  500. --- Returns the number of lines in the given buffer.
  501. ---
  502. --- @param buffer integer Buffer handle, or 0 for current buffer
  503. --- @return integer # Line count, or 0 for unloaded buffer. |api-buffer|
  504. function vim.api.nvim_buf_line_count(buffer) end
  505. --- Creates or updates an `extmark`.
  506. ---
  507. --- By default a new extmark is created when no id is passed in, but it is also
  508. --- possible to create a new mark by passing in a previously unused id or move
  509. --- an existing mark by passing in its id. The caller must then keep track of
  510. --- existing and unused ids itself. (Useful over RPC, to avoid waiting for the
  511. --- return value.)
  512. ---
  513. --- Using the optional arguments, it is possible to use this to highlight
  514. --- a range of text, and also to associate virtual text to the mark.
  515. ---
  516. --- If present, the position defined by `end_col` and `end_row` should be after
  517. --- the start position in order for the extmark to cover a range.
  518. --- An earlier end position is not an error, but then it behaves like an empty
  519. --- range (no highlighting).
  520. ---
  521. --- @param buffer integer Buffer handle, or 0 for current buffer
  522. --- @param ns_id integer Namespace id from `nvim_create_namespace()`
  523. --- @param line integer Line where to place the mark, 0-based. `api-indexing`
  524. --- @param col integer Column where to place the mark, 0-based. `api-indexing`
  525. --- @param opts vim.api.keyset.set_extmark Optional parameters.
  526. --- - id : id of the extmark to edit.
  527. --- - end_row : ending line of the mark, 0-based inclusive.
  528. --- - end_col : ending col of the mark, 0-based exclusive.
  529. --- - hl_group : highlight group used for the text range. This and below
  530. --- highlight groups can be supplied either as a string or as an integer,
  531. --- the latter of which can be obtained using `nvim_get_hl_id_by_name()`.
  532. ---
  533. --- Multiple highlight groups can be stacked by passing an array (highest
  534. --- priority last).
  535. --- - hl_eol : when true, for a multiline highlight covering the
  536. --- EOL of a line, continue the highlight for the rest
  537. --- of the screen line (just like for diff and
  538. --- cursorline highlight).
  539. --- - virt_text : virtual text to link to this mark.
  540. --- A list of `[text, highlight]` tuples, each representing a
  541. --- text chunk with specified highlight. `highlight` element
  542. --- can either be a single highlight group, or an array of
  543. --- multiple highlight groups that will be stacked
  544. --- (highest priority last).
  545. --- - virt_text_pos : position of virtual text. Possible values:
  546. --- - "eol": right after eol character (default).
  547. --- - "eol_right_align": display right aligned in the window
  548. --- unless the virtual text is longer than
  549. --- the space available. If the virtual
  550. --- text is too long, it is truncated to
  551. --- fit in the window after the EOL
  552. --- character. If the line is wrapped, the
  553. --- virtual text is shown after the end of
  554. --- the line rather than the previous
  555. --- screen line.
  556. --- - "overlay": display over the specified column, without
  557. --- shifting the underlying text.
  558. --- - "right_align": display right aligned in the window.
  559. --- - "inline": display at the specified column, and
  560. --- shift the buffer text to the right as needed.
  561. --- - virt_text_win_col : position the virtual text at a fixed
  562. --- window column (starting from the first
  563. --- text column of the screen line) instead
  564. --- of "virt_text_pos".
  565. --- - virt_text_hide : hide the virtual text when the background
  566. --- text is selected or hidden because of
  567. --- scrolling with 'nowrap' or 'smoothscroll'.
  568. --- Currently only affects "overlay" virt_text.
  569. --- - virt_text_repeat_linebreak : repeat the virtual text on
  570. --- wrapped lines.
  571. --- - hl_mode : control how highlights are combined with the
  572. --- highlights of the text. Currently only affects
  573. --- virt_text highlights, but might affect `hl_group`
  574. --- in later versions.
  575. --- - "replace": only show the virt_text color. This is the default.
  576. --- - "combine": combine with background text color.
  577. --- - "blend": blend with background text color.
  578. --- Not supported for "inline" virt_text.
  579. ---
  580. --- - virt_lines : virtual lines to add next to this mark
  581. --- This should be an array over lines, where each line in
  582. --- turn is an array over `[text, highlight]` tuples. In
  583. --- general, buffer and window options do not affect the
  584. --- display of the text. In particular 'wrap'
  585. --- and 'linebreak' options do not take effect, so
  586. --- the number of extra screen lines will always match
  587. --- the size of the array. However the 'tabstop' buffer
  588. --- option is still used for hard tabs. By default lines are
  589. --- placed below the buffer line containing the mark.
  590. ---
  591. --- - virt_lines_above: place virtual lines above instead.
  592. --- - virt_lines_leftcol: Place virtual lines in the leftmost
  593. --- column of the window, bypassing
  594. --- sign and number columns.
  595. --- - virt_lines_overflow: controls how to handle virtual lines wider
  596. --- than the window. Currently takes the one of the following values:
  597. --- - "trunc": truncate virtual lines on the right (default).
  598. --- - "scroll": virtual lines can scroll horizontally with 'nowrap',
  599. --- otherwise the same as "trunc".
  600. --- - ephemeral : for use with `nvim_set_decoration_provider()`
  601. --- callbacks. The mark will only be used for the current
  602. --- redraw cycle, and not be permantently stored in the
  603. --- buffer.
  604. --- - right_gravity : boolean that indicates the direction
  605. --- the extmark will be shifted in when new text is inserted
  606. --- (true for right, false for left). Defaults to true.
  607. --- - end_right_gravity : boolean that indicates the direction
  608. --- the extmark end position (if it exists) will be shifted
  609. --- in when new text is inserted (true for right, false
  610. --- for left). Defaults to false.
  611. --- - undo_restore : Restore the exact position of the mark
  612. --- if text around the mark was deleted and then restored by undo.
  613. --- Defaults to true.
  614. --- - invalidate : boolean that indicates whether to hide the
  615. --- extmark if the entirety of its range is deleted. For
  616. --- hidden marks, an "invalid" key is added to the "details"
  617. --- array of `nvim_buf_get_extmarks()` and family. If
  618. --- "undo_restore" is false, the extmark is deleted instead.
  619. --- - priority: a priority value for the highlight group, sign
  620. --- attribute or virtual text. For virtual text, item with
  621. --- highest priority is drawn last. For example treesitter
  622. --- highlighting uses a value of 100.
  623. --- - strict: boolean that indicates extmark should not be placed
  624. --- if the line or column value is past the end of the
  625. --- buffer or end of the line respectively. Defaults to true.
  626. --- - sign_text: string of length 1-2 used to display in the
  627. --- sign column.
  628. --- - sign_hl_group: highlight group used for the sign column text.
  629. --- - number_hl_group: highlight group used for the number column.
  630. --- - line_hl_group: highlight group used for the whole line.
  631. --- - cursorline_hl_group: highlight group used for the sign
  632. --- column text when the cursor is on the same line as the
  633. --- mark and 'cursorline' is enabled.
  634. --- - conceal: string which should be either empty or a single
  635. --- character. Enable concealing similar to `:syn-conceal`.
  636. --- When a character is supplied it is used as `:syn-cchar`.
  637. --- "hl_group" is used as highlight for the cchar if provided,
  638. --- otherwise it defaults to `hl-Conceal`.
  639. --- - conceal_lines: string which should be empty. When
  640. --- provided, lines in the range are not drawn at all
  641. --- (according to 'conceallevel'); the next unconcealed line
  642. --- is drawn instead.
  643. --- - spell: boolean indicating that spell checking should be
  644. --- performed within this extmark
  645. --- - ui_watched: boolean that indicates the mark should be drawn
  646. --- by a UI. When set, the UI will receive win_extmark events.
  647. --- Note: the mark is positioned by virt_text attributes. Can be
  648. --- used together with virt_text.
  649. --- - url: A URL to associate with this extmark. In the TUI, the OSC 8 control
  650. --- sequence is used to generate a clickable hyperlink to this URL.
  651. --- @return integer # Id of the created/updated extmark
  652. function vim.api.nvim_buf_set_extmark(buffer, ns_id, line, col, opts) end
  653. --- Sets a buffer-local `mapping` for the given mode.
  654. ---
  655. ---
  656. --- @see vim.api.nvim_set_keymap
  657. --- @param buffer integer Buffer handle, or 0 for current buffer
  658. --- @param mode string
  659. --- @param lhs string
  660. --- @param rhs string
  661. --- @param opts vim.api.keyset.keymap
  662. function vim.api.nvim_buf_set_keymap(buffer, mode, lhs, rhs, opts) end
  663. --- Sets (replaces) a line-range in the buffer.
  664. ---
  665. --- Indexing is zero-based, end-exclusive. Negative indices are interpreted
  666. --- as length+1+index: -1 refers to the index past the end. So to change
  667. --- or delete the last element use start=-2 and end=-1.
  668. ---
  669. --- To insert lines at a given index, set `start` and `end` to the same index.
  670. --- To delete a range of lines, set `replacement` to an empty array.
  671. ---
  672. --- Out-of-bounds indices are clamped to the nearest valid value, unless
  673. --- `strict_indexing` is set.
  674. ---
  675. ---
  676. --- @see vim.api.nvim_buf_set_text
  677. --- @param buffer integer Buffer handle, or 0 for current buffer
  678. --- @param start integer First line index
  679. --- @param end_ integer Last line index, exclusive
  680. --- @param strict_indexing boolean Whether out-of-bounds should be an error.
  681. --- @param replacement string[] Array of lines to use as replacement
  682. function vim.api.nvim_buf_set_lines(buffer, start, end_, strict_indexing, replacement) end
  683. --- Sets a named mark in the given buffer, all marks are allowed
  684. --- file/uppercase, visual, last change, etc. See `mark-motions`.
  685. ---
  686. --- Marks are (1,0)-indexed. `api-indexing`
  687. ---
  688. --- Note:
  689. --- Passing 0 as line deletes the mark
  690. ---
  691. ---
  692. --- @see vim.api.nvim_buf_del_mark
  693. --- @see vim.api.nvim_buf_get_mark
  694. --- @param buffer integer Buffer to set the mark on
  695. --- @param name string Mark name
  696. --- @param line integer Line number
  697. --- @param col integer Column/row number
  698. --- @param opts vim.api.keyset.empty Optional parameters. Reserved for future use.
  699. --- @return boolean # true if the mark was set, else false.
  700. function vim.api.nvim_buf_set_mark(buffer, name, line, col, opts) end
  701. --- Sets the full file name for a buffer, like `:file_f`
  702. ---
  703. --- @param buffer integer Buffer handle, or 0 for current buffer
  704. --- @param name string Buffer name
  705. function vim.api.nvim_buf_set_name(buffer, name) end
  706. --- @deprecated
  707. --- @param buffer integer
  708. --- @param name string
  709. --- @param value any
  710. function vim.api.nvim_buf_set_option(buffer, name, value) end
  711. --- Sets (replaces) a range in the buffer
  712. ---
  713. --- This is recommended over `nvim_buf_set_lines()` when only modifying parts of
  714. --- a line, as extmarks will be preserved on non-modified parts of the touched
  715. --- lines.
  716. ---
  717. --- Indexing is zero-based. Row indices are end-inclusive, and column indices
  718. --- are end-exclusive.
  719. ---
  720. --- To insert text at a given `(row, column)` location, use `start_row = end_row
  721. --- = row` and `start_col = end_col = col`. To delete the text in a range, use
  722. --- `replacement = {}`.
  723. ---
  724. --- Note:
  725. --- Prefer |nvim_buf_set_lines()| (for performance) to add or delete entire lines.
  726. --- Prefer |nvim_paste()| or |nvim_put()| to insert (instead of replace) text at cursor.
  727. ---
  728. ---
  729. --- @param buffer integer Buffer handle, or 0 for current buffer
  730. --- @param start_row integer First line index
  731. --- @param start_col integer Starting column (byte offset) on first line
  732. --- @param end_row integer Last line index, inclusive
  733. --- @param end_col integer Ending column (byte offset) on last line, exclusive
  734. --- @param replacement string[] Array of lines to use as replacement
  735. function vim.api.nvim_buf_set_text(buffer, start_row, start_col, end_row, end_col, replacement) end
  736. --- Sets a buffer-scoped (b:) variable
  737. ---
  738. --- @param buffer integer Buffer handle, or 0 for current buffer
  739. --- @param name string Variable name
  740. --- @param value any Variable value
  741. function vim.api.nvim_buf_set_var(buffer, name, value) end
  742. --- @deprecated
  743. --- @param buffer integer
  744. --- @param src_id integer
  745. --- @param line integer
  746. --- @param chunks any[]
  747. --- @param opts vim.api.keyset.empty
  748. --- @return integer
  749. function vim.api.nvim_buf_set_virtual_text(buffer, src_id, line, chunks, opts) end
  750. --- Calls a Vimscript `Dictionary-function` with the given arguments.
  751. ---
  752. --- On execution error: fails with Vimscript error, updates v:errmsg.
  753. ---
  754. --- @param dict any Dict, or String evaluating to a Vimscript `self` dict
  755. --- @param fn string Name of the function defined on the Vimscript dict
  756. --- @param args any[] Function arguments packed in an Array
  757. --- @return any # Result of the function call
  758. function vim.api.nvim_call_dict_function(dict, fn, args) end
  759. --- Calls a Vimscript function with the given arguments.
  760. ---
  761. --- On execution error: fails with Vimscript error, updates v:errmsg.
  762. ---
  763. --- @param fn string Function to call
  764. --- @param args any[] Function arguments packed in an Array
  765. --- @return any # Result of the function call
  766. function vim.api.nvim_call_function(fn, args) end
  767. --- Send data to channel `id`. For a job, it writes it to the
  768. --- stdin of the process. For the stdio channel `channel-stdio`,
  769. --- it writes to Nvim's stdout. For an internal terminal instance
  770. --- (`nvim_open_term()`) it writes directly to terminal output.
  771. --- See `channel-bytes` for more information.
  772. ---
  773. --- This function writes raw data, not RPC messages. If the channel
  774. --- was created with `rpc=true` then the channel expects RPC
  775. --- messages, use `vim.rpcnotify()` and `vim.rpcrequest()` instead.
  776. ---
  777. --- @param chan integer id of the channel
  778. --- @param data string data to write. 8-bit clean: can contain NUL bytes.
  779. function vim.api.nvim_chan_send(chan, data) end
  780. --- Clears all autocommands selected by {opts}. To delete autocmds see `nvim_del_autocmd()`.
  781. ---
  782. --- @param opts vim.api.keyset.clear_autocmds Parameters
  783. --- - event: (string|table)
  784. --- Examples:
  785. --- - event: "pat1"
  786. --- - event: { "pat1" }
  787. --- - event: { "pat1", "pat2", "pat3" }
  788. --- - pattern: (string|table)
  789. --- - pattern or patterns to match exactly.
  790. --- - For example, if you have `*.py` as that pattern for the autocmd,
  791. --- you must pass `*.py` exactly to clear it. `test.py` will not
  792. --- match the pattern.
  793. --- - defaults to clearing all patterns.
  794. --- - NOTE: Cannot be used with {buffer}
  795. --- - buffer: (bufnr)
  796. --- - clear only `autocmd-buflocal` autocommands.
  797. --- - NOTE: Cannot be used with {pattern}
  798. --- - group: (string|int) The augroup name or id.
  799. --- - NOTE: If not passed, will only delete autocmds *not* in any group.
  800. function vim.api.nvim_clear_autocmds(opts) end
  801. --- Executes an Ex command.
  802. ---
  803. --- Unlike `nvim_command()` this command takes a structured Dict instead of a String. This
  804. --- allows for easier construction and manipulation of an Ex command. This also allows for things
  805. --- such as having spaces inside a command argument, expanding filenames in a command that otherwise
  806. --- doesn't expand filenames, etc. Command arguments may also be Number, Boolean or String.
  807. ---
  808. --- The first argument may also be used instead of count for commands that support it in order to
  809. --- make their usage simpler with `vim.cmd()`. For example, instead of
  810. --- `vim.cmd.bdelete{ count = 2 }`, you may do `vim.cmd.bdelete(2)`.
  811. ---
  812. --- On execution error: fails with Vimscript error, updates v:errmsg.
  813. ---
  814. ---
  815. --- @see vim.api.nvim_exec2
  816. --- @see vim.api.nvim_command
  817. --- @param cmd vim.api.keyset.cmd Command to execute. Must be a Dict that can contain the same values as
  818. --- the return value of `nvim_parse_cmd()` except "addr", "nargs" and "nextcmd"
  819. --- which are ignored if provided. All values except for "cmd" are optional.
  820. --- @param opts vim.api.keyset.cmd_opts Optional parameters.
  821. --- - output: (boolean, default false) Whether to return command output.
  822. --- @return string # Command output (non-error, non-shell |:!|) if `output` is true, else empty string.
  823. function vim.api.nvim_cmd(cmd, opts) end
  824. --- Executes an Ex command.
  825. ---
  826. --- On execution error: fails with Vimscript error, updates v:errmsg.
  827. ---
  828. --- Prefer `nvim_cmd()` or `nvim_exec2()` instead. To modify an Ex command in a structured way
  829. --- before executing it, modify the result of `nvim_parse_cmd()` then pass it to `nvim_cmd()`.
  830. ---
  831. --- @param command string Ex command string
  832. function vim.api.nvim_command(command) end
  833. --- @deprecated
  834. --- @see vim.api.nvim_exec2
  835. --- @param command string
  836. --- @return string
  837. function vim.api.nvim_command_output(command) end
  838. --- Create or get an autocommand group `autocmd-groups`.
  839. ---
  840. --- To get an existing group id, do:
  841. ---
  842. --- ```lua
  843. --- local id = vim.api.nvim_create_augroup("MyGroup", {
  844. --- clear = false
  845. --- })
  846. --- ```
  847. ---
  848. --- @see `:help autocmd-groups`
  849. --- @param name string String: The name of the group
  850. --- @param opts vim.api.keyset.create_augroup Dict Parameters
  851. --- - clear (bool) optional: defaults to true. Clear existing
  852. --- commands if the group already exists `autocmd-groups`.
  853. --- @return integer # Integer id of the created group.
  854. function vim.api.nvim_create_augroup(name, opts) end
  855. --- Creates an `autocommand` event handler, defined by `callback` (Lua function or Vimscript
  856. --- function _name_ string) or `command` (Ex command string).
  857. ---
  858. --- Example using Lua callback:
  859. ---
  860. --- ```lua
  861. --- vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
  862. --- pattern = {"*.c", "*.h"},
  863. --- callback = function(ev)
  864. --- print(string.format('event fired: %s', vim.inspect(ev)))
  865. --- end
  866. --- })
  867. --- ```
  868. ---
  869. --- Example using an Ex command as the handler:
  870. ---
  871. --- ```lua
  872. --- vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
  873. --- pattern = {"*.c", "*.h"},
  874. --- command = "echo 'Entering a C or C++ file'",
  875. --- })
  876. --- ```
  877. ---
  878. --- Note: `pattern` is NOT automatically expanded (unlike with `:autocmd`), thus names like "$HOME"
  879. --- and "~" must be expanded explicitly:
  880. ---
  881. --- ```lua
  882. --- pattern = vim.fn.expand("~") .. "/some/path/*.py"
  883. --- ```
  884. ---
  885. --- @see `:help autocommand`
  886. --- @see vim.api.nvim_del_autocmd
  887. --- @param event any (string|array) Event(s) that will trigger the handler (`callback` or `command`).
  888. --- @param opts vim.api.keyset.create_autocmd Options dict:
  889. --- - group (string|integer) optional: autocommand group name or id to match against.
  890. --- - pattern (string|array) optional: pattern(s) to match literally `autocmd-pattern`.
  891. --- - buffer (integer) optional: buffer number for buffer-local autocommands
  892. --- `autocmd-buflocal`. Cannot be used with {pattern}.
  893. --- - desc (string) optional: description (for documentation and troubleshooting).
  894. --- - callback (function|string) optional: Lua function (or Vimscript function name, if
  895. --- string) called when the event(s) is triggered. Lua callback can return a truthy
  896. --- value (not `false` or `nil`) to delete the autocommand. Receives one argument,
  897. --- a table with these keys: [event-args]()
  898. --- - id: (number) autocommand id
  899. --- - event: (string) name of the triggered event `autocmd-events`
  900. --- - group: (number|nil) autocommand group id, if any
  901. --- - file: (string) [<afile>] (not expanded to a full path)
  902. --- - match: (string) [<amatch>] (expanded to a full path)
  903. --- - buf: (number) [<abuf>]
  904. --- - data: (any) arbitrary data passed from [nvim_exec_autocmds()] [event-data]()
  905. --- - command (string) optional: Vim command to execute on event. Cannot be used with
  906. --- {callback}
  907. --- - once (boolean) optional: defaults to false. Run the autocommand
  908. --- only once `autocmd-once`.
  909. --- - nested (boolean) optional: defaults to false. Run nested
  910. --- autocommands `autocmd-nested`.
  911. --- @return integer # Autocommand id (number)
  912. function vim.api.nvim_create_autocmd(event, opts) end
  913. --- Creates a new, empty, unnamed buffer.
  914. ---
  915. --- @see buf_open_scratch
  916. --- @param listed boolean Sets 'buflisted'
  917. --- @param scratch boolean Creates a "throwaway" `scratch-buffer` for temporary work
  918. --- (always 'nomodified'). Also sets 'nomodeline' on the buffer.
  919. --- @return integer # Buffer handle, or 0 on error
  920. ---
  921. function vim.api.nvim_create_buf(listed, scratch) end
  922. --- Creates a new namespace or gets an existing one. [namespace]()
  923. ---
  924. --- Namespaces are used for buffer highlights and virtual text, see
  925. --- `nvim_buf_set_extmark()`.
  926. ---
  927. --- Namespaces can be named or anonymous. If `name` matches an existing
  928. --- namespace, the associated id is returned. If `name` is an empty string
  929. --- a new, anonymous namespace is created.
  930. ---
  931. --- @param name string Namespace name or empty string
  932. --- @return integer # Namespace id
  933. function vim.api.nvim_create_namespace(name) end
  934. --- Creates a global `user-commands` command.
  935. ---
  936. --- For Lua usage see `lua-guide-commands-create`.
  937. ---
  938. --- Example:
  939. ---
  940. --- ```vim
  941. --- :call nvim_create_user_command('SayHello', 'echo "Hello world!"', {'bang': v:true})
  942. --- :SayHello
  943. --- Hello world!
  944. --- ```
  945. ---
  946. --- @param name string Name of the new user command. Must begin with an uppercase letter.
  947. --- @param command string|fun(args: vim.api.keyset.create_user_command.command_args) Replacement command to execute when this user command is executed. When called
  948. --- from Lua, the command can also be a Lua function. The function is called with a
  949. --- single table argument that contains the following keys:
  950. --- - name: (string) Command name
  951. --- - args: (string) The args passed to the command, if any [<args>]
  952. --- - fargs: (table) The args split by unescaped whitespace (when more than one
  953. --- argument is allowed), if any [<f-args>]
  954. --- - nargs: (string) Number of arguments `:command-nargs`
  955. --- - bang: (boolean) "true" if the command was executed with a ! modifier [<bang>]
  956. --- - line1: (number) The starting line of the command range [<line1>]
  957. --- - line2: (number) The final line of the command range [<line2>]
  958. --- - range: (number) The number of items in the command range: 0, 1, or 2 [<range>]
  959. --- - count: (number) Any count supplied [<count>]
  960. --- - reg: (string) The optional register, if specified [<reg>]
  961. --- - mods: (string) Command modifiers, if any [<mods>]
  962. --- - smods: (table) Command modifiers in a structured format. Has the same
  963. --- structure as the "mods" key of `nvim_parse_cmd()`.
  964. --- @param opts vim.api.keyset.user_command Optional `command-attributes`.
  965. --- - Set boolean attributes such as `:command-bang` or `:command-bar` to true (but
  966. --- not `:command-buffer`, use `nvim_buf_create_user_command()` instead).
  967. --- - "complete" `:command-complete` also accepts a Lua function which works like
  968. --- `:command-completion-customlist`.
  969. --- - Other parameters:
  970. --- - desc: (string) Used for listing the command when a Lua function is used for
  971. --- {command}.
  972. --- - force: (boolean, default true) Override any previous definition.
  973. --- - preview: (function) Preview callback for 'inccommand' `:command-preview`
  974. function vim.api.nvim_create_user_command(name, command, opts) end
  975. --- Delete an autocommand group by id.
  976. ---
  977. --- To get a group id one can use `nvim_get_autocmds()`.
  978. ---
  979. --- NOTE: behavior differs from `:augroup-delete`. When deleting a group, autocommands contained in
  980. --- this group will also be deleted and cleared. This group will no longer exist.
  981. --- @see vim.api.nvim_del_augroup_by_name
  982. --- @see vim.api.nvim_create_augroup
  983. --- @param id integer Integer The id of the group.
  984. function vim.api.nvim_del_augroup_by_id(id) end
  985. --- Delete an autocommand group by name.
  986. ---
  987. --- NOTE: behavior differs from `:augroup-delete`. When deleting a group, autocommands contained in
  988. --- this group will also be deleted and cleared. This group will no longer exist.
  989. --- @see `:help autocmd-groups`
  990. --- @param name string String The name of the group.
  991. function vim.api.nvim_del_augroup_by_name(name) end
  992. --- Deletes an autocommand by id.
  993. ---
  994. --- @param id integer Integer Autocommand id returned by `nvim_create_autocmd()`
  995. function vim.api.nvim_del_autocmd(id) end
  996. --- Deletes the current line.
  997. ---
  998. function vim.api.nvim_del_current_line() end
  999. --- Unmaps a global `mapping` for the given mode.
  1000. ---
  1001. --- To unmap a buffer-local mapping, use `nvim_buf_del_keymap()`.
  1002. ---
  1003. --- @see vim.api.nvim_set_keymap
  1004. --- @param mode string
  1005. --- @param lhs string
  1006. function vim.api.nvim_del_keymap(mode, lhs) end
  1007. --- Deletes an uppercase/file named mark. See `mark-motions`.
  1008. ---
  1009. --- Note:
  1010. --- Lowercase name (or other buffer-local mark) is an error.
  1011. ---
  1012. --- @see vim.api.nvim_buf_del_mark
  1013. --- @see vim.api.nvim_get_mark
  1014. --- @param name string Mark name
  1015. --- @return boolean # true if the mark was deleted, else false.
  1016. function vim.api.nvim_del_mark(name) end
  1017. --- Delete a user-defined command.
  1018. ---
  1019. --- @param name string Name of the command to delete.
  1020. function vim.api.nvim_del_user_command(name) end
  1021. --- Removes a global (g:) variable.
  1022. ---
  1023. --- @param name string Variable name
  1024. function vim.api.nvim_del_var(name) end
  1025. --- Prints a message given by a list of `[text, hl_group]` "chunks".
  1026. ---
  1027. --- Example:
  1028. --- ```lua
  1029. --- vim.api.nvim_echo({ { 'chunk1-line1\nchunk1-line2\n' }, { 'chunk2-line1' } }, true, {})
  1030. --- ```
  1031. ---
  1032. --- @param chunks any[] List of `[text, hl_group]` pairs, where each is a `text` string highlighted by
  1033. --- the (optional) name or ID `hl_group`.
  1034. --- @param history boolean if true, add to `message-history`.
  1035. --- @param opts vim.api.keyset.echo_opts Optional parameters.
  1036. --- - err: Treat the message like `:echoerr`. Sets `hl_group` to `hl-ErrorMsg` by default.
  1037. --- - verbose: Message is controlled by the 'verbose' option. Nvim invoked with `-V3log`
  1038. --- will write the message to the "log" file instead of standard output.
  1039. function vim.api.nvim_echo(chunks, history, opts) end
  1040. --- @deprecated
  1041. --- @param str string
  1042. function vim.api.nvim_err_write(str) end
  1043. --- @deprecated
  1044. --- @param str string
  1045. function vim.api.nvim_err_writeln(str) end
  1046. --- Evaluates a Vimscript `expression`. Dicts and Lists are recursively expanded.
  1047. ---
  1048. --- On execution error: fails with Vimscript error, updates v:errmsg.
  1049. ---
  1050. --- @param expr string Vimscript expression string
  1051. --- @return any # Evaluation result or expanded object
  1052. function vim.api.nvim_eval(expr) end
  1053. --- Evaluates statusline string.
  1054. ---
  1055. --- @param str string Statusline string (see 'statusline').
  1056. --- @param opts vim.api.keyset.eval_statusline Optional parameters.
  1057. --- - winid: (number) `window-ID` of the window to use as context for statusline.
  1058. --- - maxwidth: (number) Maximum width of statusline.
  1059. --- - fillchar: (string) Character to fill blank spaces in the statusline (see
  1060. --- 'fillchars'). Treated as single-width even if it isn't.
  1061. --- - highlights: (boolean) Return highlight information.
  1062. --- - use_winbar: (boolean) Evaluate winbar instead of statusline.
  1063. --- - use_tabline: (boolean) Evaluate tabline instead of statusline. When true, {winid}
  1064. --- is ignored. Mutually exclusive with {use_winbar}.
  1065. --- - use_statuscol_lnum: (number) Evaluate statuscolumn for this line number instead of statusline.
  1066. --- @return table<string,any> # Dict containing statusline information, with these keys:
  1067. --- - str: (string) Characters that will be displayed on the statusline.
  1068. --- - width: (number) Display width of the statusline.
  1069. --- - highlights: Array containing highlight information of the statusline. Only included when
  1070. --- the "highlights" key in {opts} is true. Each element of the array is a
  1071. --- |Dict| with these keys:
  1072. --- - start: (number) Byte index (0-based) of first character that uses the highlight.
  1073. --- - group: (string) Deprecated. Use `groups` instead.
  1074. --- - groups: (array) Names of stacked highlight groups (highest priority last).
  1075. function vim.api.nvim_eval_statusline(str, opts) end
  1076. --- @deprecated
  1077. --- @see vim.api.nvim_exec2
  1078. --- @param src string
  1079. --- @param output boolean
  1080. --- @return string
  1081. function vim.api.nvim_exec(src, output) end
  1082. --- Executes Vimscript (multiline block of Ex commands), like anonymous
  1083. --- `:source`.
  1084. ---
  1085. --- Unlike `nvim_command()` this function supports heredocs, script-scope (s:),
  1086. --- etc.
  1087. ---
  1088. --- On execution error: fails with Vimscript error, updates v:errmsg.
  1089. ---
  1090. ---
  1091. --- @see `:help execute()`
  1092. --- @see vim.api.nvim_command
  1093. --- @see vim.api.nvim_cmd
  1094. --- @param src string Vimscript code
  1095. --- @param opts vim.api.keyset.exec_opts Optional parameters.
  1096. --- - output: (boolean, default false) Whether to capture and return
  1097. --- all (non-error, non-shell `:!`) output.
  1098. --- @return table<string,any> # Dict containing information about execution, with these keys:
  1099. --- - output: (string|nil) Output if `opts.output` is true.
  1100. function vim.api.nvim_exec2(src, opts) end
  1101. --- Execute all autocommands for {event} that match the corresponding
  1102. --- {opts} `autocmd-execute`.
  1103. --- @see `:help :doautocmd`
  1104. --- @param event any (String|Array) The event or events to execute
  1105. --- @param opts vim.api.keyset.exec_autocmds Dict of autocommand options:
  1106. --- - group (string|integer) optional: the autocommand group name or
  1107. --- id to match against. `autocmd-groups`.
  1108. --- - pattern (string|array) optional: defaults to "*" `autocmd-pattern`. Cannot be used
  1109. --- with {buffer}.
  1110. --- - buffer (integer) optional: buffer number `autocmd-buflocal`. Cannot be used with
  1111. --- {pattern}.
  1112. --- - modeline (bool) optional: defaults to true. Process the
  1113. --- modeline after the autocommands [<nomodeline>].
  1114. --- - data (any): arbitrary data to send to the autocommand callback. See
  1115. --- `nvim_create_autocmd()` for details.
  1116. function vim.api.nvim_exec_autocmds(event, opts) end
  1117. --- Sends input-keys to Nvim, subject to various quirks controlled by `mode`
  1118. --- flags. This is a blocking call, unlike `nvim_input()`.
  1119. ---
  1120. --- On execution error: does not fail, but updates v:errmsg.
  1121. ---
  1122. --- To input sequences like [<C-o>] use `nvim_replace_termcodes()` (typically
  1123. --- with escape_ks=false) to replace `keycodes`, then pass the result to
  1124. --- nvim_feedkeys().
  1125. ---
  1126. --- Example:
  1127. ---
  1128. --- ```vim
  1129. --- :let key = nvim_replace_termcodes("<C-o>", v:true, v:false, v:true)
  1130. --- :call nvim_feedkeys(key, 'n', v:false)
  1131. --- ```
  1132. ---
  1133. --- @see feedkeys()
  1134. --- @see vim_strsave_escape_ks
  1135. --- @param keys string to be typed
  1136. --- @param mode string behavior flags, see `feedkeys()`
  1137. --- @param escape_ks boolean If true, escape K_SPECIAL bytes in `keys`.
  1138. --- This should be false if you already used
  1139. --- `nvim_replace_termcodes()`, and true otherwise.
  1140. function vim.api.nvim_feedkeys(keys, mode, escape_ks) end
  1141. --- Gets the option information for all options.
  1142. ---
  1143. --- The dict has the full option names as keys and option metadata dicts as detailed at
  1144. --- `nvim_get_option_info2()`.
  1145. ---
  1146. ---
  1147. --- @see vim.api.nvim_get_commands
  1148. --- @return table<string,any> # dict of all options
  1149. function vim.api.nvim_get_all_options_info() end
  1150. --- Get all autocommands that match the corresponding {opts}.
  1151. ---
  1152. --- These examples will get autocommands matching ALL the given criteria:
  1153. ---
  1154. --- ```lua
  1155. --- -- Matches all criteria
  1156. --- autocommands = vim.api.nvim_get_autocmds({
  1157. --- group = "MyGroup",
  1158. --- event = {"BufEnter", "BufWinEnter"},
  1159. --- pattern = {"*.c", "*.h"}
  1160. --- })
  1161. ---
  1162. --- -- All commands from one group
  1163. --- autocommands = vim.api.nvim_get_autocmds({
  1164. --- group = "MyGroup",
  1165. --- })
  1166. --- ```
  1167. ---
  1168. --- NOTE: When multiple patterns or events are provided, it will find all the autocommands that
  1169. --- match any combination of them.
  1170. ---
  1171. --- @param opts vim.api.keyset.get_autocmds Dict with at least one of the following:
  1172. --- - buffer: (integer) Buffer number or list of buffer numbers for buffer local autocommands
  1173. --- `autocmd-buflocal`. Cannot be used with {pattern}
  1174. --- - event: (string|table) event or events to match against `autocmd-events`.
  1175. --- - id: (integer) Autocommand ID to match.
  1176. --- - group: (string|table) the autocommand group name or id to match against.
  1177. --- - pattern: (string|table) pattern or patterns to match against `autocmd-pattern`.
  1178. --- Cannot be used with {buffer}
  1179. --- @return vim.api.keyset.get_autocmds.ret[] # Array of autocommands matching the criteria, with each item
  1180. --- containing the following fields:
  1181. --- - buffer: (integer) the buffer number.
  1182. --- - buflocal: (boolean) true if the autocommand is buffer local.
  1183. --- - command: (string) the autocommand command. Note: this will be empty if a callback is set.
  1184. --- - callback: (function|string|nil): Lua function or name of a Vim script function
  1185. --- which is executed when this autocommand is triggered.
  1186. --- - desc: (string) the autocommand description.
  1187. --- - event: (string) the autocommand event.
  1188. --- - id: (integer) the autocommand id (only when defined with the API).
  1189. --- - group: (integer) the autocommand group id.
  1190. --- - group_name: (string) the autocommand group name.
  1191. --- - once: (boolean) whether the autocommand is only run once.
  1192. --- - pattern: (string) the autocommand pattern.
  1193. --- If the autocommand is buffer local |autocmd-buffer-local|:
  1194. function vim.api.nvim_get_autocmds(opts) end
  1195. --- Gets information about a channel.
  1196. ---
  1197. --- See `nvim_list_uis()` for an example of how to get channel info.
  1198. ---
  1199. --- @param chan integer channel_id, or 0 for current channel
  1200. --- @return table<string,any> # Channel info dict with these keys:
  1201. --- - "id" Channel id.
  1202. --- - "argv" (optional) Job arguments list.
  1203. --- - "stream" Stream underlying the channel.
  1204. --- - "stdio" stdin and stdout of this Nvim instance
  1205. --- - "stderr" stderr of this Nvim instance
  1206. --- - "socket" TCP/IP socket or named pipe
  1207. --- - "job" Job with communication over its stdio.
  1208. --- - "mode" How data received on the channel is interpreted.
  1209. --- - "bytes" Send and receive raw bytes.
  1210. --- - "terminal" |terminal| instance interprets ASCII sequences.
  1211. --- - "rpc" |RPC| communication on the channel is active.
  1212. --- - "pty" (optional) Name of pseudoterminal. On a POSIX system this is a device path like
  1213. --- "/dev/pts/1". If unknown, the key will still be present if a pty is used (e.g.
  1214. --- for conpty on Windows).
  1215. --- - "buffer" (optional) Buffer connected to |terminal| instance.
  1216. --- - "client" (optional) Info about the peer (client on the other end of the channel), as set
  1217. --- by |nvim_set_client_info()|.
  1218. ---
  1219. function vim.api.nvim_get_chan_info(chan) end
  1220. --- Returns the 24-bit RGB value of a `nvim_get_color_map()` color name or
  1221. --- "#rrggbb" hexadecimal string.
  1222. ---
  1223. --- Example:
  1224. ---
  1225. --- ```vim
  1226. --- :echo nvim_get_color_by_name("Pink")
  1227. --- :echo nvim_get_color_by_name("#cbcbcb")
  1228. --- ```
  1229. ---
  1230. --- @param name string Color name or "#rrggbb" string
  1231. --- @return integer # 24-bit RGB value, or -1 for invalid argument.
  1232. function vim.api.nvim_get_color_by_name(name) end
  1233. --- Returns a map of color names and RGB values.
  1234. ---
  1235. --- Keys are color names (e.g. "Aqua") and values are 24-bit RGB color values
  1236. --- (e.g. 65535).
  1237. ---
  1238. --- @return table<string,integer> # Map of color names and RGB values.
  1239. function vim.api.nvim_get_color_map() end
  1240. --- Gets a map of global (non-buffer-local) Ex commands.
  1241. ---
  1242. --- Currently only `user-commands` are supported, not builtin Ex commands.
  1243. ---
  1244. ---
  1245. --- @see vim.api.nvim_get_all_options_info
  1246. --- @param opts vim.api.keyset.get_commands Optional parameters. Currently only supports
  1247. --- {"builtin":false}
  1248. --- @return table<string,any> # Map of maps describing commands.
  1249. function vim.api.nvim_get_commands(opts) end
  1250. --- Gets a map of the current editor state.
  1251. ---
  1252. --- @param opts vim.api.keyset.context Optional parameters.
  1253. --- - types: List of `context-types` ("regs", "jumps", "bufs",
  1254. --- "gvars", …) to gather, or empty for "all".
  1255. --- @return table<string,any> # map of global |context|.
  1256. function vim.api.nvim_get_context(opts) end
  1257. --- Gets the current buffer.
  1258. ---
  1259. --- @return integer # Buffer handle
  1260. function vim.api.nvim_get_current_buf() end
  1261. --- Gets the current line.
  1262. ---
  1263. --- @return string # Current line string
  1264. function vim.api.nvim_get_current_line() end
  1265. --- Gets the current tabpage.
  1266. ---
  1267. --- @return integer # |tab-ID|
  1268. function vim.api.nvim_get_current_tabpage() end
  1269. --- Gets the current window.
  1270. ---
  1271. --- @return integer # |window-ID|
  1272. function vim.api.nvim_get_current_win() end
  1273. --- Gets all or specific highlight groups in a namespace.
  1274. ---
  1275. --- Note:
  1276. --- When the `link` attribute is defined in the highlight definition
  1277. --- map, other attributes will not be taking effect (see |:hi-link|).
  1278. ---
  1279. ---
  1280. --- @param ns_id integer Get highlight groups for namespace ns_id `nvim_get_namespaces()`.
  1281. --- Use 0 to get global highlight groups `:highlight`.
  1282. --- @param opts vim.api.keyset.get_highlight Options dict:
  1283. --- - name: (string) Get a highlight definition by name.
  1284. --- - id: (integer) Get a highlight definition by id.
  1285. --- - link: (boolean, default true) Show linked group name instead of effective definition `:hi-link`.
  1286. --- - create: (boolean, default true) When highlight group doesn't exist create it.
  1287. --- @return vim.api.keyset.get_hl_info # Highlight groups as a map from group name to a highlight definition map as in |nvim_set_hl()|,
  1288. --- or only a single highlight definition map if requested by name or id.
  1289. function vim.api.nvim_get_hl(ns_id, opts) end
  1290. --- @deprecated
  1291. --- @see vim.api.nvim_get_hl_by_name
  1292. --- @param hl_id integer
  1293. --- @param rgb boolean
  1294. --- @return table<string,any>
  1295. function vim.api.nvim_get_hl_by_id(hl_id, rgb) end
  1296. --- @deprecated
  1297. --- @see vim.api.nvim_get_hl_by_id
  1298. --- @param name string
  1299. --- @param rgb boolean
  1300. --- @return table<string,any>
  1301. function vim.api.nvim_get_hl_by_name(name, rgb) end
  1302. --- Gets a highlight group by name
  1303. ---
  1304. --- similar to `hlID()`, but allocates a new ID if not present.
  1305. --- @param name string
  1306. --- @return integer
  1307. function vim.api.nvim_get_hl_id_by_name(name) end
  1308. --- Gets the active highlight namespace.
  1309. ---
  1310. --- @param opts vim.api.keyset.get_ns Optional parameters
  1311. --- - winid: (number) `window-ID` for retrieving a window's highlight
  1312. --- namespace. A value of -1 is returned when `nvim_win_set_hl_ns()`
  1313. --- has not been called for the window (or was called with a namespace
  1314. --- of -1).
  1315. --- @return integer # Namespace id, or -1
  1316. function vim.api.nvim_get_hl_ns(opts) end
  1317. --- Gets a list of global (non-buffer-local) `mapping` definitions.
  1318. ---
  1319. --- @param mode string Mode short-name ("n", "i", "v", ...)
  1320. --- @return vim.api.keyset.get_keymap[] # Array of |maparg()|-like dictionaries describing mappings.
  1321. --- The "buffer" key is always zero.
  1322. function vim.api.nvim_get_keymap(mode) end
  1323. --- Returns a `(row, col, buffer, buffername)` tuple representing the position
  1324. --- of the uppercase/file named mark. "End of line" column position is returned
  1325. --- as `v:maxcol` (big number). See `mark-motions`.
  1326. ---
  1327. --- Marks are (1,0)-indexed. `api-indexing`
  1328. ---
  1329. --- Note:
  1330. --- Lowercase name (or other buffer-local mark) is an error.
  1331. ---
  1332. --- @see vim.api.nvim_buf_set_mark
  1333. --- @see vim.api.nvim_del_mark
  1334. --- @param name string Mark name
  1335. --- @param opts vim.api.keyset.empty Optional parameters. Reserved for future use.
  1336. --- @return vim.api.keyset.get_mark # 4-tuple (row, col, buffer, buffername), (0, 0, 0, '') if the mark is
  1337. --- not set.
  1338. function vim.api.nvim_get_mark(name, opts) end
  1339. --- Gets the current mode. `mode()`
  1340. --- "blocking" is true if Nvim is waiting for input.
  1341. ---
  1342. --- @return vim.api.keyset.get_mode # Dict { "mode": String, "blocking": Boolean }
  1343. function vim.api.nvim_get_mode() end
  1344. --- Gets existing, non-anonymous `namespace`s.
  1345. ---
  1346. --- @return table<string,integer> # dict that maps from names to namespace ids.
  1347. function vim.api.nvim_get_namespaces() end
  1348. --- @deprecated
  1349. --- @param name string
  1350. --- @return any
  1351. function vim.api.nvim_get_option(name) end
  1352. --- @deprecated
  1353. --- @param name string
  1354. --- @return vim.api.keyset.get_option_info
  1355. function vim.api.nvim_get_option_info(name) end
  1356. --- Gets the option information for one option from arbitrary buffer or window
  1357. ---
  1358. --- Resulting dict has keys:
  1359. --- - name: Name of the option (like 'filetype')
  1360. --- - shortname: Shortened name of the option (like 'ft')
  1361. --- - type: type of option ("string", "number" or "boolean")
  1362. --- - default: The default value for the option
  1363. --- - was_set: Whether the option was set.
  1364. ---
  1365. --- - last_set_sid: Last set script id (if any)
  1366. --- - last_set_linenr: line number where option was set
  1367. --- - last_set_chan: Channel where option was set (0 for local)
  1368. ---
  1369. --- - scope: one of "global", "win", or "buf"
  1370. --- - global_local: whether win or buf option has a global value
  1371. ---
  1372. --- - commalist: List of comma separated values
  1373. --- - flaglist: List of single char flags
  1374. ---
  1375. --- When {scope} is not provided, the last set information applies to the local
  1376. --- value in the current buffer or window if it is available, otherwise the
  1377. --- global value information is returned. This behavior can be disabled by
  1378. --- explicitly specifying {scope} in the {opts} table.
  1379. ---
  1380. --- @param name string Option name
  1381. --- @param opts vim.api.keyset.option Optional parameters
  1382. --- - scope: One of "global" or "local". Analogous to
  1383. --- `:setglobal` and `:setlocal`, respectively.
  1384. --- - win: `window-ID`. Used for getting window local options.
  1385. --- - buf: Buffer number. Used for getting buffer local options.
  1386. --- Implies {scope} is "local".
  1387. --- @return vim.api.keyset.get_option_info # Option Information
  1388. function vim.api.nvim_get_option_info2(name, opts) end
  1389. --- Gets the value of an option. The behavior of this function matches that of
  1390. --- `:set`: the local value of an option is returned if it exists; otherwise,
  1391. --- the global value is returned. Local values always correspond to the current
  1392. --- buffer or window, unless "buf" or "win" is set in {opts}.
  1393. ---
  1394. --- @param name string Option name
  1395. --- @param opts vim.api.keyset.option Optional parameters
  1396. --- - scope: One of "global" or "local". Analogous to
  1397. --- `:setglobal` and `:setlocal`, respectively.
  1398. --- - win: `window-ID`. Used for getting window local options.
  1399. --- - buf: Buffer number. Used for getting buffer local options.
  1400. --- Implies {scope} is "local".
  1401. --- - filetype: `filetype`. Used to get the default option for a
  1402. --- specific filetype. Cannot be used with any other option.
  1403. --- Note: this will trigger `ftplugin` and all `FileType`
  1404. --- autocommands for the corresponding filetype.
  1405. --- @return any # Option value
  1406. function vim.api.nvim_get_option_value(name, opts) end
  1407. --- Gets info describing process `pid`.
  1408. ---
  1409. --- @param pid integer
  1410. --- @return any # Map of process properties, or NIL if process not found.
  1411. function vim.api.nvim_get_proc(pid) end
  1412. --- Gets the immediate children of process `pid`.
  1413. ---
  1414. --- @param pid integer
  1415. --- @return any[] # Array of child process ids, empty if process not found.
  1416. function vim.api.nvim_get_proc_children(pid) end
  1417. --- Finds files in runtime directories, in 'runtimepath' order.
  1418. ---
  1419. --- "name" can contain wildcards. For example
  1420. --- `nvim_get_runtime_file("colors/*.{vim,lua}", true)` will return all color
  1421. --- scheme files. Always use forward slashes (/) in the search pattern for
  1422. --- subdirectories regardless of platform.
  1423. ---
  1424. --- It is not an error to not find any files. An empty array is returned then.
  1425. ---
  1426. --- @param name string pattern of files to search for
  1427. --- @param all boolean whether to return all matches or only the first
  1428. --- @return string[] # list of absolute paths to the found files
  1429. function vim.api.nvim_get_runtime_file(name, all) end
  1430. --- Gets a global (g:) variable.
  1431. ---
  1432. --- @param name string Variable name
  1433. --- @return any # Variable value
  1434. function vim.api.nvim_get_var(name) end
  1435. --- Gets a v: variable.
  1436. ---
  1437. --- @param name string Variable name
  1438. --- @return any # Variable value
  1439. function vim.api.nvim_get_vvar(name) end
  1440. --- Queues raw user-input. Unlike `nvim_feedkeys()`, this uses a low-level input buffer and the call
  1441. --- is non-blocking (input is processed asynchronously by the eventloop).
  1442. ---
  1443. --- To input blocks of text, `nvim_paste()` is much faster and should be preferred.
  1444. ---
  1445. --- On execution error: does not fail, but updates v:errmsg.
  1446. ---
  1447. --- Note:
  1448. --- |keycodes| like [<CR>] are translated, so "<" is special.
  1449. --- To input a literal "<", send [<LT>].
  1450. ---
  1451. --- For mouse events use |nvim_input_mouse()|. The pseudokey form
  1452. --- `<LeftMouse><col,row>` is deprecated since |api-level| 6.
  1453. ---
  1454. ---
  1455. --- @param keys string to be typed
  1456. --- @return integer # Number of bytes actually written (can be fewer than
  1457. --- requested if the buffer becomes full).
  1458. function vim.api.nvim_input(keys) end
  1459. --- Send mouse event from GUI.
  1460. ---
  1461. --- Non-blocking: does not wait on any result, but queues the event to be
  1462. --- processed soon by the event loop.
  1463. ---
  1464. --- Note:
  1465. --- Currently this doesn't support "scripting" multiple mouse events
  1466. --- by calling it multiple times in a loop: the intermediate mouse
  1467. --- positions will be ignored. It should be used to implement real-time
  1468. --- mouse input in a GUI. The deprecated pseudokey form
  1469. --- (`<LeftMouse><col,row>`) of |nvim_input()| has the same limitation.
  1470. ---
  1471. ---
  1472. --- @param button string Mouse button: one of "left", "right", "middle", "wheel", "move",
  1473. --- "x1", "x2".
  1474. --- @param action string For ordinary buttons, one of "press", "drag", "release".
  1475. --- For the wheel, one of "up", "down", "left", "right". Ignored for "move".
  1476. --- @param modifier string String of modifiers each represented by a single char.
  1477. --- The same specifiers are used as for a key press, except
  1478. --- that the "-" separator is optional, so "C-A-", "c-a"
  1479. --- and "CA" can all be used to specify Ctrl+Alt+click.
  1480. --- @param grid integer Grid number if the client uses `ui-multigrid`, else 0.
  1481. --- @param row integer Mouse row-position (zero-based, like redraw events)
  1482. --- @param col integer Mouse column-position (zero-based, like redraw events)
  1483. function vim.api.nvim_input_mouse(button, action, modifier, grid, row, col) end
  1484. --- Gets the current list of buffer handles
  1485. ---
  1486. --- Includes unlisted (unloaded/deleted) buffers, like `:ls!`.
  1487. --- Use `nvim_buf_is_loaded()` to check if a buffer is loaded.
  1488. ---
  1489. --- @return integer[] # List of buffer handles
  1490. function vim.api.nvim_list_bufs() end
  1491. --- Get information about all open channels.
  1492. ---
  1493. --- @return any[] # Array of Dictionaries, each describing a channel with
  1494. --- the format specified at |nvim_get_chan_info()|.
  1495. function vim.api.nvim_list_chans() end
  1496. --- Gets the paths contained in `runtime-search-path`.
  1497. ---
  1498. --- @return string[] # List of paths
  1499. function vim.api.nvim_list_runtime_paths() end
  1500. --- Gets the current list of `tab-ID`s.
  1501. ---
  1502. --- @return integer[] # List of |tab-ID|s
  1503. function vim.api.nvim_list_tabpages() end
  1504. --- Gets a list of dictionaries representing attached UIs.
  1505. ---
  1506. --- Example: The Nvim builtin `TUI` sets its channel info as described in `startup-tui`. In
  1507. --- particular, it sets `client.name` to "nvim-tui". So you can check if the TUI is running by
  1508. --- inspecting the client name of each UI:
  1509. ---
  1510. --- ```lua
  1511. --- vim.print(vim.api.nvim_get_chan_info(vim.api.nvim_list_uis()[1].chan).client.name)
  1512. --- ```
  1513. ---
  1514. --- @return any[] # Array of UI dictionaries, each with these keys:
  1515. --- - "height" Requested height of the UI
  1516. --- - "width" Requested width of the UI
  1517. --- - "rgb" true if the UI uses RGB colors (false implies |cterm-colors|)
  1518. --- - "ext_..." Requested UI extensions, see |ui-option|
  1519. --- - "chan" |channel-id| of remote UI
  1520. function vim.api.nvim_list_uis() end
  1521. --- Gets the current list of window handles.
  1522. ---
  1523. --- @return integer[] # List of |window-ID|s
  1524. function vim.api.nvim_list_wins() end
  1525. --- Sets the current editor state from the given `context` map.
  1526. ---
  1527. --- @param dict table<string,any> `Context` map.
  1528. --- @return any
  1529. function vim.api.nvim_load_context(dict) end
  1530. --- @deprecated
  1531. --- @param msg string
  1532. --- @param log_level integer
  1533. --- @param opts table<string,any>
  1534. --- @return any
  1535. function vim.api.nvim_notify(msg, log_level, opts) end
  1536. --- Open a terminal instance in a buffer
  1537. ---
  1538. --- By default (and currently the only option) the terminal will not be
  1539. --- connected to an external process. Instead, input sent on the channel
  1540. --- will be echoed directly by the terminal. This is useful to display
  1541. --- ANSI terminal sequences returned as part of a rpc message, or similar.
  1542. ---
  1543. --- Note: to directly initiate the terminal using the right size, display the
  1544. --- buffer in a configured window before calling this. For instance, for a
  1545. --- floating display, first create an empty buffer using `nvim_create_buf()`,
  1546. --- then display it using `nvim_open_win()`, and then call this function.
  1547. --- Then `nvim_chan_send()` can be called immediately to process sequences
  1548. --- in a virtual terminal having the intended size.
  1549. ---
  1550. --- Example: this `TermHl` command can be used to display and highlight raw ANSI termcodes, so you
  1551. --- can use Nvim as a "scrollback pager" (for terminals like kitty): [ansi-colorize]()
  1552. --- [terminal-scrollback-pager]()
  1553. ---
  1554. --- ```lua
  1555. --- vim.api.nvim_create_user_command('TermHl', function()
  1556. --- local b = vim.api.nvim_create_buf(false, true)
  1557. --- local chan = vim.api.nvim_open_term(b, {})
  1558. --- vim.api.nvim_chan_send(chan, table.concat(vim.api.nvim_buf_get_lines(0, 0, -1, false), '\n'))
  1559. --- vim.api.nvim_win_set_buf(0, b)
  1560. --- end, { desc = 'Highlights ANSI termcodes in curbuf' })
  1561. --- ```
  1562. ---
  1563. --- @param buffer integer the buffer to use (expected to be empty)
  1564. --- @param opts vim.api.keyset.open_term Optional parameters.
  1565. --- - on_input: Lua callback for input sent, i e keypresses in terminal
  1566. --- mode. Note: keypresses are sent raw as they would be to the pty
  1567. --- master end. For instance, a carriage return is sent
  1568. --- as a "\r", not as a "\n". `textlock` applies. It is possible
  1569. --- to call `nvim_chan_send()` directly in the callback however.
  1570. --- `["input", term, bufnr, data]`
  1571. --- - force_crlf: (boolean, default true) Convert "\n" to "\r\n".
  1572. --- @return integer # Channel id, or 0 on error
  1573. function vim.api.nvim_open_term(buffer, opts) end
  1574. --- Opens a new split window, or a floating window if `relative` is specified,
  1575. --- or an external window (managed by the UI) if `external` is specified.
  1576. ---
  1577. --- Floats are windows that are drawn above the split layout, at some anchor
  1578. --- position in some other window. Floats can be drawn internally or by external
  1579. --- GUI with the `ui-multigrid` extension. External windows are only supported
  1580. --- with multigrid GUIs, and are displayed as separate top-level windows.
  1581. ---
  1582. --- For a general overview of floats, see `api-floatwin`.
  1583. ---
  1584. --- The `width` and `height` of the new window must be specified when opening
  1585. --- a floating window, but are optional for normal windows.
  1586. ---
  1587. --- If `relative` and `external` are omitted, a normal "split" window is created.
  1588. --- The `win` property determines which window will be split. If no `win` is
  1589. --- provided or `win == 0`, a window will be created adjacent to the current window.
  1590. --- If -1 is provided, a top-level split will be created. `vertical` and `split` are
  1591. --- only valid for normal windows, and are used to control split direction. For `vertical`,
  1592. --- the exact direction is determined by `'splitright'` and `'splitbelow'`.
  1593. --- Split windows cannot have `bufpos`/`row`/`col`/`border`/`title`/`footer`
  1594. --- properties.
  1595. ---
  1596. --- With relative=editor (row=0,col=0) refers to the top-left corner of the
  1597. --- screen-grid and (row=Lines-1,col=Columns-1) refers to the bottom-right
  1598. --- corner. Fractional values are allowed, but the builtin implementation
  1599. --- (used by non-multigrid UIs) will always round down to nearest integer.
  1600. ---
  1601. --- Out-of-bounds values, and configurations that make the float not fit inside
  1602. --- the main editor, are allowed. The builtin implementation truncates values
  1603. --- so floats are fully within the main screen grid. External GUIs
  1604. --- could let floats hover outside of the main window like a tooltip, but
  1605. --- this should not be used to specify arbitrary WM screen positions.
  1606. ---
  1607. --- Example (Lua): window-relative float
  1608. ---
  1609. --- ```lua
  1610. --- vim.api.nvim_open_win(0, false,
  1611. --- {relative='win', row=3, col=3, width=12, height=3})
  1612. --- ```
  1613. ---
  1614. --- Example (Lua): buffer-relative float (travels as buffer is scrolled)
  1615. ---
  1616. --- ```lua
  1617. --- vim.api.nvim_open_win(0, false,
  1618. --- {relative='win', width=12, height=3, bufpos={100,10}})
  1619. --- ```
  1620. ---
  1621. --- Example (Lua): vertical split left of the current window
  1622. ---
  1623. --- ```lua
  1624. --- vim.api.nvim_open_win(0, false, {
  1625. --- split = 'left',
  1626. --- win = 0
  1627. --- })
  1628. --- ```
  1629. ---
  1630. --- @param buffer integer Buffer to display, or 0 for current buffer
  1631. --- @param enter boolean Enter the window (make it the current window)
  1632. --- @param config vim.api.keyset.win_config Map defining the window configuration. Keys:
  1633. --- - relative: Sets the window layout to "floating", placed at (row,col)
  1634. --- coordinates relative to:
  1635. --- - "cursor" Cursor position in current window.
  1636. --- - "editor" The global editor grid.
  1637. --- - "laststatus" 'laststatus' if present, or last row.
  1638. --- - "mouse" Mouse position.
  1639. --- - "tabline" Tabline if present, or first row.
  1640. --- - "win" Window given by the `win` field, or current window.
  1641. --- - win: `window-ID` window to split, or relative window when creating a
  1642. --- float (relative="win").
  1643. --- - anchor: Decides which corner of the float to place at (row,col):
  1644. --- - "NW" northwest (default)
  1645. --- - "NE" northeast
  1646. --- - "SW" southwest
  1647. --- - "SE" southeast
  1648. --- - width: Window width (in character cells). Minimum of 1.
  1649. --- - height: Window height (in character cells). Minimum of 1.
  1650. --- - bufpos: Places float relative to buffer text (only when
  1651. --- relative="win"). Takes a tuple of zero-indexed `[line, column]`.
  1652. --- `row` and `col` if given are applied relative to this
  1653. --- position, else they default to:
  1654. --- - `row=1` and `col=0` if `anchor` is "NW" or "NE"
  1655. --- - `row=0` and `col=0` if `anchor` is "SW" or "SE"
  1656. --- (thus like a tooltip near the buffer text).
  1657. --- - row: Row position in units of "screen cell height", may be fractional.
  1658. --- - col: Column position in units of "screen cell width", may be
  1659. --- fractional.
  1660. --- - focusable: Enable focus by user actions (wincmds, mouse events).
  1661. --- Defaults to true. Non-focusable windows can be entered by
  1662. --- `nvim_set_current_win()`, or, when the `mouse` field is set to true,
  1663. --- by mouse events. See `focusable`.
  1664. --- - mouse: Specify how this window interacts with mouse events.
  1665. --- Defaults to `focusable` value.
  1666. --- - If false, mouse events pass through this window.
  1667. --- - If true, mouse events interact with this window normally.
  1668. --- - external: GUI should display the window as an external
  1669. --- top-level window. Currently accepts no other positioning
  1670. --- configuration together with this.
  1671. --- - zindex: Stacking order. floats with higher `zindex` go on top on
  1672. --- floats with lower indices. Must be larger than zero. The
  1673. --- following screen elements have hard-coded z-indices:
  1674. --- - 100: insert completion popupmenu
  1675. --- - 200: message scrollback
  1676. --- - 250: cmdline completion popupmenu (when wildoptions+=pum)
  1677. --- The default value for floats are 50. In general, values below 100 are
  1678. --- recommended, unless there is a good reason to overshadow builtin
  1679. --- elements.
  1680. --- - style: (optional) Configure the appearance of the window. Currently
  1681. --- only supports one value:
  1682. --- - "minimal" Nvim will display the window with many UI options
  1683. --- disabled. This is useful when displaying a temporary
  1684. --- float where the text should not be edited. Disables
  1685. --- 'number', 'relativenumber', 'cursorline', 'cursorcolumn',
  1686. --- 'foldcolumn', 'spell' and 'list' options. 'signcolumn'
  1687. --- is changed to `auto` and 'colorcolumn' is cleared.
  1688. --- 'statuscolumn' is changed to empty. The end-of-buffer
  1689. --- region is hidden by setting `eob` flag of
  1690. --- 'fillchars' to a space char, and clearing the
  1691. --- `hl-EndOfBuffer` region in 'winhighlight'.
  1692. --- - border: Style of (optional) window border. This can either be a string
  1693. --- or an array. The string values are
  1694. --- - "none": No border (default).
  1695. --- - "single": A single line box.
  1696. --- - "double": A double line box.
  1697. --- - "rounded": Like "single", but with rounded corners ("╭" etc.).
  1698. --- - "solid": Adds padding by a single whitespace cell.
  1699. --- - "shadow": A drop shadow effect by blending with the background.
  1700. --- - If it is an array, it should have a length of eight or any divisor of
  1701. --- eight. The array will specify the eight chars building up the border
  1702. --- in a clockwise fashion starting with the top-left corner. As an
  1703. --- example, the double box style could be specified as:
  1704. --- ```
  1705. --- [ "╔", "═" ,"╗", "║", "╝", "═", "╚", "║" ].
  1706. --- ```
  1707. --- If the number of chars are less than eight, they will be repeated. Thus
  1708. --- an ASCII border could be specified as
  1709. --- ```
  1710. --- [ "/", "-", \"\\\\\", "|" ],
  1711. --- ```
  1712. --- or all chars the same as
  1713. --- ```
  1714. --- [ "x" ].
  1715. --- ```
  1716. --- An empty string can be used to turn off a specific border, for instance,
  1717. --- ```
  1718. --- [ "", "", "", ">", "", "", "", "<" ]
  1719. --- ```
  1720. --- will only make vertical borders but not horizontal ones.
  1721. --- By default, `FloatBorder` highlight is used, which links to `WinSeparator`
  1722. --- when not defined. It could also be specified by character:
  1723. --- ```
  1724. --- [ ["+", "MyCorner"], ["x", "MyBorder"] ].
  1725. --- ```
  1726. --- - title: Title (optional) in window border, string or list.
  1727. --- List should consist of `[text, highlight]` tuples.
  1728. --- If string, or a tuple lacks a highlight, the default highlight group is `FloatTitle`.
  1729. --- - title_pos: Title position. Must be set with `title` option.
  1730. --- Value can be one of "left", "center", or "right".
  1731. --- Default is `"left"`.
  1732. --- - footer: Footer (optional) in window border, string or list.
  1733. --- List should consist of `[text, highlight]` tuples.
  1734. --- If string, or a tuple lacks a highlight, the default highlight group is `FloatFooter`.
  1735. --- - footer_pos: Footer position. Must be set with `footer` option.
  1736. --- Value can be one of "left", "center", or "right".
  1737. --- Default is `"left"`.
  1738. --- - noautocmd: If true then all autocommands are blocked for the duration of
  1739. --- the call.
  1740. --- - fixed: If true when anchor is NW or SW, the float window
  1741. --- would be kept fixed even if the window would be truncated.
  1742. --- - hide: If true the floating window will be hidden.
  1743. --- - vertical: Split vertically `:vertical`.
  1744. --- - split: Split direction: "left", "right", "above", "below".
  1745. --- @return integer # |window-ID|, or 0 on error
  1746. function vim.api.nvim_open_win(buffer, enter, config) end
  1747. --- @deprecated
  1748. --- @param str string
  1749. function vim.api.nvim_out_write(str) end
  1750. --- Parse command line.
  1751. ---
  1752. --- Doesn't check the validity of command arguments.
  1753. ---
  1754. --- @param str string Command line string to parse. Cannot contain "\n".
  1755. --- @param opts vim.api.keyset.empty Optional parameters. Reserved for future use.
  1756. --- @return vim.api.keyset.parse_cmd # Dict containing command information, with these keys:
  1757. --- - cmd: (string) Command name.
  1758. --- - range: (array) (optional) Command range ([<line1>] [<line2>]).
  1759. --- Omitted if command doesn't accept a range.
  1760. --- Otherwise, has no elements if no range was specified, one element if
  1761. --- only a single range item was specified, or two elements if both range
  1762. --- items were specified.
  1763. --- - count: (number) (optional) Command [<count>].
  1764. --- Omitted if command cannot take a count.
  1765. --- - reg: (string) (optional) Command [<register>].
  1766. --- Omitted if command cannot take a register.
  1767. --- - bang: (boolean) Whether command contains a [<bang>] (!) modifier.
  1768. --- - args: (array) Command arguments.
  1769. --- - addr: (string) Value of |:command-addr|. Uses short name or "line" for -addr=lines.
  1770. --- - nargs: (string) Value of |:command-nargs|.
  1771. --- - nextcmd: (string) Next command if there are multiple commands separated by a |:bar|.
  1772. --- Empty if there isn't a next command.
  1773. --- - magic: (dict) Which characters have special meaning in the command arguments.
  1774. --- - file: (boolean) The command expands filenames. Which means characters such as "%",
  1775. --- "#" and wildcards are expanded.
  1776. --- - bar: (boolean) The "|" character is treated as a command separator and the double
  1777. --- quote character (") is treated as the start of a comment.
  1778. --- - mods: (dict) |:command-modifiers|.
  1779. --- - filter: (dict) |:filter|.
  1780. --- - pattern: (string) Filter pattern. Empty string if there is no filter.
  1781. --- - force: (boolean) Whether filter is inverted or not.
  1782. --- - silent: (boolean) |:silent|.
  1783. --- - emsg_silent: (boolean) |:silent!|.
  1784. --- - unsilent: (boolean) |:unsilent|.
  1785. --- - sandbox: (boolean) |:sandbox|.
  1786. --- - noautocmd: (boolean) |:noautocmd|.
  1787. --- - browse: (boolean) |:browse|.
  1788. --- - confirm: (boolean) |:confirm|.
  1789. --- - hide: (boolean) |:hide|.
  1790. --- - horizontal: (boolean) |:horizontal|.
  1791. --- - keepalt: (boolean) |:keepalt|.
  1792. --- - keepjumps: (boolean) |:keepjumps|.
  1793. --- - keepmarks: (boolean) |:keepmarks|.
  1794. --- - keeppatterns: (boolean) |:keeppatterns|.
  1795. --- - lockmarks: (boolean) |:lockmarks|.
  1796. --- - noswapfile: (boolean) |:noswapfile|.
  1797. --- - tab: (integer) |:tab|. -1 when omitted.
  1798. --- - verbose: (integer) |:verbose|. -1 when omitted.
  1799. --- - vertical: (boolean) |:vertical|.
  1800. --- - split: (string) Split modifier string, is an empty string when there's no split
  1801. --- modifier. If there is a split modifier it can be one of:
  1802. --- - "aboveleft": |:aboveleft|.
  1803. --- - "belowright": |:belowright|.
  1804. --- - "topleft": |:topleft|.
  1805. --- - "botright": |:botright|.
  1806. function vim.api.nvim_parse_cmd(str, opts) end
  1807. --- Parse a Vimscript expression.
  1808. ---
  1809. --- @param expr string Expression to parse. Always treated as a single line.
  1810. --- @param flags string Flags:
  1811. --- - "m" if multiple expressions in a row are allowed (only
  1812. --- the first one will be parsed),
  1813. --- - "E" if EOC tokens are not allowed (determines whether
  1814. --- they will stop parsing process or be recognized as an
  1815. --- operator/space, though also yielding an error).
  1816. --- - "l" when needing to start parsing with lvalues for
  1817. --- ":let" or ":for".
  1818. --- Common flag sets:
  1819. --- - "m" to parse like for `":echo"`.
  1820. --- - "E" to parse like for `"<C-r>="`.
  1821. --- - empty string for ":call".
  1822. --- - "lm" to parse for ":let".
  1823. --- @param highlight boolean If true, return value will also include "highlight"
  1824. --- key containing array of 4-tuples (arrays) (Integer,
  1825. --- Integer, Integer, String), where first three numbers
  1826. --- define the highlighted region and represent line,
  1827. --- starting column and ending column (latter exclusive:
  1828. --- one should highlight region [start_col, end_col)).
  1829. --- @return table<string,any> #
  1830. --- - AST: top-level dict with these keys:
  1831. --- - "error": Dict with error, present only if parser saw some
  1832. --- error. Contains the following keys:
  1833. --- - "message": String, error message in printf format, translated.
  1834. --- Must contain exactly one "%.*s".
  1835. --- - "arg": String, error message argument.
  1836. --- - "len": Amount of bytes successfully parsed. With flags equal to ""
  1837. --- that should be equal to the length of expr string.
  1838. --- ("Successfully parsed" here means "participated in AST
  1839. --- creation", not "till the first error".)
  1840. --- - "ast": AST, either nil or a dict with these keys:
  1841. --- - "type": node type, one of the value names from ExprASTNodeType
  1842. --- stringified without "kExprNode" prefix.
  1843. --- - "start": a pair `[line, column]` describing where node is "started"
  1844. --- where "line" is always 0 (will not be 0 if you will be
  1845. --- using this API on e.g. ":let", but that is not
  1846. --- present yet). Both elements are Integers.
  1847. --- - "len": “length” of the node. This and "start" are there for
  1848. --- debugging purposes primary (debugging parser and providing
  1849. --- debug information).
  1850. --- - "children": a list of nodes described in top/"ast". There always
  1851. --- is zero, one or two children, key will not be present
  1852. --- if node has no children. Maximum number of children
  1853. --- may be found in node_maxchildren array.
  1854. --- - Local values (present only for certain nodes):
  1855. --- - "scope": a single Integer, specifies scope for "Option" and
  1856. --- "PlainIdentifier" nodes. For "Option" it is one of
  1857. --- ExprOptScope values, for "PlainIdentifier" it is one of
  1858. --- ExprVarScope values.
  1859. --- - "ident": identifier (without scope, if any), present for "Option",
  1860. --- "PlainIdentifier", "PlainKey" and "Environment" nodes.
  1861. --- - "name": Integer, register name (one character) or -1. Only present
  1862. --- for "Register" nodes.
  1863. --- - "cmp_type": String, comparison type, one of the value names from
  1864. --- ExprComparisonType, stringified without "kExprCmp"
  1865. --- prefix. Only present for "Comparison" nodes.
  1866. --- - "ccs_strategy": String, case comparison strategy, one of the
  1867. --- value names from ExprCaseCompareStrategy,
  1868. --- stringified without "kCCStrategy" prefix. Only
  1869. --- present for "Comparison" nodes.
  1870. --- - "augmentation": String, augmentation type for "Assignment" nodes.
  1871. --- Is either an empty string, "Add", "Subtract" or
  1872. --- "Concat" for "=", "+=", "-=" or ".=" respectively.
  1873. --- - "invert": Boolean, true if result of comparison needs to be
  1874. --- inverted. Only present for "Comparison" nodes.
  1875. --- - "ivalue": Integer, integer value for "Integer" nodes.
  1876. --- - "fvalue": Float, floating-point value for "Float" nodes.
  1877. --- - "svalue": String, value for "SingleQuotedString" and
  1878. --- "DoubleQuotedString" nodes.
  1879. function vim.api.nvim_parse_expression(expr, flags, highlight) end
  1880. --- Pastes at cursor (in any mode), and sets "redo" so dot (`.`) will repeat the input. UIs call
  1881. --- this to implement "paste", but it's also intended for use by scripts to input large,
  1882. --- dot-repeatable blocks of text (as opposed to `nvim_input()` which is subject to mappings/events
  1883. --- and is thus much slower).
  1884. ---
  1885. --- Invokes the `vim.paste()` handler, which handles each mode appropriately.
  1886. ---
  1887. --- Errors ('nomodifiable', `vim.paste()` failure, …) are reflected in `err` but do not affect the
  1888. --- return value (which is strictly decided by `vim.paste()`). On error or cancel, subsequent calls
  1889. --- are ignored ("drained") until the next paste is initiated (phase 1 or -1).
  1890. ---
  1891. --- Useful in mappings and scripts to insert multiline text. Example:
  1892. ---
  1893. --- ```lua
  1894. --- vim.keymap.set('n', 'x', function()
  1895. --- vim.api.nvim_paste([[
  1896. --- line1
  1897. --- line2
  1898. --- line3
  1899. --- ]], false, -1)
  1900. --- end, { buffer = true })
  1901. --- ```
  1902. ---
  1903. --- @param data string Multiline input. Lines break at LF ("\n"). May be binary (containing NUL bytes).
  1904. --- @param crlf boolean Also break lines at CR and CRLF.
  1905. --- @param phase integer -1: paste in a single call (i.e. without streaming).
  1906. --- To "stream" a paste, call `nvim_paste` sequentially with
  1907. --- these `phase` values:
  1908. --- - 1: starts the paste (exactly once)
  1909. --- - 2: continues the paste (zero or more times)
  1910. --- - 3: ends the paste (exactly once)
  1911. --- @return boolean #
  1912. --- - true: Client may continue pasting.
  1913. --- - false: Client should cancel the paste.
  1914. function vim.api.nvim_paste(data, crlf, phase) end
  1915. --- Puts text at cursor, in any mode. For dot-repeatable input, use `nvim_paste()`.
  1916. ---
  1917. --- Compare `:put` and `p` which are always linewise.
  1918. ---
  1919. --- @param lines string[] `readfile()`-style list of lines. `channel-lines`
  1920. --- @param type string Edit behavior: any `getregtype()` result, or:
  1921. --- - "b" `blockwise-visual` mode (may include width, e.g. "b3")
  1922. --- - "c" `charwise` mode
  1923. --- - "l" `linewise` mode
  1924. --- - "" guess by contents, see `setreg()`
  1925. --- @param after boolean If true insert after cursor (like `p`), or before (like `P`).
  1926. --- @param follow boolean If true place cursor at end of inserted text.
  1927. function vim.api.nvim_put(lines, type, after, follow) end
  1928. --- Replaces terminal codes and `keycodes` ([<CR>], [<Esc>], ...) in a string with
  1929. --- the internal representation.
  1930. ---
  1931. --- @see replace_termcodes
  1932. --- @see cpoptions
  1933. --- @param str string String to be converted.
  1934. --- @param from_part boolean Legacy Vim parameter. Usually true.
  1935. --- @param do_lt boolean Also translate [<lt>]. Ignored if `special` is false.
  1936. --- @param special boolean Replace `keycodes`, e.g. [<CR>] becomes a "\r" char.
  1937. --- @return string
  1938. function vim.api.nvim_replace_termcodes(str, from_part, do_lt, special) end
  1939. --- Selects an item in the completion popup menu.
  1940. ---
  1941. --- If neither `ins-completion` nor `cmdline-completion` popup menu is active
  1942. --- this API call is silently ignored.
  1943. --- Useful for an external UI using `ui-popupmenu` to control the popup menu with the mouse.
  1944. --- Can also be used in a mapping; use [<Cmd>] `:map-cmd` or a Lua mapping to ensure the mapping
  1945. --- doesn't end completion mode.
  1946. ---
  1947. --- @param item integer Index (zero-based) of the item to select. Value of -1 selects nothing
  1948. --- and restores the original text.
  1949. --- @param insert boolean For `ins-completion`, whether the selection should be inserted in the buffer.
  1950. --- Ignored for `cmdline-completion`.
  1951. --- @param finish boolean Finish the completion and dismiss the popup menu. Implies {insert}.
  1952. --- @param opts vim.api.keyset.empty Optional parameters. Reserved for future use.
  1953. function vim.api.nvim_select_popupmenu_item(item, insert, finish, opts) end
  1954. --- Sets the current window's buffer to `buffer`.
  1955. ---
  1956. --- @param buffer integer Buffer handle
  1957. function vim.api.nvim_set_current_buf(buffer) end
  1958. --- Changes the global working directory.
  1959. ---
  1960. --- @param dir string Directory path
  1961. function vim.api.nvim_set_current_dir(dir) end
  1962. --- Sets the text on the current line.
  1963. ---
  1964. --- @param line string Line contents
  1965. function vim.api.nvim_set_current_line(line) end
  1966. --- Sets the current tabpage.
  1967. ---
  1968. --- @param tabpage integer `tab-ID` to focus
  1969. function vim.api.nvim_set_current_tabpage(tabpage) end
  1970. --- Sets the current window. Also changes tabpage, if necessary.
  1971. ---
  1972. --- @param window integer `window-ID` to focus
  1973. function vim.api.nvim_set_current_win(window) end
  1974. --- Set or change decoration provider for a `namespace`
  1975. ---
  1976. --- This is a very general purpose interface for having Lua callbacks
  1977. --- being triggered during the redraw code.
  1978. ---
  1979. --- The expected usage is to set `extmarks` for the currently
  1980. --- redrawn buffer. `nvim_buf_set_extmark()` can be called to add marks
  1981. --- on a per-window or per-lines basis. Use the `ephemeral` key to only
  1982. --- use the mark for the current screen redraw (the callback will be called
  1983. --- again for the next redraw).
  1984. ---
  1985. --- Note: this function should not be called often. Rather, the callbacks
  1986. --- themselves can be used to throttle unneeded callbacks. the `on_start`
  1987. --- callback can return `false` to disable the provider until the next redraw.
  1988. --- Similarly, return `false` in `on_win` will skip the `on_line` calls
  1989. --- for that window (but any extmarks set in `on_win` will still be used).
  1990. --- A plugin managing multiple sources of decoration should ideally only set
  1991. --- one provider, and merge the sources internally. You can use multiple `ns_id`
  1992. --- for the extmarks set/modified inside the callback anyway.
  1993. ---
  1994. --- Note: doing anything other than setting extmarks is considered experimental.
  1995. --- Doing things like changing options are not explicitly forbidden, but is
  1996. --- likely to have unexpected consequences (such as 100% CPU consumption).
  1997. --- Doing `vim.rpcnotify` should be OK, but `vim.rpcrequest` is quite dubious
  1998. --- for the moment.
  1999. ---
  2000. --- Note: It is not allowed to remove or update extmarks in `on_line` callbacks.
  2001. ---
  2002. --- @param ns_id integer Namespace id from `nvim_create_namespace()`
  2003. --- @param opts vim.api.keyset.set_decoration_provider Table of callbacks:
  2004. --- - on_start: called first on each screen redraw
  2005. --- ```
  2006. --- ["start", tick]
  2007. --- ```
  2008. --- - on_buf: called for each buffer being redrawn (once per edit,
  2009. --- before window callbacks)
  2010. --- ```
  2011. --- ["buf", bufnr, tick]
  2012. --- ```
  2013. --- - on_win: called when starting to redraw a specific window.
  2014. --- ```
  2015. --- ["win", winid, bufnr, toprow, botrow]
  2016. --- ```
  2017. --- - on_line: called for each buffer line being redrawn.
  2018. --- (The interaction with fold lines is subject to change)
  2019. --- ```
  2020. --- ["line", winid, bufnr, row]
  2021. --- ```
  2022. --- - on_end: called at the end of a redraw cycle
  2023. --- ```
  2024. --- ["end", tick]
  2025. --- ```
  2026. function vim.api.nvim_set_decoration_provider(ns_id, opts) end
  2027. --- Sets a highlight group.
  2028. ---
  2029. --- Note:
  2030. --- Unlike the `:highlight` command which can update a highlight group,
  2031. --- this function completely replaces the definition. For example:
  2032. --- `nvim_set_hl(0, 'Visual', {})` will clear the highlight group
  2033. --- 'Visual'.
  2034. ---
  2035. --- The fg and bg keys also accept the string values `"fg"` or `"bg"`
  2036. --- which act as aliases to the corresponding foreground and background
  2037. --- values of the Normal group. If the Normal group has not been defined,
  2038. --- using these values results in an error.
  2039. ---
  2040. ---
  2041. --- If `link` is used in combination with other attributes; only the
  2042. --- `link` will take effect (see |:hi-link|).
  2043. ---
  2044. ---
  2045. --- @param ns_id integer Namespace id for this highlight `nvim_create_namespace()`.
  2046. --- Use 0 to set a highlight group globally `:highlight`.
  2047. --- Highlights from non-global namespaces are not active by default, use
  2048. --- `nvim_set_hl_ns()` or `nvim_win_set_hl_ns()` to activate them.
  2049. --- @param name string Highlight group name, e.g. "ErrorMsg"
  2050. --- @param val vim.api.keyset.highlight Highlight definition map, accepts the following keys:
  2051. --- - fg: color name or "#RRGGBB", see note.
  2052. --- - bg: color name or "#RRGGBB", see note.
  2053. --- - sp: color name or "#RRGGBB"
  2054. --- - blend: integer between 0 and 100
  2055. --- - bold: boolean
  2056. --- - standout: boolean
  2057. --- - underline: boolean
  2058. --- - undercurl: boolean
  2059. --- - underdouble: boolean
  2060. --- - underdotted: boolean
  2061. --- - underdashed: boolean
  2062. --- - strikethrough: boolean
  2063. --- - italic: boolean
  2064. --- - reverse: boolean
  2065. --- - nocombine: boolean
  2066. --- - link: name of another highlight group to link to, see `:hi-link`.
  2067. --- - default: Don't override existing definition `:hi-default`
  2068. --- - ctermfg: Sets foreground of cterm color `ctermfg`
  2069. --- - ctermbg: Sets background of cterm color `ctermbg`
  2070. --- - cterm: cterm attribute map, like `highlight-args`. If not set,
  2071. --- cterm attributes will match those from the attribute map
  2072. --- documented above.
  2073. --- - force: if true force update the highlight group when it exists.
  2074. function vim.api.nvim_set_hl(ns_id, name, val) end
  2075. --- Set active namespace for highlights defined with `nvim_set_hl()`. This can be set for
  2076. --- a single window, see `nvim_win_set_hl_ns()`.
  2077. ---
  2078. --- @param ns_id integer the namespace to use
  2079. function vim.api.nvim_set_hl_ns(ns_id) end
  2080. --- Set active namespace for highlights defined with `nvim_set_hl()` while redrawing.
  2081. ---
  2082. --- This function meant to be called while redrawing, primarily from
  2083. --- `nvim_set_decoration_provider()` on_win and on_line callbacks, which
  2084. --- are allowed to change the namespace during a redraw cycle.
  2085. ---
  2086. --- @param ns_id integer the namespace to activate
  2087. function vim.api.nvim_set_hl_ns_fast(ns_id) end
  2088. --- Sets a global `mapping` for the given mode.
  2089. ---
  2090. --- To set a buffer-local mapping, use `nvim_buf_set_keymap()`.
  2091. ---
  2092. --- Unlike `:map`, leading/trailing whitespace is accepted as part of the {lhs} or {rhs}.
  2093. --- Empty {rhs} is [<Nop>]. `keycodes` are replaced as usual.
  2094. ---
  2095. --- Example:
  2096. ---
  2097. --- ```vim
  2098. --- call nvim_set_keymap('n', ' <NL>', '', {'nowait': v:true})
  2099. --- ```
  2100. ---
  2101. --- is equivalent to:
  2102. ---
  2103. --- ```vim
  2104. --- nmap <nowait> <Space><NL> <Nop>
  2105. --- ```
  2106. ---
  2107. --- @param mode string Mode short-name (map command prefix: "n", "i", "v", "x", …)
  2108. --- or "!" for `:map!`, or empty string for `:map`.
  2109. --- "ia", "ca" or "!a" for abbreviation in Insert mode, Cmdline mode, or both, respectively
  2110. --- @param lhs string Left-hand-side `{lhs}` of the mapping.
  2111. --- @param rhs string Right-hand-side `{rhs}` of the mapping.
  2112. --- @param opts vim.api.keyset.keymap Optional parameters map: Accepts all `:map-arguments` as keys except [<buffer>],
  2113. --- values are booleans (default false). Also:
  2114. --- - "noremap" disables `recursive_mapping`, like `:noremap`
  2115. --- - "desc" human-readable description.
  2116. --- - "callback" Lua function called in place of {rhs}.
  2117. --- - "replace_keycodes" (boolean) When "expr" is true, replace keycodes in the
  2118. --- resulting string (see `nvim_replace_termcodes()`). Returning nil from the Lua
  2119. --- "callback" is equivalent to returning an empty string.
  2120. function vim.api.nvim_set_keymap(mode, lhs, rhs, opts) end
  2121. --- @deprecated
  2122. --- @param name string
  2123. --- @param value any
  2124. function vim.api.nvim_set_option(name, value) end
  2125. --- Sets the value of an option. The behavior of this function matches that of
  2126. --- `:set`: for global-local options, both the global and local value are set
  2127. --- unless otherwise specified with {scope}.
  2128. ---
  2129. --- Note the options {win} and {buf} cannot be used together.
  2130. ---
  2131. --- @param name string Option name
  2132. --- @param value any New option value
  2133. --- @param opts vim.api.keyset.option Optional parameters
  2134. --- - scope: One of "global" or "local". Analogous to
  2135. --- `:setglobal` and `:setlocal`, respectively.
  2136. --- - win: `window-ID`. Used for setting window local option.
  2137. --- - buf: Buffer number. Used for setting buffer local option.
  2138. function vim.api.nvim_set_option_value(name, value, opts) end
  2139. --- Sets a global (g:) variable.
  2140. ---
  2141. --- @param name string Variable name
  2142. --- @param value any Variable value
  2143. function vim.api.nvim_set_var(name, value) end
  2144. --- Sets a v: variable, if it is not readonly.
  2145. ---
  2146. --- @param name string Variable name
  2147. --- @param value any Variable value
  2148. function vim.api.nvim_set_vvar(name, value) end
  2149. --- Calculates the number of display cells occupied by `text`.
  2150. --- Control characters including [<Tab>] count as one cell.
  2151. ---
  2152. --- @param text string Some text
  2153. --- @return integer # Number of cells
  2154. function vim.api.nvim_strwidth(text) end
  2155. --- Removes a tab-scoped (t:) variable
  2156. ---
  2157. --- @param tabpage integer `tab-ID`, or 0 for current tabpage
  2158. --- @param name string Variable name
  2159. function vim.api.nvim_tabpage_del_var(tabpage, name) end
  2160. --- Gets the tabpage number
  2161. ---
  2162. --- @param tabpage integer `tab-ID`, or 0 for current tabpage
  2163. --- @return integer # Tabpage number
  2164. function vim.api.nvim_tabpage_get_number(tabpage) end
  2165. --- Gets a tab-scoped (t:) variable
  2166. ---
  2167. --- @param tabpage integer `tab-ID`, or 0 for current tabpage
  2168. --- @param name string Variable name
  2169. --- @return any # Variable value
  2170. function vim.api.nvim_tabpage_get_var(tabpage, name) end
  2171. --- Gets the current window in a tabpage
  2172. ---
  2173. --- @param tabpage integer `tab-ID`, or 0 for current tabpage
  2174. --- @return integer # |window-ID|
  2175. function vim.api.nvim_tabpage_get_win(tabpage) end
  2176. --- Checks if a tabpage is valid
  2177. ---
  2178. --- @param tabpage integer `tab-ID`, or 0 for current tabpage
  2179. --- @return boolean # true if the tabpage is valid, false otherwise
  2180. function vim.api.nvim_tabpage_is_valid(tabpage) end
  2181. --- Gets the windows in a tabpage
  2182. ---
  2183. --- @param tabpage integer `tab-ID`, or 0 for current tabpage
  2184. --- @return integer[] # List of windows in `tabpage`
  2185. function vim.api.nvim_tabpage_list_wins(tabpage) end
  2186. --- Sets a tab-scoped (t:) variable
  2187. ---
  2188. --- @param tabpage integer `tab-ID`, or 0 for current tabpage
  2189. --- @param name string Variable name
  2190. --- @param value any Variable value
  2191. function vim.api.nvim_tabpage_set_var(tabpage, name, value) end
  2192. --- Sets the current window in a tabpage
  2193. ---
  2194. --- @param tabpage integer `tab-ID`, or 0 for current tabpage
  2195. --- @param win integer `window-ID`, must already belong to {tabpage}
  2196. function vim.api.nvim_tabpage_set_win(tabpage, win) end
  2197. --- Calls a function with window as temporary current window.
  2198. ---
  2199. ---
  2200. --- @see `:help win_execute()`
  2201. --- @see vim.api.nvim_buf_call
  2202. --- @param window integer `window-ID`, or 0 for current window
  2203. --- @param fun function Function to call inside the window (currently Lua callable
  2204. --- only)
  2205. --- @return any # Return value of function.
  2206. function vim.api.nvim_win_call(window, fun) end
  2207. --- Closes the window (like `:close` with a `window-ID`).
  2208. ---
  2209. --- @param window integer `window-ID`, or 0 for current window
  2210. --- @param force boolean Behave like `:close!` The last window of a buffer with
  2211. --- unwritten changes can be closed. The buffer will become
  2212. --- hidden, even if 'hidden' is not set.
  2213. function vim.api.nvim_win_close(window, force) end
  2214. --- Removes a window-scoped (w:) variable
  2215. ---
  2216. --- @param window integer `window-ID`, or 0 for current window
  2217. --- @param name string Variable name
  2218. function vim.api.nvim_win_del_var(window, name) end
  2219. --- Gets the current buffer in a window
  2220. ---
  2221. --- @param window integer `window-ID`, or 0 for current window
  2222. --- @return integer # Buffer handle
  2223. function vim.api.nvim_win_get_buf(window) end
  2224. --- Gets window configuration.
  2225. ---
  2226. --- The returned value may be given to `nvim_open_win()`.
  2227. ---
  2228. --- `relative` is empty for normal windows.
  2229. ---
  2230. --- @param window integer `window-ID`, or 0 for current window
  2231. --- @return vim.api.keyset.win_config # Map defining the window configuration, see |nvim_open_win()|
  2232. function vim.api.nvim_win_get_config(window) end
  2233. --- Gets the (1,0)-indexed, buffer-relative cursor position for a given window
  2234. --- (different windows showing the same buffer have independent cursor
  2235. --- positions). `api-indexing`
  2236. ---
  2237. ---
  2238. --- @see `:help getcurpos()`
  2239. --- @param window integer `window-ID`, or 0 for current window
  2240. --- @return integer[] # (row, col) tuple
  2241. function vim.api.nvim_win_get_cursor(window) end
  2242. --- Gets the window height
  2243. ---
  2244. --- @param window integer `window-ID`, or 0 for current window
  2245. --- @return integer # Height as a count of rows
  2246. function vim.api.nvim_win_get_height(window) end
  2247. --- Gets the window number
  2248. ---
  2249. --- @param window integer `window-ID`, or 0 for current window
  2250. --- @return integer # Window number
  2251. function vim.api.nvim_win_get_number(window) end
  2252. --- @deprecated
  2253. --- @param window integer
  2254. --- @param name string
  2255. --- @return any
  2256. function vim.api.nvim_win_get_option(window, name) end
  2257. --- Gets the window position in display cells. First position is zero.
  2258. ---
  2259. --- @param window integer `window-ID`, or 0 for current window
  2260. --- @return integer[] # (row, col) tuple with the window position
  2261. function vim.api.nvim_win_get_position(window) end
  2262. --- Gets the window tabpage
  2263. ---
  2264. --- @param window integer `window-ID`, or 0 for current window
  2265. --- @return integer # Tabpage that contains the window
  2266. function vim.api.nvim_win_get_tabpage(window) end
  2267. --- Gets a window-scoped (w:) variable
  2268. ---
  2269. --- @param window integer `window-ID`, or 0 for current window
  2270. --- @param name string Variable name
  2271. --- @return any # Variable value
  2272. function vim.api.nvim_win_get_var(window, name) end
  2273. --- Gets the window width
  2274. ---
  2275. --- @param window integer `window-ID`, or 0 for current window
  2276. --- @return integer # Width as a count of columns
  2277. function vim.api.nvim_win_get_width(window) end
  2278. --- Closes the window and hide the buffer it contains (like `:hide` with a
  2279. --- `window-ID`).
  2280. ---
  2281. --- Like `:hide` the buffer becomes hidden unless another window is editing it,
  2282. --- or 'bufhidden' is `unload`, `delete` or `wipe` as opposed to `:close` or
  2283. --- `nvim_win_close()`, which will close the buffer.
  2284. ---
  2285. --- @param window integer `window-ID`, or 0 for current window
  2286. function vim.api.nvim_win_hide(window) end
  2287. --- Checks if a window is valid
  2288. ---
  2289. --- @param window integer `window-ID`, or 0 for current window
  2290. --- @return boolean # true if the window is valid, false otherwise
  2291. function vim.api.nvim_win_is_valid(window) end
  2292. --- Sets the current buffer in a window, without side effects
  2293. ---
  2294. --- @param window integer `window-ID`, or 0 for current window
  2295. --- @param buffer integer Buffer handle
  2296. function vim.api.nvim_win_set_buf(window, buffer) end
  2297. --- Configures window layout. Cannot be used to move the last window in a
  2298. --- tabpage to a different one.
  2299. ---
  2300. --- When reconfiguring a window, absent option keys will not be changed.
  2301. --- `row`/`col` and `relative` must be reconfigured together.
  2302. ---
  2303. ---
  2304. --- @see vim.api.nvim_open_win
  2305. --- @param window integer `window-ID`, or 0 for current window
  2306. --- @param config vim.api.keyset.win_config Map defining the window configuration,
  2307. --- see `nvim_open_win()`
  2308. function vim.api.nvim_win_set_config(window, config) end
  2309. --- Sets the (1,0)-indexed cursor position in the window. `api-indexing`
  2310. --- This scrolls the window even if it is not the current one.
  2311. ---
  2312. --- @param window integer `window-ID`, or 0 for current window
  2313. --- @param pos integer[] (row, col) tuple representing the new position
  2314. function vim.api.nvim_win_set_cursor(window, pos) end
  2315. --- Sets the window height.
  2316. ---
  2317. --- @param window integer `window-ID`, or 0 for current window
  2318. --- @param height integer Height as a count of rows
  2319. function vim.api.nvim_win_set_height(window, height) end
  2320. --- Set highlight namespace for a window. This will use highlights defined with
  2321. --- `nvim_set_hl()` for this namespace, but fall back to global highlights (ns=0) when
  2322. --- missing.
  2323. ---
  2324. --- This takes precedence over the 'winhighlight' option.
  2325. ---
  2326. --- @param window integer
  2327. --- @param ns_id integer the namespace to use
  2328. function vim.api.nvim_win_set_hl_ns(window, ns_id) end
  2329. --- @deprecated
  2330. --- @param window integer
  2331. --- @param name string
  2332. --- @param value any
  2333. function vim.api.nvim_win_set_option(window, name, value) end
  2334. --- Sets a window-scoped (w:) variable
  2335. ---
  2336. --- @param window integer `window-ID`, or 0 for current window
  2337. --- @param name string Variable name
  2338. --- @param value any Variable value
  2339. function vim.api.nvim_win_set_var(window, name, value) end
  2340. --- Sets the window width. This will only succeed if the screen is split
  2341. --- vertically.
  2342. ---
  2343. --- @param window integer `window-ID`, or 0 for current window
  2344. --- @param width integer Width as a count of columns
  2345. function vim.api.nvim_win_set_width(window, width) end
  2346. --- Computes the number of screen lines occupied by a range of text in a given window.
  2347. --- Works for off-screen text and takes folds into account.
  2348. ---
  2349. --- Diff filler or virtual lines above a line are counted as a part of that line,
  2350. --- unless the line is on "start_row" and "start_vcol" is specified.
  2351. ---
  2352. --- Diff filler or virtual lines below the last buffer line are counted in the result
  2353. --- when "end_row" is omitted.
  2354. ---
  2355. --- Line indexing is similar to `nvim_buf_get_text()`.
  2356. ---
  2357. --- @see `:help virtcol()` for text width.
  2358. --- @param window integer `window-ID`, or 0 for current window.
  2359. --- @param opts vim.api.keyset.win_text_height Optional parameters:
  2360. --- - start_row: Starting line index, 0-based inclusive.
  2361. --- When omitted start at the very top.
  2362. --- - end_row: Ending line index, 0-based inclusive.
  2363. --- When omitted end at the very bottom.
  2364. --- - start_vcol: Starting virtual column index on "start_row",
  2365. --- 0-based inclusive, rounded down to full screen lines.
  2366. --- When omitted include the whole line.
  2367. --- - end_vcol: Ending virtual column index on "end_row",
  2368. --- 0-based exclusive, rounded up to full screen lines.
  2369. --- When omitted include the whole line.
  2370. --- @return table<string,any> # Dict containing text height information, with these keys:
  2371. --- - all: The total number of screen lines occupied by the range.
  2372. --- - fill: The number of diff filler or virtual lines among them.
  2373. ---
  2374. function vim.api.nvim_win_text_height(window, opts) end