api.lua 107 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547
  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 these 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 `termopen()`.
  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.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 using `nvim_cmd()` or `nvim_exec2()` over this. To evaluate multiple lines of Vim script
  827. --- or an Ex command directly, use `nvim_exec2()`. To construct an Ex command using a structured
  828. --- format and then execute it, use `nvim_cmd()`. To modify an Ex command before evaluating it, use
  829. --- `nvim_parse_cmd()` in conjunction with `nvim_cmd()`.
  830. ---
  831. --- @param command string Ex command string
  832. function vim.api.nvim_command(command) end
  833. --- @deprecated
  834. --- @see vim.api.nvim_exec2
  835. --- @param command string
  836. --- @return string
  837. function vim.api.nvim_command_output(command) end
  838. --- Create or get an autocommand group `autocmd-groups`.
  839. ---
  840. --- To get an existing group id, do:
  841. ---
  842. --- ```lua
  843. --- local id = vim.api.nvim_create_augroup("MyGroup", {
  844. --- clear = false
  845. --- })
  846. --- ```
  847. ---
  848. --- @see `:help autocmd-groups`
  849. --- @param name string String: The name of the group
  850. --- @param opts vim.api.keyset.create_augroup Dict Parameters
  851. --- - clear (bool) optional: defaults to true. Clear existing
  852. --- commands if the group already exists `autocmd-groups`.
  853. --- @return integer # Integer id of the created group.
  854. function vim.api.nvim_create_augroup(name, opts) end
  855. --- Creates an `autocommand` event handler, defined by `callback` (Lua function or Vimscript
  856. --- function _name_ string) or `command` (Ex command string).
  857. ---
  858. --- Example using Lua callback:
  859. ---
  860. --- ```lua
  861. --- vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
  862. --- pattern = {"*.c", "*.h"},
  863. --- callback = function(ev)
  864. --- print(string.format('event fired: %s', vim.inspect(ev)))
  865. --- end
  866. --- })
  867. --- ```
  868. ---
  869. --- Example using an Ex command as the handler:
  870. ---
  871. --- ```lua
  872. --- vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
  873. --- pattern = {"*.c", "*.h"},
  874. --- command = "echo 'Entering a C or C++ file'",
  875. --- })
  876. --- ```
  877. ---
  878. --- Note: `pattern` is NOT automatically expanded (unlike with `:autocmd`), thus names like "$HOME"
  879. --- and "~" must be expanded explicitly:
  880. ---
  881. --- ```lua
  882. --- pattern = vim.fn.expand("~") .. "/some/path/*.py"
  883. --- ```
  884. ---
  885. --- @see `:help autocommand`
  886. --- @see vim.api.nvim_del_autocmd
  887. --- @param event any (string|array) Event(s) that will trigger the handler (`callback` or `command`).
  888. --- @param opts vim.api.keyset.create_autocmd Options dict:
  889. --- - group (string|integer) optional: autocommand group name or id to match against.
  890. --- - pattern (string|array) optional: pattern(s) to match literally `autocmd-pattern`.
  891. --- - buffer (integer) optional: buffer number for buffer-local autocommands
  892. --- `autocmd-buflocal`. Cannot be used with {pattern}.
  893. --- - desc (string) optional: description (for documentation and troubleshooting).
  894. --- - callback (function|string) optional: Lua function (or Vimscript function name, if
  895. --- string) called when the event(s) is triggered. Lua callback can return a truthy
  896. --- value (not `false` or `nil`) to delete the autocommand. Receives one argument,
  897. --- a table with these keys: [event-args]()
  898. --- - id: (number) autocommand id
  899. --- - event: (string) name of the triggered event `autocmd-events`
  900. --- - group: (number|nil) autocommand group id, if any
  901. --- - file: (string) [<afile>] (not expanded to a full path)
  902. --- - match: (string) [<amatch>] (expanded to a full path)
  903. --- - buf: (number) [<abuf>]
  904. --- - data: (any) arbitrary data passed from [nvim_exec_autocmds()] [event-data]()
  905. --- - command (string) optional: Vim command to execute on event. Cannot be used with
  906. --- {callback}
  907. --- - once (boolean) optional: defaults to false. Run the autocommand
  908. --- only once `autocmd-once`.
  909. --- - nested (boolean) optional: defaults to false. Run nested
  910. --- autocommands `autocmd-nested`.
  911. --- @return integer # Autocommand id (number)
  912. function vim.api.nvim_create_autocmd(event, opts) end
  913. --- Creates a new, empty, unnamed buffer.
  914. ---
  915. --- @see buf_open_scratch
  916. --- @param listed boolean Sets 'buflisted'
  917. --- @param scratch boolean Creates a "throwaway" `scratch-buffer` for temporary work
  918. --- (always 'nomodified'). Also sets 'nomodeline' on the buffer.
  919. --- @return integer # Buffer handle, or 0 on error
  920. ---
  921. function vim.api.nvim_create_buf(listed, scratch) end
  922. --- Creates a new namespace or gets an existing one. [namespace]()
  923. ---
  924. --- Namespaces are used for buffer highlights and virtual text, see
  925. --- `nvim_buf_add_highlight()` and `nvim_buf_set_extmark()`.
  926. ---
  927. --- Namespaces can be named or anonymous. If `name` matches an existing
  928. --- namespace, the associated id is returned. If `name` is an empty string
  929. --- a new, anonymous namespace is created.
  930. ---
  931. --- @param name string Namespace name or empty string
  932. --- @return integer # Namespace id
  933. function vim.api.nvim_create_namespace(name) end
  934. --- Creates a global `user-commands` command.
  935. ---
  936. --- For Lua usage see `lua-guide-commands-create`.
  937. ---
  938. --- Example:
  939. ---
  940. --- ```vim
  941. --- :call nvim_create_user_command('SayHello', 'echo "Hello world!"', {'bang': v:true})
  942. --- :SayHello
  943. --- Hello world!
  944. --- ```
  945. ---
  946. --- @param name string Name of the new user command. Must begin with an uppercase letter.
  947. --- @param command string|fun(args: vim.api.keyset.create_user_command.command_args) Replacement command to execute when this user command is executed. When called
  948. --- from Lua, the command can also be a Lua function. The function is called with a
  949. --- single table argument that contains the following keys:
  950. --- - name: (string) Command name
  951. --- - args: (string) The args passed to the command, if any [<args>]
  952. --- - fargs: (table) The args split by unescaped whitespace (when more than one
  953. --- argument is allowed), if any [<f-args>]
  954. --- - nargs: (string) Number of arguments `:command-nargs`
  955. --- - bang: (boolean) "true" if the command was executed with a ! modifier [<bang>]
  956. --- - line1: (number) The starting line of the command range [<line1>]
  957. --- - line2: (number) The final line of the command range [<line2>]
  958. --- - range: (number) The number of items in the command range: 0, 1, or 2 [<range>]
  959. --- - count: (number) Any count supplied [<count>]
  960. --- - reg: (string) The optional register, if specified [<reg>]
  961. --- - mods: (string) Command modifiers, if any [<mods>]
  962. --- - smods: (table) Command modifiers in a structured format. Has the same
  963. --- structure as the "mods" key of `nvim_parse_cmd()`.
  964. --- @param opts vim.api.keyset.user_command Optional `command-attributes`.
  965. --- - Set boolean attributes such as `:command-bang` or `:command-bar` to true (but
  966. --- not `:command-buffer`, use `nvim_buf_create_user_command()` instead).
  967. --- - "complete" `:command-complete` also accepts a Lua function which works like
  968. --- `:command-completion-customlist`.
  969. --- - Other parameters:
  970. --- - desc: (string) Used for listing the command when a Lua function is used for
  971. --- {command}.
  972. --- - force: (boolean, default true) Override any previous definition.
  973. --- - preview: (function) Preview callback for 'inccommand' `:command-preview`
  974. function vim.api.nvim_create_user_command(name, command, opts) end
  975. --- Delete an autocommand group by id.
  976. ---
  977. --- To get a group id one can use `nvim_get_autocmds()`.
  978. ---
  979. --- NOTE: behavior differs from `:augroup-delete`. When deleting a group, autocommands contained in
  980. --- this group will also be deleted and cleared. This group will no longer exist.
  981. --- @see vim.api.nvim_del_augroup_by_name
  982. --- @see vim.api.nvim_create_augroup
  983. --- @param id integer Integer The id of the group.
  984. function vim.api.nvim_del_augroup_by_id(id) end
  985. --- Delete an autocommand group by name.
  986. ---
  987. --- NOTE: behavior differs from `:augroup-delete`. When deleting a group, autocommands contained in
  988. --- this group will also be deleted and cleared. This group will no longer exist.
  989. --- @see `:help autocmd-groups`
  990. --- @param name string String The name of the group.
  991. function vim.api.nvim_del_augroup_by_name(name) end
  992. --- Deletes an autocommand by id.
  993. ---
  994. --- @param id integer Integer Autocommand id returned by `nvim_create_autocmd()`
  995. function vim.api.nvim_del_autocmd(id) end
  996. --- Deletes the current line.
  997. ---
  998. function vim.api.nvim_del_current_line() end
  999. --- Unmaps a global `mapping` for the given mode.
  1000. ---
  1001. --- To unmap a buffer-local mapping, use `nvim_buf_del_keymap()`.
  1002. ---
  1003. --- @see vim.api.nvim_set_keymap
  1004. --- @param mode string
  1005. --- @param lhs string
  1006. function vim.api.nvim_del_keymap(mode, lhs) end
  1007. --- Deletes an uppercase/file named mark. See `mark-motions`.
  1008. ---
  1009. --- Note:
  1010. --- Lowercase name (or other buffer-local mark) is an error.
  1011. ---
  1012. --- @see vim.api.nvim_buf_del_mark
  1013. --- @see vim.api.nvim_get_mark
  1014. --- @param name string Mark name
  1015. --- @return boolean # true if the mark was deleted, else false.
  1016. function vim.api.nvim_del_mark(name) end
  1017. --- Delete a user-defined command.
  1018. ---
  1019. --- @param name string Name of the command to delete.
  1020. function vim.api.nvim_del_user_command(name) end
  1021. --- Removes a global (g:) variable.
  1022. ---
  1023. --- @param name string Variable name
  1024. function vim.api.nvim_del_var(name) end
  1025. --- Echo a message.
  1026. ---
  1027. --- @param chunks any[] A list of `[text, hl_group]` arrays, each representing a
  1028. --- text chunk with specified highlight group name or ID.
  1029. --- `hl_group` element can be omitted for no highlight.
  1030. --- @param history boolean if true, add to `message-history`.
  1031. --- @param opts vim.api.keyset.echo_opts Optional parameters.
  1032. --- - verbose: Message is printed as a result of 'verbose' option.
  1033. --- If Nvim was invoked with -V3log_file, the message will be
  1034. --- redirected to the log_file and suppressed from direct output.
  1035. function vim.api.nvim_echo(chunks, history, opts) end
  1036. --- Writes a message to the Vim error buffer. Does not append "\n", the
  1037. --- message is buffered (won't display) until a linefeed is written.
  1038. ---
  1039. --- @param str string Message
  1040. function vim.api.nvim_err_write(str) end
  1041. --- Writes a message to the Vim error buffer. Appends "\n", so the buffer is
  1042. --- flushed (and displayed).
  1043. ---
  1044. --- @see vim.api.nvim_err_write
  1045. --- @param str string Message
  1046. function vim.api.nvim_err_writeln(str) end
  1047. --- Evaluates a Vimscript `expression`. Dicts and Lists are recursively expanded.
  1048. ---
  1049. --- On execution error: fails with Vimscript error, updates v:errmsg.
  1050. ---
  1051. --- @param expr string Vimscript expression string
  1052. --- @return any # Evaluation result or expanded object
  1053. function vim.api.nvim_eval(expr) end
  1054. --- Evaluates statusline string.
  1055. ---
  1056. --- @param str string Statusline string (see 'statusline').
  1057. --- @param opts vim.api.keyset.eval_statusline Optional parameters.
  1058. --- - winid: (number) `window-ID` of the window to use as context for statusline.
  1059. --- - maxwidth: (number) Maximum width of statusline.
  1060. --- - fillchar: (string) Character to fill blank spaces in the statusline (see
  1061. --- 'fillchars'). Treated as single-width even if it isn't.
  1062. --- - highlights: (boolean) Return highlight information.
  1063. --- - use_winbar: (boolean) Evaluate winbar instead of statusline.
  1064. --- - use_tabline: (boolean) Evaluate tabline instead of statusline. When true, {winid}
  1065. --- is ignored. Mutually exclusive with {use_winbar}.
  1066. --- - use_statuscol_lnum: (number) Evaluate statuscolumn for this line number instead of statusline.
  1067. --- @return table<string,any> # Dict containing statusline information, with these keys:
  1068. --- - str: (string) Characters that will be displayed on the statusline.
  1069. --- - width: (number) Display width of the statusline.
  1070. --- - highlights: Array containing highlight information of the statusline. Only included when
  1071. --- the "highlights" key in {opts} is true. Each element of the array is a
  1072. --- |Dict| with these keys:
  1073. --- - start: (number) Byte index (0-based) of first character that uses the highlight.
  1074. --- - group: (string) Name of highlight group.
  1075. function vim.api.nvim_eval_statusline(str, opts) end
  1076. --- @deprecated
  1077. --- @see vim.api.nvim_exec2
  1078. --- @param src string
  1079. --- @param output boolean
  1080. --- @return string
  1081. function vim.api.nvim_exec(src, output) end
  1082. --- Executes Vimscript (multiline block of Ex commands), like anonymous
  1083. --- `:source`.
  1084. ---
  1085. --- Unlike `nvim_command()` this function supports heredocs, script-scope (s:),
  1086. --- etc.
  1087. ---
  1088. --- On execution error: fails with Vimscript error, updates v:errmsg.
  1089. ---
  1090. ---
  1091. --- @see `:help execute()`
  1092. --- @see vim.api.nvim_command
  1093. --- @see vim.api.nvim_cmd
  1094. --- @param src string Vimscript code
  1095. --- @param opts vim.api.keyset.exec_opts Optional parameters.
  1096. --- - output: (boolean, default false) Whether to capture and return
  1097. --- all (non-error, non-shell `:!`) output.
  1098. --- @return table<string,any> # Dict containing information about execution, with these keys:
  1099. --- - output: (string|nil) Output if `opts.output` is true.
  1100. function vim.api.nvim_exec2(src, opts) end
  1101. --- Execute all autocommands for {event} that match the corresponding
  1102. --- {opts} `autocmd-execute`.
  1103. --- @see `:help :doautocmd`
  1104. --- @param event any (String|Array) The event or events to execute
  1105. --- @param opts vim.api.keyset.exec_autocmds Dict of autocommand options:
  1106. --- - group (string|integer) optional: the autocommand group name or
  1107. --- id to match against. `autocmd-groups`.
  1108. --- - pattern (string|array) optional: defaults to "*" `autocmd-pattern`. Cannot be used
  1109. --- with {buffer}.
  1110. --- - buffer (integer) optional: buffer number `autocmd-buflocal`. Cannot be used with
  1111. --- {pattern}.
  1112. --- - modeline (bool) optional: defaults to true. Process the
  1113. --- modeline after the autocommands [<nomodeline>].
  1114. --- - data (any): arbitrary data to send to the autocommand callback. See
  1115. --- `nvim_create_autocmd()` for details.
  1116. function vim.api.nvim_exec_autocmds(event, opts) end
  1117. --- Sends input-keys to Nvim, subject to various quirks controlled by `mode`
  1118. --- flags. This is a blocking call, unlike `nvim_input()`.
  1119. ---
  1120. --- On execution error: does not fail, but updates v:errmsg.
  1121. ---
  1122. --- To input sequences like [<C-o>] use `nvim_replace_termcodes()` (typically
  1123. --- with escape_ks=false) to replace `keycodes`, then pass the result to
  1124. --- nvim_feedkeys().
  1125. ---
  1126. --- Example:
  1127. ---
  1128. --- ```vim
  1129. --- :let key = nvim_replace_termcodes("<C-o>", v:true, v:false, v:true)
  1130. --- :call nvim_feedkeys(key, 'n', v:false)
  1131. --- ```
  1132. ---
  1133. --- @see feedkeys()
  1134. --- @see vim_strsave_escape_ks
  1135. --- @param keys string to be typed
  1136. --- @param mode string behavior flags, see `feedkeys()`
  1137. --- @param escape_ks boolean If true, escape K_SPECIAL bytes in `keys`.
  1138. --- This should be false if you already used
  1139. --- `nvim_replace_termcodes()`, and true otherwise.
  1140. function vim.api.nvim_feedkeys(keys, mode, escape_ks) end
  1141. --- Gets the option information for all options.
  1142. ---
  1143. --- The dict has the full option names as keys and option metadata dicts as detailed at
  1144. --- `nvim_get_option_info2()`.
  1145. ---
  1146. ---
  1147. --- @see vim.api.nvim_get_commands
  1148. --- @return table<string,any> # dict of all options
  1149. function vim.api.nvim_get_all_options_info() end
  1150. --- Get all autocommands that match the corresponding {opts}.
  1151. ---
  1152. --- These examples will get autocommands matching ALL the given criteria:
  1153. ---
  1154. --- ```lua
  1155. --- -- Matches all criteria
  1156. --- autocommands = vim.api.nvim_get_autocmds({
  1157. --- group = "MyGroup",
  1158. --- event = {"BufEnter", "BufWinEnter"},
  1159. --- pattern = {"*.c", "*.h"}
  1160. --- })
  1161. ---
  1162. --- -- All commands from one group
  1163. --- autocommands = vim.api.nvim_get_autocmds({
  1164. --- group = "MyGroup",
  1165. --- })
  1166. --- ```
  1167. ---
  1168. --- NOTE: When multiple patterns or events are provided, it will find all the autocommands that
  1169. --- match any combination of them.
  1170. ---
  1171. --- @param opts vim.api.keyset.get_autocmds Dict with at least one of the following:
  1172. --- - group (string|integer): the autocommand group name or id to match against.
  1173. --- - event (string|array): event or events to match against `autocmd-events`.
  1174. --- - pattern (string|array): pattern or patterns to match against `autocmd-pattern`.
  1175. --- Cannot be used with {buffer}
  1176. --- - buffer: Buffer number or list of buffer numbers for buffer local autocommands
  1177. --- `autocmd-buflocal`. Cannot be used with {pattern}
  1178. --- @return vim.api.keyset.get_autocmds.ret[] # Array of autocommands matching the criteria, with each item
  1179. --- containing the following fields:
  1180. --- - id (number): the autocommand id (only when defined with the API).
  1181. --- - group (integer): the autocommand group id.
  1182. --- - group_name (string): the autocommand group name.
  1183. --- - desc (string): the autocommand description.
  1184. --- - event (string): the autocommand event.
  1185. --- - command (string): the autocommand command. Note: this will be empty if a callback is set.
  1186. --- - callback (function|string|nil): Lua function or name of a Vim script function
  1187. --- which is executed when this autocommand is triggered.
  1188. --- - once (boolean): whether the autocommand is only run once.
  1189. --- - pattern (string): the autocommand pattern.
  1190. --- If the autocommand is buffer local |autocmd-buffer-local|:
  1191. --- - buflocal (boolean): true if the autocommand is buffer local.
  1192. --- - buffer (number): the buffer number.
  1193. function vim.api.nvim_get_autocmds(opts) end
  1194. --- Gets information about a channel.
  1195. ---
  1196. --- @param chan integer channel_id, or 0 for current channel
  1197. --- @return table<string,any> # Channel info dict with these keys:
  1198. --- - "id" Channel id.
  1199. --- - "argv" (optional) Job arguments list.
  1200. --- - "stream" Stream underlying the channel.
  1201. --- - "stdio" stdin and stdout of this Nvim instance
  1202. --- - "stderr" stderr of this Nvim instance
  1203. --- - "socket" TCP/IP socket or named pipe
  1204. --- - "job" Job with communication over its stdio.
  1205. --- - "mode" How data received on the channel is interpreted.
  1206. --- - "bytes" Send and receive raw bytes.
  1207. --- - "terminal" |terminal| instance interprets ASCII sequences.
  1208. --- - "rpc" |RPC| communication on the channel is active.
  1209. --- - "pty" (optional) Name of pseudoterminal. On a POSIX system this is a device path like
  1210. --- "/dev/pts/1". If unknown, the key will still be present if a pty is used (e.g.
  1211. --- for conpty on Windows).
  1212. --- - "buffer" (optional) Buffer connected to |terminal| instance.
  1213. --- - "client" (optional) Info about the peer (client on the other end of the RPC channel),
  1214. --- which it provided via |nvim_set_client_info()|.
  1215. ---
  1216. function vim.api.nvim_get_chan_info(chan) end
  1217. --- Returns the 24-bit RGB value of a `nvim_get_color_map()` color name or
  1218. --- "#rrggbb" hexadecimal string.
  1219. ---
  1220. --- Example:
  1221. ---
  1222. --- ```vim
  1223. --- :echo nvim_get_color_by_name("Pink")
  1224. --- :echo nvim_get_color_by_name("#cbcbcb")
  1225. --- ```
  1226. ---
  1227. --- @param name string Color name or "#rrggbb" string
  1228. --- @return integer # 24-bit RGB value, or -1 for invalid argument.
  1229. function vim.api.nvim_get_color_by_name(name) end
  1230. --- Returns a map of color names and RGB values.
  1231. ---
  1232. --- Keys are color names (e.g. "Aqua") and values are 24-bit RGB color values
  1233. --- (e.g. 65535).
  1234. ---
  1235. --- @return table<string,integer> # Map of color names and RGB values.
  1236. function vim.api.nvim_get_color_map() end
  1237. --- Gets a map of global (non-buffer-local) Ex commands.
  1238. ---
  1239. --- Currently only `user-commands` are supported, not builtin Ex commands.
  1240. ---
  1241. ---
  1242. --- @see vim.api.nvim_get_all_options_info
  1243. --- @param opts vim.api.keyset.get_commands Optional parameters. Currently only supports
  1244. --- {"builtin":false}
  1245. --- @return table<string,any> # Map of maps describing commands.
  1246. function vim.api.nvim_get_commands(opts) end
  1247. --- Gets a map of the current editor state.
  1248. ---
  1249. --- @param opts vim.api.keyset.context Optional parameters.
  1250. --- - types: List of `context-types` ("regs", "jumps", "bufs",
  1251. --- "gvars", …) to gather, or empty for "all".
  1252. --- @return table<string,any> # map of global |context|.
  1253. function vim.api.nvim_get_context(opts) end
  1254. --- Gets the current buffer.
  1255. ---
  1256. --- @return integer # Buffer handle
  1257. function vim.api.nvim_get_current_buf() end
  1258. --- Gets the current line.
  1259. ---
  1260. --- @return string # Current line string
  1261. function vim.api.nvim_get_current_line() end
  1262. --- Gets the current tabpage.
  1263. ---
  1264. --- @return integer # Tabpage handle
  1265. function vim.api.nvim_get_current_tabpage() end
  1266. --- Gets the current window.
  1267. ---
  1268. --- @return integer # Window handle
  1269. function vim.api.nvim_get_current_win() end
  1270. --- Gets all or specific highlight groups in a namespace.
  1271. ---
  1272. --- Note:
  1273. --- When the `link` attribute is defined in the highlight definition
  1274. --- map, other attributes will not be taking effect (see |:hi-link|).
  1275. ---
  1276. ---
  1277. --- @param ns_id integer Get highlight groups for namespace ns_id `nvim_get_namespaces()`.
  1278. --- Use 0 to get global highlight groups `:highlight`.
  1279. --- @param opts vim.api.keyset.get_highlight Options dict:
  1280. --- - name: (string) Get a highlight definition by name.
  1281. --- - id: (integer) Get a highlight definition by id.
  1282. --- - link: (boolean, default true) Show linked group name instead of effective definition `:hi-link`.
  1283. --- - create: (boolean, default true) When highlight group doesn't exist create it.
  1284. --- @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()|,
  1285. --- or only a single highlight definition map if requested by name or id.
  1286. function vim.api.nvim_get_hl(ns_id, opts) end
  1287. --- @deprecated
  1288. --- @see vim.api.nvim_get_hl_by_name
  1289. --- @param hl_id integer
  1290. --- @param rgb boolean
  1291. --- @return table<string,any>
  1292. function vim.api.nvim_get_hl_by_id(hl_id, rgb) end
  1293. --- @deprecated
  1294. --- @see vim.api.nvim_get_hl_by_id
  1295. --- @param name string
  1296. --- @param rgb boolean
  1297. --- @return table<string,any>
  1298. function vim.api.nvim_get_hl_by_name(name, rgb) end
  1299. --- Gets a highlight group by name
  1300. ---
  1301. --- similar to `hlID()`, but allocates a new ID if not present.
  1302. --- @param name string
  1303. --- @return integer
  1304. function vim.api.nvim_get_hl_id_by_name(name) end
  1305. --- Gets the active highlight namespace.
  1306. ---
  1307. --- @param opts vim.api.keyset.get_ns Optional parameters
  1308. --- - winid: (number) `window-ID` for retrieving a window's highlight
  1309. --- namespace. A value of -1 is returned when `nvim_win_set_hl_ns()`
  1310. --- has not been called for the window (or was called with a namespace
  1311. --- of -1).
  1312. --- @return integer # Namespace id, or -1
  1313. function vim.api.nvim_get_hl_ns(opts) end
  1314. --- Gets a list of global (non-buffer-local) `mapping` definitions.
  1315. ---
  1316. --- @param mode string Mode short-name ("n", "i", "v", ...)
  1317. --- @return vim.api.keyset.keymap[] # Array of |maparg()|-like dictionaries describing mappings.
  1318. --- The "buffer" key is always zero.
  1319. function vim.api.nvim_get_keymap(mode) end
  1320. --- Returns a `(row, col, buffer, buffername)` tuple representing the position
  1321. --- of the uppercase/file named mark. "End of line" column position is returned
  1322. --- as `v:maxcol` (big number). See `mark-motions`.
  1323. ---
  1324. --- Marks are (1,0)-indexed. `api-indexing`
  1325. ---
  1326. --- Note:
  1327. --- Lowercase name (or other buffer-local mark) is an error.
  1328. ---
  1329. --- @see vim.api.nvim_buf_set_mark
  1330. --- @see vim.api.nvim_del_mark
  1331. --- @param name string Mark name
  1332. --- @param opts vim.api.keyset.empty Optional parameters. Reserved for future use.
  1333. --- @return vim.api.keyset.get_mark # 4-tuple (row, col, buffer, buffername), (0, 0, 0, '') if the mark is
  1334. --- not set.
  1335. function vim.api.nvim_get_mark(name, opts) end
  1336. --- Gets the current mode. `mode()`
  1337. --- "blocking" is true if Nvim is waiting for input.
  1338. ---
  1339. --- @return vim.api.keyset.get_mode # Dict { "mode": String, "blocking": Boolean }
  1340. function vim.api.nvim_get_mode() end
  1341. --- Gets existing, non-anonymous `namespace`s.
  1342. ---
  1343. --- @return table<string,integer> # dict that maps from names to namespace ids.
  1344. function vim.api.nvim_get_namespaces() end
  1345. --- @deprecated
  1346. --- @param name string
  1347. --- @return any
  1348. function vim.api.nvim_get_option(name) end
  1349. --- @deprecated
  1350. --- @param name string
  1351. --- @return vim.api.keyset.get_option_info
  1352. function vim.api.nvim_get_option_info(name) end
  1353. --- Gets the option information for one option from arbitrary buffer or window
  1354. ---
  1355. --- Resulting dict has keys:
  1356. --- - name: Name of the option (like 'filetype')
  1357. --- - shortname: Shortened name of the option (like 'ft')
  1358. --- - type: type of option ("string", "number" or "boolean")
  1359. --- - default: The default value for the option
  1360. --- - was_set: Whether the option was set.
  1361. ---
  1362. --- - last_set_sid: Last set script id (if any)
  1363. --- - last_set_linenr: line number where option was set
  1364. --- - last_set_chan: Channel where option was set (0 for local)
  1365. ---
  1366. --- - scope: one of "global", "win", or "buf"
  1367. --- - global_local: whether win or buf option has a global value
  1368. ---
  1369. --- - commalist: List of comma separated values
  1370. --- - flaglist: List of single char flags
  1371. ---
  1372. --- When {scope} is not provided, the last set information applies to the local
  1373. --- value in the current buffer or window if it is available, otherwise the
  1374. --- global value information is returned. This behavior can be disabled by
  1375. --- explicitly specifying {scope} in the {opts} table.
  1376. ---
  1377. --- @param name string Option name
  1378. --- @param opts vim.api.keyset.option Optional parameters
  1379. --- - scope: One of "global" or "local". Analogous to
  1380. --- `:setglobal` and `:setlocal`, respectively.
  1381. --- - win: `window-ID`. Used for getting window local options.
  1382. --- - buf: Buffer number. Used for getting buffer local options.
  1383. --- Implies {scope} is "local".
  1384. --- @return vim.api.keyset.get_option_info # Option Information
  1385. function vim.api.nvim_get_option_info2(name, opts) end
  1386. --- Gets the value of an option. The behavior of this function matches that of
  1387. --- `:set`: the local value of an option is returned if it exists; otherwise,
  1388. --- the global value is returned. Local values always correspond to the current
  1389. --- buffer or window, unless "buf" or "win" is set in {opts}.
  1390. ---
  1391. --- @param name string Option name
  1392. --- @param opts vim.api.keyset.option Optional parameters
  1393. --- - scope: One of "global" or "local". Analogous to
  1394. --- `:setglobal` and `:setlocal`, respectively.
  1395. --- - win: `window-ID`. Used for getting window local options.
  1396. --- - buf: Buffer number. Used for getting buffer local options.
  1397. --- Implies {scope} is "local".
  1398. --- - filetype: `filetype`. Used to get the default option for a
  1399. --- specific filetype. Cannot be used with any other option.
  1400. --- Note: this will trigger `ftplugin` and all `FileType`
  1401. --- autocommands for the corresponding filetype.
  1402. --- @return any # Option value
  1403. function vim.api.nvim_get_option_value(name, opts) end
  1404. --- Gets info describing process `pid`.
  1405. ---
  1406. --- @param pid integer
  1407. --- @return any # Map of process properties, or NIL if process not found.
  1408. function vim.api.nvim_get_proc(pid) end
  1409. --- Gets the immediate children of process `pid`.
  1410. ---
  1411. --- @param pid integer
  1412. --- @return any[] # Array of child process ids, empty if process not found.
  1413. function vim.api.nvim_get_proc_children(pid) end
  1414. --- Finds files in runtime directories, in 'runtimepath' order.
  1415. ---
  1416. --- "name" can contain wildcards. For example
  1417. --- `nvim_get_runtime_file("colors/*.{vim,lua}", true)` will return all color
  1418. --- scheme files. Always use forward slashes (/) in the search pattern for
  1419. --- subdirectories regardless of platform.
  1420. ---
  1421. --- It is not an error to not find any files. An empty array is returned then.
  1422. ---
  1423. --- @param name string pattern of files to search for
  1424. --- @param all boolean whether to return all matches or only the first
  1425. --- @return string[] # list of absolute paths to the found files
  1426. function vim.api.nvim_get_runtime_file(name, all) end
  1427. --- Gets a global (g:) variable.
  1428. ---
  1429. --- @param name string Variable name
  1430. --- @return any # Variable value
  1431. function vim.api.nvim_get_var(name) end
  1432. --- Gets a v: variable.
  1433. ---
  1434. --- @param name string Variable name
  1435. --- @return any # Variable value
  1436. function vim.api.nvim_get_vvar(name) end
  1437. --- Queues raw user-input. Unlike `nvim_feedkeys()`, this uses a low-level input buffer and the call
  1438. --- is non-blocking (input is processed asynchronously by the eventloop).
  1439. ---
  1440. --- To input blocks of text, `nvim_paste()` is much faster and should be preferred.
  1441. ---
  1442. --- On execution error: does not fail, but updates v:errmsg.
  1443. ---
  1444. --- Note:
  1445. --- |keycodes| like [<CR>] are translated, so "<" is special.
  1446. --- To input a literal "<", send [<LT>].
  1447. ---
  1448. --- For mouse events use |nvim_input_mouse()|. The pseudokey form
  1449. --- `<LeftMouse><col,row>` is deprecated since |api-level| 6.
  1450. ---
  1451. ---
  1452. --- @param keys string to be typed
  1453. --- @return integer # Number of bytes actually written (can be fewer than
  1454. --- requested if the buffer becomes full).
  1455. function vim.api.nvim_input(keys) end
  1456. --- Send mouse event from GUI.
  1457. ---
  1458. --- Non-blocking: does not wait on any result, but queues the event to be
  1459. --- processed soon by the event loop.
  1460. ---
  1461. --- Note:
  1462. --- Currently this doesn't support "scripting" multiple mouse events
  1463. --- by calling it multiple times in a loop: the intermediate mouse
  1464. --- positions will be ignored. It should be used to implement real-time
  1465. --- mouse input in a GUI. The deprecated pseudokey form
  1466. --- (`<LeftMouse><col,row>`) of |nvim_input()| has the same limitation.
  1467. ---
  1468. ---
  1469. --- @param button string Mouse button: one of "left", "right", "middle", "wheel", "move",
  1470. --- "x1", "x2".
  1471. --- @param action string For ordinary buttons, one of "press", "drag", "release".
  1472. --- For the wheel, one of "up", "down", "left", "right". Ignored for "move".
  1473. --- @param modifier string String of modifiers each represented by a single char.
  1474. --- The same specifiers are used as for a key press, except
  1475. --- that the "-" separator is optional, so "C-A-", "c-a"
  1476. --- and "CA" can all be used to specify Ctrl+Alt+click.
  1477. --- @param grid integer Grid number if the client uses `ui-multigrid`, else 0.
  1478. --- @param row integer Mouse row-position (zero-based, like redraw events)
  1479. --- @param col integer Mouse column-position (zero-based, like redraw events)
  1480. function vim.api.nvim_input_mouse(button, action, modifier, grid, row, col) end
  1481. --- Gets the current list of buffer handles
  1482. ---
  1483. --- Includes unlisted (unloaded/deleted) buffers, like `:ls!`.
  1484. --- Use `nvim_buf_is_loaded()` to check if a buffer is loaded.
  1485. ---
  1486. --- @return integer[] # List of buffer handles
  1487. function vim.api.nvim_list_bufs() end
  1488. --- Get information about all open channels.
  1489. ---
  1490. --- @return any[] # Array of Dictionaries, each describing a channel with
  1491. --- the format specified at |nvim_get_chan_info()|.
  1492. function vim.api.nvim_list_chans() end
  1493. --- Gets the paths contained in `runtime-search-path`.
  1494. ---
  1495. --- @return string[] # List of paths
  1496. function vim.api.nvim_list_runtime_paths() end
  1497. --- Gets the current list of tabpage handles.
  1498. ---
  1499. --- @return integer[] # List of tabpage handles
  1500. function vim.api.nvim_list_tabpages() end
  1501. --- Gets a list of dictionaries representing attached UIs.
  1502. ---
  1503. --- @return any[] # Array of UI dictionaries, each with these keys:
  1504. --- - "height" Requested height of the UI
  1505. --- - "width" Requested width of the UI
  1506. --- - "rgb" true if the UI uses RGB colors (false implies |cterm-colors|)
  1507. --- - "ext_..." Requested UI extensions, see |ui-option|
  1508. --- - "chan" |channel-id| of remote UI
  1509. function vim.api.nvim_list_uis() end
  1510. --- Gets the current list of window handles.
  1511. ---
  1512. --- @return integer[] # List of window handles
  1513. function vim.api.nvim_list_wins() end
  1514. --- Sets the current editor state from the given `context` map.
  1515. ---
  1516. --- @param dict table<string,any> `Context` map.
  1517. --- @return any
  1518. function vim.api.nvim_load_context(dict) end
  1519. --- Notify the user with a message
  1520. ---
  1521. --- Relays the call to vim.notify . By default forwards your message in the
  1522. --- echo area but can be overridden to trigger desktop notifications.
  1523. ---
  1524. --- @param msg string Message to display to the user
  1525. --- @param log_level integer The log level
  1526. --- @param opts table<string,any> Reserved for future use.
  1527. --- @return any
  1528. function vim.api.nvim_notify(msg, log_level, opts) end
  1529. --- Open a terminal instance in a buffer
  1530. ---
  1531. --- By default (and currently the only option) the terminal will not be
  1532. --- connected to an external process. Instead, input sent on the channel
  1533. --- will be echoed directly by the terminal. This is useful to display
  1534. --- ANSI terminal sequences returned as part of a rpc message, or similar.
  1535. ---
  1536. --- Note: to directly initiate the terminal using the right size, display the
  1537. --- buffer in a configured window before calling this. For instance, for a
  1538. --- floating display, first create an empty buffer using `nvim_create_buf()`,
  1539. --- then display it using `nvim_open_win()`, and then call this function.
  1540. --- Then `nvim_chan_send()` can be called immediately to process sequences
  1541. --- in a virtual terminal having the intended size.
  1542. ---
  1543. --- Example: this `TermHl` command can be used to display and highlight raw ANSI termcodes, so you
  1544. --- can use Nvim as a "scrollback pager" (for terminals like kitty): [terminal-scrollback-pager]()
  1545. ---
  1546. --- ```lua
  1547. --- vim.api.nvim_create_user_command('TermHl', function()
  1548. --- local b = vim.api.nvim_create_buf(false, true)
  1549. --- local chan = vim.api.nvim_open_term(b, {})
  1550. --- vim.api.nvim_chan_send(chan, table.concat(vim.api.nvim_buf_get_lines(0, 0, -1, false), '\n'))
  1551. --- vim.api.nvim_win_set_buf(0, b)
  1552. --- end, { desc = 'Highlights ANSI termcodes in curbuf' })
  1553. --- ```
  1554. ---
  1555. --- @param buffer integer the buffer to use (expected to be empty)
  1556. --- @param opts vim.api.keyset.open_term Optional parameters.
  1557. --- - on_input: Lua callback for input sent, i e keypresses in terminal
  1558. --- mode. Note: keypresses are sent raw as they would be to the pty
  1559. --- master end. For instance, a carriage return is sent
  1560. --- as a "\r", not as a "\n". `textlock` applies. It is possible
  1561. --- to call `nvim_chan_send()` directly in the callback however.
  1562. --- `["input", term, bufnr, data]`
  1563. --- - force_crlf: (boolean, default true) Convert "\n" to "\r\n".
  1564. --- @return integer # Channel id, or 0 on error
  1565. function vim.api.nvim_open_term(buffer, opts) end
  1566. --- Opens a new split window, or a floating window if `relative` is specified,
  1567. --- or an external window (managed by the UI) if `external` is specified.
  1568. ---
  1569. --- Floats are windows that are drawn above the split layout, at some anchor
  1570. --- position in some other window. Floats can be drawn internally or by external
  1571. --- GUI with the `ui-multigrid` extension. External windows are only supported
  1572. --- with multigrid GUIs, and are displayed as separate top-level windows.
  1573. ---
  1574. --- For a general overview of floats, see `api-floatwin`.
  1575. ---
  1576. --- The `width` and `height` of the new window must be specified when opening
  1577. --- a floating window, but are optional for normal windows.
  1578. ---
  1579. --- If `relative` and `external` are omitted, a normal "split" window is created.
  1580. --- The `win` property determines which window will be split. If no `win` is
  1581. --- provided or `win == 0`, a window will be created adjacent to the current window.
  1582. --- If -1 is provided, a top-level split will be created. `vertical` and `split` are
  1583. --- only valid for normal windows, and are used to control split direction. For `vertical`,
  1584. --- the exact direction is determined by `'splitright'` and `'splitbelow'`.
  1585. --- Split windows cannot have `bufpos`/`row`/`col`/`border`/`title`/`footer`
  1586. --- properties.
  1587. ---
  1588. --- With relative=editor (row=0,col=0) refers to the top-left corner of the
  1589. --- screen-grid and (row=Lines-1,col=Columns-1) refers to the bottom-right
  1590. --- corner. Fractional values are allowed, but the builtin implementation
  1591. --- (used by non-multigrid UIs) will always round down to nearest integer.
  1592. ---
  1593. --- Out-of-bounds values, and configurations that make the float not fit inside
  1594. --- the main editor, are allowed. The builtin implementation truncates values
  1595. --- so floats are fully within the main screen grid. External GUIs
  1596. --- could let floats hover outside of the main window like a tooltip, but
  1597. --- this should not be used to specify arbitrary WM screen positions.
  1598. ---
  1599. --- Example (Lua): window-relative float
  1600. ---
  1601. --- ```lua
  1602. --- vim.api.nvim_open_win(0, false,
  1603. --- {relative='win', row=3, col=3, width=12, height=3})
  1604. --- ```
  1605. ---
  1606. --- Example (Lua): buffer-relative float (travels as buffer is scrolled)
  1607. ---
  1608. --- ```lua
  1609. --- vim.api.nvim_open_win(0, false,
  1610. --- {relative='win', width=12, height=3, bufpos={100,10}})
  1611. --- ```
  1612. ---
  1613. --- Example (Lua): vertical split left of the current window
  1614. ---
  1615. --- ```lua
  1616. --- vim.api.nvim_open_win(0, false, {
  1617. --- split = 'left',
  1618. --- win = 0
  1619. --- })
  1620. --- ```
  1621. ---
  1622. --- @param buffer integer Buffer to display, or 0 for current buffer
  1623. --- @param enter boolean Enter the window (make it the current window)
  1624. --- @param config vim.api.keyset.win_config Map defining the window configuration. Keys:
  1625. --- - relative: Sets the window layout to "floating", placed at (row,col)
  1626. --- coordinates relative to:
  1627. --- - "editor" The global editor grid
  1628. --- - "win" Window given by the `win` field, or current window.
  1629. --- - "cursor" Cursor position in current window.
  1630. --- - "mouse" Mouse position
  1631. --- - win: `window-ID` window to split, or relative window when creating a
  1632. --- float (relative="win").
  1633. --- - anchor: Decides which corner of the float to place at (row,col):
  1634. --- - "NW" northwest (default)
  1635. --- - "NE" northeast
  1636. --- - "SW" southwest
  1637. --- - "SE" southeast
  1638. --- - width: Window width (in character cells). Minimum of 1.
  1639. --- - height: Window height (in character cells). Minimum of 1.
  1640. --- - bufpos: Places float relative to buffer text (only when
  1641. --- relative="win"). Takes a tuple of zero-indexed `[line, column]`.
  1642. --- `row` and `col` if given are applied relative to this
  1643. --- position, else they default to:
  1644. --- - `row=1` and `col=0` if `anchor` is "NW" or "NE"
  1645. --- - `row=0` and `col=0` if `anchor` is "SW" or "SE"
  1646. --- (thus like a tooltip near the buffer text).
  1647. --- - row: Row position in units of "screen cell height", may be fractional.
  1648. --- - col: Column position in units of "screen cell width", may be
  1649. --- fractional.
  1650. --- - focusable: Enable focus by user actions (wincmds, mouse events).
  1651. --- Defaults to true. Non-focusable windows can be entered by
  1652. --- `nvim_set_current_win()`, or, when the `mouse` field is set to true,
  1653. --- by mouse events. See `focusable`.
  1654. --- - mouse: Specify how this window interacts with mouse events.
  1655. --- Defaults to `focusable` value.
  1656. --- - If false, mouse events pass through this window.
  1657. --- - If true, mouse events interact with this window normally.
  1658. --- - external: GUI should display the window as an external
  1659. --- top-level window. Currently accepts no other positioning
  1660. --- configuration together with this.
  1661. --- - zindex: Stacking order. floats with higher `zindex` go on top on
  1662. --- floats with lower indices. Must be larger than zero. The
  1663. --- following screen elements have hard-coded z-indices:
  1664. --- - 100: insert completion popupmenu
  1665. --- - 200: message scrollback
  1666. --- - 250: cmdline completion popupmenu (when wildoptions+=pum)
  1667. --- The default value for floats are 50. In general, values below 100 are
  1668. --- recommended, unless there is a good reason to overshadow builtin
  1669. --- elements.
  1670. --- - style: (optional) Configure the appearance of the window. Currently
  1671. --- only supports one value:
  1672. --- - "minimal" Nvim will display the window with many UI options
  1673. --- disabled. This is useful when displaying a temporary
  1674. --- float where the text should not be edited. Disables
  1675. --- 'number', 'relativenumber', 'cursorline', 'cursorcolumn',
  1676. --- 'foldcolumn', 'spell' and 'list' options. 'signcolumn'
  1677. --- is changed to `auto` and 'colorcolumn' is cleared.
  1678. --- 'statuscolumn' is changed to empty. The end-of-buffer
  1679. --- region is hidden by setting `eob` flag of
  1680. --- 'fillchars' to a space char, and clearing the
  1681. --- `hl-EndOfBuffer` region in 'winhighlight'.
  1682. --- - border: Style of (optional) window border. This can either be a string
  1683. --- or an array. The string values are
  1684. --- - "none": No border (default).
  1685. --- - "single": A single line box.
  1686. --- - "double": A double line box.
  1687. --- - "rounded": Like "single", but with rounded corners ("╭" etc.).
  1688. --- - "solid": Adds padding by a single whitespace cell.
  1689. --- - "shadow": A drop shadow effect by blending with the background.
  1690. --- - If it is an array, it should have a length of eight or any divisor of
  1691. --- eight. The array will specify the eight chars building up the border
  1692. --- in a clockwise fashion starting with the top-left corner. As an
  1693. --- example, the double box style could be specified as:
  1694. --- ```
  1695. --- [ "╔", "═" ,"╗", "║", "╝", "═", "╚", "║" ].
  1696. --- ```
  1697. --- If the number of chars are less than eight, they will be repeated. Thus
  1698. --- an ASCII border could be specified as
  1699. --- ```
  1700. --- [ "/", "-", \"\\\\\", "|" ],
  1701. --- ```
  1702. --- or all chars the same as
  1703. --- ```
  1704. --- [ "x" ].
  1705. --- ```
  1706. --- An empty string can be used to turn off a specific border, for instance,
  1707. --- ```
  1708. --- [ "", "", "", ">", "", "", "", "<" ]
  1709. --- ```
  1710. --- will only make vertical borders but not horizontal ones.
  1711. --- By default, `FloatBorder` highlight is used, which links to `WinSeparator`
  1712. --- when not defined. It could also be specified by character:
  1713. --- ```
  1714. --- [ ["+", "MyCorner"], ["x", "MyBorder"] ].
  1715. --- ```
  1716. --- - title: Title (optional) in window border, string or list.
  1717. --- List should consist of `[text, highlight]` tuples.
  1718. --- If string, or a tuple lacks a highlight, the default highlight group is `FloatTitle`.
  1719. --- - title_pos: Title position. Must be set with `title` option.
  1720. --- Value can be one of "left", "center", or "right".
  1721. --- Default is `"left"`.
  1722. --- - footer: Footer (optional) in window border, string or list.
  1723. --- List should consist of `[text, highlight]` tuples.
  1724. --- If string, or a tuple lacks a highlight, the default highlight group is `FloatFooter`.
  1725. --- - footer_pos: Footer position. Must be set with `footer` option.
  1726. --- Value can be one of "left", "center", or "right".
  1727. --- Default is `"left"`.
  1728. --- - noautocmd: If true then all autocommands are blocked for the duration of
  1729. --- the call.
  1730. --- - fixed: If true when anchor is NW or SW, the float window
  1731. --- would be kept fixed even if the window would be truncated.
  1732. --- - hide: If true the floating window will be hidden.
  1733. --- - vertical: Split vertically `:vertical`.
  1734. --- - split: Split direction: "left", "right", "above", "below".
  1735. --- @return integer # Window handle, or 0 on error
  1736. function vim.api.nvim_open_win(buffer, enter, config) end
  1737. --- Writes a message to the Vim output buffer. Does not append "\n", the
  1738. --- message is buffered (won't display) until a linefeed is written.
  1739. ---
  1740. --- @param str string Message
  1741. function vim.api.nvim_out_write(str) end
  1742. --- Parse command line.
  1743. ---
  1744. --- Doesn't check the validity of command arguments.
  1745. ---
  1746. --- @param str string Command line string to parse. Cannot contain "\n".
  1747. --- @param opts vim.api.keyset.empty Optional parameters. Reserved for future use.
  1748. --- @return vim.api.keyset.parse_cmd # Dict containing command information, with these keys:
  1749. --- - cmd: (string) Command name.
  1750. --- - range: (array) (optional) Command range ([<line1>] [<line2>]).
  1751. --- Omitted if command doesn't accept a range.
  1752. --- Otherwise, has no elements if no range was specified, one element if
  1753. --- only a single range item was specified, or two elements if both range
  1754. --- items were specified.
  1755. --- - count: (number) (optional) Command [<count>].
  1756. --- Omitted if command cannot take a count.
  1757. --- - reg: (string) (optional) Command [<register>].
  1758. --- Omitted if command cannot take a register.
  1759. --- - bang: (boolean) Whether command contains a [<bang>] (!) modifier.
  1760. --- - args: (array) Command arguments.
  1761. --- - addr: (string) Value of |:command-addr|. Uses short name or "line" for -addr=lines.
  1762. --- - nargs: (string) Value of |:command-nargs|.
  1763. --- - nextcmd: (string) Next command if there are multiple commands separated by a |:bar|.
  1764. --- Empty if there isn't a next command.
  1765. --- - magic: (dict) Which characters have special meaning in the command arguments.
  1766. --- - file: (boolean) The command expands filenames. Which means characters such as "%",
  1767. --- "#" and wildcards are expanded.
  1768. --- - bar: (boolean) The "|" character is treated as a command separator and the double
  1769. --- quote character (") is treated as the start of a comment.
  1770. --- - mods: (dict) |:command-modifiers|.
  1771. --- - filter: (dict) |:filter|.
  1772. --- - pattern: (string) Filter pattern. Empty string if there is no filter.
  1773. --- - force: (boolean) Whether filter is inverted or not.
  1774. --- - silent: (boolean) |:silent|.
  1775. --- - emsg_silent: (boolean) |:silent!|.
  1776. --- - unsilent: (boolean) |:unsilent|.
  1777. --- - sandbox: (boolean) |:sandbox|.
  1778. --- - noautocmd: (boolean) |:noautocmd|.
  1779. --- - browse: (boolean) |:browse|.
  1780. --- - confirm: (boolean) |:confirm|.
  1781. --- - hide: (boolean) |:hide|.
  1782. --- - horizontal: (boolean) |:horizontal|.
  1783. --- - keepalt: (boolean) |:keepalt|.
  1784. --- - keepjumps: (boolean) |:keepjumps|.
  1785. --- - keepmarks: (boolean) |:keepmarks|.
  1786. --- - keeppatterns: (boolean) |:keeppatterns|.
  1787. --- - lockmarks: (boolean) |:lockmarks|.
  1788. --- - noswapfile: (boolean) |:noswapfile|.
  1789. --- - tab: (integer) |:tab|. -1 when omitted.
  1790. --- - verbose: (integer) |:verbose|. -1 when omitted.
  1791. --- - vertical: (boolean) |:vertical|.
  1792. --- - split: (string) Split modifier string, is an empty string when there's no split
  1793. --- modifier. If there is a split modifier it can be one of:
  1794. --- - "aboveleft": |:aboveleft|.
  1795. --- - "belowright": |:belowright|.
  1796. --- - "topleft": |:topleft|.
  1797. --- - "botright": |:botright|.
  1798. function vim.api.nvim_parse_cmd(str, opts) end
  1799. --- Parse a Vimscript expression.
  1800. ---
  1801. --- @param expr string Expression to parse. Always treated as a single line.
  1802. --- @param flags string Flags:
  1803. --- - "m" if multiple expressions in a row are allowed (only
  1804. --- the first one will be parsed),
  1805. --- - "E" if EOC tokens are not allowed (determines whether
  1806. --- they will stop parsing process or be recognized as an
  1807. --- operator/space, though also yielding an error).
  1808. --- - "l" when needing to start parsing with lvalues for
  1809. --- ":let" or ":for".
  1810. --- Common flag sets:
  1811. --- - "m" to parse like for `":echo"`.
  1812. --- - "E" to parse like for `"<C-r>="`.
  1813. --- - empty string for ":call".
  1814. --- - "lm" to parse for ":let".
  1815. --- @param highlight boolean If true, return value will also include "highlight"
  1816. --- key containing array of 4-tuples (arrays) (Integer,
  1817. --- Integer, Integer, String), where first three numbers
  1818. --- define the highlighted region and represent line,
  1819. --- starting column and ending column (latter exclusive:
  1820. --- one should highlight region [start_col, end_col)).
  1821. --- @return table<string,any> #
  1822. --- - AST: top-level dict with these keys:
  1823. --- - "error": Dict with error, present only if parser saw some
  1824. --- error. Contains the following keys:
  1825. --- - "message": String, error message in printf format, translated.
  1826. --- Must contain exactly one "%.*s".
  1827. --- - "arg": String, error message argument.
  1828. --- - "len": Amount of bytes successfully parsed. With flags equal to ""
  1829. --- that should be equal to the length of expr string.
  1830. --- ("Successfully parsed" here means "participated in AST
  1831. --- creation", not "till the first error".)
  1832. --- - "ast": AST, either nil or a dict with these keys:
  1833. --- - "type": node type, one of the value names from ExprASTNodeType
  1834. --- stringified without "kExprNode" prefix.
  1835. --- - "start": a pair `[line, column]` describing where node is "started"
  1836. --- where "line" is always 0 (will not be 0 if you will be
  1837. --- using this API on e.g. ":let", but that is not
  1838. --- present yet). Both elements are Integers.
  1839. --- - "len": “length” of the node. This and "start" are there for
  1840. --- debugging purposes primary (debugging parser and providing
  1841. --- debug information).
  1842. --- - "children": a list of nodes described in top/"ast". There always
  1843. --- is zero, one or two children, key will not be present
  1844. --- if node has no children. Maximum number of children
  1845. --- may be found in node_maxchildren array.
  1846. --- - Local values (present only for certain nodes):
  1847. --- - "scope": a single Integer, specifies scope for "Option" and
  1848. --- "PlainIdentifier" nodes. For "Option" it is one of
  1849. --- ExprOptScope values, for "PlainIdentifier" it is one of
  1850. --- ExprVarScope values.
  1851. --- - "ident": identifier (without scope, if any), present for "Option",
  1852. --- "PlainIdentifier", "PlainKey" and "Environment" nodes.
  1853. --- - "name": Integer, register name (one character) or -1. Only present
  1854. --- for "Register" nodes.
  1855. --- - "cmp_type": String, comparison type, one of the value names from
  1856. --- ExprComparisonType, stringified without "kExprCmp"
  1857. --- prefix. Only present for "Comparison" nodes.
  1858. --- - "ccs_strategy": String, case comparison strategy, one of the
  1859. --- value names from ExprCaseCompareStrategy,
  1860. --- stringified without "kCCStrategy" prefix. Only
  1861. --- present for "Comparison" nodes.
  1862. --- - "augmentation": String, augmentation type for "Assignment" nodes.
  1863. --- Is either an empty string, "Add", "Subtract" or
  1864. --- "Concat" for "=", "+=", "-=" or ".=" respectively.
  1865. --- - "invert": Boolean, true if result of comparison needs to be
  1866. --- inverted. Only present for "Comparison" nodes.
  1867. --- - "ivalue": Integer, integer value for "Integer" nodes.
  1868. --- - "fvalue": Float, floating-point value for "Float" nodes.
  1869. --- - "svalue": String, value for "SingleQuotedString" and
  1870. --- "DoubleQuotedString" nodes.
  1871. function vim.api.nvim_parse_expression(expr, flags, highlight) end
  1872. --- Pastes at cursor (in any mode), and sets "redo" so dot (`.`) will repeat the input. UIs call
  1873. --- this to implement "paste", but it's also intended for use by scripts to input large,
  1874. --- dot-repeatable blocks of text (as opposed to `nvim_input()` which is subject to mappings/events
  1875. --- and is thus much slower).
  1876. ---
  1877. --- Invokes the `vim.paste()` handler, which handles each mode appropriately.
  1878. ---
  1879. --- Errors ('nomodifiable', `vim.paste()` failure, …) are reflected in `err` but do not affect the
  1880. --- return value (which is strictly decided by `vim.paste()`). On error or cancel, subsequent calls
  1881. --- are ignored ("drained") until the next paste is initiated (phase 1 or -1).
  1882. ---
  1883. --- Useful in mappings and scripts to insert multiline text. Example:
  1884. ---
  1885. --- ```lua
  1886. --- vim.keymap.set('n', 'x', function()
  1887. --- vim.api.nvim_paste([[
  1888. --- line1
  1889. --- line2
  1890. --- line3
  1891. --- ]], false, -1)
  1892. --- end, { buffer = true })
  1893. --- ```
  1894. ---
  1895. --- @param data string Multiline input. Lines break at LF ("\n"). May be binary (containing NUL bytes).
  1896. --- @param crlf boolean Also break lines at CR and CRLF.
  1897. --- @param phase integer -1: paste in a single call (i.e. without streaming).
  1898. --- To "stream" a paste, call `nvim_paste` sequentially with
  1899. --- these `phase` values:
  1900. --- - 1: starts the paste (exactly once)
  1901. --- - 2: continues the paste (zero or more times)
  1902. --- - 3: ends the paste (exactly once)
  1903. --- @return boolean #
  1904. --- - true: Client may continue pasting.
  1905. --- - false: Client should cancel the paste.
  1906. function vim.api.nvim_paste(data, crlf, phase) end
  1907. --- Puts text at cursor, in any mode. For dot-repeatable input, use `nvim_paste()`.
  1908. ---
  1909. --- Compare `:put` and `p` which are always linewise.
  1910. ---
  1911. --- @param lines string[] `readfile()`-style list of lines. `channel-lines`
  1912. --- @param type string Edit behavior: any `getregtype()` result, or:
  1913. --- - "b" `blockwise-visual` mode (may include width, e.g. "b3")
  1914. --- - "c" `charwise` mode
  1915. --- - "l" `linewise` mode
  1916. --- - "" guess by contents, see `setreg()`
  1917. --- @param after boolean If true insert after cursor (like `p`), or before (like `P`).
  1918. --- @param follow boolean If true place cursor at end of inserted text.
  1919. function vim.api.nvim_put(lines, type, after, follow) end
  1920. --- Replaces terminal codes and `keycodes` ([<CR>], [<Esc>], ...) in a string with
  1921. --- the internal representation.
  1922. ---
  1923. --- @see replace_termcodes
  1924. --- @see cpoptions
  1925. --- @param str string String to be converted.
  1926. --- @param from_part boolean Legacy Vim parameter. Usually true.
  1927. --- @param do_lt boolean Also translate [<lt>]. Ignored if `special` is false.
  1928. --- @param special boolean Replace `keycodes`, e.g. [<CR>] becomes a "\r" char.
  1929. --- @return string
  1930. function vim.api.nvim_replace_termcodes(str, from_part, do_lt, special) end
  1931. --- Selects an item in the completion popup menu.
  1932. ---
  1933. --- If neither `ins-completion` nor `cmdline-completion` popup menu is active
  1934. --- this API call is silently ignored.
  1935. --- Useful for an external UI using `ui-popupmenu` to control the popup menu with the mouse.
  1936. --- Can also be used in a mapping; use [<Cmd>] `:map-cmd` or a Lua mapping to ensure the mapping
  1937. --- doesn't end completion mode.
  1938. ---
  1939. --- @param item integer Index (zero-based) of the item to select. Value of -1 selects nothing
  1940. --- and restores the original text.
  1941. --- @param insert boolean For `ins-completion`, whether the selection should be inserted in the buffer.
  1942. --- Ignored for `cmdline-completion`.
  1943. --- @param finish boolean Finish the completion and dismiss the popup menu. Implies {insert}.
  1944. --- @param opts vim.api.keyset.empty Optional parameters. Reserved for future use.
  1945. function vim.api.nvim_select_popupmenu_item(item, insert, finish, opts) end
  1946. --- Sets the current buffer.
  1947. ---
  1948. --- @param buffer integer Buffer handle
  1949. function vim.api.nvim_set_current_buf(buffer) end
  1950. --- Changes the global working directory.
  1951. ---
  1952. --- @param dir string Directory path
  1953. function vim.api.nvim_set_current_dir(dir) end
  1954. --- Sets the current line.
  1955. ---
  1956. --- @param line string Line contents
  1957. function vim.api.nvim_set_current_line(line) end
  1958. --- Sets the current tabpage.
  1959. ---
  1960. --- @param tabpage integer Tabpage handle
  1961. function vim.api.nvim_set_current_tabpage(tabpage) end
  1962. --- Sets the current window.
  1963. ---
  1964. --- @param window integer Window handle
  1965. function vim.api.nvim_set_current_win(window) end
  1966. --- Set or change decoration provider for a `namespace`
  1967. ---
  1968. --- This is a very general purpose interface for having Lua callbacks
  1969. --- being triggered during the redraw code.
  1970. ---
  1971. --- The expected usage is to set `extmarks` for the currently
  1972. --- redrawn buffer. `nvim_buf_set_extmark()` can be called to add marks
  1973. --- on a per-window or per-lines basis. Use the `ephemeral` key to only
  1974. --- use the mark for the current screen redraw (the callback will be called
  1975. --- again for the next redraw).
  1976. ---
  1977. --- Note: this function should not be called often. Rather, the callbacks
  1978. --- themselves can be used to throttle unneeded callbacks. the `on_start`
  1979. --- callback can return `false` to disable the provider until the next redraw.
  1980. --- Similarly, return `false` in `on_win` will skip the `on_line` calls
  1981. --- for that window (but any extmarks set in `on_win` will still be used).
  1982. --- A plugin managing multiple sources of decoration should ideally only set
  1983. --- one provider, and merge the sources internally. You can use multiple `ns_id`
  1984. --- for the extmarks set/modified inside the callback anyway.
  1985. ---
  1986. --- Note: doing anything other than setting extmarks is considered experimental.
  1987. --- Doing things like changing options are not explicitly forbidden, but is
  1988. --- likely to have unexpected consequences (such as 100% CPU consumption).
  1989. --- Doing `vim.rpcnotify` should be OK, but `vim.rpcrequest` is quite dubious
  1990. --- for the moment.
  1991. ---
  1992. --- Note: It is not allowed to remove or update extmarks in `on_line` callbacks.
  1993. ---
  1994. --- @param ns_id integer Namespace id from `nvim_create_namespace()`
  1995. --- @param opts vim.api.keyset.set_decoration_provider Table of callbacks:
  1996. --- - on_start: called first on each screen redraw
  1997. --- ```
  1998. --- ["start", tick]
  1999. --- ```
  2000. --- - on_buf: called for each buffer being redrawn (before
  2001. --- window callbacks)
  2002. --- ```
  2003. --- ["buf", bufnr, tick]
  2004. --- ```
  2005. --- - on_win: called when starting to redraw a specific window.
  2006. --- ```
  2007. --- ["win", winid, bufnr, toprow, botrow]
  2008. --- ```
  2009. --- - on_line: called for each buffer line being redrawn.
  2010. --- (The interaction with fold lines is subject to change)
  2011. --- ```
  2012. --- ["line", winid, bufnr, row]
  2013. --- ```
  2014. --- - on_end: called at the end of a redraw cycle
  2015. --- ```
  2016. --- ["end", tick]
  2017. --- ```
  2018. function vim.api.nvim_set_decoration_provider(ns_id, opts) end
  2019. --- Sets a highlight group.
  2020. ---
  2021. --- Note:
  2022. --- Unlike the `:highlight` command which can update a highlight group,
  2023. --- this function completely replaces the definition. For example:
  2024. --- `nvim_set_hl(0, 'Visual', {})` will clear the highlight group
  2025. --- 'Visual'.
  2026. ---
  2027. --- The fg and bg keys also accept the string values `"fg"` or `"bg"`
  2028. --- which act as aliases to the corresponding foreground and background
  2029. --- values of the Normal group. If the Normal group has not been defined,
  2030. --- using these values results in an error.
  2031. ---
  2032. ---
  2033. --- If `link` is used in combination with other attributes; only the
  2034. --- `link` will take effect (see |:hi-link|).
  2035. ---
  2036. ---
  2037. --- @param ns_id integer Namespace id for this highlight `nvim_create_namespace()`.
  2038. --- Use 0 to set a highlight group globally `:highlight`.
  2039. --- Highlights from non-global namespaces are not active by default, use
  2040. --- `nvim_set_hl_ns()` or `nvim_win_set_hl_ns()` to activate them.
  2041. --- @param name string Highlight group name, e.g. "ErrorMsg"
  2042. --- @param val vim.api.keyset.highlight Highlight definition map, accepts the following keys:
  2043. --- - fg: color name or "#RRGGBB", see note.
  2044. --- - bg: color name or "#RRGGBB", see note.
  2045. --- - sp: color name or "#RRGGBB"
  2046. --- - blend: integer between 0 and 100
  2047. --- - bold: boolean
  2048. --- - standout: boolean
  2049. --- - underline: boolean
  2050. --- - undercurl: boolean
  2051. --- - underdouble: boolean
  2052. --- - underdotted: boolean
  2053. --- - underdashed: boolean
  2054. --- - strikethrough: boolean
  2055. --- - italic: boolean
  2056. --- - reverse: boolean
  2057. --- - nocombine: boolean
  2058. --- - link: name of another highlight group to link to, see `:hi-link`.
  2059. --- - default: Don't override existing definition `:hi-default`
  2060. --- - ctermfg: Sets foreground of cterm color `ctermfg`
  2061. --- - ctermbg: Sets background of cterm color `ctermbg`
  2062. --- - cterm: cterm attribute map, like `highlight-args`. If not set,
  2063. --- cterm attributes will match those from the attribute map
  2064. --- documented above.
  2065. --- - force: if true force update the highlight group when it exists.
  2066. function vim.api.nvim_set_hl(ns_id, name, val) end
  2067. --- Set active namespace for highlights defined with `nvim_set_hl()`. This can be set for
  2068. --- a single window, see `nvim_win_set_hl_ns()`.
  2069. ---
  2070. --- @param ns_id integer the namespace to use
  2071. function vim.api.nvim_set_hl_ns(ns_id) end
  2072. --- Set active namespace for highlights defined with `nvim_set_hl()` while redrawing.
  2073. ---
  2074. --- This function meant to be called while redrawing, primarily from
  2075. --- `nvim_set_decoration_provider()` on_win and on_line callbacks, which
  2076. --- are allowed to change the namespace during a redraw cycle.
  2077. ---
  2078. --- @param ns_id integer the namespace to activate
  2079. function vim.api.nvim_set_hl_ns_fast(ns_id) end
  2080. --- Sets a global `mapping` for the given mode.
  2081. ---
  2082. --- To set a buffer-local mapping, use `nvim_buf_set_keymap()`.
  2083. ---
  2084. --- Unlike `:map`, leading/trailing whitespace is accepted as part of the {lhs} or {rhs}.
  2085. --- Empty {rhs} is [<Nop>]. `keycodes` are replaced as usual.
  2086. ---
  2087. --- Example:
  2088. ---
  2089. --- ```vim
  2090. --- call nvim_set_keymap('n', ' <NL>', '', {'nowait': v:true})
  2091. --- ```
  2092. ---
  2093. --- is equivalent to:
  2094. ---
  2095. --- ```vim
  2096. --- nmap <nowait> <Space><NL> <Nop>
  2097. --- ```
  2098. ---
  2099. --- @param mode string Mode short-name (map command prefix: "n", "i", "v", "x", …)
  2100. --- or "!" for `:map!`, or empty string for `:map`.
  2101. --- "ia", "ca" or "!a" for abbreviation in Insert mode, Cmdline mode, or both, respectively
  2102. --- @param lhs string Left-hand-side `{lhs}` of the mapping.
  2103. --- @param rhs string Right-hand-side `{rhs}` of the mapping.
  2104. --- @param opts vim.api.keyset.keymap Optional parameters map: Accepts all `:map-arguments` as keys except [<buffer>],
  2105. --- values are booleans (default false). Also:
  2106. --- - "noremap" disables `recursive_mapping`, like `:noremap`
  2107. --- - "desc" human-readable description.
  2108. --- - "callback" Lua function called in place of {rhs}.
  2109. --- - "replace_keycodes" (boolean) When "expr" is true, replace keycodes in the
  2110. --- resulting string (see `nvim_replace_termcodes()`). Returning nil from the Lua
  2111. --- "callback" is equivalent to returning an empty string.
  2112. function vim.api.nvim_set_keymap(mode, lhs, rhs, opts) end
  2113. --- @deprecated
  2114. --- @param name string
  2115. --- @param value any
  2116. function vim.api.nvim_set_option(name, value) end
  2117. --- Sets the value of an option. The behavior of this function matches that of
  2118. --- `:set`: for global-local options, both the global and local value are set
  2119. --- unless otherwise specified with {scope}.
  2120. ---
  2121. --- Note the options {win} and {buf} cannot be used together.
  2122. ---
  2123. --- @param name string Option name
  2124. --- @param value any New option value
  2125. --- @param opts vim.api.keyset.option Optional parameters
  2126. --- - scope: One of "global" or "local". Analogous to
  2127. --- `:setglobal` and `:setlocal`, respectively.
  2128. --- - win: `window-ID`. Used for setting window local option.
  2129. --- - buf: Buffer number. Used for setting buffer local option.
  2130. function vim.api.nvim_set_option_value(name, value, opts) end
  2131. --- Sets a global (g:) variable.
  2132. ---
  2133. --- @param name string Variable name
  2134. --- @param value any Variable value
  2135. function vim.api.nvim_set_var(name, value) end
  2136. --- Sets a v: variable, if it is not readonly.
  2137. ---
  2138. --- @param name string Variable name
  2139. --- @param value any Variable value
  2140. function vim.api.nvim_set_vvar(name, value) end
  2141. --- Calculates the number of display cells occupied by `text`.
  2142. --- Control characters including [<Tab>] count as one cell.
  2143. ---
  2144. --- @param text string Some text
  2145. --- @return integer # Number of cells
  2146. function vim.api.nvim_strwidth(text) end
  2147. --- Removes a tab-scoped (t:) variable
  2148. ---
  2149. --- @param tabpage integer Tabpage handle, or 0 for current tabpage
  2150. --- @param name string Variable name
  2151. function vim.api.nvim_tabpage_del_var(tabpage, name) end
  2152. --- Gets the tabpage number
  2153. ---
  2154. --- @param tabpage integer Tabpage handle, or 0 for current tabpage
  2155. --- @return integer # Tabpage number
  2156. function vim.api.nvim_tabpage_get_number(tabpage) end
  2157. --- Gets a tab-scoped (t:) variable
  2158. ---
  2159. --- @param tabpage integer Tabpage handle, or 0 for current tabpage
  2160. --- @param name string Variable name
  2161. --- @return any # Variable value
  2162. function vim.api.nvim_tabpage_get_var(tabpage, name) end
  2163. --- Gets the current window in a tabpage
  2164. ---
  2165. --- @param tabpage integer Tabpage handle, or 0 for current tabpage
  2166. --- @return integer # Window handle
  2167. function vim.api.nvim_tabpage_get_win(tabpage) end
  2168. --- Checks if a tabpage is valid
  2169. ---
  2170. --- @param tabpage integer Tabpage handle, or 0 for current tabpage
  2171. --- @return boolean # true if the tabpage is valid, false otherwise
  2172. function vim.api.nvim_tabpage_is_valid(tabpage) end
  2173. --- Gets the windows in a tabpage
  2174. ---
  2175. --- @param tabpage integer Tabpage handle, or 0 for current tabpage
  2176. --- @return integer[] # List of windows in `tabpage`
  2177. function vim.api.nvim_tabpage_list_wins(tabpage) end
  2178. --- Sets a tab-scoped (t:) variable
  2179. ---
  2180. --- @param tabpage integer Tabpage handle, or 0 for current tabpage
  2181. --- @param name string Variable name
  2182. --- @param value any Variable value
  2183. function vim.api.nvim_tabpage_set_var(tabpage, name, value) end
  2184. --- Sets the current window in a tabpage
  2185. ---
  2186. --- @param tabpage integer Tabpage handle, or 0 for current tabpage
  2187. --- @param win integer Window handle, must already belong to {tabpage}
  2188. function vim.api.nvim_tabpage_set_win(tabpage, win) end
  2189. --- Calls a function with window as temporary current window.
  2190. ---
  2191. ---
  2192. --- @see `:help win_execute()`
  2193. --- @see vim.api.nvim_buf_call
  2194. --- @param window integer Window handle, or 0 for current window
  2195. --- @param fun function Function to call inside the window (currently Lua callable
  2196. --- only)
  2197. --- @return any # Return value of function.
  2198. function vim.api.nvim_win_call(window, fun) end
  2199. --- Closes the window (like `:close` with a `window-ID`).
  2200. ---
  2201. --- @param window integer Window handle, or 0 for current window
  2202. --- @param force boolean Behave like `:close!` The last window of a buffer with
  2203. --- unwritten changes can be closed. The buffer will become
  2204. --- hidden, even if 'hidden' is not set.
  2205. function vim.api.nvim_win_close(window, force) end
  2206. --- Removes a window-scoped (w:) variable
  2207. ---
  2208. --- @param window integer Window handle, or 0 for current window
  2209. --- @param name string Variable name
  2210. function vim.api.nvim_win_del_var(window, name) end
  2211. --- Gets the current buffer in a window
  2212. ---
  2213. --- @param window integer Window handle, or 0 for current window
  2214. --- @return integer # Buffer handle
  2215. function vim.api.nvim_win_get_buf(window) end
  2216. --- Gets window configuration.
  2217. ---
  2218. --- The returned value may be given to `nvim_open_win()`.
  2219. ---
  2220. --- `relative` is empty for normal windows.
  2221. ---
  2222. --- @param window integer Window handle, or 0 for current window
  2223. --- @return vim.api.keyset.win_config # Map defining the window configuration, see |nvim_open_win()|
  2224. function vim.api.nvim_win_get_config(window) end
  2225. --- Gets the (1,0)-indexed, buffer-relative cursor position for a given window
  2226. --- (different windows showing the same buffer have independent cursor
  2227. --- positions). `api-indexing`
  2228. ---
  2229. ---
  2230. --- @see `:help getcurpos()`
  2231. --- @param window integer Window handle, or 0 for current window
  2232. --- @return integer[] # (row, col) tuple
  2233. function vim.api.nvim_win_get_cursor(window) end
  2234. --- Gets the window height
  2235. ---
  2236. --- @param window integer Window handle, or 0 for current window
  2237. --- @return integer # Height as a count of rows
  2238. function vim.api.nvim_win_get_height(window) end
  2239. --- Gets the window number
  2240. ---
  2241. --- @param window integer Window handle, or 0 for current window
  2242. --- @return integer # Window number
  2243. function vim.api.nvim_win_get_number(window) end
  2244. --- @deprecated
  2245. --- @param window integer
  2246. --- @param name string
  2247. --- @return any
  2248. function vim.api.nvim_win_get_option(window, name) end
  2249. --- Gets the window position in display cells. First position is zero.
  2250. ---
  2251. --- @param window integer Window handle, or 0 for current window
  2252. --- @return integer[] # (row, col) tuple with the window position
  2253. function vim.api.nvim_win_get_position(window) end
  2254. --- Gets the window tabpage
  2255. ---
  2256. --- @param window integer Window handle, or 0 for current window
  2257. --- @return integer # Tabpage that contains the window
  2258. function vim.api.nvim_win_get_tabpage(window) end
  2259. --- Gets a window-scoped (w:) variable
  2260. ---
  2261. --- @param window integer Window handle, or 0 for current window
  2262. --- @param name string Variable name
  2263. --- @return any # Variable value
  2264. function vim.api.nvim_win_get_var(window, name) end
  2265. --- Gets the window width
  2266. ---
  2267. --- @param window integer Window handle, or 0 for current window
  2268. --- @return integer # Width as a count of columns
  2269. function vim.api.nvim_win_get_width(window) end
  2270. --- Closes the window and hide the buffer it contains (like `:hide` with a
  2271. --- `window-ID`).
  2272. ---
  2273. --- Like `:hide` the buffer becomes hidden unless another window is editing it,
  2274. --- or 'bufhidden' is `unload`, `delete` or `wipe` as opposed to `:close` or
  2275. --- `nvim_win_close()`, which will close the buffer.
  2276. ---
  2277. --- @param window integer Window handle, or 0 for current window
  2278. function vim.api.nvim_win_hide(window) end
  2279. --- Checks if a window is valid
  2280. ---
  2281. --- @param window integer Window handle, or 0 for current window
  2282. --- @return boolean # true if the window is valid, false otherwise
  2283. function vim.api.nvim_win_is_valid(window) end
  2284. --- Sets the current buffer in a window, without side effects
  2285. ---
  2286. --- @param window integer Window handle, or 0 for current window
  2287. --- @param buffer integer Buffer handle
  2288. function vim.api.nvim_win_set_buf(window, buffer) end
  2289. --- Configures window layout. Cannot be used to move the last window in a
  2290. --- tabpage to a different one.
  2291. ---
  2292. --- When reconfiguring a window, absent option keys will not be changed.
  2293. --- `row`/`col` and `relative` must be reconfigured together.
  2294. ---
  2295. ---
  2296. --- @see vim.api.nvim_open_win
  2297. --- @param window integer Window handle, or 0 for current window
  2298. --- @param config vim.api.keyset.win_config Map defining the window configuration,
  2299. --- see `nvim_open_win()`
  2300. function vim.api.nvim_win_set_config(window, config) end
  2301. --- Sets the (1,0)-indexed cursor position in the window. `api-indexing`
  2302. --- This scrolls the window even if it is not the current one.
  2303. ---
  2304. --- @param window integer Window handle, or 0 for current window
  2305. --- @param pos integer[] (row, col) tuple representing the new position
  2306. function vim.api.nvim_win_set_cursor(window, pos) end
  2307. --- Sets the window height.
  2308. ---
  2309. --- @param window integer Window handle, or 0 for current window
  2310. --- @param height integer Height as a count of rows
  2311. function vim.api.nvim_win_set_height(window, height) end
  2312. --- Set highlight namespace for a window. This will use highlights defined with
  2313. --- `nvim_set_hl()` for this namespace, but fall back to global highlights (ns=0) when
  2314. --- missing.
  2315. ---
  2316. --- This takes precedence over the 'winhighlight' option.
  2317. ---
  2318. --- @param window integer
  2319. --- @param ns_id integer the namespace to use
  2320. function vim.api.nvim_win_set_hl_ns(window, ns_id) end
  2321. --- @deprecated
  2322. --- @param window integer
  2323. --- @param name string
  2324. --- @param value any
  2325. function vim.api.nvim_win_set_option(window, name, value) end
  2326. --- Sets a window-scoped (w:) variable
  2327. ---
  2328. --- @param window integer Window handle, or 0 for current window
  2329. --- @param name string Variable name
  2330. --- @param value any Variable value
  2331. function vim.api.nvim_win_set_var(window, name, value) end
  2332. --- Sets the window width. This will only succeed if the screen is split
  2333. --- vertically.
  2334. ---
  2335. --- @param window integer Window handle, or 0 for current window
  2336. --- @param width integer Width as a count of columns
  2337. function vim.api.nvim_win_set_width(window, width) end
  2338. --- Computes the number of screen lines occupied by a range of text in a given window.
  2339. --- Works for off-screen text and takes folds into account.
  2340. ---
  2341. --- Diff filler or virtual lines above a line are counted as a part of that line,
  2342. --- unless the line is on "start_row" and "start_vcol" is specified.
  2343. ---
  2344. --- Diff filler or virtual lines below the last buffer line are counted in the result
  2345. --- when "end_row" is omitted.
  2346. ---
  2347. --- Line indexing is similar to `nvim_buf_get_text()`.
  2348. ---
  2349. --- @see `:help virtcol()` for text width.
  2350. --- @param window integer Window handle, or 0 for current window.
  2351. --- @param opts vim.api.keyset.win_text_height Optional parameters:
  2352. --- - start_row: Starting line index, 0-based inclusive.
  2353. --- When omitted start at the very top.
  2354. --- - end_row: Ending line index, 0-based inclusive.
  2355. --- When omitted end at the very bottom.
  2356. --- - start_vcol: Starting virtual column index on "start_row",
  2357. --- 0-based inclusive, rounded down to full screen lines.
  2358. --- When omitted include the whole line.
  2359. --- - end_vcol: Ending virtual column index on "end_row",
  2360. --- 0-based exclusive, rounded up to full screen lines.
  2361. --- When omitted include the whole line.
  2362. --- @return table<string,any> # Dict containing text height information, with these keys:
  2363. --- - all: The total number of screen lines occupied by the range.
  2364. --- - fill: The number of diff filler or virtual lines among them.
  2365. ---
  2366. function vim.api.nvim_win_text_height(window, opts) end