├── .github └── workflows │ └── gen.yml ├── LICENSE.txt ├── Makefile ├── README.md ├── fns.txt ├── gen_api.lua ├── gen_fn.lua ├── gen_opt.lua ├── gen_opt_doc.lua ├── gen_vim.lua └── nvim ├── config.lua └── library ├── vim.api.lua ├── vim.fn.lua ├── vim.lua ├── vim.o.lua └── vim.opt.lua /.github/workflows/gen.yml: -------------------------------------------------------------------------------- 1 | name: gen 2 | on: 3 | workflow_dispatch: 4 | schedule: 5 | - cron: '0 0 * * *' # Runs every day 6 | 7 | jobs: 8 | gen: 9 | runs-on: ubuntu-latest 10 | if: ${{ github.ref == 'refs/heads/master' }} 11 | steps: 12 | - uses: actions/checkout@v3 13 | - name: Install Neovim 14 | shell: bash 15 | run: | 16 | mkdir -p /tmp/nvim 17 | wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage -O /tmp/nvim/nvim.appimage 18 | cd /tmp/nvim 19 | chmod a+x ./nvim.appimage 20 | ./nvim.appimage --appimage-extract 21 | echo "/tmp/nvim/squashfs-root/usr/bin/" >> $GITHUB_PATH 22 | - name: gen 23 | shell: bash 24 | run: | 25 | nvim --clean --headless -c 'so gen_vim.lua' -c 'so gen_api.lua' -c 'so gen_fn.lua' -c 'so gen_opt.lua' -c 'qa!' 26 | git diff --quiet --exit-code && exit 27 | git config user.name github-actions 28 | git config user.email github-actions@github.com 29 | git add . 30 | git commit -m "auto generate vimdoc" 31 | git push 32 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | NVIM := nvim 2 | 3 | gen: 4 | $(NVIM) --clean --headless \ 5 | -c 'so gen_vim.lua' \ 6 | -c 'so gen_api.lua' \ 7 | -c 'so gen_fn.lua' \ 8 | -c 'so gen_opt.lua' \ 9 | -c 'qa!' 10 | 11 | .PHONY: gen 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EmmyLua library for Neovim 2 | 3 | Neovim completion library for [sumneko/lua-language-server](https://github.com/sumneko/lua-language-server) 4 | 5 | If you have your entire runtime path as a workspace (like on the code snippet below), 6 | it should just work after installing this just like any other plugin. If not, include 7 | the cloned repository in `Lua.workspace.library`. 8 | ```lua 9 | lspconfig.sumneko_lua.setup { 10 | settings = { 11 | Lua = { 12 | workspace = { 13 | library = vim.api.nvim_get_runtime_file('', true), 14 | }, 15 | }, 16 | }, 17 | } 18 | ``` 19 | 20 | Completion for: 21 | * `vim.api` (no documentation) 22 | * `vim.fn` (no documentation) 23 | * `vim.o`, `vim.opt`, `vim.opt_local`, `vim.opt_global` (with documentation) 24 | * modules: 25 | `vim.F`, `vim.filetype`, `vim.fs`, `vim.health`, `vim.highlight`, `vim.keymap`, 26 | `vim.lsp`, `vim.treesitter`, `vim.ui` 27 | * some of the top-level `vim.*` functions 28 | -------------------------------------------------------------------------------- /fns.txt: -------------------------------------------------------------------------------- 1 | abs({expr}) Float or Number absolute value of {expr} 2 | acos({expr}) Float arc cosine of {expr} 3 | add({object}, {item}) List/Blob append {item} to {object} 4 | and({expr}, {expr}) Number bitwise AND 5 | api_info() Dict api metadata 6 | append({lnum}, {text}) Number append {text} below line {lnum} 7 | appendbufline({expr}, {lnum}, {text}) 8 | Number append {text} below line {lnum} 9 | in buffer {expr} 10 | argc([{winid}]) Number number of files in the argument list 11 | argidx() Number current index in the argument list 12 | arglistid([{winnr} [, {tabnr}]]) Number argument list id 13 | argv({nr} [, {winid}]) String {nr} entry of the argument list 14 | argv([-1, {winid}]) List the argument list 15 | asin({expr}) Float arc sine of {expr} 16 | assert_beeps({cmd}) Number assert {cmd} causes a beep 17 | assert_equal({exp}, {act} [, {msg}]) 18 | Number assert {exp} is equal to {act} 19 | assert_equalfile({fname-one}, {fname-two} [, {msg}]) 20 | Number assert file contents are equal 21 | assert_exception({error} [, {msg}]) 22 | Number assert {error} is in v:exception 23 | assert_fails({cmd} [, {error}]) Number assert {cmd} fails 24 | assert_false({actual} [, {msg}]) 25 | Number assert {actual} is false 26 | assert_inrange({lower}, {upper}, {actual} [, {msg}]) 27 | Number assert {actual} is inside the range 28 | assert_match({pat}, {text} [, {msg}]) 29 | Number assert {pat} matches {text} 30 | assert_nobeep({cmd}) Number assert {cmd} does not cause a beep 31 | assert_notequal({exp}, {act} [, {msg}]) 32 | Number assert {exp} is not equal {act} 33 | assert_notmatch({pat}, {text} [, {msg}]) 34 | Number assert {pat} not matches {text} 35 | assert_report({msg}) Number report a test failure 36 | assert_true({actual} [, {msg}]) Number assert {actual} is true 37 | atan({expr}) Float arc tangent of {expr} 38 | atan2({expr1}, {expr2}) Float arc tangent of {expr1} / {expr2} 39 | blob2list({blob}) List convert {blob} into a list of numbers 40 | browse({save}, {title}, {initdir}, {default}) 41 | String put up a file requester 42 | browsedir({title}, {initdir}) String put up a directory requester 43 | bufadd({name}) Number add a buffer to the buffer list 44 | bufexists({buf}) Number |TRUE| if buffer {buf} exists 45 | buflisted({buf}) Number |TRUE| if buffer {buf} is listed 46 | bufload({buf}) Number load buffer {buf} if not loaded yet 47 | bufloaded({buf}) Number |TRUE| if buffer {buf} is loaded 48 | bufname([{buf}]) String Name of the buffer {buf} 49 | bufnr([{buf} [, {create}]]) Number Number of the buffer {buf} 50 | bufwinid({buf}) Number window ID of buffer {buf} 51 | bufwinnr({buf}) Number window number of buffer {buf} 52 | byte2line({byte}) Number line number at byte count {byte} 53 | byteidx({expr}, {nr} [, {utf16}]) 54 | Number byte index of {nr}th char in {expr} 55 | byteidxcomp({expr}, {nr} [, {utf16}]) 56 | Number byte index of {nr}th char in {expr} 57 | call({func}, {arglist} [, {dict}]) 58 | any call {func} with arguments {arglist} 59 | ceil({expr}) Float round {expr} up 60 | changenr() Number current change number 61 | chanclose({id} [, {stream}]) Number Closes a channel or one of its streams 62 | chansend({id}, {data}) Number Writes {data} to channel 63 | char2nr({expr} [, {utf8}]) Number ASCII/UTF-8 value of first char in {expr} 64 | charclass({string}) Number character class of {string} 65 | charcol({expr} [, {winid}]) Number column number of cursor or mark 66 | charidx({string}, {idx} [, {countcc} [, {utf16}]]) 67 | Number char index of byte {idx} in {string} 68 | chdir({dir}) String change current working directory 69 | cindent({lnum}) Number C indent for line {lnum} 70 | clearmatches([{win}]) none clear all matches 71 | col({expr} [, {winid}]) Number column byte index of cursor or mark 72 | complete({startcol}, {matches}) none set Insert mode completion 73 | complete_add({expr}) Number add completion match 74 | complete_check() Number check for key typed during completion 75 | complete_info([{what}]) Dict get current completion information 76 | confirm({msg} [, {choices} [, {default} [, {type}]]]) 77 | Number number of choice picked by user 78 | copy({expr}) any make a shallow copy of {expr} 79 | cos({expr}) Float cosine of {expr} 80 | cosh({expr}) Float hyperbolic cosine of {expr} 81 | count({comp}, {expr} [, {ic} [, {start}]]) 82 | Number count how many {expr} are in {comp} 83 | ctxget([{index}]) Dict return the |context| dict at {index} 84 | ctxpop() none pop and restore |context| from the 85 | |context-stack| 86 | ctxpush([{types}]) none push the current |context| to the 87 | |context-stack| 88 | ctxset({context} [, {index}]) none set |context| at {index} 89 | ctxsize() Number return |context-stack| size 90 | cursor({lnum}, {col} [, {off}]) 91 | Number move cursor to {lnum}, {col}, {off} 92 | cursor({list}) Number move cursor to position in {list} 93 | debugbreak({pid}) Number interrupt process being debugged 94 | deepcopy({expr} [, {noref}]) any make a full copy of {expr} 95 | delete({fname} [, {flags}]) Number delete the file or directory {fname} 96 | deletebufline({buf}, {first} [, {last}]) 97 | Number delete lines from buffer {buf} 98 | dictwatcheradd({dict}, {pattern}, {callback}) 99 | Start watching a dictionary 100 | dictwatcherdel({dict}, {pattern}, {callback}) 101 | Stop watching a dictionary 102 | did_filetype() Number |TRUE| if FileType autocommand event used 103 | diff_filler({lnum}) Number diff filler lines about {lnum} 104 | diff_hlID({lnum}, {col}) Number diff highlighting at {lnum}/{col} 105 | digraph_get({chars}) String get the |digraph| of {chars} 106 | digraph_getlist([{listall}]) List get all |digraph|s 107 | digraph_set({chars}, {digraph}) Boolean register |digraph| 108 | digraph_setlist({digraphlist}) Boolean register multiple |digraph|s 109 | empty({expr}) Number |TRUE| if {expr} is empty 110 | environ() Dict return environment variables 111 | escape({string}, {chars}) String escape {chars} in {string} with '\' 112 | eval({string}) any evaluate {string} into its value 113 | eventhandler() Number |TRUE| if inside an event handler 114 | executable({expr}) Number 1 if executable {expr} exists 115 | execute({command}) String execute and capture output of {command} 116 | exepath({expr}) String full path of the command {expr} 117 | exists({expr}) Number |TRUE| if {expr} exists 118 | exp({expr}) Float exponential of {expr} 119 | expand({expr} [, {nosuf} [, {list}]]) 120 | any expand special keywords in {expr} 121 | expandcmd({string} [, {options}]) 122 | String expand {string} like with `:edit` 123 | extend({expr1}, {expr2} [, {expr3}]) 124 | List/Dict insert items of {expr2} into {expr1} 125 | extendnew({expr1}, {expr2} [, {expr3}]) 126 | List/Dict like |extend()| but creates a new 127 | List or Dictionary 128 | feedkeys({string} [, {mode}]) Number add key sequence to typeahead buffer 129 | filereadable({file}) Number |TRUE| if {file} is a readable file 130 | filewritable({file}) Number |TRUE| if {file} is a writable file 131 | filter({expr1}, {expr2}) List/Dict remove items from {expr1} where 132 | {expr2} is 0 133 | finddir({name} [, {path} [, {count}]]) 134 | String find directory {name} in {path} 135 | findfile({name} [, {path} [, {count}]]) 136 | String find file {name} in {path} 137 | flatten({list} [, {maxdepth}]) List flatten {list} up to {maxdepth} levels 138 | flattennew({list} [, {maxdepth}]) 139 | List flatten a copy of {list} 140 | float2nr({expr}) Number convert Float {expr} to a Number 141 | floor({expr}) Float round {expr} down 142 | fmod({expr1}, {expr2}) Float remainder of {expr1} / {expr2} 143 | fnameescape({fname}) String escape special characters in {fname} 144 | fnamemodify({fname}, {mods}) String modify file name 145 | foldclosed({lnum}) Number first line of fold at {lnum} if closed 146 | foldclosedend({lnum}) Number last line of fold at {lnum} if closed 147 | foldlevel({lnum}) Number fold level at {lnum} 148 | foldtext() String line displayed for closed fold 149 | foldtextresult({lnum}) String text for closed fold at {lnum} 150 | fullcommand({name}) String get full command from {name} 151 | funcref({name} [, {arglist}] [, {dict}]) 152 | Funcref reference to function {name} 153 | function({name} [, {arglist}] [, {dict}]) 154 | Funcref named reference to function {name} 155 | garbagecollect([{atexit}]) none free memory, breaking cyclic references 156 | get({list}, {idx} [, {def}]) any get item {idx} from {list} or {def} 157 | get({dict}, {key} [, {def}]) any get item {key} from {dict} or {def} 158 | get({func}, {what}) any get property of funcref/partial {func} 159 | getbufinfo([{buf}]) List information about buffers 160 | getbufline({buf}, {lnum} [, {end}]) 161 | List lines {lnum} to {end} of buffer {buf} 162 | getbufoneline({buf}, {lnum}) String line {lnum} of buffer {buf} 163 | getbufvar({buf}, {varname} [, {def}]) 164 | any variable {varname} in buffer {buf} 165 | getcellwidths() List get character cell width overrides 166 | getchangelist([{buf}]) List list of change list items 167 | getchar([expr]) Number or String 168 | get one character from the user 169 | getcharmod() Number modifiers for the last typed character 170 | getcharpos({expr}) List position of cursor, mark, etc. 171 | getcharsearch() Dict last character search 172 | getcharstr([expr]) String get one character from the user 173 | getcmdcompltype() String return the type of the current 174 | command-line completion 175 | getcmdline() String return the current command-line 176 | getcmdpos() Number return cursor position in command-line 177 | getcmdscreenpos() Number return cursor screen position in 178 | command-line 179 | getcmdtype() String return current command-line type 180 | getcmdwintype() String return current command-line window type 181 | getcompletion({pat}, {type} [, {filtered}]) 182 | List list of cmdline completion matches 183 | getcurpos([{winnr}]) List position of the cursor 184 | getcursorcharpos([{winnr}]) List character position of the cursor 185 | getcwd([{winnr} [, {tabnr}]]) String get the current working directory 186 | getenv({name}) String return environment variable 187 | getfontname([{name}]) String name of font being used 188 | getfperm({fname}) String file permissions of file {fname} 189 | getfsize({fname}) Number size in bytes of file {fname} 190 | getftime({fname}) Number last modification time of file 191 | getftype({fname}) String description of type of file {fname} 192 | getjumplist([{winnr} [, {tabnr}]]) 193 | List list of jump list items 194 | getline({lnum}) String line {lnum} of current buffer 195 | getline({lnum}, {end}) List lines {lnum} to {end} of current buffer 196 | getloclist({nr}) List list of location list items 197 | getloclist({nr}, {what}) Dict get specific location list properties 198 | getmarklist([{buf}]) List list of global/local marks 199 | getmatches([{win}]) List list of current matches 200 | getmousepos() Dict last known mouse position 201 | getpid() Number process ID of Vim 202 | getpos({expr}) List position of cursor, mark, etc. 203 | getqflist() List list of quickfix items 204 | getqflist({what}) Dict get specific quickfix list properties 205 | getreg([{regname} [, 1 [, {list}]]]) 206 | String or List contents of a register 207 | getreginfo([{regname}]) Dict information about a register 208 | getregtype([{regname}]) String type of a register 209 | getscriptinfo([{opts}]) List list of sourced scripts 210 | gettabinfo([{expr}]) List list of tab pages 211 | gettabvar({nr}, {varname} [, {def}]) 212 | any variable {varname} in tab {nr} or {def} 213 | gettabwinvar({tabnr}, {winnr}, {name} [, {def}]) 214 | any {name} in {winnr} in tab page {tabnr} 215 | gettagstack([{nr}]) Dict get the tag stack of window {nr} 216 | gettext({text}) String lookup translation of {text} 217 | getwininfo([{winid}]) List list of info about each window 218 | getwinpos([{timeout}]) List X and Y coord in pixels of Vim window 219 | getwinposx() Number X coord in pixels of Vim window 220 | getwinposy() Number Y coord in pixels of Vim window 221 | getwinvar({nr}, {varname} [, {def}]) 222 | any variable {varname} in window {nr} 223 | glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) 224 | any expand file wildcards in {expr} 225 | glob2regpat({expr}) String convert a glob pat into a search pat 226 | globpath({path}, {expr} [, {nosuf} [, {list} [, {alllinks}]]]) 227 | String do glob({expr}) for all dirs in {path} 228 | has({feature}) Number |TRUE| if feature {feature} supported 229 | has_key({dict}, {key}) Number |TRUE| if {dict} has entry {key} 230 | haslocaldir([{winnr} [, {tabnr}]]) 231 | Number |TRUE| if the window executed |:lcd| or 232 | the tab executed |:tcd| 233 | hasmapto({what} [, {mode} [, {abbr}]]) 234 | Number |TRUE| if mapping to {what} exists 235 | histadd({history}, {item}) Number add an item to a history 236 | histdel({history} [, {item}]) Number remove an item from a history 237 | histget({history} [, {index}]) String get the item {index} from a history 238 | histnr({history}) Number highest index of a history 239 | hlID({name}) Number syntax ID of highlight group {name} 240 | hlexists({name}) Number |TRUE| if highlight group {name} exists 241 | hostname() String name of the machine Vim is running on 242 | iconv({expr}, {from}, {to}) String convert encoding of {expr} 243 | indent({lnum}) Number indent of line {lnum} 244 | index({object}, {expr} [, {start} [, {ic}]]) 245 | Number index in {object} where {expr} appears 246 | indexof({object}, {expr} [, {opts}]]) 247 | Number index in {object} where {expr} is true 248 | input({prompt} [, {text} [, {completion}]]) 249 | String get input from the user 250 | inputlist({textlist}) Number let the user pick from a choice list 251 | inputrestore() Number restore typeahead 252 | inputsave() Number save and clear typeahead 253 | inputsecret({prompt} [, {text}]) 254 | String like input() but hiding the text 255 | insert({object}, {item} [, {idx}]) 256 | List insert {item} in {object} [before {idx}] 257 | interrupt() none interrupt script execution 258 | invert({expr}) Number bitwise invert 259 | isdirectory({directory}) Number |TRUE| if {directory} is a directory 260 | isinf({expr}) Number determine if {expr} is infinity value 261 | (positive or negative) 262 | islocked({expr}) Number |TRUE| if {expr} is locked 263 | isnan({expr}) Number |TRUE| if {expr} is NaN 264 | id({expr}) String identifier of the container 265 | items({dict}) List key-value pairs in {dict} 266 | jobpid({id}) Number Returns pid of a job. 267 | jobresize({id}, {width}, {height}) 268 | Number Resize pseudo terminal window of a job 269 | jobstart({cmd} [, {opts}]) Number Spawns {cmd} as a job 270 | jobstop({id}) Number Stops a job 271 | jobwait({ids} [, {timeout}]) Number Wait for a set of jobs 272 | join({list} [, {sep}]) String join {list} items into one String 273 | json_decode({expr}) any Convert {expr} from JSON 274 | json_encode({expr}) String Convert {expr} to JSON 275 | keys({dict}) List keys in {dict} 276 | keytrans({string}) String translate internal keycodes to a form 277 | that can be used by |:map| 278 | len({expr}) Number the length of {expr} 279 | libcall({lib}, {func}, {arg}) String call {func} in library {lib} with {arg} 280 | libcallnr({lib}, {func}, {arg}) Number idem, but return a Number 281 | line({expr} [, {winid}]) Number line nr of cursor, last line or mark 282 | line2byte({lnum}) Number byte count of line {lnum} 283 | lispindent({lnum}) Number Lisp indent for line {lnum} 284 | list2blob({list}) Blob turn {list} of numbers into a Blob 285 | list2str({list} [, {utf8}]) String turn {list} of numbers into a String 286 | localtime() Number current time 287 | log({expr}) Float natural logarithm (base e) of {expr} 288 | log10({expr}) Float logarithm of Float {expr} to base 10 289 | luaeval({expr} [, {expr}]) any evaluate |Lua| expression 290 | map({expr1}, {expr2}) List/Dict change each item in {expr1} to {expr} 291 | maparg({name} [, {mode} [, {abbr} [, {dict}]]]) 292 | String or Dict 293 | rhs of mapping {name} in mode {mode} 294 | mapcheck({name} [, {mode} [, {abbr}]]) 295 | String check for mappings matching {name} 296 | mapset({mode}, {abbr}, {dict}) 297 | none restore mapping from |maparg()| result 298 | match({expr}, {pat} [, {start} [, {count}]]) 299 | Number position where {pat} matches in {expr} 300 | matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]]) 301 | Number highlight {pattern} with {group} 302 | matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]]) 303 | Number highlight positions with {group} 304 | matcharg({nr}) List arguments of |:match| 305 | matchdelete({id} [, {win}]) Number delete match identified by {id} 306 | matchend({expr}, {pat} [, {start} [, {count}]]) 307 | Number position where {pat} ends in {expr} 308 | matchfuzzy({list}, {str} [, {dict}]) 309 | List fuzzy match {str} in {list} 310 | matchfuzzypos({list}, {str} [, {dict}]) 311 | List fuzzy match {str} in {list} 312 | matchlist({expr}, {pat} [, {start} [, {count}]]) 313 | List match and submatches of {pat} in {expr} 314 | matchstr({expr}, {pat} [, {start} [, {count}]]) 315 | String {count}th match of {pat} in {expr} 316 | matchstrpos({expr}, {pat} [, {start} [, {count}]]) 317 | List {count}th match of {pat} in {expr} 318 | max({expr}) Number maximum value of items in {expr} 319 | menu_get({path} [, {modes}]) List description of |menus| matched by {path} 320 | menu_info({name} [, {mode}]) Dict get menu item information 321 | min({expr}) Number minimum value of items in {expr} 322 | mkdir({name} [, {flags} [, {prot}]]) 323 | Number create directory {name} 324 | mode([expr]) String current editing mode 325 | msgpackdump({list} [, {type}]) List/Blob dump objects to msgpack 326 | msgpackparse({data}) List parse msgpack to a list of objects 327 | nextnonblank({lnum}) Number line nr of non-blank line >= {lnum} 328 | nr2char({expr} [, {utf8}]) String single char with ASCII/UTF-8 value {expr} 329 | nvim_...({args}...) any call nvim |api| functions 330 | or({expr}, {expr}) Number bitwise OR 331 | pathshorten({expr} [, {len}]) String shorten directory names in a path 332 | perleval({expr}) any evaluate |perl| expression 333 | pow({x}, {y}) Float {x} to the power of {y} 334 | prevnonblank({lnum}) Number line nr of non-blank line <= {lnum} 335 | printf({fmt}, {expr1}...) String format text 336 | prompt_getprompt({buf}) String get prompt text 337 | prompt_setcallback({buf}, {expr}) none set prompt callback function 338 | prompt_setinterrupt({buf}, {text}) none set prompt interrupt function 339 | prompt_setprompt({buf}, {text}) none set prompt text 340 | pum_getpos() Dict position and size of pum if visible 341 | pumvisible() Number whether popup menu is visible 342 | py3eval({expr}) any evaluate |python3| expression 343 | pyeval({expr}) any evaluate |Python| expression 344 | pyxeval({expr}) any evaluate |python_x| expression 345 | rand([{expr}]) Number get pseudo-random number 346 | range({expr} [, {max} [, {stride}]]) 347 | List items from {expr} to {max} 348 | readblob({fname} [, {offset} [, {size}]]) 349 | Blob read a |Blob| from {fname} 350 | readdir({dir} [, {expr}]) List file names in {dir} selected by {expr} 351 | readfile({fname} [, {type} [, {max}]]) 352 | List get list of lines from file {fname} 353 | reduce({object}, {func} [, {initial}]) 354 | any reduce {object} using {func} 355 | reg_executing() String get the executing register name 356 | reg_recorded() String get the last recorded register name 357 | reg_recording() String get the recording register name 358 | reltime([{start} [, {end}]]) List get time value 359 | reltimefloat({time}) Float turn the time value into a Float 360 | reltimestr({time}) String turn time value into a String 361 | remove({list}, {idx} [, {end}]) any/List 362 | remove items {idx}-{end} from {list} 363 | remove({blob}, {idx} [, {end}]) Number/Blob 364 | remove bytes {idx}-{end} from {blob} 365 | remove({dict}, {key}) any remove entry {key} from {dict} 366 | rename({from}, {to}) Number rename (move) file from {from} to {to} 367 | repeat({expr}, {count}) List/Blob/String 368 | repeat {expr} {count} times 369 | resolve({filename}) String get filename a shortcut points to 370 | reverse({list}) List reverse {list} in-place 371 | round({expr}) Float round off {expr} 372 | rubyeval({expr}) any evaluate |Ruby| expression 373 | rpcnotify({channel}, {event} [, {args}...]) 374 | Sends an |RPC| notification to {channel} 375 | rpcrequest({channel}, {method} [, {args}...]) 376 | Sends an |RPC| request to {channel} 377 | screenattr({row}, {col}) Number attribute at screen position 378 | screenchar({row}, {col}) Number character at screen position 379 | screenchars({row}, {col}) List List of characters at screen position 380 | screencol() Number current cursor column 381 | screenpos({winid}, {lnum}, {col}) Dict screen row and col of a text character 382 | screenrow() Number current cursor row 383 | screenstring({row}, {col}) String characters at screen position 384 | search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) 385 | Number search for {pattern} 386 | searchcount([{options}]) Dict Get or update the last search count 387 | searchdecl({name} [, {global} [, {thisblock}]]) 388 | Number search for variable declaration 389 | searchpair({start}, {middle}, {end} [, {flags} [, {skip} [...]]]) 390 | Number search for other end of start/end pair 391 | searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [...]]]) 392 | List search for other end of start/end pair 393 | searchpos({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) 394 | List search for {pattern} 395 | serverlist() String get a list of available servers 396 | setbufline({expr}, {lnum}, {text}) 397 | Number set line {lnum} to {text} in buffer 398 | {expr} 399 | setbufvar({buf}, {varname}, {val}) set {varname} in buffer {buf} to {val} 400 | setcellwidths({list}) none set character cell width overrides 401 | setcharpos({expr}, {list}) Number set the {expr} position to {list} 402 | setcharsearch({dict}) Dict set character search from {dict} 403 | setcmdline({str} [, {pos}]) Number set command-line 404 | setcmdpos({pos}) Number set cursor position in command-line 405 | setcursorcharpos({list}) Number move cursor to position in {list} 406 | setenv({name}, {val}) none set environment variable 407 | setfperm({fname}, {mode} Number set {fname} file permissions to {mode} 408 | setline({lnum}, {line}) Number set line {lnum} to {line} 409 | setloclist({nr}, {list} [, {action}]) 410 | Number modify location list using {list} 411 | setloclist({nr}, {list}, {action}, {what}) 412 | Number modify specific location list props 413 | setmatches({list} [, {win}]) Number restore a list of matches 414 | setpos({expr}, {list}) Number set the {expr} position to {list} 415 | setqflist({list} [, {action}]) Number modify quickfix list using {list} 416 | setqflist({list}, {action}, {what}) 417 | Number modify specific quickfix list props 418 | setreg({n}, {v} [, {opt}]) Number set register to value and type 419 | settabvar({nr}, {varname}, {val}) set {varname} in tab page {nr} to {val} 420 | settabwinvar({tabnr}, {winnr}, {varname}, {val}) set {varname} in window 421 | {winnr} in tab page {tabnr} to {val} 422 | settagstack({nr}, {dict} [, {action}]) 423 | Number modify tag stack using {dict} 424 | setwinvar({nr}, {varname}, {val}) set {varname} in window {nr} to {val} 425 | sha256({string}) String SHA256 checksum of {string} 426 | shellescape({string} [, {special}]) 427 | String escape {string} for use as shell 428 | command argument 429 | shiftwidth([{col}]) Number effective value of 'shiftwidth' 430 | sign_define({name} [, {dict}]) Number define or update a sign 431 | sign_define({list}) List define or update a list of signs 432 | sign_getdefined([{name}]) List get a list of defined signs 433 | sign_getplaced([{buf} [, {dict}]]) 434 | List get a list of placed signs 435 | sign_jump({id}, {group}, {buf}) 436 | Number jump to a sign 437 | sign_place({id}, {group}, {name}, {buf} [, {dict}]) 438 | Number place a sign 439 | sign_placelist({list}) List place a list of signs 440 | sign_undefine([{name}]) Number undefine a sign 441 | sign_undefine({list}) List undefine a list of signs 442 | sign_unplace({group} [, {dict}]) 443 | Number unplace a sign 444 | sign_unplacelist({list}) List unplace a list of signs 445 | simplify({filename}) String simplify filename as much as possible 446 | sin({expr}) Float sine of {expr} 447 | sinh({expr}) Float hyperbolic sine of {expr} 448 | slice({expr}, {start} [, {end}]) String, List or Blob 449 | slice of a String, List or Blob 450 | sockconnect({mode}, {address} [, {opts}]) 451 | Number Connects to socket 452 | sort({list} [, {func} [, {dict}]]) 453 | List sort {list}, using {func} to compare 454 | soundfold({word}) String sound-fold {word} 455 | spellbadword() String badly spelled word at cursor 456 | spellsuggest({word} [, {max} [, {capital}]]) 457 | List spelling suggestions 458 | split({expr} [, {pat} [, {keepempty}]]) 459 | List make |List| from {pat} separated {expr} 460 | sqrt({expr}) Float square root of {expr} 461 | srand([{expr}]) List get seed for |rand()| 462 | stdioopen({dict}) Number open stdio in a headless instance. 463 | stdpath({what}) String/List returns the standard path(s) for {what} 464 | str2float({expr} [, {quoted}]) Float convert String to Float 465 | str2list({expr} [, {utf8}]) List convert each character of {expr} to 466 | ASCII/UTF-8 value 467 | str2nr({expr} [, {base} [, {quoted}]]) 468 | Number convert String to Number 469 | strcharlen({expr}) Number character length of the String {expr} 470 | strcharpart({str}, {start} [, {len} [, {skipcc}]]) 471 | String {len} characters of {str} at 472 | character {start} 473 | strchars({expr} [, {skipcc}]) Number character count of the String {expr} 474 | strdisplaywidth({expr} [, {col}]) Number display length of the String {expr} 475 | strftime({format} [, {time}]) String format time with a specified format 476 | strgetchar({str}, {index}) Number get char {index} from {str} 477 | stridx({haystack}, {needle} [, {start}]) 478 | Number index of {needle} in {haystack} 479 | string({expr}) String String representation of {expr} value 480 | strlen({expr}) Number length of the String {expr} 481 | strpart({str}, {start} [, {len} [, {chars}]]) 482 | String {len} bytes/chars of {str} at 483 | byte {start} 484 | strptime({format}, {timestring}) 485 | Number Convert {timestring} to unix timestamp 486 | strridx({haystack}, {needle} [, {start}]) 487 | Number last index of {needle} in {haystack} 488 | strtrans({expr}) String translate string to make it printable 489 | strutf16len({string} [, {countcc}]) 490 | Number number of UTF-16 code units in {string} 491 | strwidth({expr}) Number display cell length of the String {expr} 492 | submatch({nr} [, {list}]) String or List 493 | specific match in ":s" or substitute() 494 | substitute({expr}, {pat}, {sub}, {flags}) 495 | String all {pat} in {expr} replaced with {sub} 496 | swapfilelist() List swap files found in 'directory' 497 | swapinfo({fname}) Dict information about swap file {fname} 498 | swapname({buf}) String swap file of buffer {buf} 499 | synID({lnum}, {col}, {trans}) Number syntax ID at {lnum} and {col} 500 | synIDattr({synID}, {what} [, {mode}]) 501 | String attribute {what} of syntax ID {synID} 502 | synIDtrans({synID}) Number translated syntax ID of {synID} 503 | synconcealed({lnum}, {col}) List info about concealing 504 | synstack({lnum}, {col}) List stack of syntax IDs at {lnum} and {col} 505 | system({cmd} [, {input}]) String output of shell command/filter {cmd} 506 | systemlist({cmd} [, {input}]) List output of shell command/filter {cmd} 507 | tabpagebuflist([{arg}]) List list of buffer numbers in tab page 508 | tabpagenr([{arg}]) Number number of current or last tab page 509 | tabpagewinnr({tabarg} [, {arg}]) 510 | Number number of current window in tab page 511 | tagfiles() List tags files used 512 | taglist({expr} [, {filename}]) List list of tags matching {expr} 513 | tan({expr}) Float tangent of {expr} 514 | tanh({expr}) Float hyperbolic tangent of {expr} 515 | tempname() String name for a temporary file 516 | test_garbagecollect_now() none free memory right now for testing 517 | timer_info([{id}]) List information about timers 518 | timer_pause({id}, {pause}) none pause or unpause a timer 519 | timer_start({time}, {callback} [, {options}]) 520 | Number create a timer 521 | timer_stop({timer}) none stop a timer 522 | timer_stopall() none stop all timers 523 | tolower({expr}) String the String {expr} switched to lowercase 524 | toupper({expr}) String the String {expr} switched to uppercase 525 | tr({src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr} 526 | to chars in {tostr} 527 | trim({text} [, {mask} [, {dir}]]) 528 | String trim characters in {mask} from {text} 529 | trunc({expr}) Float truncate Float {expr} 530 | type({name}) Number type of variable {name} 531 | undofile({name}) String undo file name for {name} 532 | undotree() List undo file tree 533 | uniq({list} [, {func} [, {dict}]]) 534 | List remove adjacent duplicates from a list 535 | utf16idx({string}, {idx} [, {countcc} [, {charidx}]]) 536 | Number UTF-16 index of byte {idx} in {string} 537 | values({dict}) List values in {dict} 538 | virtcol({expr} [, {list}]) Number or List 539 | screen column of cursor or mark 540 | virtcol2col({winid}, {lnum}, {col}) 541 | Number byte index of a character on screen 542 | visualmode([expr]) String last visual mode used 543 | wait({timeout}, {condition} [, {interval}]) 544 | Number Wait until {condition} is satisfied 545 | wildmenumode() Number whether 'wildmenu' mode is active 546 | win_execute({id}, {command} [, {silent}]) 547 | String execute {command} in window {id} 548 | win_findbuf({bufnr}) List find windows containing {bufnr} 549 | win_getid([{win} [, {tab}]]) Number get |window-ID| for {win} in {tab} 550 | win_gettype([{nr}]) String type of window {nr} 551 | win_gotoid({expr}) Number go to |window-ID| {expr} 552 | win_id2tabwin({expr}) List get tab and window nr from |window-ID| 553 | win_id2win({expr}) Number get window nr from |window-ID| 554 | win_move_separator({nr}) Number move window vertical separator 555 | win_move_statusline({nr}) Number move window status line 556 | win_screenpos({nr}) List get screen position of window {nr} 557 | win_splitmove({nr}, {target} [, {options}]) 558 | Number move window {nr} to split of {target} 559 | winbufnr({nr}) Number buffer number of window {nr} 560 | wincol() Number window column of the cursor 561 | windowsversion() String MS-Windows OS version 562 | winheight({nr}) Number height of window {nr} 563 | winlayout([{tabnr}]) List layout of windows in tab {tabnr} 564 | winline() Number window line of the cursor 565 | winnr([{expr}]) Number number of current window 566 | winrestcmd() String returns command to restore window sizes 567 | winrestview({dict}) none restore view of current window 568 | winsaveview() Dict save view of current window 569 | winwidth({nr}) Number width of window {nr} 570 | wordcount() Dict get byte/char/word statistics 571 | writefile({object}, {fname} [, {flags}]) 572 | Number write |Blob| or |List| of lines to file 573 | xor({expr}, {expr}) Number bitwise XOR 574 | -------------------------------------------------------------------------------- /gen_api.lua: -------------------------------------------------------------------------------- 1 | local functions = vim.fn.api_info().functions 2 | table.sort(functions, function(a, b) 3 | return a.name < b.name 4 | end) 5 | 6 | local types = {} 7 | 8 | local TYPEMAP = { 9 | void = 'nil', 10 | Boolean = 'boolean', 11 | Integer = 'integer', 12 | Float = 'number', 13 | String = 'string', 14 | 15 | Array = 'table', 16 | Dictionary = 'table', 17 | LuaRef = 'function', 18 | Object = 'any', 19 | 20 | Buffer = 'Buffer', 21 | Window = 'Window', 22 | Tabpage = 'Tabpage', 23 | } 24 | 25 | local function new_type(s) 26 | if not types[s] then 27 | local arrayof = s:match('^ArrayOf%((.*)%)$') 28 | if arrayof then 29 | local tp, cnt = arrayof:match('^(%w+), (%d+)$') 30 | if tp then 31 | tp = assert(TYPEMAP[tp], 'unknown type: '..tp) 32 | local tbl = {} 33 | for i = 1, cnt do 34 | table.insert(tbl, ('[%d]: %s'):format(i, tp)) 35 | end 36 | types[s] = '{ '..table.concat(tbl, ', ')..' }' 37 | else 38 | types[s] = assert(TYPEMAP[arrayof], 'unknown type: '..arrayof)..'[]' 39 | end 40 | else 41 | types[s] = assert(TYPEMAP[s], 'unknown type: '..s) 42 | end 43 | end 44 | return types[s] 45 | end 46 | 47 | local lines = {[[ 48 | ---@meta 49 | 50 | ---@class vim.api 51 | vim.api = {} 52 | 53 | ---@alias Buffer integer 54 | ---@alias Tabpage integer 55 | ---@alias Window integer 56 | ]]} 57 | 58 | local function ins(s) 59 | table.insert(lines, s) 60 | end 61 | 62 | for _, f in ipairs(functions) do 63 | if f.name:find('^nvim_') then 64 | f.return_type = new_type(f.return_type) 65 | for _, parameter in ipairs(f.parameters) do 66 | parameter[1] = new_type(parameter[1]) 67 | end 68 | 69 | local p1, p2 = {}, {} 70 | for _, param in ipairs(f.parameters) do 71 | if param[2] == 'end' then param[2] = '_end' end 72 | table.insert(p1, assert(param[2])) 73 | table.insert(p2, ('---@param %s %s'):format(param[2], param[1])) 74 | end 75 | 76 | ins('') 77 | if #p2 > 0 then 78 | ins(table.concat(p2, '\n')) 79 | end 80 | if f.return_type ~= 'nil' then 81 | ins(('---@return %s'):format(f.return_type)) 82 | end 83 | ins(('function vim.api.%s(%s) end'):format(f.name, table.concat(p1, ', '))) 84 | end 85 | end 86 | ins('') 87 | 88 | local f = io.open('./nvim/library/vim.api.lua', 'w+b') 89 | f:write(table.concat(lines, '\n')) 90 | f:flush() 91 | -------------------------------------------------------------------------------- /gen_fn.lua: -------------------------------------------------------------------------------- 1 | local txt do 2 | -- TODO: parse it from current runtime 3 | local f = io.open('./fns.txt', 'rb') 4 | txt = f:read('*a') 5 | f:close() 6 | end 7 | 8 | local KEYWORDS = { 9 | ['and'] = true, 10 | ['break'] = true, 11 | ['do'] = true, 12 | ['else'] = true, 13 | ['elseif'] = true, 14 | ['end'] = true, 15 | ['false'] = true, 16 | ['for'] = true, 17 | ['function'] = true, 18 | ['if'] = true, 19 | ['in'] = true, 20 | ['local'] = true, 21 | ['nil'] = true, 22 | ['not'] = true, 23 | ['or'] = true, 24 | ['repeat'] = true, 25 | ['return'] = true, 26 | ['then'] = true, 27 | ['true'] = true, 28 | ['until'] = true, 29 | ['while'] = true, 30 | } 31 | 32 | local lines = {[[ 33 | ---@meta 34 | ]]} 35 | 36 | local function ins(s) 37 | table.insert(lines, s) 38 | end 39 | 40 | local fns = {} 41 | 42 | for line in txt:gmatch('([^\n]*)\n?') do 43 | if line:find('^\t') then 44 | fns[#fns] = fns[#fns] .. line:match('[^\t].*$'):gsub('\t', ' ') 45 | else 46 | fns[#fns+1] = line:gsub('\t', ' ') 47 | end 48 | end 49 | 50 | local function parse_fn(line) 51 | local name, args = line:match('^([%w%d_]+)%((.-)%)(.*)') 52 | if not name then return end 53 | args = args:gsub('[%[%]{}]', '') 54 | args = vim.split(args, '%s*,%s*') 55 | for i, arg in ipairs(args) do 56 | if KEYWORDS[arg] then 57 | args[i] = arg..'_' 58 | elseif arg:find('%.%.%.$') then 59 | args[i] = '...' 60 | elseif arg:find('%-') and arg:find('%a') then 61 | args[i] = arg:gsub('-', '_') 62 | elseif arg:find('^[%d%-]*$') then 63 | return 64 | end 65 | end 66 | 67 | ins('') 68 | ins('---@return any') 69 | if not KEYWORDS[name] then 70 | ins(('function vim.fn.%s(%s) end'):format(name, table.concat(args, ', '))) 71 | else 72 | ins(('vim.fn["%s"] = function(%s) end'):format(name, table.concat(args, ', '))) 73 | end 74 | end 75 | 76 | for _, line in ipairs(fns) do 77 | parse_fn(line) 78 | end 79 | 80 | local f = io.open('./nvim/library/vim.fn.lua', 'w+b') 81 | f:write(table.concat(lines, '\n')) 82 | f:flush() 83 | -------------------------------------------------------------------------------- /gen_opt.lua: -------------------------------------------------------------------------------- 1 | local opt_keys = vim.api.nvim_get_all_options_info() 2 | local inspect = vim.inspect 3 | 4 | local opt_lines = {[[ 5 | ---@meta 6 | 7 | ---@class vim.opt.Opt 8 | local Opt = {} 9 | 10 | ---@return any 11 | function Opt:get() end 12 | 13 | ---@param value any 14 | function Opt:append(value) end 15 | 16 | ---@param value any 17 | function Opt:prepend(value) end 18 | 19 | ---@param value any 20 | function Opt:remove(value) end 21 | ]]} 22 | 23 | local o_lines = {[[ 24 | ---@meta 25 | ]]} 26 | 27 | local function opt_ins(s) 28 | table.insert(opt_lines, s) 29 | end 30 | 31 | local function o_ins(s) 32 | table.insert(o_lines, s) 33 | end 34 | 35 | local docs = dofile('gen_opt_doc.lua') 36 | 37 | local opts = {} 38 | for opt in pairs(opt_keys) do 39 | table.insert(opts, opt) 40 | end 41 | table.sort(opts) 42 | 43 | local IGNORED_DEFAULTS = { 44 | runtimepath = true, 45 | packpath = true, 46 | helpfile = true, 47 | backupdir = true, 48 | directory = true, 49 | shell = true, 50 | undodir = true, 51 | viewdir = true, 52 | } 53 | 54 | for _, key in ipairs(opts) do 55 | local opt = opt_keys[key] 56 | local doc = docs[key] 57 | local default = inspect(opt.default) 58 | if IGNORED_DEFAULTS[opt.name] then 59 | default = '""' 60 | end 61 | 62 | if doc then 63 | for i, line in ipairs(doc) do 64 | doc[i] = '---'..line 65 | end 66 | doc[#doc+1] = '---' 67 | doc = table.concat(doc, '\n') 68 | end 69 | 70 | o_ins('') 71 | if doc then o_ins(doc) end 72 | o_ins(('---@type %s'):format(opt.type)) 73 | o_ins(('vim.o.%s = %s'):format(opt.name, default)) 74 | 75 | opt_ins('') 76 | if doc then opt_ins(doc) end 77 | opt_ins('---@type vim.opt.Opt') 78 | opt_ins(('vim.opt.%s = %s'):format(opt.name, default)) 79 | 80 | -- vim.bo and vim.wo sucks anyway 81 | -- if opt.scope == 'buf' then 82 | -- o_ins(('---@type %s'):format(opt.type)) 83 | -- o_ins(('vim.bo.%s = %s'):format(opt.name, default)) 84 | -- elseif opt.scope == 'win' then 85 | -- o_ins(('---@type %s'):format(opt.type)) 86 | -- o_ins(('vim.wo.%s = %s'):format(opt.name, default)) 87 | -- end 88 | 89 | -- no short options 90 | -- if opt.shortname and opt.shortname ~= '' then 91 | -- o_ins(('--- %s'):format(opt.name)) 92 | -- o_ins(('---@type %s'):format(opt.type)) 93 | -- o_ins(('vim.o.%s = %s'):format(opt.shortname, default)) 94 | -- if opt.scope == 'buf' then 95 | -- o_ins(('---@type %s'):format(opt.type)) 96 | -- o_ins(('vim.bo.%s = %s'):format(opt.shortname, default)) 97 | -- elseif opt.scope == 'win' then 98 | -- o_ins(('---@type %s'):format(opt.type)) 99 | -- o_ins(('vim.wo.%s = %s'):format(opt.shortname, default)) 100 | -- end 101 | -- end 102 | end 103 | 104 | opt_ins('') 105 | opt_ins('vim.opt_local = vim.opt') 106 | opt_ins('vim.opt_global = vim.opt') 107 | 108 | do 109 | local f = io.open('./nvim/library/vim.opt.lua', 'w+b') 110 | f:write(table.concat(opt_lines, '\n')) 111 | f:flush() 112 | end 113 | 114 | do 115 | local f = io.open('./nvim/library/vim.o.lua', 'w+b') 116 | f:write(table.concat(o_lines, '\n')) 117 | f:flush() 118 | end 119 | -------------------------------------------------------------------------------- /gen_opt_doc.lua: -------------------------------------------------------------------------------- 1 | local RUNTIME = vim.env.VIMRUNTIME 2 | 3 | local opts = {} 4 | local opt 5 | 6 | local section = 0 7 | local got_tag = false 8 | 9 | local function iter(line) 10 | if line:find('^================') then 11 | section = section + 1 12 | return 13 | elseif section ~= 3 then 14 | return 15 | elseif line:find("^%s*%*'%S+'%*") then 16 | got_tag = true 17 | return 18 | end 19 | 20 | if got_tag and line:find("^'") then 21 | opt = { line } 22 | opts[#opts+1] = opt 23 | elseif opt then 24 | opt[#opt+1] = line 25 | end 26 | 27 | got_tag = false 28 | end 29 | 30 | for line in io.lines(RUNTIME..'/doc/options.txt') do 31 | iter(line) 32 | end 33 | 34 | do 35 | -- remove modeline 36 | local last = opts[#opts] 37 | if last and last[#last]:find('^%s*vim:') then 38 | last[#last] = nil 39 | end 40 | end 41 | 42 | local res = {} 43 | 44 | for _, o in ipairs(opts) do 45 | -- remove lines with just tags 46 | while o[#o] and o[#o]:find("^' then 83 | o[i] = '```' 84 | closed = false 85 | i = i + 1 86 | elseif o[i]:find(' >$') then 87 | o[i] = o[i]:gsub('%s*>$', '') 88 | table.insert(o, i + 1, '```') 89 | closed = false 90 | i = i + 2 91 | elseif o[i]:find('^<%s*$') then 92 | o[i] = '```' 93 | closed = true 94 | i = i + 1 95 | elseif o[i]:find('^<') then 96 | o[i] = o[i]:sub(2) 97 | table.insert(o, i, '```') 98 | closed = true 99 | i = i + 2 100 | else 101 | i = i + 1 102 | end 103 | if i > #o then 104 | break 105 | end 106 | end 107 | end 108 | 109 | -- remove leading and trailing empty lines 110 | while o[1] and not o[1]:find('%S') do 111 | table.remove(o, 1) 112 | end 113 | while o[#o] and not o[#o]:find('%S') do 114 | o[#o] = nil 115 | end 116 | 117 | --- close code blocks 118 | if not closed then 119 | o[#o+1] = '```' 120 | end 121 | 122 | -- remove leading indentation (should be just one level) 123 | for i, v in ipairs(o) do 124 | o[i] = v:gsub('^\t', '') 125 | end 126 | 127 | res[name] = o 128 | end 129 | 130 | return res 131 | -------------------------------------------------------------------------------- /gen_vim.lua: -------------------------------------------------------------------------------- 1 | local fns = {} 2 | 3 | local RUNTIME = vim.env.VIMRUNTIME 4 | 5 | local files = { 'shared.lua', '_editor.lua' } 6 | 7 | local lines = {[[ 8 | ---@meta 9 | 10 | vim.F = require('vim.F') 11 | vim.filetype = require('vim.filetype') 12 | vim.fs = require('vim.fs') 13 | vim.health = require('vim.health') 14 | vim.highlight = require('vim.highlight') 15 | vim.keymap = require('vim.keymap') 16 | vim.lsp = require('vim.lsp') 17 | vim.treesitter = require('vim.treesitter') 18 | vim.ui = require('vim.ui') 19 | vim.inspect = require('vim.inspect') 20 | 21 | vim.log = { 22 | levels = { 23 | TRACE = 0, 24 | DEBUG = 1, 25 | INFO = 2, 26 | WARN = 3, 27 | ERROR = 4, 28 | OFF = 5, 29 | }, 30 | } 31 | 32 | --- Gets the version of the current Nvim build. 33 | ---@return table 34 | function vim.version() end 35 | 36 | --- Schedules callback to be invoked soon by the main event-loop. Useful 37 | --- to avoid textlock or other temporary restrictions. 38 | ---@param cb function 39 | function vim.schedule(cb) end 40 | 41 | --- Returns true if the code is executing as part of a "fast" event 42 | --- handler, where most of the API is disabled. These are low-level events 43 | --- (e.g. lua-loop-callbacks) which can be invoked whenever Nvim polls 44 | --- for input. When this is `false` most API functions are callable (but 45 | --- may be subject to other restrictions such as textlock). 46 | ---@return boolean 47 | function vim.in_fast_event() end 48 | 49 | --- Invokes vim-function or user-function {func} with arguments {...}. 50 | --- See also vim.fn. 51 | --- Equivalent to: `vim.fn[func]({...})` 52 | ---@param func string 53 | function vim.call(func, ...) end 54 | 55 | function vim.rpcrequest(channel, method, ...) end 56 | 57 | function vim.rpcnotify(channel, method, ...) end 58 | 59 | --- Wait for {time} in milliseconds until {callback} returns `true`. 60 | --- 61 | --- Executes {callback} immediately and at approximately {interval} 62 | --- milliseconds (default 200). Nvim still processes other events during 63 | --- this time. 64 | --- 65 | --- Parameters: 66 | --- - {time} Number of milliseconds to wait 67 | --- - {callback} Optional callback. Waits until {callback} returns true 68 | --- - {interval} (Approximate) number of milliseconds to wait between polls 69 | --- - {fast_only} If true, only api-fast events will be processed. 70 | --- If called from while in an api-fast event, will 71 | --- automatically be set to `true`. 72 | --- 73 | --- Returns: 74 | --- - If {callback} returns `true` during the {time}: `true, nil` 75 | --- - If {callback} never returns `true` during the {time}: `false, -1` 76 | --- - If {callback} is interrupted during the {time}: `false, -2` 77 | --- - If {callback} errors, the error is raised. 78 | --- 79 | --- Examples: 80 | --- 81 | --- ``` 82 | --- -- Wait for 100 ms, allowing other events to process 83 | --- vim.wait(100, function() end) 84 | --- -- Wait for 100 ms or until global variable set. 85 | --- vim.wait(100, function() return vim.g.waiting_for_var end) 86 | --- -- Wait for 1 second or until global variable set, checking every ~500 ms 87 | --- vim.wait(1000, function() return vim.g.waiting_for_var end, 500) 88 | --- -- Schedule a function to set a value in 100ms 89 | --- vim.defer_fn(function() vim.g.timer_result = true end, 100) 90 | --- -- Would wait ten seconds if results blocked. Actually only waits 100 ms 91 | --- if vim.wait(10000, function() return vim.g.timer_result end) then 92 | --- print('Only waiting a little bit of time!') 93 | --- end 94 | --- ``` 95 | --- 96 | ---@param time integer 97 | ---@param callback function? 98 | ---@param interval integer? 99 | ---@param fast_only boolean? 100 | ---@return boolean, integer 101 | function vim.wait(time, callback, interval, fast_only) end 102 | ]]} 103 | 104 | local function ins(s) 105 | table.insert(lines, s) 106 | end 107 | 108 | 109 | local buf = {} 110 | for _, file in ipairs(files) do 111 | for line in io.lines(RUNTIME..'/lua/vim/'..file) do 112 | local doc = line:match('^%s*(%-%-%-.*)') 113 | if doc then 114 | buf[#buf+1] = doc 115 | else 116 | local sig = line:match('^%s*function%s+(vim%..*%(.*%))') 117 | if sig then 118 | fns[#fns+1] = { doc = buf, sig = sig } 119 | end 120 | buf = {} 121 | end 122 | end 123 | end 124 | 125 | for _, fn in ipairs(fns) do 126 | ins('') 127 | ins(table.concat(fn.doc, '\n')) 128 | ins(('function %s end'):format(fn.sig)) 129 | end 130 | 131 | local f = io.open('./nvim/library/vim.lua', 'w+b') 132 | f:write(table.concat(lines, '\n')) 133 | f:flush() 134 | -------------------------------------------------------------------------------- /nvim/config.lua: -------------------------------------------------------------------------------- 1 | name = 'nvim' 2 | 3 | files = { 4 | 'lua/.*%.lua', 5 | 6 | 'nvim/init.lua', 7 | 8 | 'color/.*%.lua', 9 | 'compiler/.*%.lua', 10 | 'ftdetect/.*%.lua', 11 | 'ftplugin/.*%.lua', 12 | 'plugin/.*%.lua', 13 | 14 | 'after/color/.*%.lua', 15 | 'after/compiler/.*%.lua', 16 | 'after/ftdetect/.*%.lua', 17 | 'after/ftplugin/.*%.lua', 18 | 'after/plugin/.*%.lua', 19 | } 20 | 21 | words = { 22 | 'vim%.' 23 | } 24 | 25 | configs = { 26 | { 27 | key = 'Lua.runtime.version', 28 | action = 'set', 29 | value = 'LuaJIT', 30 | }, 31 | { 32 | key = 'Lua.diagnostics.globals', 33 | action = 'add', 34 | value = 'vim', 35 | }, 36 | } 37 | -------------------------------------------------------------------------------- /nvim/library/vim.api.lua: -------------------------------------------------------------------------------- 1 | ---@meta 2 | 3 | ---@class vim.api 4 | vim.api = {} 5 | 6 | ---@alias Buffer integer 7 | ---@alias Tabpage integer 8 | ---@alias Window integer 9 | 10 | 11 | ---@param buffer Buffer 12 | ---@param ns_id integer 13 | ---@param hl_group string 14 | ---@param line integer 15 | ---@param col_start integer 16 | ---@param col_end integer 17 | ---@return integer 18 | function vim.api.nvim_buf_add_highlight(buffer, ns_id, hl_group, line, col_start, col_end) end 19 | 20 | ---@param buffer Buffer 21 | ---@param send_buffer boolean 22 | ---@param opts table 23 | ---@return boolean 24 | function vim.api.nvim_buf_attach(buffer, send_buffer, opts) end 25 | 26 | ---@param buffer Buffer 27 | ---@param fun function 28 | ---@return any 29 | function vim.api.nvim_buf_call(buffer, fun) end 30 | 31 | ---@param buffer Buffer 32 | ---@param ns_id integer 33 | ---@param line_start integer 34 | ---@param line_end integer 35 | function vim.api.nvim_buf_clear_highlight(buffer, ns_id, line_start, line_end) end 36 | 37 | ---@param buffer Buffer 38 | ---@param ns_id integer 39 | ---@param line_start integer 40 | ---@param line_end integer 41 | function vim.api.nvim_buf_clear_namespace(buffer, ns_id, line_start, line_end) end 42 | 43 | ---@param buffer Buffer 44 | ---@param name string 45 | ---@param command any 46 | ---@param opts table 47 | function vim.api.nvim_buf_create_user_command(buffer, name, command, opts) end 48 | 49 | ---@param buffer Buffer 50 | ---@param ns_id integer 51 | ---@param id integer 52 | ---@return boolean 53 | function vim.api.nvim_buf_del_extmark(buffer, ns_id, id) end 54 | 55 | ---@param buffer Buffer 56 | ---@param mode string 57 | ---@param lhs string 58 | function vim.api.nvim_buf_del_keymap(buffer, mode, lhs) end 59 | 60 | ---@param buffer Buffer 61 | ---@param name string 62 | ---@return boolean 63 | function vim.api.nvim_buf_del_mark(buffer, name) end 64 | 65 | ---@param buffer Buffer 66 | ---@param name string 67 | function vim.api.nvim_buf_del_user_command(buffer, name) end 68 | 69 | ---@param buffer Buffer 70 | ---@param name string 71 | function vim.api.nvim_buf_del_var(buffer, name) end 72 | 73 | ---@param buffer Buffer 74 | ---@param opts table 75 | function vim.api.nvim_buf_delete(buffer, opts) end 76 | 77 | ---@param buffer Buffer 78 | ---@return boolean 79 | function vim.api.nvim_buf_detach(buffer) end 80 | 81 | ---@param buffer Buffer 82 | ---@return integer 83 | function vim.api.nvim_buf_get_changedtick(buffer) end 84 | 85 | ---@param buffer Buffer 86 | ---@param opts table 87 | ---@return table 88 | function vim.api.nvim_buf_get_commands(buffer, opts) end 89 | 90 | ---@param buffer Buffer 91 | ---@param ns_id integer 92 | ---@param id integer 93 | ---@param opts table 94 | ---@return integer[] 95 | function vim.api.nvim_buf_get_extmark_by_id(buffer, ns_id, id, opts) end 96 | 97 | ---@param buffer Buffer 98 | ---@param ns_id integer 99 | ---@param start any 100 | ---@param _end any 101 | ---@param opts table 102 | ---@return table 103 | function vim.api.nvim_buf_get_extmarks(buffer, ns_id, start, _end, opts) end 104 | 105 | ---@param buffer Buffer 106 | ---@param mode string 107 | ---@return table[] 108 | function vim.api.nvim_buf_get_keymap(buffer, mode) end 109 | 110 | ---@param buffer Buffer 111 | ---@param start integer 112 | ---@param _end integer 113 | ---@param strict_indexing boolean 114 | ---@return string[] 115 | function vim.api.nvim_buf_get_lines(buffer, start, _end, strict_indexing) end 116 | 117 | ---@param buffer Buffer 118 | ---@param name string 119 | ---@return { [1]: integer, [2]: integer } 120 | function vim.api.nvim_buf_get_mark(buffer, name) end 121 | 122 | ---@param buffer Buffer 123 | ---@return string 124 | function vim.api.nvim_buf_get_name(buffer) end 125 | 126 | ---@param buffer Buffer 127 | ---@return integer 128 | function vim.api.nvim_buf_get_number(buffer) end 129 | 130 | ---@param buffer Buffer 131 | ---@param index integer 132 | ---@return integer 133 | function vim.api.nvim_buf_get_offset(buffer, index) end 134 | 135 | ---@param buffer Buffer 136 | ---@param name string 137 | ---@return any 138 | function vim.api.nvim_buf_get_option(buffer, name) end 139 | 140 | ---@param buffer Buffer 141 | ---@param start_row integer 142 | ---@param start_col integer 143 | ---@param end_row integer 144 | ---@param end_col integer 145 | ---@param opts table 146 | ---@return string[] 147 | function vim.api.nvim_buf_get_text(buffer, start_row, start_col, end_row, end_col, opts) end 148 | 149 | ---@param buffer Buffer 150 | ---@param name string 151 | ---@return any 152 | function vim.api.nvim_buf_get_var(buffer, name) end 153 | 154 | ---@param buffer Buffer 155 | ---@return boolean 156 | function vim.api.nvim_buf_is_loaded(buffer) end 157 | 158 | ---@param buffer Buffer 159 | ---@return boolean 160 | function vim.api.nvim_buf_is_valid(buffer) end 161 | 162 | ---@param buffer Buffer 163 | ---@return integer 164 | function vim.api.nvim_buf_line_count(buffer) end 165 | 166 | ---@param buffer Buffer 167 | ---@param ns_id integer 168 | ---@param line integer 169 | ---@param col integer 170 | ---@param opts table 171 | ---@return integer 172 | function vim.api.nvim_buf_set_extmark(buffer, ns_id, line, col, opts) end 173 | 174 | ---@param buffer Buffer 175 | ---@param mode string 176 | ---@param lhs string 177 | ---@param rhs string 178 | ---@param opts table 179 | function vim.api.nvim_buf_set_keymap(buffer, mode, lhs, rhs, opts) end 180 | 181 | ---@param buffer Buffer 182 | ---@param start integer 183 | ---@param _end integer 184 | ---@param strict_indexing boolean 185 | ---@param replacement string[] 186 | function vim.api.nvim_buf_set_lines(buffer, start, _end, strict_indexing, replacement) end 187 | 188 | ---@param buffer Buffer 189 | ---@param name string 190 | ---@param line integer 191 | ---@param col integer 192 | ---@param opts table 193 | ---@return boolean 194 | function vim.api.nvim_buf_set_mark(buffer, name, line, col, opts) end 195 | 196 | ---@param buffer Buffer 197 | ---@param name string 198 | function vim.api.nvim_buf_set_name(buffer, name) end 199 | 200 | ---@param buffer Buffer 201 | ---@param name string 202 | ---@param value any 203 | function vim.api.nvim_buf_set_option(buffer, name, value) end 204 | 205 | ---@param buffer Buffer 206 | ---@param start_row integer 207 | ---@param start_col integer 208 | ---@param end_row integer 209 | ---@param end_col integer 210 | ---@param replacement string[] 211 | function vim.api.nvim_buf_set_text(buffer, start_row, start_col, end_row, end_col, replacement) end 212 | 213 | ---@param buffer Buffer 214 | ---@param name string 215 | ---@param value any 216 | function vim.api.nvim_buf_set_var(buffer, name, value) end 217 | 218 | ---@param buffer Buffer 219 | ---@param src_id integer 220 | ---@param line integer 221 | ---@param chunks table 222 | ---@param opts table 223 | ---@return integer 224 | function vim.api.nvim_buf_set_virtual_text(buffer, src_id, line, chunks, opts) end 225 | 226 | ---@param calls table 227 | ---@return table 228 | function vim.api.nvim_call_atomic(calls) end 229 | 230 | ---@param dict any 231 | ---@param fn string 232 | ---@param args table 233 | ---@return any 234 | function vim.api.nvim_call_dict_function(dict, fn, args) end 235 | 236 | ---@param fn string 237 | ---@param args table 238 | ---@return any 239 | function vim.api.nvim_call_function(fn, args) end 240 | 241 | ---@param chan integer 242 | ---@param data string 243 | function vim.api.nvim_chan_send(chan, data) end 244 | 245 | ---@param opts table 246 | function vim.api.nvim_clear_autocmds(opts) end 247 | 248 | ---@param cmd table 249 | ---@param opts table 250 | ---@return string 251 | function vim.api.nvim_cmd(cmd, opts) end 252 | 253 | ---@param command string 254 | function vim.api.nvim_command(command) end 255 | 256 | ---@param command string 257 | ---@return string 258 | function vim.api.nvim_command_output(command) end 259 | 260 | ---@param name string 261 | ---@param opts table 262 | ---@return integer 263 | function vim.api.nvim_create_augroup(name, opts) end 264 | 265 | ---@param event any 266 | ---@param opts table 267 | ---@return integer 268 | function vim.api.nvim_create_autocmd(event, opts) end 269 | 270 | ---@param listed boolean 271 | ---@param scratch boolean 272 | ---@return Buffer 273 | function vim.api.nvim_create_buf(listed, scratch) end 274 | 275 | ---@param name string 276 | ---@return integer 277 | function vim.api.nvim_create_namespace(name) end 278 | 279 | ---@param name string 280 | ---@param command any 281 | ---@param opts table 282 | function vim.api.nvim_create_user_command(name, command, opts) end 283 | 284 | ---@param id integer 285 | function vim.api.nvim_del_augroup_by_id(id) end 286 | 287 | ---@param name string 288 | function vim.api.nvim_del_augroup_by_name(name) end 289 | 290 | ---@param id integer 291 | function vim.api.nvim_del_autocmd(id) end 292 | 293 | function vim.api.nvim_del_current_line() end 294 | 295 | ---@param mode string 296 | ---@param lhs string 297 | function vim.api.nvim_del_keymap(mode, lhs) end 298 | 299 | ---@param name string 300 | ---@return boolean 301 | function vim.api.nvim_del_mark(name) end 302 | 303 | ---@param name string 304 | function vim.api.nvim_del_user_command(name) end 305 | 306 | ---@param name string 307 | function vim.api.nvim_del_var(name) end 308 | 309 | ---@param chunks table 310 | ---@param history boolean 311 | ---@param opts table 312 | function vim.api.nvim_echo(chunks, history, opts) end 313 | 314 | ---@param str string 315 | function vim.api.nvim_err_write(str) end 316 | 317 | ---@param str string 318 | function vim.api.nvim_err_writeln(str) end 319 | 320 | ---@param expr string 321 | ---@return any 322 | function vim.api.nvim_eval(expr) end 323 | 324 | ---@param str string 325 | ---@param opts table 326 | ---@return table 327 | function vim.api.nvim_eval_statusline(str, opts) end 328 | 329 | ---@param src string 330 | ---@param output boolean 331 | ---@return string 332 | function vim.api.nvim_exec(src, output) end 333 | 334 | ---@param src string 335 | ---@param opts table 336 | ---@return table 337 | function vim.api.nvim_exec2(src, opts) end 338 | 339 | ---@param event any 340 | ---@param opts table 341 | function vim.api.nvim_exec_autocmds(event, opts) end 342 | 343 | ---@param code string 344 | ---@param args table 345 | ---@return any 346 | function vim.api.nvim_exec_lua(code, args) end 347 | 348 | ---@param code string 349 | ---@param args table 350 | ---@return any 351 | function vim.api.nvim_execute_lua(code, args) end 352 | 353 | ---@param keys string 354 | ---@param mode string 355 | ---@param escape_ks boolean 356 | function vim.api.nvim_feedkeys(keys, mode, escape_ks) end 357 | 358 | ---@return table 359 | function vim.api.nvim_get_all_options_info() end 360 | 361 | ---@return table 362 | function vim.api.nvim_get_api_info() end 363 | 364 | ---@param opts table 365 | ---@return table 366 | function vim.api.nvim_get_autocmds(opts) end 367 | 368 | ---@param chan integer 369 | ---@return table 370 | function vim.api.nvim_get_chan_info(chan) end 371 | 372 | ---@param name string 373 | ---@return integer 374 | function vim.api.nvim_get_color_by_name(name) end 375 | 376 | ---@return table 377 | function vim.api.nvim_get_color_map() end 378 | 379 | ---@param opts table 380 | ---@return table 381 | function vim.api.nvim_get_commands(opts) end 382 | 383 | ---@param opts table 384 | ---@return table 385 | function vim.api.nvim_get_context(opts) end 386 | 387 | ---@return Buffer 388 | function vim.api.nvim_get_current_buf() end 389 | 390 | ---@return string 391 | function vim.api.nvim_get_current_line() end 392 | 393 | ---@return Tabpage 394 | function vim.api.nvim_get_current_tabpage() end 395 | 396 | ---@return Window 397 | function vim.api.nvim_get_current_win() end 398 | 399 | ---@param ns_id integer 400 | ---@param opts table 401 | ---@return table 402 | function vim.api.nvim_get_hl(ns_id, opts) end 403 | 404 | ---@param hl_id integer 405 | ---@param rgb boolean 406 | ---@return table 407 | function vim.api.nvim_get_hl_by_id(hl_id, rgb) end 408 | 409 | ---@param name string 410 | ---@param rgb boolean 411 | ---@return table 412 | function vim.api.nvim_get_hl_by_name(name, rgb) end 413 | 414 | ---@param name string 415 | ---@return integer 416 | function vim.api.nvim_get_hl_id_by_name(name) end 417 | 418 | ---@param opts table 419 | ---@return integer 420 | function vim.api.nvim_get_hl_ns(opts) end 421 | 422 | ---@param mode string 423 | ---@return table[] 424 | function vim.api.nvim_get_keymap(mode) end 425 | 426 | ---@param name string 427 | ---@param opts table 428 | ---@return table 429 | function vim.api.nvim_get_mark(name, opts) end 430 | 431 | ---@return table 432 | function vim.api.nvim_get_mode() end 433 | 434 | ---@return table 435 | function vim.api.nvim_get_namespaces() end 436 | 437 | ---@param name string 438 | ---@return any 439 | function vim.api.nvim_get_option(name) end 440 | 441 | ---@param name string 442 | ---@return table 443 | function vim.api.nvim_get_option_info(name) end 444 | 445 | ---@param name string 446 | ---@param opts table 447 | ---@return table 448 | function vim.api.nvim_get_option_info2(name, opts) end 449 | 450 | ---@param name string 451 | ---@param opts table 452 | ---@return any 453 | function vim.api.nvim_get_option_value(name, opts) end 454 | 455 | ---@param pid integer 456 | ---@return any 457 | function vim.api.nvim_get_proc(pid) end 458 | 459 | ---@param pid integer 460 | ---@return table 461 | function vim.api.nvim_get_proc_children(pid) end 462 | 463 | ---@param name string 464 | ---@param all boolean 465 | ---@return string[] 466 | function vim.api.nvim_get_runtime_file(name, all) end 467 | 468 | ---@param name string 469 | ---@return any 470 | function vim.api.nvim_get_var(name) end 471 | 472 | ---@param name string 473 | ---@return any 474 | function vim.api.nvim_get_vvar(name) end 475 | 476 | ---@param keys string 477 | ---@return integer 478 | function vim.api.nvim_input(keys) end 479 | 480 | ---@param button string 481 | ---@param action string 482 | ---@param modifier string 483 | ---@param grid integer 484 | ---@param row integer 485 | ---@param col integer 486 | function vim.api.nvim_input_mouse(button, action, modifier, grid, row, col) end 487 | 488 | ---@return Buffer[] 489 | function vim.api.nvim_list_bufs() end 490 | 491 | ---@return table 492 | function vim.api.nvim_list_chans() end 493 | 494 | ---@return string[] 495 | function vim.api.nvim_list_runtime_paths() end 496 | 497 | ---@return Tabpage[] 498 | function vim.api.nvim_list_tabpages() end 499 | 500 | ---@return table 501 | function vim.api.nvim_list_uis() end 502 | 503 | ---@return Window[] 504 | function vim.api.nvim_list_wins() end 505 | 506 | ---@param dict table 507 | ---@return any 508 | function vim.api.nvim_load_context(dict) end 509 | 510 | ---@param msg string 511 | ---@param log_level integer 512 | ---@param opts table 513 | ---@return any 514 | function vim.api.nvim_notify(msg, log_level, opts) end 515 | 516 | ---@param buffer Buffer 517 | ---@param opts table 518 | ---@return integer 519 | function vim.api.nvim_open_term(buffer, opts) end 520 | 521 | ---@param buffer Buffer 522 | ---@param enter boolean 523 | ---@param config table 524 | ---@return Window 525 | function vim.api.nvim_open_win(buffer, enter, config) end 526 | 527 | ---@param str string 528 | function vim.api.nvim_out_write(str) end 529 | 530 | ---@param str string 531 | ---@param opts table 532 | ---@return table 533 | function vim.api.nvim_parse_cmd(str, opts) end 534 | 535 | ---@param expr string 536 | ---@param flags string 537 | ---@param highlight boolean 538 | ---@return table 539 | function vim.api.nvim_parse_expression(expr, flags, highlight) end 540 | 541 | ---@param data string 542 | ---@param crlf boolean 543 | ---@param phase integer 544 | ---@return boolean 545 | function vim.api.nvim_paste(data, crlf, phase) end 546 | 547 | ---@param lines string[] 548 | ---@param type string 549 | ---@param after boolean 550 | ---@param follow boolean 551 | function vim.api.nvim_put(lines, type, after, follow) end 552 | 553 | ---@param str string 554 | ---@param from_part boolean 555 | ---@param do_lt boolean 556 | ---@param special boolean 557 | ---@return string 558 | function vim.api.nvim_replace_termcodes(str, from_part, do_lt, special) end 559 | 560 | ---@param item integer 561 | ---@param insert boolean 562 | ---@param finish boolean 563 | ---@param opts table 564 | function vim.api.nvim_select_popupmenu_item(item, insert, finish, opts) end 565 | 566 | ---@param name string 567 | ---@param version table 568 | ---@param type string 569 | ---@param methods table 570 | ---@param attributes table 571 | function vim.api.nvim_set_client_info(name, version, type, methods, attributes) end 572 | 573 | ---@param buffer Buffer 574 | function vim.api.nvim_set_current_buf(buffer) end 575 | 576 | ---@param dir string 577 | function vim.api.nvim_set_current_dir(dir) end 578 | 579 | ---@param line string 580 | function vim.api.nvim_set_current_line(line) end 581 | 582 | ---@param tabpage Tabpage 583 | function vim.api.nvim_set_current_tabpage(tabpage) end 584 | 585 | ---@param window Window 586 | function vim.api.nvim_set_current_win(window) end 587 | 588 | ---@param ns_id integer 589 | ---@param opts table 590 | function vim.api.nvim_set_decoration_provider(ns_id, opts) end 591 | 592 | ---@param ns_id integer 593 | ---@param name string 594 | ---@param val table 595 | function vim.api.nvim_set_hl(ns_id, name, val) end 596 | 597 | ---@param ns_id integer 598 | function vim.api.nvim_set_hl_ns(ns_id) end 599 | 600 | ---@param ns_id integer 601 | function vim.api.nvim_set_hl_ns_fast(ns_id) end 602 | 603 | ---@param mode string 604 | ---@param lhs string 605 | ---@param rhs string 606 | ---@param opts table 607 | function vim.api.nvim_set_keymap(mode, lhs, rhs, opts) end 608 | 609 | ---@param name string 610 | ---@param value any 611 | function vim.api.nvim_set_option(name, value) end 612 | 613 | ---@param name string 614 | ---@param value any 615 | ---@param opts table 616 | function vim.api.nvim_set_option_value(name, value, opts) end 617 | 618 | ---@param name string 619 | ---@param value any 620 | function vim.api.nvim_set_var(name, value) end 621 | 622 | ---@param name string 623 | ---@param value any 624 | function vim.api.nvim_set_vvar(name, value) end 625 | 626 | ---@param text string 627 | ---@return integer 628 | function vim.api.nvim_strwidth(text) end 629 | 630 | ---@param event string 631 | function vim.api.nvim_subscribe(event) end 632 | 633 | ---@param tabpage Tabpage 634 | ---@param name string 635 | function vim.api.nvim_tabpage_del_var(tabpage, name) end 636 | 637 | ---@param tabpage Tabpage 638 | ---@return integer 639 | function vim.api.nvim_tabpage_get_number(tabpage) end 640 | 641 | ---@param tabpage Tabpage 642 | ---@param name string 643 | ---@return any 644 | function vim.api.nvim_tabpage_get_var(tabpage, name) end 645 | 646 | ---@param tabpage Tabpage 647 | ---@return Window 648 | function vim.api.nvim_tabpage_get_win(tabpage) end 649 | 650 | ---@param tabpage Tabpage 651 | ---@return boolean 652 | function vim.api.nvim_tabpage_is_valid(tabpage) end 653 | 654 | ---@param tabpage Tabpage 655 | ---@return Window[] 656 | function vim.api.nvim_tabpage_list_wins(tabpage) end 657 | 658 | ---@param tabpage Tabpage 659 | ---@param name string 660 | ---@param value any 661 | function vim.api.nvim_tabpage_set_var(tabpage, name, value) end 662 | 663 | ---@param tabpage Tabpage 664 | ---@param win Window 665 | function vim.api.nvim_tabpage_set_win(tabpage, win) end 666 | 667 | ---@param width integer 668 | ---@param height integer 669 | ---@param options table 670 | function vim.api.nvim_ui_attach(width, height, options) end 671 | 672 | function vim.api.nvim_ui_detach() end 673 | 674 | ---@param width number 675 | ---@param height number 676 | ---@param row number 677 | ---@param col number 678 | function vim.api.nvim_ui_pum_set_bounds(width, height, row, col) end 679 | 680 | ---@param height integer 681 | function vim.api.nvim_ui_pum_set_height(height) end 682 | 683 | ---@param gained boolean 684 | function vim.api.nvim_ui_set_focus(gained) end 685 | 686 | ---@param name string 687 | ---@param value any 688 | function vim.api.nvim_ui_set_option(name, value) end 689 | 690 | ---@param event string 691 | ---@param value any 692 | function vim.api.nvim_ui_term_event(event, value) end 693 | 694 | ---@param width integer 695 | ---@param height integer 696 | function vim.api.nvim_ui_try_resize(width, height) end 697 | 698 | ---@param grid integer 699 | ---@param width integer 700 | ---@param height integer 701 | function vim.api.nvim_ui_try_resize_grid(grid, width, height) end 702 | 703 | ---@param event string 704 | function vim.api.nvim_unsubscribe(event) end 705 | 706 | ---@param window Window 707 | ---@param fun function 708 | ---@return any 709 | function vim.api.nvim_win_call(window, fun) end 710 | 711 | ---@param window Window 712 | ---@param force boolean 713 | function vim.api.nvim_win_close(window, force) end 714 | 715 | ---@param window Window 716 | ---@param name string 717 | function vim.api.nvim_win_del_var(window, name) end 718 | 719 | ---@param window Window 720 | ---@return Buffer 721 | function vim.api.nvim_win_get_buf(window) end 722 | 723 | ---@param window Window 724 | ---@return table 725 | function vim.api.nvim_win_get_config(window) end 726 | 727 | ---@param window Window 728 | ---@return { [1]: integer, [2]: integer } 729 | function vim.api.nvim_win_get_cursor(window) end 730 | 731 | ---@param window Window 732 | ---@return integer 733 | function vim.api.nvim_win_get_height(window) end 734 | 735 | ---@param window Window 736 | ---@return integer 737 | function vim.api.nvim_win_get_number(window) end 738 | 739 | ---@param window Window 740 | ---@param name string 741 | ---@return any 742 | function vim.api.nvim_win_get_option(window, name) end 743 | 744 | ---@param window Window 745 | ---@return { [1]: integer, [2]: integer } 746 | function vim.api.nvim_win_get_position(window) end 747 | 748 | ---@param window Window 749 | ---@return Tabpage 750 | function vim.api.nvim_win_get_tabpage(window) end 751 | 752 | ---@param window Window 753 | ---@param name string 754 | ---@return any 755 | function vim.api.nvim_win_get_var(window, name) end 756 | 757 | ---@param window Window 758 | ---@return integer 759 | function vim.api.nvim_win_get_width(window) end 760 | 761 | ---@param window Window 762 | function vim.api.nvim_win_hide(window) end 763 | 764 | ---@param window Window 765 | ---@return boolean 766 | function vim.api.nvim_win_is_valid(window) end 767 | 768 | ---@param window Window 769 | ---@param buffer Buffer 770 | function vim.api.nvim_win_set_buf(window, buffer) end 771 | 772 | ---@param window Window 773 | ---@param config table 774 | function vim.api.nvim_win_set_config(window, config) end 775 | 776 | ---@param window Window 777 | ---@param pos { [1]: integer, [2]: integer } 778 | function vim.api.nvim_win_set_cursor(window, pos) end 779 | 780 | ---@param window Window 781 | ---@param height integer 782 | function vim.api.nvim_win_set_height(window, height) end 783 | 784 | ---@param window Window 785 | ---@param ns_id integer 786 | function vim.api.nvim_win_set_hl_ns(window, ns_id) end 787 | 788 | ---@param window Window 789 | ---@param name string 790 | ---@param value any 791 | function vim.api.nvim_win_set_option(window, name, value) end 792 | 793 | ---@param window Window 794 | ---@param name string 795 | ---@param value any 796 | function vim.api.nvim_win_set_var(window, name, value) end 797 | 798 | ---@param window Window 799 | ---@param width integer 800 | function vim.api.nvim_win_set_width(window, width) end 801 | 802 | ---@param window Window 803 | ---@param opts table 804 | ---@return table 805 | function vim.api.nvim_win_text_height(window, opts) end 806 | -------------------------------------------------------------------------------- /nvim/library/vim.fn.lua: -------------------------------------------------------------------------------- 1 | ---@meta 2 | 3 | 4 | ---@return any 5 | function vim.fn.abs(expr) end 6 | 7 | ---@return any 8 | function vim.fn.acos(expr) end 9 | 10 | ---@return any 11 | function vim.fn.add(object, item) end 12 | 13 | ---@return any 14 | vim.fn["and"] = function(expr, expr) end 15 | 16 | ---@return any 17 | function vim.fn.append(lnum, text) end 18 | 19 | ---@return any 20 | function vim.fn.appendbufline(expr, lnum, text) end 21 | 22 | ---@return any 23 | function vim.fn.argc(winid) end 24 | 25 | ---@return any 26 | function vim.fn.arglistid(winnr, tabnr) end 27 | 28 | ---@return any 29 | function vim.fn.argv(nr, winid) end 30 | 31 | ---@return any 32 | function vim.fn.asin(expr) end 33 | 34 | ---@return any 35 | function vim.fn.assert_beeps(cmd) end 36 | 37 | ---@return any 38 | function vim.fn.assert_equal(exp, act, msg) end 39 | 40 | ---@return any 41 | function vim.fn.assert_equalfile(fname_one, fname_two, msg) end 42 | 43 | ---@return any 44 | function vim.fn.assert_exception(error, msg) end 45 | 46 | ---@return any 47 | function vim.fn.assert_fails(cmd, error) end 48 | 49 | ---@return any 50 | function vim.fn.assert_false(actual, msg) end 51 | 52 | ---@return any 53 | function vim.fn.assert_inrange(lower, upper, actual, msg) end 54 | 55 | ---@return any 56 | function vim.fn.assert_match(pat, text, msg) end 57 | 58 | ---@return any 59 | function vim.fn.assert_nobeep(cmd) end 60 | 61 | ---@return any 62 | function vim.fn.assert_notequal(exp, act, msg) end 63 | 64 | ---@return any 65 | function vim.fn.assert_notmatch(pat, text, msg) end 66 | 67 | ---@return any 68 | function vim.fn.assert_report(msg) end 69 | 70 | ---@return any 71 | function vim.fn.assert_true(actual, msg) end 72 | 73 | ---@return any 74 | function vim.fn.atan(expr) end 75 | 76 | ---@return any 77 | function vim.fn.atan2(expr1, expr2) end 78 | 79 | ---@return any 80 | function vim.fn.blob2list(blob) end 81 | 82 | ---@return any 83 | function vim.fn.browse(save, title, initdir, default) end 84 | 85 | ---@return any 86 | function vim.fn.browsedir(title, initdir) end 87 | 88 | ---@return any 89 | function vim.fn.bufadd(name) end 90 | 91 | ---@return any 92 | function vim.fn.bufexists(buf) end 93 | 94 | ---@return any 95 | function vim.fn.buflisted(buf) end 96 | 97 | ---@return any 98 | function vim.fn.bufload(buf) end 99 | 100 | ---@return any 101 | function vim.fn.bufloaded(buf) end 102 | 103 | ---@return any 104 | function vim.fn.bufname(buf) end 105 | 106 | ---@return any 107 | function vim.fn.bufnr(buf, create) end 108 | 109 | ---@return any 110 | function vim.fn.bufwinid(buf) end 111 | 112 | ---@return any 113 | function vim.fn.bufwinnr(buf) end 114 | 115 | ---@return any 116 | function vim.fn.byte2line(byte) end 117 | 118 | ---@return any 119 | function vim.fn.byteidx(expr, nr, utf16) end 120 | 121 | ---@return any 122 | function vim.fn.byteidxcomp(expr, nr, utf16) end 123 | 124 | ---@return any 125 | function vim.fn.call(func, arglist, dict) end 126 | 127 | ---@return any 128 | function vim.fn.ceil(expr) end 129 | 130 | ---@return any 131 | function vim.fn.chanclose(id, stream) end 132 | 133 | ---@return any 134 | function vim.fn.chansend(id, data) end 135 | 136 | ---@return any 137 | function vim.fn.char2nr(expr, utf8) end 138 | 139 | ---@return any 140 | function vim.fn.charclass(string) end 141 | 142 | ---@return any 143 | function vim.fn.charcol(expr, winid) end 144 | 145 | ---@return any 146 | function vim.fn.charidx(string, idx, countcc, utf16) end 147 | 148 | ---@return any 149 | function vim.fn.chdir(dir) end 150 | 151 | ---@return any 152 | function vim.fn.cindent(lnum) end 153 | 154 | ---@return any 155 | function vim.fn.clearmatches(win) end 156 | 157 | ---@return any 158 | function vim.fn.col(expr, winid) end 159 | 160 | ---@return any 161 | function vim.fn.complete(startcol, matches) end 162 | 163 | ---@return any 164 | function vim.fn.complete_add(expr) end 165 | 166 | ---@return any 167 | function vim.fn.complete_info(what) end 168 | 169 | ---@return any 170 | function vim.fn.confirm(msg, choices, default, type) end 171 | 172 | ---@return any 173 | function vim.fn.copy(expr) end 174 | 175 | ---@return any 176 | function vim.fn.cos(expr) end 177 | 178 | ---@return any 179 | function vim.fn.cosh(expr) end 180 | 181 | ---@return any 182 | function vim.fn.count(comp, expr, ic, start) end 183 | 184 | ---@return any 185 | function vim.fn.ctxget(index) end 186 | 187 | ---@return any 188 | function vim.fn.ctxpush(types) end 189 | 190 | ---@return any 191 | function vim.fn.ctxset(context, index) end 192 | 193 | ---@return any 194 | function vim.fn.cursor(lnum, col, off) end 195 | 196 | ---@return any 197 | function vim.fn.cursor(list) end 198 | 199 | ---@return any 200 | function vim.fn.debugbreak(pid) end 201 | 202 | ---@return any 203 | function vim.fn.deepcopy(expr, noref) end 204 | 205 | ---@return any 206 | function vim.fn.delete(fname, flags) end 207 | 208 | ---@return any 209 | function vim.fn.deletebufline(buf, first, last) end 210 | 211 | ---@return any 212 | function vim.fn.dictwatcheradd(dict, pattern, callback) end 213 | 214 | ---@return any 215 | function vim.fn.dictwatcherdel(dict, pattern, callback) end 216 | 217 | ---@return any 218 | function vim.fn.diff_filler(lnum) end 219 | 220 | ---@return any 221 | function vim.fn.diff_hlID(lnum, col) end 222 | 223 | ---@return any 224 | function vim.fn.digraph_get(chars) end 225 | 226 | ---@return any 227 | function vim.fn.digraph_getlist(listall) end 228 | 229 | ---@return any 230 | function vim.fn.digraph_set(chars, digraph) end 231 | 232 | ---@return any 233 | function vim.fn.digraph_setlist(digraphlist) end 234 | 235 | ---@return any 236 | function vim.fn.empty(expr) end 237 | 238 | ---@return any 239 | function vim.fn.escape(string, chars) end 240 | 241 | ---@return any 242 | function vim.fn.eval(string) end 243 | 244 | ---@return any 245 | function vim.fn.executable(expr) end 246 | 247 | ---@return any 248 | function vim.fn.execute(command) end 249 | 250 | ---@return any 251 | function vim.fn.exepath(expr) end 252 | 253 | ---@return any 254 | function vim.fn.exists(expr) end 255 | 256 | ---@return any 257 | function vim.fn.exp(expr) end 258 | 259 | ---@return any 260 | function vim.fn.expand(expr, nosuf, list) end 261 | 262 | ---@return any 263 | function vim.fn.expandcmd(string, options) end 264 | 265 | ---@return any 266 | function vim.fn.extend(expr1, expr2, expr3) end 267 | 268 | ---@return any 269 | function vim.fn.extendnew(expr1, expr2, expr3) end 270 | 271 | ---@return any 272 | function vim.fn.feedkeys(string, mode) end 273 | 274 | ---@return any 275 | function vim.fn.filereadable(file) end 276 | 277 | ---@return any 278 | function vim.fn.filewritable(file) end 279 | 280 | ---@return any 281 | function vim.fn.filter(expr1, expr2) end 282 | 283 | ---@return any 284 | function vim.fn.finddir(name, path, count) end 285 | 286 | ---@return any 287 | function vim.fn.findfile(name, path, count) end 288 | 289 | ---@return any 290 | function vim.fn.flatten(list, maxdepth) end 291 | 292 | ---@return any 293 | function vim.fn.flattennew(list, maxdepth) end 294 | 295 | ---@return any 296 | function vim.fn.float2nr(expr) end 297 | 298 | ---@return any 299 | function vim.fn.floor(expr) end 300 | 301 | ---@return any 302 | function vim.fn.fmod(expr1, expr2) end 303 | 304 | ---@return any 305 | function vim.fn.fnameescape(fname) end 306 | 307 | ---@return any 308 | function vim.fn.fnamemodify(fname, mods) end 309 | 310 | ---@return any 311 | function vim.fn.foldclosed(lnum) end 312 | 313 | ---@return any 314 | function vim.fn.foldclosedend(lnum) end 315 | 316 | ---@return any 317 | function vim.fn.foldlevel(lnum) end 318 | 319 | ---@return any 320 | function vim.fn.foldtextresult(lnum) end 321 | 322 | ---@return any 323 | function vim.fn.fullcommand(name) end 324 | 325 | ---@return any 326 | function vim.fn.funcref(name, arglist, dict) end 327 | 328 | ---@return any 329 | vim.fn["function"] = function(name, arglist, dict) end 330 | 331 | ---@return any 332 | function vim.fn.garbagecollect(atexit) end 333 | 334 | ---@return any 335 | function vim.fn.get(list, idx, def) end 336 | 337 | ---@return any 338 | function vim.fn.get(dict, key, def) end 339 | 340 | ---@return any 341 | function vim.fn.get(func, what) end 342 | 343 | ---@return any 344 | function vim.fn.getbufinfo(buf) end 345 | 346 | ---@return any 347 | function vim.fn.getbufline(buf, lnum, end_) end 348 | 349 | ---@return any 350 | function vim.fn.getbufoneline(buf, lnum) end 351 | 352 | ---@return any 353 | function vim.fn.getbufvar(buf, varname, def) end 354 | 355 | ---@return any 356 | function vim.fn.getchangelist(buf) end 357 | 358 | ---@return any 359 | function vim.fn.getchar(expr) end 360 | 361 | ---@return any 362 | function vim.fn.getcharpos(expr) end 363 | 364 | ---@return any 365 | function vim.fn.getcharstr(expr) end 366 | 367 | ---@return any 368 | function vim.fn.getcompletion(pat, type, filtered) end 369 | 370 | ---@return any 371 | function vim.fn.getcurpos(winnr) end 372 | 373 | ---@return any 374 | function vim.fn.getcursorcharpos(winnr) end 375 | 376 | ---@return any 377 | function vim.fn.getcwd(winnr, tabnr) end 378 | 379 | ---@return any 380 | function vim.fn.getenv(name) end 381 | 382 | ---@return any 383 | function vim.fn.getfontname(name) end 384 | 385 | ---@return any 386 | function vim.fn.getfperm(fname) end 387 | 388 | ---@return any 389 | function vim.fn.getfsize(fname) end 390 | 391 | ---@return any 392 | function vim.fn.getftime(fname) end 393 | 394 | ---@return any 395 | function vim.fn.getftype(fname) end 396 | 397 | ---@return any 398 | function vim.fn.getjumplist(winnr, tabnr) end 399 | 400 | ---@return any 401 | function vim.fn.getline(lnum) end 402 | 403 | ---@return any 404 | function vim.fn.getline(lnum, end_) end 405 | 406 | ---@return any 407 | function vim.fn.getloclist(nr) end 408 | 409 | ---@return any 410 | function vim.fn.getloclist(nr, what) end 411 | 412 | ---@return any 413 | function vim.fn.getmarklist(buf) end 414 | 415 | ---@return any 416 | function vim.fn.getmatches(win) end 417 | 418 | ---@return any 419 | function vim.fn.getpos(expr) end 420 | 421 | ---@return any 422 | function vim.fn.getqflist(what) end 423 | 424 | ---@return any 425 | function vim.fn.getreginfo(regname) end 426 | 427 | ---@return any 428 | function vim.fn.getregtype(regname) end 429 | 430 | ---@return any 431 | function vim.fn.getscriptinfo(opts) end 432 | 433 | ---@return any 434 | function vim.fn.gettabinfo(expr) end 435 | 436 | ---@return any 437 | function vim.fn.gettabvar(nr, varname, def) end 438 | 439 | ---@return any 440 | function vim.fn.gettabwinvar(tabnr, winnr, name, def) end 441 | 442 | ---@return any 443 | function vim.fn.gettagstack(nr) end 444 | 445 | ---@return any 446 | function vim.fn.gettext(text) end 447 | 448 | ---@return any 449 | function vim.fn.getwininfo(winid) end 450 | 451 | ---@return any 452 | function vim.fn.getwinpos(timeout) end 453 | 454 | ---@return any 455 | function vim.fn.getwinvar(nr, varname, def) end 456 | 457 | ---@return any 458 | function vim.fn.glob(expr, nosuf, list, alllinks) end 459 | 460 | ---@return any 461 | function vim.fn.glob2regpat(expr) end 462 | 463 | ---@return any 464 | function vim.fn.globpath(path, expr, nosuf, list, alllinks) end 465 | 466 | ---@return any 467 | function vim.fn.has(feature) end 468 | 469 | ---@return any 470 | function vim.fn.has_key(dict, key) end 471 | 472 | ---@return any 473 | function vim.fn.haslocaldir(winnr, tabnr) end 474 | 475 | ---@return any 476 | function vim.fn.hasmapto(what, mode, abbr) end 477 | 478 | ---@return any 479 | function vim.fn.histadd(history, item) end 480 | 481 | ---@return any 482 | function vim.fn.histdel(history, item) end 483 | 484 | ---@return any 485 | function vim.fn.histget(history, index) end 486 | 487 | ---@return any 488 | function vim.fn.histnr(history) end 489 | 490 | ---@return any 491 | function vim.fn.hlID(name) end 492 | 493 | ---@return any 494 | function vim.fn.hlexists(name) end 495 | 496 | ---@return any 497 | function vim.fn.iconv(expr, from, to) end 498 | 499 | ---@return any 500 | function vim.fn.indent(lnum) end 501 | 502 | ---@return any 503 | function vim.fn.index(object, expr, start, ic) end 504 | 505 | ---@return any 506 | function vim.fn.indexof(object, expr, opts) end 507 | 508 | ---@return any 509 | function vim.fn.input(prompt, text, completion) end 510 | 511 | ---@return any 512 | function vim.fn.inputlist(textlist) end 513 | 514 | ---@return any 515 | function vim.fn.inputsecret(prompt, text) end 516 | 517 | ---@return any 518 | function vim.fn.insert(object, item, idx) end 519 | 520 | ---@return any 521 | function vim.fn.invert(expr) end 522 | 523 | ---@return any 524 | function vim.fn.isdirectory(directory) end 525 | 526 | ---@return any 527 | function vim.fn.isinf(expr) end 528 | 529 | ---@return any 530 | function vim.fn.islocked(expr) end 531 | 532 | ---@return any 533 | function vim.fn.isnan(expr) end 534 | 535 | ---@return any 536 | function vim.fn.id(expr) end 537 | 538 | ---@return any 539 | function vim.fn.items(dict) end 540 | 541 | ---@return any 542 | function vim.fn.jobpid(id) end 543 | 544 | ---@return any 545 | function vim.fn.jobresize(id, width, height) end 546 | 547 | ---@return any 548 | function vim.fn.jobstart(cmd, opts) end 549 | 550 | ---@return any 551 | function vim.fn.jobstop(id) end 552 | 553 | ---@return any 554 | function vim.fn.jobwait(ids, timeout) end 555 | 556 | ---@return any 557 | function vim.fn.join(list, sep) end 558 | 559 | ---@return any 560 | function vim.fn.json_decode(expr) end 561 | 562 | ---@return any 563 | function vim.fn.json_encode(expr) end 564 | 565 | ---@return any 566 | function vim.fn.keys(dict) end 567 | 568 | ---@return any 569 | function vim.fn.keytrans(string) end 570 | 571 | ---@return any 572 | function vim.fn.len(expr) end 573 | 574 | ---@return any 575 | function vim.fn.libcall(lib, func, arg) end 576 | 577 | ---@return any 578 | function vim.fn.libcallnr(lib, func, arg) end 579 | 580 | ---@return any 581 | function vim.fn.line(expr, winid) end 582 | 583 | ---@return any 584 | function vim.fn.line2byte(lnum) end 585 | 586 | ---@return any 587 | function vim.fn.lispindent(lnum) end 588 | 589 | ---@return any 590 | function vim.fn.list2blob(list) end 591 | 592 | ---@return any 593 | function vim.fn.list2str(list, utf8) end 594 | 595 | ---@return any 596 | function vim.fn.log(expr) end 597 | 598 | ---@return any 599 | function vim.fn.log10(expr) end 600 | 601 | ---@return any 602 | function vim.fn.luaeval(expr, expr) end 603 | 604 | ---@return any 605 | function vim.fn.map(expr1, expr2) end 606 | 607 | ---@return any 608 | function vim.fn.maparg(name, mode, abbr, dict) end 609 | 610 | ---@return any 611 | function vim.fn.mapcheck(name, mode, abbr) end 612 | 613 | ---@return any 614 | function vim.fn.mapset(mode, abbr, dict) end 615 | 616 | ---@return any 617 | function vim.fn.match(expr, pat, start, count) end 618 | 619 | ---@return any 620 | function vim.fn.matchadd(group, pattern, priority, id, dict) end 621 | 622 | ---@return any 623 | function vim.fn.matchaddpos(group, pos, priority, id, dict) end 624 | 625 | ---@return any 626 | function vim.fn.matcharg(nr) end 627 | 628 | ---@return any 629 | function vim.fn.matchdelete(id, win) end 630 | 631 | ---@return any 632 | function vim.fn.matchend(expr, pat, start, count) end 633 | 634 | ---@return any 635 | function vim.fn.matchfuzzy(list, str, dict) end 636 | 637 | ---@return any 638 | function vim.fn.matchfuzzypos(list, str, dict) end 639 | 640 | ---@return any 641 | function vim.fn.matchlist(expr, pat, start, count) end 642 | 643 | ---@return any 644 | function vim.fn.matchstr(expr, pat, start, count) end 645 | 646 | ---@return any 647 | function vim.fn.matchstrpos(expr, pat, start, count) end 648 | 649 | ---@return any 650 | function vim.fn.max(expr) end 651 | 652 | ---@return any 653 | function vim.fn.menu_get(path, modes) end 654 | 655 | ---@return any 656 | function vim.fn.menu_info(name, mode) end 657 | 658 | ---@return any 659 | function vim.fn.min(expr) end 660 | 661 | ---@return any 662 | function vim.fn.mkdir(name, flags, prot) end 663 | 664 | ---@return any 665 | function vim.fn.mode(expr) end 666 | 667 | ---@return any 668 | function vim.fn.msgpackdump(list, type) end 669 | 670 | ---@return any 671 | function vim.fn.msgpackparse(data) end 672 | 673 | ---@return any 674 | function vim.fn.nextnonblank(lnum) end 675 | 676 | ---@return any 677 | function vim.fn.nr2char(expr, utf8) end 678 | 679 | ---@return any 680 | vim.fn["or"] = function(expr, expr) end 681 | 682 | ---@return any 683 | function vim.fn.pathshorten(expr, len) end 684 | 685 | ---@return any 686 | function vim.fn.perleval(expr) end 687 | 688 | ---@return any 689 | function vim.fn.pow(x, y) end 690 | 691 | ---@return any 692 | function vim.fn.prevnonblank(lnum) end 693 | 694 | ---@return any 695 | function vim.fn.printf(fmt, ...) end 696 | 697 | ---@return any 698 | function vim.fn.prompt_getprompt(buf) end 699 | 700 | ---@return any 701 | function vim.fn.prompt_setcallback(buf, expr) end 702 | 703 | ---@return any 704 | function vim.fn.prompt_setinterrupt(buf, text) end 705 | 706 | ---@return any 707 | function vim.fn.prompt_setprompt(buf, text) end 708 | 709 | ---@return any 710 | function vim.fn.py3eval(expr) end 711 | 712 | ---@return any 713 | function vim.fn.pyeval(expr) end 714 | 715 | ---@return any 716 | function vim.fn.pyxeval(expr) end 717 | 718 | ---@return any 719 | function vim.fn.rand(expr) end 720 | 721 | ---@return any 722 | function vim.fn.range(expr, max, stride) end 723 | 724 | ---@return any 725 | function vim.fn.readblob(fname, offset, size) end 726 | 727 | ---@return any 728 | function vim.fn.readdir(dir, expr) end 729 | 730 | ---@return any 731 | function vim.fn.readfile(fname, type, max) end 732 | 733 | ---@return any 734 | function vim.fn.reduce(object, func, initial) end 735 | 736 | ---@return any 737 | function vim.fn.reltime(start, end_) end 738 | 739 | ---@return any 740 | function vim.fn.reltimefloat(time) end 741 | 742 | ---@return any 743 | function vim.fn.reltimestr(time) end 744 | 745 | ---@return any 746 | function vim.fn.remove(list, idx, end_) end 747 | 748 | ---@return any 749 | function vim.fn.remove(blob, idx, end_) end 750 | 751 | ---@return any 752 | function vim.fn.remove(dict, key) end 753 | 754 | ---@return any 755 | function vim.fn.rename(from, to) end 756 | 757 | ---@return any 758 | vim.fn["repeat"] = function(expr, count) end 759 | 760 | ---@return any 761 | function vim.fn.resolve(filename) end 762 | 763 | ---@return any 764 | function vim.fn.reverse(list) end 765 | 766 | ---@return any 767 | function vim.fn.round(expr) end 768 | 769 | ---@return any 770 | function vim.fn.rubyeval(expr) end 771 | 772 | ---@return any 773 | function vim.fn.rpcnotify(channel, event, ...) end 774 | 775 | ---@return any 776 | function vim.fn.rpcrequest(channel, method, ...) end 777 | 778 | ---@return any 779 | function vim.fn.screenattr(row, col) end 780 | 781 | ---@return any 782 | function vim.fn.screenchar(row, col) end 783 | 784 | ---@return any 785 | function vim.fn.screenchars(row, col) end 786 | 787 | ---@return any 788 | function vim.fn.screenpos(winid, lnum, col) end 789 | 790 | ---@return any 791 | function vim.fn.screenstring(row, col) end 792 | 793 | ---@return any 794 | function vim.fn.search(pattern, flags, stopline, timeout, skip) end 795 | 796 | ---@return any 797 | function vim.fn.searchcount(options) end 798 | 799 | ---@return any 800 | function vim.fn.searchdecl(name, global, thisblock) end 801 | 802 | ---@return any 803 | function vim.fn.searchpair(start, middle, end_, flags, ...) end 804 | 805 | ---@return any 806 | function vim.fn.searchpairpos(start, middle, end_, flags, ...) end 807 | 808 | ---@return any 809 | function vim.fn.searchpos(pattern, flags, stopline, timeout, skip) end 810 | 811 | ---@return any 812 | function vim.fn.setbufline(expr, lnum, text) end 813 | 814 | ---@return any 815 | function vim.fn.setbufvar(buf, varname, val) end 816 | 817 | ---@return any 818 | function vim.fn.setcellwidths(list) end 819 | 820 | ---@return any 821 | function vim.fn.setcharpos(expr, list) end 822 | 823 | ---@return any 824 | function vim.fn.setcharsearch(dict) end 825 | 826 | ---@return any 827 | function vim.fn.setcmdline(str, pos) end 828 | 829 | ---@return any 830 | function vim.fn.setcmdpos(pos) end 831 | 832 | ---@return any 833 | function vim.fn.setcursorcharpos(list) end 834 | 835 | ---@return any 836 | function vim.fn.setenv(name, val) end 837 | 838 | ---@return any 839 | function vim.fn.setline(lnum, line) end 840 | 841 | ---@return any 842 | function vim.fn.setloclist(nr, list, action) end 843 | 844 | ---@return any 845 | function vim.fn.setloclist(nr, list, action, what) end 846 | 847 | ---@return any 848 | function vim.fn.setmatches(list, win) end 849 | 850 | ---@return any 851 | function vim.fn.setpos(expr, list) end 852 | 853 | ---@return any 854 | function vim.fn.setqflist(list, action) end 855 | 856 | ---@return any 857 | function vim.fn.setqflist(list, action, what) end 858 | 859 | ---@return any 860 | function vim.fn.setreg(n, v, opt) end 861 | 862 | ---@return any 863 | function vim.fn.settabvar(nr, varname, val) end 864 | 865 | ---@return any 866 | function vim.fn.settabwinvar(tabnr, winnr, varname, val) end 867 | 868 | ---@return any 869 | function vim.fn.settagstack(nr, dict, action) end 870 | 871 | ---@return any 872 | function vim.fn.setwinvar(nr, varname, val) end 873 | 874 | ---@return any 875 | function vim.fn.sha256(string) end 876 | 877 | ---@return any 878 | function vim.fn.shellescape(string, special) end 879 | 880 | ---@return any 881 | function vim.fn.shiftwidth(col) end 882 | 883 | ---@return any 884 | function vim.fn.sign_define(name, dict) end 885 | 886 | ---@return any 887 | function vim.fn.sign_define(list) end 888 | 889 | ---@return any 890 | function vim.fn.sign_getdefined(name) end 891 | 892 | ---@return any 893 | function vim.fn.sign_getplaced(buf, dict) end 894 | 895 | ---@return any 896 | function vim.fn.sign_jump(id, group, buf) end 897 | 898 | ---@return any 899 | function vim.fn.sign_place(id, group, name, buf, dict) end 900 | 901 | ---@return any 902 | function vim.fn.sign_placelist(list) end 903 | 904 | ---@return any 905 | function vim.fn.sign_undefine(name) end 906 | 907 | ---@return any 908 | function vim.fn.sign_undefine(list) end 909 | 910 | ---@return any 911 | function vim.fn.sign_unplace(group, dict) end 912 | 913 | ---@return any 914 | function vim.fn.sign_unplacelist(list) end 915 | 916 | ---@return any 917 | function vim.fn.simplify(filename) end 918 | 919 | ---@return any 920 | function vim.fn.sin(expr) end 921 | 922 | ---@return any 923 | function vim.fn.sinh(expr) end 924 | 925 | ---@return any 926 | function vim.fn.slice(expr, start, end_) end 927 | 928 | ---@return any 929 | function vim.fn.sockconnect(mode, address, opts) end 930 | 931 | ---@return any 932 | function vim.fn.sort(list, func, dict) end 933 | 934 | ---@return any 935 | function vim.fn.soundfold(word) end 936 | 937 | ---@return any 938 | function vim.fn.spellsuggest(word, max, capital) end 939 | 940 | ---@return any 941 | function vim.fn.split(expr, pat, keepempty) end 942 | 943 | ---@return any 944 | function vim.fn.sqrt(expr) end 945 | 946 | ---@return any 947 | function vim.fn.srand(expr) end 948 | 949 | ---@return any 950 | function vim.fn.stdioopen(dict) end 951 | 952 | ---@return any 953 | function vim.fn.stdpath(what) end 954 | 955 | ---@return any 956 | function vim.fn.str2float(expr, quoted) end 957 | 958 | ---@return any 959 | function vim.fn.str2list(expr, utf8) end 960 | 961 | ---@return any 962 | function vim.fn.str2nr(expr, base, quoted) end 963 | 964 | ---@return any 965 | function vim.fn.strcharlen(expr) end 966 | 967 | ---@return any 968 | function vim.fn.strcharpart(str, start, len, skipcc) end 969 | 970 | ---@return any 971 | function vim.fn.strchars(expr, skipcc) end 972 | 973 | ---@return any 974 | function vim.fn.strdisplaywidth(expr, col) end 975 | 976 | ---@return any 977 | function vim.fn.strftime(format, time) end 978 | 979 | ---@return any 980 | function vim.fn.strgetchar(str, index) end 981 | 982 | ---@return any 983 | function vim.fn.stridx(haystack, needle, start) end 984 | 985 | ---@return any 986 | function vim.fn.string(expr) end 987 | 988 | ---@return any 989 | function vim.fn.strlen(expr) end 990 | 991 | ---@return any 992 | function vim.fn.strpart(str, start, len, chars) end 993 | 994 | ---@return any 995 | function vim.fn.strptime(format, timestring) end 996 | 997 | ---@return any 998 | function vim.fn.strridx(haystack, needle, start) end 999 | 1000 | ---@return any 1001 | function vim.fn.strtrans(expr) end 1002 | 1003 | ---@return any 1004 | function vim.fn.strutf16len(string, countcc) end 1005 | 1006 | ---@return any 1007 | function vim.fn.strwidth(expr) end 1008 | 1009 | ---@return any 1010 | function vim.fn.submatch(nr, list) end 1011 | 1012 | ---@return any 1013 | function vim.fn.substitute(expr, pat, sub, flags) end 1014 | 1015 | ---@return any 1016 | function vim.fn.swapinfo(fname) end 1017 | 1018 | ---@return any 1019 | function vim.fn.swapname(buf) end 1020 | 1021 | ---@return any 1022 | function vim.fn.synID(lnum, col, trans) end 1023 | 1024 | ---@return any 1025 | function vim.fn.synIDattr(synID, what, mode) end 1026 | 1027 | ---@return any 1028 | function vim.fn.synIDtrans(synID) end 1029 | 1030 | ---@return any 1031 | function vim.fn.synconcealed(lnum, col) end 1032 | 1033 | ---@return any 1034 | function vim.fn.synstack(lnum, col) end 1035 | 1036 | ---@return any 1037 | function vim.fn.system(cmd, input) end 1038 | 1039 | ---@return any 1040 | function vim.fn.systemlist(cmd, input) end 1041 | 1042 | ---@return any 1043 | function vim.fn.tabpagebuflist(arg) end 1044 | 1045 | ---@return any 1046 | function vim.fn.tabpagenr(arg) end 1047 | 1048 | ---@return any 1049 | function vim.fn.tabpagewinnr(tabarg, arg) end 1050 | 1051 | ---@return any 1052 | function vim.fn.taglist(expr, filename) end 1053 | 1054 | ---@return any 1055 | function vim.fn.tan(expr) end 1056 | 1057 | ---@return any 1058 | function vim.fn.tanh(expr) end 1059 | 1060 | ---@return any 1061 | function vim.fn.timer_info(id) end 1062 | 1063 | ---@return any 1064 | function vim.fn.timer_pause(id, pause) end 1065 | 1066 | ---@return any 1067 | function vim.fn.timer_start(time, callback, options) end 1068 | 1069 | ---@return any 1070 | function vim.fn.timer_stop(timer) end 1071 | 1072 | ---@return any 1073 | function vim.fn.tolower(expr) end 1074 | 1075 | ---@return any 1076 | function vim.fn.toupper(expr) end 1077 | 1078 | ---@return any 1079 | function vim.fn.tr(src, fromstr, tostr) end 1080 | 1081 | ---@return any 1082 | function vim.fn.trim(text, mask, dir) end 1083 | 1084 | ---@return any 1085 | function vim.fn.trunc(expr) end 1086 | 1087 | ---@return any 1088 | function vim.fn.type(name) end 1089 | 1090 | ---@return any 1091 | function vim.fn.undofile(name) end 1092 | 1093 | ---@return any 1094 | function vim.fn.uniq(list, func, dict) end 1095 | 1096 | ---@return any 1097 | function vim.fn.utf16idx(string, idx, countcc, charidx) end 1098 | 1099 | ---@return any 1100 | function vim.fn.values(dict) end 1101 | 1102 | ---@return any 1103 | function vim.fn.virtcol(expr, list) end 1104 | 1105 | ---@return any 1106 | function vim.fn.virtcol2col(winid, lnum, col) end 1107 | 1108 | ---@return any 1109 | function vim.fn.visualmode(expr) end 1110 | 1111 | ---@return any 1112 | function vim.fn.wait(timeout, condition, interval) end 1113 | 1114 | ---@return any 1115 | function vim.fn.win_execute(id, command, silent) end 1116 | 1117 | ---@return any 1118 | function vim.fn.win_findbuf(bufnr) end 1119 | 1120 | ---@return any 1121 | function vim.fn.win_getid(win, tab) end 1122 | 1123 | ---@return any 1124 | function vim.fn.win_gettype(nr) end 1125 | 1126 | ---@return any 1127 | function vim.fn.win_gotoid(expr) end 1128 | 1129 | ---@return any 1130 | function vim.fn.win_id2tabwin(expr) end 1131 | 1132 | ---@return any 1133 | function vim.fn.win_id2win(expr) end 1134 | 1135 | ---@return any 1136 | function vim.fn.win_move_separator(nr) end 1137 | 1138 | ---@return any 1139 | function vim.fn.win_move_statusline(nr) end 1140 | 1141 | ---@return any 1142 | function vim.fn.win_screenpos(nr) end 1143 | 1144 | ---@return any 1145 | function vim.fn.win_splitmove(nr, target, options) end 1146 | 1147 | ---@return any 1148 | function vim.fn.winbufnr(nr) end 1149 | 1150 | ---@return any 1151 | function vim.fn.winheight(nr) end 1152 | 1153 | ---@return any 1154 | function vim.fn.winlayout(tabnr) end 1155 | 1156 | ---@return any 1157 | function vim.fn.winnr(expr) end 1158 | 1159 | ---@return any 1160 | function vim.fn.winrestview(dict) end 1161 | 1162 | ---@return any 1163 | function vim.fn.winwidth(nr) end 1164 | 1165 | ---@return any 1166 | function vim.fn.writefile(object, fname, flags) end 1167 | 1168 | ---@return any 1169 | function vim.fn.xor(expr, expr) end -------------------------------------------------------------------------------- /nvim/library/vim.lua: -------------------------------------------------------------------------------- 1 | ---@meta 2 | 3 | vim.F = require('vim.F') 4 | vim.filetype = require('vim.filetype') 5 | vim.fs = require('vim.fs') 6 | vim.health = require('vim.health') 7 | vim.highlight = require('vim.highlight') 8 | vim.keymap = require('vim.keymap') 9 | vim.lsp = require('vim.lsp') 10 | vim.treesitter = require('vim.treesitter') 11 | vim.ui = require('vim.ui') 12 | vim.inspect = require('vim.inspect') 13 | 14 | vim.log = { 15 | levels = { 16 | TRACE = 0, 17 | DEBUG = 1, 18 | INFO = 2, 19 | WARN = 3, 20 | ERROR = 4, 21 | OFF = 5, 22 | }, 23 | } 24 | 25 | --- Gets the version of the current Nvim build. 26 | ---@return table 27 | function vim.version() end 28 | 29 | --- Schedules callback to be invoked soon by the main event-loop. Useful 30 | --- to avoid textlock or other temporary restrictions. 31 | ---@param cb function 32 | function vim.schedule(cb) end 33 | 34 | --- Returns true if the code is executing as part of a "fast" event 35 | --- handler, where most of the API is disabled. These are low-level events 36 | --- (e.g. lua-loop-callbacks) which can be invoked whenever Nvim polls 37 | --- for input. When this is `false` most API functions are callable (but 38 | --- may be subject to other restrictions such as textlock). 39 | ---@return boolean 40 | function vim.in_fast_event() end 41 | 42 | --- Invokes vim-function or user-function {func} with arguments {...}. 43 | --- See also vim.fn. 44 | --- Equivalent to: `vim.fn[func]({...})` 45 | ---@param func string 46 | function vim.call(func, ...) end 47 | 48 | function vim.rpcrequest(channel, method, ...) end 49 | 50 | function vim.rpcnotify(channel, method, ...) end 51 | 52 | --- Wait for {time} in milliseconds until {callback} returns `true`. 53 | --- 54 | --- Executes {callback} immediately and at approximately {interval} 55 | --- milliseconds (default 200). Nvim still processes other events during 56 | --- this time. 57 | --- 58 | --- Parameters: 59 | --- - {time} Number of milliseconds to wait 60 | --- - {callback} Optional callback. Waits until {callback} returns true 61 | --- - {interval} (Approximate) number of milliseconds to wait between polls 62 | --- - {fast_only} If true, only api-fast events will be processed. 63 | --- If called from while in an api-fast event, will 64 | --- automatically be set to `true`. 65 | --- 66 | --- Returns: 67 | --- - If {callback} returns `true` during the {time}: `true, nil` 68 | --- - If {callback} never returns `true` during the {time}: `false, -1` 69 | --- - If {callback} is interrupted during the {time}: `false, -2` 70 | --- - If {callback} errors, the error is raised. 71 | --- 72 | --- Examples: 73 | --- 74 | --- ``` 75 | --- -- Wait for 100 ms, allowing other events to process 76 | --- vim.wait(100, function() end) 77 | --- -- Wait for 100 ms or until global variable set. 78 | --- vim.wait(100, function() return vim.g.waiting_for_var end) 79 | --- -- Wait for 1 second or until global variable set, checking every ~500 ms 80 | --- vim.wait(1000, function() return vim.g.waiting_for_var end, 500) 81 | --- -- Schedule a function to set a value in 100ms 82 | --- vim.defer_fn(function() vim.g.timer_result = true end, 100) 83 | --- -- Would wait ten seconds if results blocked. Actually only waits 100 ms 84 | --- if vim.wait(10000, function() return vim.g.timer_result end) then 85 | --- print('Only waiting a little bit of time!') 86 | --- end 87 | --- ``` 88 | --- 89 | ---@param time integer 90 | ---@param callback function? 91 | ---@param interval integer? 92 | ---@param fast_only boolean? 93 | ---@return boolean, integer 94 | function vim.wait(time, callback, interval, fast_only) end 95 | 96 | 97 | --- Returns a deep copy of the given object. Non-table objects are copied as 98 | --- in a typical Lua assignment, whereas table objects are copied recursively. 99 | --- Functions are naively copied, so functions in the copied table point to the 100 | --- same functions as those in the input table. Userdata and threads are not 101 | --- copied and will throw an error. 102 | --- 103 | --- Note: `noref=true` is much more performant on tables with unique table 104 | --- fields, while `noref=false` is more performant on tables that reuse table 105 | --- fields. 106 | --- 107 | ---@generic T: table 108 | ---@param orig T Table to copy 109 | ---@param noref? boolean 110 | --- When `false` (default) a contained table is only copied once and all 111 | --- references point to this single copy. When `true` every occurrence of a 112 | --- table results in a new copy. This also means that a cyclic reference can 113 | --- cause `deepcopy()` to fail. 114 | ---@return T Table of copied keys and (nested) values. 115 | function vim.deepcopy(orig, noref) end 116 | 117 | --- Gets an |iterator| that splits a string at each instance of a separator, in "lazy" fashion 118 | --- (as opposed to |vim.split()| which is "eager"). 119 | --- 120 | --- Example: 121 | --- 122 | --- ```lua 123 | --- for s in vim.gsplit(':aa::b:', ':', {plain=true}) do 124 | --- print(s) 125 | --- end 126 | --- ``` 127 | --- 128 | --- If you want to also inspect the separator itself (instead of discarding it), use 129 | --- |string.gmatch()|. Example: 130 | --- 131 | --- ```lua 132 | --- for word, num in ('foo111bar222'):gmatch('([^0-9]*)(%d*)') do 133 | --- print(('word: %s num: %s'):format(word, num)) 134 | --- end 135 | --- ``` 136 | --- 137 | --- @see |string.gmatch()| 138 | --- @see |vim.split()| 139 | --- @see |lua-patterns| 140 | --- @see https://www.lua.org/pil/20.2.html 141 | --- @see http://lua-users.org/wiki/StringLibraryTutorial 142 | --- 143 | --- @param s string String to split 144 | --- @param sep string Separator or pattern 145 | --- @param opts? vim.gsplit.Opts Keyword arguments |kwargs|: 146 | --- @return fun():string? : Iterator over the split components 147 | function vim.gsplit(s, sep, opts) end 148 | 149 | --- Splits a string at each instance of a separator and returns the result as a table (unlike 150 | --- |vim.gsplit()|). 151 | --- 152 | --- Examples: 153 | --- 154 | --- ```lua 155 | --- split(":aa::b:", ":") --> {'','aa','','b',''} 156 | --- split("axaby", "ab?") --> {'','x','y'} 157 | --- split("x*yz*o", "*", {plain=true}) --> {'x','yz','o'} 158 | --- split("|x|y|z|", "|", {trimempty=true}) --> {'x', 'y', 'z'} 159 | --- ``` 160 | --- 161 | ---@see |vim.gsplit()| 162 | ---@see |string.gmatch()| 163 | --- 164 | ---@param s string String to split 165 | ---@param sep string Separator or pattern 166 | ---@param opts? vim.gsplit.Opts Keyword arguments |kwargs|: 167 | ---@return string[] : List of split components 168 | function vim.split(s, sep, opts) end 169 | 170 | --- Return a list of all keys used in a table. 171 | --- However, the order of the return table of keys is not guaranteed. 172 | --- 173 | ---@see From https://github.com/premake/premake-core/blob/master/src/base/table.lua 174 | --- 175 | ---@generic T 176 | ---@param t table (table) Table 177 | ---@return T[] : List of keys 178 | function vim.tbl_keys(t) end 179 | 180 | --- Return a list of all values used in a table. 181 | --- However, the order of the return table of values is not guaranteed. 182 | --- 183 | ---@generic T 184 | ---@param t table (table) Table 185 | ---@return T[] : List of values 186 | function vim.tbl_values(t) end 187 | 188 | --- Apply a function to all values of a table. 189 | --- 190 | ---@generic T 191 | ---@param func fun(value: T): any Function 192 | ---@param t table Table 193 | ---@return table : Table of transformed values 194 | function vim.tbl_map(func, t) end 195 | 196 | --- Filter a table using a predicate function 197 | --- 198 | ---@generic T 199 | ---@param func fun(value: T): boolean (function) Function 200 | ---@param t table (table) Table 201 | ---@return T[] : Table of filtered values 202 | function vim.tbl_filter(func, t) end 203 | 204 | --- Checks if a table contains a given value, specified either directly or via 205 | --- a predicate that is checked for each value. 206 | --- 207 | --- Example: 208 | --- 209 | --- ```lua 210 | --- vim.tbl_contains({ 'a', { 'b', 'c' } }, function(v) 211 | --- return vim.deep_equal(v, { 'b', 'c' }) 212 | --- end, { predicate = true }) 213 | --- -- true 214 | --- ``` 215 | --- 216 | ---@see |vim.list_contains()| for checking values in list-like tables 217 | --- 218 | ---@param t table Table to check 219 | ---@param value any Value to compare or predicate function reference 220 | ---@param opts? vim.tbl_contains.Opts Keyword arguments |kwargs|: 221 | ---@return boolean `true` if `t` contains `value` 222 | function vim.tbl_contains(t, value, opts) end 223 | 224 | --- Checks if a list-like table (integer keys without gaps) contains `value`. 225 | --- 226 | ---@see |vim.tbl_contains()| for checking values in general tables 227 | --- 228 | ---@param t table Table to check (must be list-like, not validated) 229 | ---@param value any Value to compare 230 | ---@return boolean `true` if `t` contains `value` 231 | function vim.list_contains(t, value) end 232 | 233 | --- Checks if a table is empty. 234 | --- 235 | ---@see https://github.com/premake/premake-core/blob/master/src/base/table.lua 236 | --- 237 | ---@param t table Table to check 238 | ---@return boolean `true` if `t` is empty 239 | function vim.tbl_isempty(t) end 240 | 241 | --- Merges two or more tables. 242 | --- 243 | ---@see |extend()| 244 | --- 245 | ---@param behavior 'error'|'keep'|'force' Decides what to do if a key is found in more than one map: 246 | --- - "error": raise an error 247 | --- - "keep": use value from the leftmost map 248 | --- - "force": use value from the rightmost map 249 | ---@param ... table Two or more tables 250 | ---@return table : Merged table 251 | function vim.tbl_extend(behavior, ...) end 252 | 253 | --- Merges recursively two or more tables. 254 | --- 255 | --- Only values that are empty tables or tables that are not |lua-list|s (indexed by consecutive 256 | --- integers starting from 1) are merged recursively. This is useful for merging nested tables 257 | --- like default and user configurations where lists should be treated as literals (i.e., are 258 | --- overwritten instead of merged). 259 | --- 260 | ---@see |vim.tbl_extend()| 261 | --- 262 | ---@generic T1: table 263 | ---@generic T2: table 264 | ---@param behavior 'error'|'keep'|'force' Decides what to do if a key is found in more than one map: 265 | --- - "error": raise an error 266 | --- - "keep": use value from the leftmost map 267 | --- - "force": use value from the rightmost map 268 | ---@param ... T2 Two or more tables 269 | ---@return T1|T2 (table) Merged table 270 | function vim.tbl_deep_extend(behavior, ...) end 271 | 272 | --- Deep compare values for equality 273 | --- 274 | --- Tables are compared recursively unless they both provide the `eq` metamethod. 275 | --- All other types are compared using the equality `==` operator. 276 | ---@param a any First value 277 | ---@param b any Second value 278 | ---@return boolean `true` if values are equals, else `false` 279 | function vim.deep_equal(a, b) end 280 | 281 | --- Add the reverse lookup values to an existing table. 282 | --- For example: 283 | --- `tbl_add_reverse_lookup { A = 1 } == { [1] = 'A', A = 1 }` 284 | --- 285 | --- Note that this *modifies* the input. 286 | ---@deprecated 287 | ---@param o table Table to add the reverse to 288 | ---@return table o 289 | function vim.tbl_add_reverse_lookup(o) end 290 | 291 | --- Index into a table (first argument) via string keys passed as subsequent arguments. 292 | --- Return `nil` if the key does not exist. 293 | --- 294 | --- Examples: 295 | --- 296 | --- ```lua 297 | --- vim.tbl_get({ key = { nested_key = true }}, 'key', 'nested_key') == true 298 | --- vim.tbl_get({ key = {}}, 'key', 'nested_key') == nil 299 | --- ``` 300 | --- 301 | ---@param o table Table to index 302 | ---@param ... any Optional keys (0 or more, variadic) via which to index the table 303 | ---@return any # Nested value indexed by key (if it exists), else nil 304 | function vim.tbl_get(o, ...) end 305 | 306 | --- Extends a list-like table with the values of another list-like table. 307 | --- 308 | --- NOTE: This mutates dst! 309 | --- 310 | ---@see |vim.tbl_extend()| 311 | --- 312 | ---@generic T: table 313 | ---@param dst T List which will be modified and appended to 314 | ---@param src table List from which values will be inserted 315 | ---@param start integer? Start index on src. Defaults to 1 316 | ---@param finish integer? Final index on src. Defaults to `#src` 317 | ---@return T dst 318 | function vim.list_extend(dst, src, start, finish) end 319 | 320 | --- @deprecated 321 | --- Creates a copy of a list-like table such that any nested tables are 322 | --- "unrolled" and appended to the result. 323 | --- 324 | ---@see From https://github.com/premake/premake-core/blob/master/src/base/table.lua 325 | --- 326 | ---@param t table List-like table 327 | ---@return table Flattened copy of the given list-like table 328 | function vim.tbl_flatten(t) end 329 | 330 | --- Enumerates key-value pairs of a table, ordered by key. 331 | --- 332 | ---@see Based on https://github.com/premake/premake-core/blob/master/src/base/table.lua 333 | --- 334 | ---@generic T: table, K, V 335 | ---@param t T Dict-like table 336 | ---@return fun(table: table, index?: K):K, V # |for-in| iterator over sorted keys and their values 337 | ---@return T 338 | function vim.spairs(t) end 339 | 340 | --- Tests if `t` is an "array": a table indexed _only_ by integers (potentially non-contiguous). 341 | --- 342 | --- If the indexes start from 1 and are contiguous then the array is also a list. |vim.islist()| 343 | --- 344 | --- Empty table `{}` is an array, unless it was created by |vim.empty_dict()| or returned as 345 | --- a dict-like |API| or Vimscript result, for example from |rpcrequest()| or |vim.fn|. 346 | --- 347 | ---@see https://github.com/openresty/luajit2#tableisarray 348 | --- 349 | ---@param t? table 350 | ---@return boolean `true` if array-like table, else `false`. 351 | function vim.isarray(t) end 352 | 353 | --- @deprecated 354 | function vim.tbl_islist(t) end 355 | 356 | --- Tests if `t` is a "list": a table indexed _only_ by contiguous integers starting from 1 (what 357 | --- |lua-length| calls a "regular array"). 358 | --- 359 | --- Empty table `{}` is a list, unless it was created by |vim.empty_dict()| or returned as 360 | --- a dict-like |API| or Vimscript result, for example from |rpcrequest()| or |vim.fn|. 361 | --- 362 | ---@see |vim.isarray()| 363 | --- 364 | ---@param t? table 365 | ---@return boolean `true` if list-like table, else `false`. 366 | function vim.islist(t) end 367 | 368 | --- Counts the number of non-nil values in table `t`. 369 | --- 370 | --- ```lua 371 | --- vim.tbl_count({ a=1, b=2 }) --> 2 372 | --- vim.tbl_count({ 1, 2 }) --> 2 373 | --- ``` 374 | --- 375 | ---@see https://github.com/Tieske/Penlight/blob/master/lua/pl/tablex.lua 376 | ---@param t table Table 377 | ---@return integer : Number of non-nil values in table 378 | function vim.tbl_count(t) end 379 | 380 | --- Creates a copy of a table containing only elements from start to end (inclusive) 381 | --- 382 | ---@generic T 383 | ---@param list T[] Table 384 | ---@param start integer|nil Start range of slice 385 | ---@param finish integer|nil End range of slice 386 | ---@return T[] Copy of table sliced from start to finish (inclusive) 387 | function vim.list_slice(list, start, finish) end 388 | 389 | --- Efficiently insert items into the middle of a list. 390 | --- 391 | --- Calling table.insert() in a loop will re-index the tail of the table on 392 | --- every iteration, instead this function will re-index the table exactly 393 | --- once. 394 | --- 395 | --- Based on https://stackoverflow.com/questions/12394841/safely-remove-items-from-an-array-table-while-iterating/53038524#53038524 396 | --- 397 | ---@param t any[] 398 | ---@param first integer 399 | ---@param last integer 400 | ---@param v any 401 | function vim._list_insert(t, first, last, v) end 402 | 403 | --- Efficiently remove items from middle of a list. 404 | --- 405 | --- Calling table.remove() in a loop will re-index the tail of the table on 406 | --- every iteration, instead this function will re-index the table exactly 407 | --- once. 408 | --- 409 | --- Based on https://stackoverflow.com/questions/12394841/safely-remove-items-from-an-array-table-while-iterating/53038524#53038524 410 | --- 411 | ---@param t any[] 412 | ---@param first integer 413 | ---@param last integer 414 | function vim._list_remove(t, first, last) end 415 | 416 | --- Trim whitespace (Lua pattern "%s") from both sides of a string. 417 | --- 418 | ---@see |lua-patterns| 419 | ---@see https://www.lua.org/pil/20.2.html 420 | ---@param s string String to trim 421 | ---@return string String with whitespace removed from its beginning and end 422 | function vim.trim(s) end 423 | 424 | --- Escapes magic chars in |lua-patterns|. 425 | --- 426 | ---@see https://github.com/rxi/lume 427 | ---@param s string String to escape 428 | ---@return string %-escaped pattern string 429 | function vim.pesc(s) end 430 | 431 | --- Tests if `s` starts with `prefix`. 432 | --- 433 | ---@param s string String 434 | ---@param prefix string Prefix to match 435 | ---@return boolean `true` if `prefix` is a prefix of `s` 436 | function vim.startswith(s, prefix) end 437 | 438 | --- Tests if `s` ends with `suffix`. 439 | --- 440 | ---@param s string String 441 | ---@param suffix string Suffix to match 442 | ---@return boolean `true` if `suffix` is a suffix of `s` 443 | function vim.endswith(s, suffix) end 444 | 445 | --- Validate function arguments. 446 | --- 447 | --- This function has two valid forms: 448 | --- 449 | --- 1. `vim.validate(name, value, validator[, optional][, message])` 450 | --- 451 | --- Validates that argument {name} with value {value} satisfies 452 | --- {validator}. If {optional} is given and is `true`, then {value} may be 453 | --- `nil`. If {message} is given, then it is used as the expected type in the 454 | --- error message. 455 | --- 456 | --- Example: 457 | --- 458 | --- ```lua 459 | --- function vim.startswith(s, prefix) 460 | --- vim.validate('s', s, 'string') 461 | --- vim.validate('prefix', prefix, 'string') 462 | --- -- ... 463 | --- end 464 | --- ``` 465 | --- 466 | --- 2. `vim.validate(spec)` (deprecated) 467 | --- where `spec` is of type 468 | --- `table)` 469 | --- 470 | --- Validates a argument specification. 471 | --- Specs are evaluated in alphanumeric order, until the first failure. 472 | --- 473 | --- Example: 474 | --- 475 | --- ```lua 476 | --- function user.new(name, age, hobbies) 477 | --- vim.validate{ 478 | --- name={name, 'string'}, 479 | --- age={age, 'number'}, 480 | --- hobbies={hobbies, 'table'}, 481 | --- } 482 | --- -- ... 483 | --- end 484 | --- ``` 485 | --- 486 | --- Examples with explicit argument values (can be run directly): 487 | --- 488 | --- ```lua 489 | --- vim.validate('arg1', {'foo'}, 'table') 490 | --- --> NOP (success) 491 | --- vim.validate('arg2', 'foo', 'string') 492 | --- --> NOP (success) 493 | --- 494 | --- vim.validate('arg1', 1, 'table') 495 | --- --> error('arg1: expected table, got number') 496 | --- 497 | --- vim.validate('arg1', 3, function(a) return (a % 2) == 0 end, 'even number') 498 | --- --> error('arg1: expected even number, got 3') 499 | --- ``` 500 | --- 501 | --- If multiple types are valid they can be given as a list. 502 | --- 503 | --- ```lua 504 | --- vim.validate('arg1', {'foo'}, {'table', 'string'}) 505 | --- vim.validate('arg2', 'foo', {'table', 'string'}) 506 | --- -- NOP (success) 507 | --- 508 | --- vim.validate('arg1', 1, {'string', 'table'}) 509 | --- -- error('arg1: expected string|table, got number') 510 | --- ``` 511 | --- 512 | --- @note `validator` set to a value returned by |lua-type()| provides the 513 | --- best performance. 514 | --- 515 | --- @param name string Argument name 516 | --- @param value any Argument value 517 | --- @param validator vim.validate.Validator 518 | --- - (`string|string[]`): Any value that can be returned from |lua-type()| in addition to 519 | --- `'callable'`: `'boolean'`, `'callable'`, `'function'`, `'nil'`, `'number'`, `'string'`, `'table'`, 520 | --- `'thread'`, `'userdata'`. 521 | --- - (`fun(val:any): boolean, string?`) A function that returns a boolean and an optional 522 | --- string message. 523 | --- @param optional? boolean Argument is optional (may be omitted) 524 | --- @param message? string message when validation fails 525 | --- @overload fun(name: string, val: any, validator: vim.validate.Validator, message: string) 526 | --- @overload fun(spec: table) 527 | function vim.validate(name, value, validator, optional, message) end 528 | 529 | --- Returns true if object `f` can be called as a function. 530 | --- 531 | ---@param f any Any object 532 | ---@return boolean `true` if `f` is callable, else `false` 533 | function vim.is_callable(f) end 534 | 535 | --- Creates a table whose missing keys are provided by {createfn} (like Python's "defaultdict"). 536 | --- 537 | --- If {createfn} is `nil` it defaults to defaulttable() itself, so accessing nested keys creates 538 | --- nested tables: 539 | --- 540 | --- ```lua 541 | --- local a = vim.defaulttable() 542 | --- a.b.c = 1 543 | --- ``` 544 | --- 545 | ---@param createfn? fun(key:any):any Provides the value for a missing `key`. 546 | ---@return table # Empty table with `__index` metamethod. 547 | function vim.defaulttable(createfn) end 548 | 549 | --- Create a ring buffer limited to a maximal number of items. 550 | --- Once the buffer is full, adding a new entry overrides the oldest entry. 551 | --- 552 | --- ```lua 553 | --- local ringbuf = vim.ringbuf(4) 554 | --- ringbuf:push("a") 555 | --- ringbuf:push("b") 556 | --- ringbuf:push("c") 557 | --- ringbuf:push("d") 558 | --- ringbuf:push("e") -- overrides "a" 559 | --- print(ringbuf:pop()) -- returns "b" 560 | --- print(ringbuf:pop()) -- returns "c" 561 | --- 562 | --- -- Can be used as iterator. Pops remaining items: 563 | --- for val in ringbuf do 564 | --- print(val) 565 | --- end 566 | --- ``` 567 | --- 568 | --- Returns a Ringbuf instance with the following methods: 569 | --- 570 | --- - |Ringbuf:push()| 571 | --- - |Ringbuf:pop()| 572 | --- - |Ringbuf:peek()| 573 | --- - |Ringbuf:clear()| 574 | --- 575 | ---@param size integer 576 | ---@return vim.Ringbuf ringbuf 577 | function vim.ringbuf(size) end 578 | 579 | --- @private 580 | --- @generic T 581 | --- @param root string 582 | --- @param mod T 583 | --- @return T 584 | function vim._defer_require(root, mod) end 585 | 586 | --- @private 587 | --- Creates a module alias/shim that lazy-loads a target module. 588 | --- 589 | --- Unlike `vim.defaulttable()` this also: 590 | --- - implements __call 591 | --- - calls vim.deprecate() 592 | --- 593 | --- @param old_name string Name of the deprecated module, which will be shimmed. 594 | --- @param new_name string Name of the new module, which will be loaded by require(). 595 | function vim._defer_deprecated_module(old_name, new_name) end 596 | 597 | --- Executes function `f` with the given context specification. 598 | --- 599 | --- Notes: 600 | --- - Context `{ buf = buf }` has no guarantees about current window when 601 | --- inside context. 602 | --- - Context `{ buf = buf, win = win }` is yet not allowed, but this seems 603 | --- to be an implementation detail. 604 | --- - There should be no way to revert currently set `context.sandbox = true` 605 | --- (like with nested `vim._with()` calls). Otherwise it kind of breaks the 606 | --- whole purpose of sandbox execution. 607 | --- - Saving and restoring option contexts (`bo`, `go`, `o`, `wo`) trigger 608 | --- `OptionSet` events. This is an implementation issue because not doing it 609 | --- seems to mean using either 'eventignore' option or extra nesting with 610 | --- `{ noautocmd = true }` (which itself is a wrapper for 'eventignore'). 611 | --- As `{ go = { eventignore = '...' } }` is a valid context which should be 612 | --- properly set and restored, this is not a good approach. 613 | --- Not triggering `OptionSet` seems to be a good idea, though. So probably 614 | --- only moving context save and restore to lower level might resolve this. 615 | --- 616 | --- @param context vim.context.mods 617 | --- @param f function 618 | --- @return any 619 | function vim._with(context, f) end 620 | 621 | --- @param bufnr? integer 622 | --- @return integer 623 | function vim._resolve_bufnr(bufnr) end 624 | 625 | --- @generic T 626 | --- @param x elem_or_list? 627 | --- @return T[] 628 | function vim._ensure_list(x) end 629 | 630 | --- Runs a system command or throws an error if {cmd} cannot be run. 631 | --- 632 | --- Examples: 633 | --- 634 | --- ```lua 635 | --- local on_exit = function(obj) 636 | --- print(obj.code) 637 | --- print(obj.signal) 638 | --- print(obj.stdout) 639 | --- print(obj.stderr) 640 | --- end 641 | --- 642 | --- -- Runs asynchronously: 643 | --- vim.system({'echo', 'hello'}, { text = true }, on_exit) 644 | --- 645 | --- -- Runs synchronously: 646 | --- local obj = vim.system({'echo', 'hello'}, { text = true }):wait() 647 | --- -- { code = 0, signal = 0, stdout = 'hello\n', stderr = '' } 648 | --- 649 | --- ``` 650 | --- 651 | --- See |uv.spawn()| for more details. Note: unlike |uv.spawn()|, vim.system 652 | --- throws an error if {cmd} cannot be run. 653 | --- 654 | --- @param cmd (string[]) Command to execute 655 | --- @param opts vim.SystemOpts? Options: 656 | --- - cwd: (string) Set the current working directory for the sub-process. 657 | --- - env: table Set environment variables for the new process. Inherits the 658 | --- current environment with `NVIM` set to |v:servername|. 659 | --- - clear_env: (boolean) `env` defines the job environment exactly, instead of merging current 660 | --- environment. 661 | --- - stdin: (string|string[]|boolean) If `true`, then a pipe to stdin is opened and can be written 662 | --- to via the `write()` method to SystemObj. If string or string[] then will be written to stdin 663 | --- and closed. Defaults to `false`. 664 | --- - stdout: (boolean|function) 665 | --- Handle output from stdout. When passed as a function must have the signature `fun(err: string, data: string)`. 666 | --- Defaults to `true` 667 | --- - stderr: (boolean|function) 668 | --- Handle output from stderr. When passed as a function must have the signature `fun(err: string, data: string)`. 669 | --- Defaults to `true`. 670 | --- - text: (boolean) Handle stdout and stderr as text. Replaces `\r\n` with `\n`. 671 | --- - timeout: (integer) Run the command with a time limit. Upon timeout the process is sent the 672 | --- TERM signal (15) and the exit code is set to 124. 673 | --- - detach: (boolean) If true, spawn the child process in a detached state - this will make it 674 | --- a process group leader, and will effectively enable the child to keep running after the 675 | --- parent exits. Note that the child process will still keep the parent's event loop alive 676 | --- unless the parent process calls |uv.unref()| on the child's process handle. 677 | --- 678 | --- @param on_exit? fun(out: vim.SystemCompleted) Called when subprocess exits. When provided, the command runs 679 | --- asynchronously. Receives SystemCompleted object, see return of SystemObj:wait(). 680 | --- 681 | --- @return vim.SystemObj Object with the fields: 682 | --- - cmd (string[]) Command name and args 683 | --- - pid (integer) Process ID 684 | --- - wait (fun(timeout: integer|nil): SystemCompleted) Wait for the process to complete. Upon 685 | --- timeout the process is sent the KILL signal (9) and the exit code is set to 124. Cannot 686 | --- be called in |api-fast|. 687 | --- - SystemCompleted is an object with the fields: 688 | --- - code: (integer) 689 | --- - signal: (integer) 690 | --- - stdout: (string), nil if stdout argument is passed 691 | --- - stderr: (string), nil if stderr argument is passed 692 | --- - kill (fun(signal: integer|string)) 693 | --- - write (fun(data: string|nil)) Requires `stdin=true`. Pass `nil` to close the stream. 694 | --- - is_closing (fun(): boolean) 695 | function vim.system(cmd, opts, on_exit) end 696 | 697 | 698 | function vim._os_proc_info(pid) end 699 | 700 | 701 | function vim._os_proc_children(ppid) end 702 | 703 | --- Paste handler, invoked by |nvim_paste()|. 704 | --- 705 | --- Note: This is provided only as a "hook", don't call it directly; call |nvim_paste()| instead, 706 | --- which arranges redo (dot-repeat) and invokes `vim.paste`. 707 | --- 708 | --- Example: To remove ANSI color codes when pasting: 709 | --- 710 | --- ```lua 711 | --- vim.paste = (function(overridden) 712 | --- return function(lines, phase) 713 | --- for i,line in ipairs(lines) do 714 | --- -- Scrub ANSI color codes from paste input. 715 | --- lines[i] = line:gsub('\27%[[0-9;mK]+', '') 716 | --- end 717 | --- return overridden(lines, phase) 718 | --- end 719 | --- end)(vim.paste) 720 | --- ``` 721 | --- 722 | ---@see |paste| 723 | --- 724 | ---@param lines string[] # |readfile()|-style list of lines to paste. |channel-lines| 725 | ---@param phase (-1|1|2|3) -1: "non-streaming" paste: the call contains all lines. 726 | --- If paste is "streamed", `phase` indicates the stream state: 727 | --- - 1: starts the paste (exactly once) 728 | --- - 2: continues the paste (zero or more times) 729 | --- - 3: ends the paste (exactly once) 730 | ---@return boolean result false if client should cancel the paste. 731 | function vim.paste(lines, phase) end 732 | 733 | --- Returns a function which calls {fn} via |vim.schedule()|. 734 | --- 735 | --- The returned function passes all arguments to {fn}. 736 | --- 737 | --- Example: 738 | --- 739 | --- ```lua 740 | --- function notify_readable(_err, readable) 741 | --- vim.notify("readable? " .. tostring(readable)) 742 | --- end 743 | --- vim.uv.fs_access(vim.fn.stdpath("config"), "R", vim.schedule_wrap(notify_readable)) 744 | --- ``` 745 | --- 746 | ---@see |lua-loop-callbacks| 747 | ---@see |vim.schedule()| 748 | ---@see |vim.in_fast_event()| 749 | ---@param fn function 750 | ---@return function 751 | function vim.schedule_wrap(fn) end 752 | 753 | --- @deprecated 754 | --- Gets a dict of line segment ("chunk") positions for the region from `pos1` to `pos2`. 755 | --- 756 | --- Input and output positions are byte positions, (0,0)-indexed. "End of line" column 757 | --- position (for example, |linewise| visual selection) is returned as |v:maxcol| (big number). 758 | --- 759 | ---@param bufnr integer Buffer number, or 0 for current buffer 760 | ---@param pos1 integer[]|string Start of region as a (line, column) tuple or |getpos()|-compatible string 761 | ---@param pos2 integer[]|string End of region as a (line, column) tuple or |getpos()|-compatible string 762 | ---@param regtype string [setreg()]-style selection type 763 | ---@param inclusive boolean Controls whether the ending column is inclusive (see also 'selection'). 764 | ---@return table region Dict of the form `{linenr = {startcol,endcol}}`. `endcol` is exclusive, and 765 | ---whole lines are returned as `{startcol,endcol} = {0,-1}`. 766 | function vim.region(bufnr, pos1, pos2, regtype, inclusive) end 767 | 768 | --- Defers calling {fn} until {timeout} ms passes. 769 | --- 770 | --- Use to do a one-shot timer that calls {fn} 771 | --- Note: The {fn} is |vim.schedule_wrap()|ped automatically, so API functions are 772 | --- safe to call. 773 | ---@param fn function Callback to call once `timeout` expires 774 | ---@param timeout integer Number of milliseconds to wait before calling `fn` 775 | ---@return table timer luv timer object 776 | function vim.defer_fn(fn, timeout) end 777 | 778 | --- Displays a notification to the user. 779 | --- 780 | --- This function can be overridden by plugins to display notifications using 781 | --- a custom provider (such as the system notification provider). By default, 782 | --- writes to |:messages|. 783 | ---@param msg string Content of the notification to show to the user. 784 | ---@param level integer|nil One of the values from |vim.log.levels|. 785 | ---@param opts table|nil Optional parameters. Unused by default. 786 | ---@diagnostic disable-next-line: unused-local 787 | function vim.notify(msg, level, opts) end 788 | 789 | --- Displays a notification only one time. 790 | --- 791 | --- Like |vim.notify()|, but subsequent calls with the same message will not 792 | --- display a notification. 793 | --- 794 | ---@param msg string Content of the notification to show to the user. 795 | ---@param level integer|nil One of the values from |vim.log.levels|. 796 | ---@param opts table|nil Optional parameters. Unused by default. 797 | ---@return boolean true if message was displayed, else false 798 | function vim.notify_once(msg, level, opts) end 799 | 800 | --- Adds Lua function {fn} with namespace id {ns_id} as a listener to every, 801 | --- yes every, input key. 802 | --- 803 | --- The Nvim command-line option |-w| is related but does not support callbacks 804 | --- and cannot be toggled dynamically. 805 | --- 806 | ---@note {fn} will be removed on error. 807 | ---@note {fn} won't be invoked recursively, i.e. if {fn} itself consumes input, 808 | --- it won't be invoked for those keys. 809 | ---@note {fn} will not be cleared by |nvim_buf_clear_namespace()| 810 | --- 811 | ---@param fn nil|fun(key: string, typed: string): string? Function invoked for every input key, 812 | --- after mappings have been applied but before further processing. Arguments 813 | --- {key} and {typed} are raw keycodes, where {key} is the key after mappings 814 | --- are applied, and {typed} is the key(s) before mappings are applied. 815 | --- {typed} may be empty if {key} is produced by non-typed key(s) or by the 816 | --- same typed key(s) that produced a previous {key}. 817 | --- If {fn} returns an empty string, {key} is discarded/ignored. 818 | --- When {fn} is `nil`, the callback associated with namespace {ns_id} is removed. 819 | ---@param ns_id integer? Namespace ID. If nil or 0, generates and returns a 820 | --- new |nvim_create_namespace()| id. 821 | ---@param opts table? Optional parameters 822 | --- 823 | ---@see |keytrans()| 824 | --- 825 | ---@return integer Namespace id associated with {fn}. Or count of all callbacks 826 | ---if on_key() is called without arguments. 827 | function vim.on_key(fn, ns_id, opts) end 828 | 829 | --- Executes the on_key callbacks. 830 | ---@private 831 | function vim._on_key(buf, typed_buf) end 832 | 833 | --- Convert UTF-32, UTF-16 or UTF-8 {index} to byte index. 834 | --- If {strict_indexing} is false 835 | --- then then an out of range index will return byte length 836 | --- instead of throwing an error. 837 | --- 838 | --- Invalid UTF-8 and NUL is treated like in |vim.str_utfindex()|. 839 | --- An {index} in the middle of a UTF-16 sequence is rounded upwards to 840 | --- the end of that sequence. 841 | ---@param s string 842 | ---@param encoding "utf-8"|"utf-16"|"utf-32" 843 | ---@param index integer 844 | ---@param strict_indexing? boolean # default: true 845 | ---@return integer 846 | function vim.str_byteindex(s, encoding, index, strict_indexing) end 847 | 848 | --- Convert byte index to UTF-32, UTF-16 or UTF-8 indices. If {index} is not 849 | --- supplied, the length of the string is used. All indices are zero-based. 850 | --- 851 | --- If {strict_indexing} is false then an out of range index will return string 852 | --- length instead of throwing an error. 853 | --- Invalid UTF-8 bytes, and embedded surrogates are counted as one code point 854 | --- each. An {index} in the middle of a UTF-8 sequence is rounded upwards to the end of 855 | --- that sequence. 856 | ---@param s string 857 | ---@param encoding "utf-8"|"utf-16"|"utf-32" 858 | ---@param index? integer 859 | ---@param strict_indexing? boolean # default: true 860 | ---@return integer 861 | function vim.str_utfindex(s, encoding, index, strict_indexing) end 862 | 863 | --- Generates a list of possible completions for the str 864 | --- String has the pattern. 865 | --- 866 | --- 1. Can we get it to just return things in the global namespace with that name prefix 867 | --- 2. Can we get it to return things from global namespace even with `print(` in front. 868 | --- 869 | --- @param pat string 870 | --- @return any[], integer 871 | function vim._expand_pat(pat, env) end 872 | 873 | --- Omnifunc for completing Lua values from the runtime Lua interpreter, 874 | --- similar to the builtin completion for the `:lua` command. 875 | --- 876 | --- Activate using `set omnifunc=v:lua.vim.lua_omnifunc` in a Lua buffer. 877 | --- @param find_start 1|0 878 | function vim.lua_omnifunc(find_start, _) end 879 | 880 | --- "Pretty prints" the given arguments and returns them unmodified. 881 | --- 882 | --- Example: 883 | --- 884 | --- ```lua 885 | --- local hl_normal = vim.print(vim.api.nvim_get_hl(0, { name = 'Normal' })) 886 | --- ``` 887 | --- 888 | --- @see |vim.inspect()| 889 | --- @see |:=| 890 | --- @param ... any 891 | --- @return any # given arguments. 892 | function vim.print(...) end 893 | 894 | --- Translates keycodes. 895 | --- 896 | --- Example: 897 | --- 898 | --- ```lua 899 | --- local k = vim.keycode 900 | --- vim.g.mapleader = k'' 901 | --- ``` 902 | --- 903 | --- @param str string String to be converted. 904 | --- @return string 905 | --- @see |nvim_replace_termcodes()| 906 | function vim.keycode(str) end 907 | 908 | --- @param server_addr string 909 | --- @param connect_error string 910 | function vim._cs_remote(rcid, server_addr, connect_error, args) end 911 | 912 | 913 | function vim._truncated_echo_once(msg) end 914 | 915 | --- Shows a deprecation message to the user. 916 | --- 917 | ---@param name string Deprecated feature (function, API, etc.). 918 | ---@param alternative string|nil Suggested alternative feature. 919 | ---@param version string Version when the deprecated function will be removed. 920 | ---@param plugin string|nil Name of the plugin that owns the deprecated feature. 921 | --- Defaults to "Nvim". 922 | ---@param backtrace boolean|nil Prints backtrace. Defaults to true. 923 | --- 924 | ---@return string|nil # Deprecated message, or nil if no message was shown. 925 | function vim.deprecate(name, alternative, version, plugin, backtrace) end --------------------------------------------------------------------------------