api.lua 107 KB

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