├── .gitignore ├── selene.toml ├── vim.toml ├── stylua.toml ├── data ├── api.mpack ├── lsp.mpack ├── lua.mpack ├── diagnostic.mpack └── treesitter.mpack ├── BUILD.md ├── .neoconf.json ├── lua └── lua-dev │ ├── util.lua │ ├── init.lua │ ├── config.lua │ ├── lsp.lua │ ├── sumneko.lua │ └── parser.lua ├── types ├── vim.lua ├── options.1.lua └── api.lua ├── .github └── workflows │ └── ci.yml ├── README.md ├── doc └── lua-dev.txt └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | doc/tags 2 | -------------------------------------------------------------------------------- /selene.toml: -------------------------------------------------------------------------------- 1 | std="lua51+vim" 2 | -------------------------------------------------------------------------------- /vim.toml: -------------------------------------------------------------------------------- 1 | [vim] 2 | any = true 3 | -------------------------------------------------------------------------------- /stylua.toml: -------------------------------------------------------------------------------- 1 | indent_type = "Spaces" 2 | indent_width = 2 3 | column_width = 120 -------------------------------------------------------------------------------- /data/api.mpack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WillianFuks/lua-dev.nvim/main/data/api.mpack -------------------------------------------------------------------------------- /data/lsp.mpack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WillianFuks/lua-dev.nvim/main/data/lsp.mpack -------------------------------------------------------------------------------- /data/lua.mpack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WillianFuks/lua-dev.nvim/main/data/lua.mpack -------------------------------------------------------------------------------- /data/diagnostic.mpack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WillianFuks/lua-dev.nvim/main/data/diagnostic.mpack -------------------------------------------------------------------------------- /data/treesitter.mpack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WillianFuks/lua-dev.nvim/main/data/treesitter.mpack -------------------------------------------------------------------------------- /BUILD.md: -------------------------------------------------------------------------------- 1 | # Updating Lua API Docs 2 | 3 | 1. Clone the neovim repo somewhere on your system 4 | 2. Run `./scripts/gen_vimdoc.py` 5 | 3. Copy `mpack` files to the **lua-dev.nvim** data directory 6 | 4. Open the file `lua-dev.nvim/lua/parser.lua` in Neovim 7 | 5. Execute `:luafile %` 8 | 6. Create a PR with new EmmyLua annotations 9 | -------------------------------------------------------------------------------- /.neoconf.json: -------------------------------------------------------------------------------- 1 | { 2 | "settings": { 3 | "plugins": { 4 | "sumneko_lua": { 5 | "enabled": true 6 | } 7 | } 8 | }, 9 | "lua-dev": { 10 | "library": { 11 | "enabled": true, 12 | "plugins": [ 13 | "neoconf.nvim", 14 | "nvim-lspconfig" 15 | ] 16 | } 17 | }, 18 | "lspconfig": { 19 | "sumneko_lua": {} 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lua/lua-dev/util.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.fqn(fname) 4 | fname = vim.fn.fnamemodify(fname, ":p") 5 | return vim.loop.fs_realpath(fname) or fname 6 | end 7 | 8 | function M.exists(fname) 9 | local stat = vim.loop.fs_stat(fname) 10 | return (stat and stat.type) or false 11 | end 12 | 13 | ---@param root_dir string 14 | ---@param file string 15 | function M.has_file(root_dir, file) 16 | root_dir = M.fqn(root_dir) 17 | file = M.fqn(file) 18 | return M.exists(file) and file:find(root_dir, 1, true) == 1 19 | end 20 | 21 | function M.config_path() 22 | return vim.loop.fs_realpath(vim.fn.stdpath("config")) 23 | end 24 | 25 | function M.is_plugin(path) 26 | return M.fqn(path):find("/lua[/$]") ~= nil or M.has_file(path, path .. "/lua") 27 | end 28 | 29 | function M.is_nvim_config(path) 30 | return M.has_file(M.fqn(path), M.config_path()) 31 | end 32 | 33 | return M 34 | -------------------------------------------------------------------------------- /lua/lua-dev/init.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | local function neoconf(config) 4 | pcall(function() 5 | require("neoconf.plugins").register({ 6 | on_schema = function(schema) 7 | schema:import("lua-dev", config.defaults) 8 | schema:set("lua-dev.library.plugins", { 9 | description = "true/false or an array of plugin names to enable", 10 | anyOf = { 11 | { type = "boolean" }, 12 | { type = "array", items = { type = "string" } }, 13 | }, 14 | }) 15 | end, 16 | }) 17 | end) 18 | end 19 | 20 | ---@param opts LuaApiOptions 21 | function M.setup(opts) 22 | local config = require("lua-dev.config") 23 | config.setup(opts) 24 | require("lua-dev.lsp").setup() 25 | 26 | neoconf(config) 27 | 28 | -- leave this for now for backward compatibility 29 | local ret = require("lua-dev.sumneko").setup() 30 | ret.settings.legacy = true 31 | ---@diagnostic disable-next-line: undefined-field 32 | return vim.tbl_deep_extend("force", {}, ret, config.options.lspconfig or {}) 33 | end 34 | 35 | return M 36 | -------------------------------------------------------------------------------- /types/vim.lua: -------------------------------------------------------------------------------- 1 | ---@meta 2 | 3 | ---@alias window number 4 | ---@alias buffer number 5 | ---@alias tabpage number 6 | ---@alias job number 7 | ---@alias channel number 8 | ---@alias sends number 9 | ---@alias blob number 10 | ---@alias list any[] 11 | ---@alias array any[] 12 | ---@alias dictionary table 13 | ---@alias dict table 14 | ---@alias object any 15 | ---@alias float number 16 | ---@alias luaref fun() 17 | ---@alias funcref fun() 18 | ---@alias none nil 19 | ---@alias start number 20 | ---@alias stop number 21 | ---@alias expr string 22 | ---@alias set boolean 23 | 24 | vim = require("vim.shared") 25 | vim = require("vim.uri") 26 | vim = require("vim.inspect") 27 | vim = require("vim._editor") 28 | 29 | vim.diagnostic = require("vim.diagnostic") 30 | vim.filetype = require("vim.filetype") 31 | vim.F = require("vim.F") 32 | vim.fs = require("vim.fs") 33 | vim.health = require("vim.health") 34 | vim.highlight = require("vim.highlight") 35 | vim.inspect = require("vim.inspect") 36 | vim.keymap = require("vim.keymap") 37 | vim.lsp = require("vim.lsp") 38 | vim.treesitter = require("vim.treesitter") 39 | vim.treesitter.highlighter = require("vim.treesitter.highlighter") 40 | vim.ui = require("vim.ui") 41 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | workflow_dispatch: 4 | push: 5 | schedule: 6 | # Run this every day 7 | - cron: '0 * * * *' 8 | 9 | jobs: 10 | update-docs: 11 | runs-on: ubuntu-22.04 12 | steps: 13 | - name: Install dependencies 14 | run: | 15 | sudo add-apt-repository -y ppa:neovim-ppa/unstable 16 | sudo apt-get -y update 17 | sudo apt-get -y install doxygen luajit neovim python3-msgpack 18 | - name: Clone Neovim's repo and run gen_vimdoc.py 19 | run: | 20 | git clone --depth=1 https://github.com/neovim/neovim.git /tmp/neovim-repo 21 | cd /tmp/neovim-repo 22 | python3 ./scripts/gen_vimdoc.py 23 | - uses: actions/checkout@v3 24 | - name: panvimdoc 25 | uses: kdheepak/panvimdoc@main 26 | with: 27 | vimdoc: lua-dev 28 | demojify: true 29 | - name: Generate new docs 30 | run: | 31 | cp /tmp/neovim-repo/runtime/doc/*.mpack ./data/ 32 | nvim -u NONE -E -R --headless --cmd "set rtp^=." --cmd "packloadall" --cmd "luafile lua/lua-dev/parser.lua" --cmd q 33 | - name: Push changes 34 | uses: stefanzweifel/git-auto-commit-action@v4 35 | with: 36 | commit_message: "chore: update api docs" 37 | commit_user_name: "github-actions[bot]" 38 | commit_user_email: "github-actions[bot]@users.noreply.github.com" 39 | commit_author: "github-actions[bot] " 40 | -------------------------------------------------------------------------------- /lua/lua-dev/config.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | --- @class LuaDevOptions 4 | M.defaults = { 5 | library = { 6 | enabled = true, -- when not enabled, lua-dev will not change any settings to the LSP server 7 | -- these settings will be used for your neovim config directory 8 | runtime = true, -- runtime path 9 | types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others 10 | plugins = true, -- installed opt or start plugins in packpath 11 | -- you can also specify the list of plugins to make available as a workspace library 12 | -- plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" }, 13 | }, 14 | setup_jsonls = true, -- configures jsonls to provide completion for .luarc.json files 15 | -- for your neovim config directory, the config.library settings will be used as is 16 | -- for plugin directories (root_dirs having a /lua directory), config.library.plugins will be disabled 17 | -- for any other directory, config.library.enabled will be set to false 18 | override = function(root_dir, options) end, 19 | } 20 | 21 | --- @type LuaDevOptions 22 | M.options = {} 23 | 24 | function M.setup(options) 25 | M.options = vim.tbl_deep_extend("force", {}, M.defaults, options or {}) 26 | 27 | -- legacy config 28 | if M.options.library.vimruntime ~= nil then 29 | M.options.library.runtime = M.options.library.vimruntime 30 | end 31 | end 32 | 33 | ---@return LuaDevOptions 34 | function M.merge(options) 35 | return vim.tbl_deep_extend("force", {}, M.options, options or {}) 36 | end 37 | 38 | return M 39 | -------------------------------------------------------------------------------- /lua/lua-dev/lsp.lua: -------------------------------------------------------------------------------- 1 | local util = require("lua-dev.util") 2 | 3 | local M = {} 4 | 5 | function M.setup() 6 | local opts = require("lua-dev.config").options 7 | 8 | local lsputil = require("lspconfig.util") 9 | local hook = lsputil.add_hook_after 10 | lsputil.on_setup = hook(lsputil.on_setup, function(config) 11 | if opts.setup_jsonls and config.name == "jsonls" then 12 | M.setup_jsonls(config) 13 | end 14 | if config.name == "sumneko_lua" then 15 | config.on_new_config = hook(config.on_new_config, M.on_new_config) 16 | end 17 | end) 18 | end 19 | 20 | function M.setup_jsonls(config) 21 | local schemas = config.settings.json and config.settings.json.schemas or {} 22 | table.insert(schemas, { 23 | name = "Sumneko Lua Settings", 24 | url = "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", 25 | fileMatch = { ".luarc.json", ".luarc.jsonc" }, 26 | }) 27 | config.settings = vim.tbl_deep_extend("force", config.settings, { 28 | json = { 29 | schemas = schemas, 30 | validate = { 31 | enable = true, 32 | }, 33 | }, 34 | }) 35 | end 36 | 37 | function M.on_new_config(config, root_dir) 38 | -- don't do anything when old style setup was used 39 | if config.settings.legacy then 40 | return 41 | end 42 | 43 | local opts = require("lua-dev.config").merge() 44 | 45 | opts.library.enabled = util.is_nvim_config(root_dir) 46 | 47 | if not opts.library.enabled and util.is_plugin(root_dir) then 48 | opts.library.enabled = true 49 | opts.library.plugins = false 50 | end 51 | 52 | pcall(function() 53 | opts = require("neoconf").get("lua-dev", opts, { file = root_dir }) 54 | end) 55 | 56 | pcall(opts.override, root_dir, opts.library) 57 | 58 | local library = config.settings 59 | and config.settings.Lua 60 | and config.settings.Lua.workspace 61 | and config.settings.Lua.workspace.library 62 | or {} 63 | 64 | if opts.library.enabled then 65 | config.settings = vim.tbl_deep_extend( 66 | "force", 67 | config.settings or {}, 68 | require("lua-dev.sumneko").setup(opts, config.settings).settings 69 | ) 70 | for _, lib in ipairs(library) do 71 | table.insert(config.settings.Lua.workspace.library, lib) 72 | end 73 | end 74 | end 75 | 76 | return M 77 | -------------------------------------------------------------------------------- /lua/lua-dev/sumneko.lua: -------------------------------------------------------------------------------- 1 | local config = require("lua-dev.config") 2 | 3 | local M = {} 4 | 5 | ---@param opts LuaDevOptions 6 | function M.library(opts) 7 | opts = config.merge(opts) 8 | local ret = {} 9 | 10 | if opts.library.types then 11 | table.insert(ret, M.types()) 12 | end 13 | 14 | local function add(lib, filter) 15 | ---@diagnostic disable-next-line: param-type-mismatch 16 | for _, p in pairs(vim.fn.expand(lib .. "/lua", false, true)) do 17 | p = vim.loop.fs_realpath(p) 18 | if p and (not filter or filter[vim.fn.fnamemodify(p, ":h:t")]) then 19 | table.insert(ret, vim.fn.fnamemodify(p, ":h")) 20 | end 21 | end 22 | end 23 | 24 | if opts.library.runtime then 25 | add(type(opts.library.runtime) == "string" and opts.library.runtime or "$VIMRUNTIME") 26 | end 27 | 28 | if opts.library.plugins then 29 | local filter 30 | if type(opts.library.plugins) == "table" then 31 | filter = {} 32 | for _, p in pairs(opts.library.plugins) do 33 | filter[p] = true 34 | end 35 | end 36 | for _, site in pairs(vim.split(vim.o.packpath, ",")) do 37 | add(site .. "/pack/*/opt/*", filter) 38 | add(site .. "/pack/*/start/*", filter) 39 | end 40 | end 41 | 42 | return ret 43 | end 44 | 45 | ---@param settings? lspconfig.settings.sumneko_lua 46 | function M.path(settings) 47 | settings = settings or {} 48 | local runtime = settings.Lua and settings.Lua.runtime or {} 49 | local meta = runtime.meta or "${version} ${language} ${encoding}" 50 | meta = meta:gsub("%${version}", runtime.version or "LuaJIT") 51 | meta = meta:gsub("%${language}", "en-us") 52 | meta = meta:gsub("%${encoding}", runtime.fileEncoding or "utf8") 53 | 54 | return { 55 | -- paths for builtin libraries 56 | ("meta/%s/?.lua"):format(meta), 57 | ("meta/%s/?/init.lua"):format(meta), 58 | -- paths for meta/3rd libraries 59 | "library/?.lua", 60 | "library/?/init.lua", 61 | -- Neovim lua files, config and plugins 62 | "lua/?.lua", 63 | "lua/?/init.lua", 64 | } 65 | end 66 | 67 | function M.types() 68 | local f = debug.getinfo(1, "S").source:sub(2) 69 | return vim.loop.fs_realpath(vim.fn.fnamemodify(f, ":h:h:h") .. "/types") 70 | end 71 | 72 | ---@param opts? LuaDevOptions 73 | ---@param settings? lspconfig.settings.sumneko_lua 74 | function M.setup(opts, settings) 75 | opts = config.merge(opts) 76 | return { 77 | ---@type lspconfig.settings.sumneko_lua 78 | settings = { 79 | Lua = { 80 | runtime = { 81 | version = "LuaJIT", 82 | path = M.path(settings), 83 | pathStrict = false, 84 | }, 85 | ---@diagnostic disable-next-line: undefined-field 86 | completion = opts.snippet and { callSnippet = "Replace" } or nil, 87 | workspace = { 88 | -- Make the server aware of Neovim runtime files 89 | library = M.library(opts), 90 | }, 91 | }, 92 | }, 93 | } 94 | end 95 | 96 | return M 97 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 💻 lua-dev 2 | 3 | Dev setup for init.lua and plugin development with full signature help, docs and 4 | completion for the nvim lua API. 5 | 6 | ![image](https://user-images.githubusercontent.com/292349/118822916-6af02080-b86d-11eb-9990-942fe9b55541.png) 7 | 8 | ![image](https://user-images.githubusercontent.com/292349/118823099-9115c080-b86d-11eb-9a68-521c6cb9905a.png) 9 | 10 | ## ✨ Features 11 | 12 | - Automatically configures **sumneko_lua** for your **Neovim** config, **Neovim** runtime and plugin 13 | directories 14 | - [Annotations](https://github.com/sumneko/lua-language-server/wiki/Annotations) 15 | library for the nvim lua API for: 16 | - completion 17 | - hover docs 18 | - function signatures 19 | - properly configures the `require` path. 20 | - adds all plugins in `opt` and `start` to the workspace so you get completion 21 | for all installed plugins 22 | - properly configure the vim runtime 23 | 24 | ## ⚡️ Requirements 25 | 26 | - Neovim >= 0.5.0 27 | - completion plugin like [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) 28 | 29 | ## 📦 Installation 30 | 31 | Install the plugin with your preferred package manager: 32 | 33 | ### [packer](https://github.com/wbthomason/packer.nvim) 34 | 35 | ```lua 36 | use "folke/lua-dev.nvim" 37 | ``` 38 | 39 | ### [vim-plug](https://github.com/junegunn/vim-plug) 40 | 41 | ```vim 42 | Plug 'folke/lua-dev.nvim' 43 | ``` 44 | 45 | ## ⚙️ Configuration 46 | 47 | **lua-dev** comes with the following defaults: 48 | 49 | ```lua 50 | { 51 | library = { 52 | enabled = true, -- when not enabled, lua-dev will not change any settings to the LSP server 53 | -- these settings will be used for your Neovim config directory 54 | runtime = true, -- runtime path 55 | types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others 56 | plugins = true, -- installed opt or start plugins in packpath 57 | -- you can also specify the list of plugins to make available as a workspace library 58 | -- plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" }, 59 | }, 60 | setup_jsonls = true, -- configures jsonls to provide completion for project specific .luarc.json files 61 | -- for your Neovim config directory, the config.library settings will be used as is 62 | -- for plugin directories (root_dirs having a /lua directory), config.library.plugins will be disabled 63 | -- for any other directory, config.library.enabled will be set to false 64 | override = function(root_dir, options) end, 65 | 66 | } 67 | ``` 68 | 69 | ## 🚀 Setup 70 | 71 | **lua-dev** will **ONLY** change the **sumneko_lua** settings for: 72 | 73 | - your Neovim config directory 74 | - your Neovim runtime directory 75 | - any plugin directory (this is an lsp root_dir that contains a `/lua` 76 | directory) 77 | 78 | For any other `root_dir`, **lua-dev** will **NOT** change any settings. 79 | 80 | ```lua 81 | -- IMPORTANT: make sure to setup lua-dev BEFORE lspconfig 82 | require("lua-dev").setup({ 83 | -- add any options here, or leave empty to use the default settings 84 | }) 85 | 86 | -- then setup your lsp server as usual 87 | local lspconfig = require('lspconfig') 88 | 89 | -- example to setup sumneko and enable call snippets 90 | lspconfig.sumneko_lua.setup({ 91 | settings = { 92 | Lua = { 93 | completion = { 94 | callSnippet = "Replace" 95 | } 96 | } 97 | } 98 | }) 99 | ``` 100 | 101 | Example for setting up **lua-dev** that overrides the settings for `/etc/nixos` 102 | 103 | ```lua 104 | -- You can override the default detection using the override function 105 | -- EXAMPLE: If you want a certain directory to be configured differently, you can override its settings 106 | require("lua-dev").setup({ 107 | override = function(root_dir, library) 108 | if require("lua-dev.util").has_file(root_dir, "/etc/nixos") then 109 | library.enabled = true 110 | library.plugins = true 111 | end 112 | end, 113 | }) 114 | ``` 115 | 116 | ## ❓ How? 117 | 118 | **Neovim** includes a 119 | [script](https://github.com/neovim/neovim/blob/master/scripts/gen_vimdoc.py) to 120 | generate the nvim docs. That script also creates message pack files containing 121 | all the API metadata in a structured way. Unfortunately these files are not 122 | packaged in the releases. 123 | 124 | Using the message pack files, I converted all the API data to 125 | [EmmyLua annotations](https://github.com/sumneko/lua-language-server/wiki/EmmyLua-Annotations) 126 | and make them available for the 127 | [Sumneko LSP](https://github.com/sumneko/lua-language-server) as a workspace 128 | library. 129 | 130 | ## 🗒️ Limitations 131 | 132 | - [x] `vim.fn` functions are currently not part of the EmmyLua library since no 133 | message pack files are generated. Implemented using vim-lsp 134 | - function return types are always `any`, since that information is missing 135 | 136 | ## ⭐ Acknowledgment 137 | 138 | - docs for options and functions are based on the work of 139 | [vim-lsp](https://github.com/prabirshrestha/vim-lsp) 140 | -------------------------------------------------------------------------------- /doc/lua-dev.txt: -------------------------------------------------------------------------------- 1 | *lua-dev.txt* For NVIM v0.5.0 Last change: 2022 October 03 2 | 3 | ============================================================================== 4 | Table of Contents *lua-dev-table-of-contents* 5 | 6 | 1. lua-dev |lua-dev-lua-dev| 7 | - Features |lua-dev-features| 8 | - Requirements |lua-dev-requirements| 9 | - Installation |lua-dev-installation| 10 | - Configuration |lua-dev-configuration| 11 | - Setup |lua-dev-setup| 12 | - How? |lua-dev-how?| 13 | - Limitations |lua-dev-limitations| 14 | - Acknowledgment |lua-dev-acknowledgment| 15 | 16 | ============================================================================== 17 | 1. lua-dev *lua-dev-lua-dev* 18 | 19 | Dev setup for init.lua and plugin development with full signature help, docs 20 | and completion for the nvim lua API. 21 | 22 |
23 | 24 |

image

25 |
26 | 27 |
28 | 29 |

image

30 |
31 | 32 | FEATURES *lua-dev-features* 33 | 34 | 35 | - Automatically configures **sumneko_lua** for your **Neovim** config, **Neovim** runtime and plugin 36 | directories 37 | - Annotations 38 | library for the nvim lua API for: 39 | - completion 40 | - hover docs 41 | - function signatures 42 | - properly configures the `require` path. 43 | - adds all plugins in `opt` and `start` to the workspace so you get completion 44 | for all installed plugins 45 | - properly configure the vim runtime 46 | 47 | 48 | REQUIREMENTS *lua-dev-requirements* 49 | 50 | 51 | - Neovim >= 0.5.0 52 | - completion plugin like nvim-cmp 53 | 54 | 55 | INSTALLATION *lua-dev-installation* 56 | 57 | Install the plugin with your preferred package manager: 58 | 59 | PACKER ~ 60 | 61 | > 62 | use "folke/lua-dev.nvim" 63 | < 64 | 65 | 66 | VIM-PLUG ~ 67 | 68 | > 69 | Plug 'folke/lua-dev.nvim' 70 | < 71 | 72 | 73 | CONFIGURATION *lua-dev-configuration* 74 | 75 | **lua-dev** comes with the following defaults: 76 | 77 | > 78 | { 79 | library = { 80 | enabled = true, -- when not enabled, lua-dev will not change any settings to the LSP server 81 | -- these settings will be used for your Neovim config directory 82 | runtime = true, -- runtime path 83 | types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others 84 | plugins = true, -- installed opt or start plugins in packpath 85 | -- you can also specify the list of plugins to make available as a workspace library 86 | -- plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" }, 87 | }, 88 | setup_jsonls = true, -- configures jsonls to provide completion for project specific .luarc.json files 89 | -- for your Neovim config directory, the config.library settings will be used as is 90 | -- for plugin directories (root_dirs having a /lua directory), config.library.plugins will be disabled 91 | -- for any other directory, config.library.enabled will be set to false 92 | override = function(root_dir, options) end, 93 | 94 | } 95 | < 96 | 97 | 98 | SETUP *lua-dev-setup* 99 | 100 | **lua-dev** will **ONLY** change the **sumneko_lua** settings for: 101 | 102 | 103 | - your Neovim config directory 104 | - your Neovim runtime directory 105 | - any plugin directory (this is an lsp root_dir that contains a `/lua` 106 | directory) 107 | 108 | 109 | For any other `root_dir`, **lua-dev** will **NOT** change any settings. 110 | 111 | > 112 | -- IMPORTANT: make sure to setup lua-dev BEFORE lspconfig 113 | require("lua-dev").setup({ 114 | -- add any options here, or leave empty to use the default settings 115 | }) 116 | 117 | -- then setup your lsp server as usual 118 | local lspconfig = require('lspconfig') 119 | 120 | -- example to setup sumneko and enable call snippets 121 | lspconfig.sumneko_lua.setup({ 122 | settings = { 123 | Lua = { 124 | completion = { 125 | callSnippet = "Replace" 126 | } 127 | } 128 | } 129 | }) 130 | < 131 | 132 | 133 | Example for setting up **lua-dev** that overrides the settings for `/etc/nixos` 134 | 135 | > 136 | -- You can override the default detection using the override function 137 | -- EXAMPLE: If you want a certain directory to be configured differently, you can override its settings 138 | require("lua-dev").setup({ 139 | override = function(root_dir, library) 140 | if require("lua-dev.util").has_file(root_dir, "/etc/nixos") then 141 | library.enabled = true 142 | library.plugins = true 143 | end 144 | end, 145 | }) 146 | < 147 | 148 | 149 | HOW? *lua-dev-how?* 150 | 151 | **Neovim** includes a script 152 | to 153 | generate the nvim docs. That script also creates message pack files containing 154 | all the API metadata in a structured way. Unfortunately these files are not 155 | packaged in the releases. 156 | 157 | Using the message pack files, I converted all the API data to EmmyLua 158 | annotations 159 | and 160 | make them available for the Sumneko LSP 161 | as a workspace library. 162 | 163 | LIMITATIONS *lua-dev-limitations* 164 | 165 | 166 | - `vim.fn` functions are currently not part of the EmmyLua library since no 167 | message pack files are generated. Implemented using vim-lsp 168 | - function return types are always `any`, since that information is missing 169 | 170 | 171 | ACKNOWLEDGMENT *lua-dev-acknowledgment* 172 | 173 | 174 | - docs for options and functions are based on the work of 175 | vim-lsp 176 | 177 | 178 | Generated by panvimdoc 179 | 180 | vim:tw=78:ts=8:noet:ft=help:norl: 181 | -------------------------------------------------------------------------------- /lua/lua-dev/parser.lua: -------------------------------------------------------------------------------- 1 | local uv = vim.loop 2 | local M = {} 3 | 4 | function M.comment(str, prefix, prefix_first) 5 | prefix = prefix or "--" 6 | return (prefix_first or prefix) .. " " .. vim.fn.trim(str):gsub("[\n]", "\n" .. prefix .. " "):gsub("%s+\n", "\n") 7 | end 8 | 9 | function M.infer_type(param) 10 | local type = param.type or "any" 11 | if type == "" then 12 | type = "any" 13 | end 14 | if type == "any" then 15 | if param.name == "fn" then 16 | type = "fun(...)" 17 | elseif param.name == "args" or param.name == "list" then 18 | type = "any[]" 19 | elseif param.name == "dict" then 20 | type = "dictionary" 21 | end 22 | return type 23 | end 24 | 25 | if type == "arrayof(string)" then 26 | type = "string[]" 27 | elseif type == "arrayof(integer, 2)" then 28 | type = "number[]" 29 | elseif type == "dictionaryof(luaref)" then 30 | type = "table" 31 | elseif type and type:find("dict%(") == 1 then 32 | type = "dict" 33 | end 34 | return type 35 | end 36 | 37 | function M.emmy_param(param, is_return) 38 | local type = M.infer_type(param) 39 | local parts = {} 40 | if param.name then 41 | table.insert(parts, param.name .. (param.optional and "?" or "")) 42 | end 43 | if type then 44 | table.insert(parts, type) 45 | end 46 | if param.doc then 47 | table.insert(parts, "# " .. param.doc) 48 | end 49 | 50 | if not param.doc and type == "any" then 51 | return "" 52 | end 53 | 54 | local ret = table.concat(parts, " ") 55 | if is_return then 56 | return M.comment("@return " .. ret, "--", "---") .. "\n" 57 | else 58 | return M.comment("@param " .. ret, "--", "---") .. "\n" 59 | end 60 | end 61 | 62 | ---@class MpackFunction 63 | ---@field doc string[] 64 | ---@field parameters string[][] 65 | ---@field parameters_doc table 66 | ---@field return string[] 67 | ---@field seealso string[] 68 | ---@field signature string 69 | 70 | ---@class ApiFunctionParam 71 | ---@field name string 72 | ---@field type string 73 | ---@field doc string 74 | ---@field optional boolean 75 | 76 | --- @param fun MpackFunction 77 | --- @return ApiFunction 78 | function M.process(name, fun, prefix) 79 | --- @class ApiFunction 80 | --- @field params ApiFunctionParam[] 81 | --- @field return ApiFunctionParam 82 | local ret = { 83 | doc = (fun.doc and fun.doc[1]) and table.concat(fun.doc, "\n\n") or "", 84 | name = name, 85 | fqname = prefix .. "." .. name, 86 | params = {}, 87 | seealso = fun.seealso or {}, 88 | ["return"] = {}, 89 | } 90 | 91 | -- make markdown lua code blocks for code regions 92 | ret.doc = ret.doc:gsub(">\n", "\n```lua\n") 93 | ret.doc = ret.doc:gsub("\n<\n", "\n```\n") 94 | ret.doc = ret.doc:gsub("\n<$", "\n```") 95 | 96 | for _, r in pairs(fun["return"]) do 97 | table.insert(ret["return"], { doc = r }) 98 | end 99 | 100 | local param_docs = {} 101 | for param, doc in pairs(fun.parameters_doc or {}) do 102 | param_docs[param] = doc 103 | end 104 | 105 | for i, p in ipairs(fun.parameters or {}) do 106 | local type, pname = unpack(p) 107 | local param = { name = pname } 108 | if type ~= "" then 109 | param.type = type:lower() 110 | end 111 | if param_docs[pname] then 112 | param.doc = param_docs[pname] 113 | end 114 | if param.name == "end" then 115 | param.name = "end_" 116 | end 117 | if param.type and param.type:find("%*$") then 118 | param.type = param.type:sub(1, -2) 119 | param.optional = true 120 | end 121 | -- only include err param if it's documented 122 | -- most nvim_ functions have an err param at the end, but these should not be included 123 | local skip = i == #fun.parameters and (pname == "err" or pname == "error") 124 | -- skip self params 125 | if param.name == "self" or param.name == "" or param.name == "arena" then 126 | skip = true 127 | end 128 | if not skip then 129 | table.insert(ret.params, param) 130 | end 131 | end 132 | return ret 133 | end 134 | 135 | --- @param fun ApiFunction 136 | function M.emmy(fun) 137 | local ret = "" 138 | if fun.doc ~= "" then 139 | ret = ret .. (M.comment(fun.doc)) .. "\n" 140 | end 141 | 142 | if fun.seealso and #fun.seealso > 0 then 143 | for _, also in ipairs(fun.seealso) do 144 | ret = ret .. "--- @see " .. also .. "\n" 145 | end 146 | end 147 | 148 | local params = {} 149 | 150 | for _, param in pairs(fun.params) do 151 | table.insert(params, param.name) 152 | ret = ret .. M.emmy_param(param) 153 | end 154 | for _, r in pairs(fun["return"]) do 155 | ret = ret .. M.emmy_param(r, true) 156 | end 157 | 158 | local signature = "function %s(%s) end" 159 | 160 | ret = ret .. signature:format(fun.fqname, table.concat(params, ", ")) 161 | return ret .. "\n\n" 162 | end 163 | 164 | function M.intro(fd) 165 | uv.fs_write( 166 | fd, 167 | [[ 168 | ---@meta 169 | 170 | --# selene: allow(unused_variable) 171 | ---@diagnostic disable: unused-local 172 | 173 | ]], 174 | -1 175 | ) 176 | end 177 | 178 | function M.get_functions(mpack) 179 | mpack = "data/" .. mpack 180 | local data = vim.fn.msgpackparse(vim.fn.readfile(mpack, "b")) 181 | local ret = {} 182 | for _, functions in pairs(data) do 183 | for name, fun in pairs(functions) do 184 | table.insert(ret, { name, fun }) 185 | end 186 | end 187 | table.sort(ret, function(a, b) 188 | return a[1] < b[1] 189 | end) 190 | return ret 191 | end 192 | 193 | function M.parse(mpack, prefix, exclude) 194 | print(prefix) 195 | -- exclude signatures for functions that are existing lua sources 196 | local skip = {} 197 | for _, value in pairs(exclude or {}) do 198 | for key, _ in pairs(require(value)) do 199 | print("skipping " .. value .. ": " .. key) 200 | skip[key] = true 201 | end 202 | end 203 | prefix = prefix or "vim" 204 | local fname = vim.fn.fnamemodify(mpack, ":t:r") 205 | 206 | local writer = M.writer("types/" .. fname) 207 | local classes = {} 208 | for _, f in pairs(M.get_functions(mpack)) do 209 | local name, fun = unpack(f) 210 | if not skip[name] then 211 | local parts = vim.fn.split(name, ":") 212 | if #parts > 1 and not classes[parts[1]] then 213 | writer.write(([[ 214 | --- @class %s 215 | %s = {} 216 | 217 | ]]):format(prefix .. "." .. parts[1], prefix .. "." .. parts[1])) 218 | classes[parts[1]] = true 219 | end 220 | local emmy = M.emmy(M.process(name, fun, prefix)) 221 | writer.write(emmy) 222 | end 223 | end 224 | writer.close() 225 | end 226 | 227 | function M.options() 228 | local data = vim.fn.json_decode(vim.fn.readfile("data/builtin-docs.json")) 229 | local docs = data.documents.options 230 | 231 | local ret = { o = {}, wo = {}, bo = {} } 232 | for name, option in pairs(vim.api.nvim_get_all_options_info()) do 233 | if option.scope == "buf" then 234 | ret.bo[name] = option.default 235 | elseif option.scope == "win" then 236 | ret.wo[name] = option.default 237 | end 238 | if option.scope == "global" or option.global_local then 239 | ret.o[name] = option.default 240 | end 241 | end 242 | 243 | local writer = M.writer("types/options") 244 | for _, scope in ipairs({ "bo", "o", "wo" }) do 245 | local options = ret[scope] 246 | local names = vim.tbl_keys(options) 247 | table.sort(names) 248 | for _, key in ipairs(names) do 249 | local value = options[key] 250 | local str = ("vim.%s.%s = %q\n"):format(scope, key, value) 251 | local doc = docs[key] and table.concat(docs[key], "\n") or nil 252 | if doc then 253 | str = M.comment(doc) .. "\n" .. str 254 | end 255 | writer.write(str) 256 | end 257 | end 258 | writer.close() 259 | end 260 | 261 | function M.writer(file) 262 | local fd = uv.fs_open(file .. ".lua", "w+", 420) 263 | local size = 0 264 | local fnum = 0 265 | M.intro(fd) 266 | return { 267 | write = function(str) 268 | uv.fs_write(fd, str, -1) 269 | size = size + #str 270 | if size > 1024 * 200 then 271 | uv.fs_close(fd) 272 | fnum = fnum + 1 273 | size = 0 274 | fd = uv.fs_open(file .. "." .. fnum .. ".lua", "w+", 420) 275 | M.intro(fd) 276 | end 277 | end, 278 | close = function() 279 | uv.fs_close(fd) 280 | end, 281 | } 282 | end 283 | 284 | function M.functions() 285 | local data = vim.fn.json_decode(vim.fn.readfile("data/builtin-docs.json")) 286 | local functions = data.signatureHelp 287 | local docs = data.documents.functions 288 | 289 | local writer = M.writer("types/vim.fn") 290 | local exclude = { ["or"] = true, ["and"] = true, ["repeat"] = true, ["function"] = true, ["end"] = true } 291 | local names = vim.tbl_keys(functions) 292 | table.sort(names) 293 | for _, name in ipairs(names) do 294 | local props = functions[name] 295 | if vim.fn[name] and not vim.api[name] and not exclude[name] then 296 | local fun = { 297 | name = name, 298 | fqname = "vim.fn." .. name, 299 | doc = table.concat(docs[name] or {}, "\n"), 300 | params = {}, 301 | ["return"] = {}, 302 | } 303 | if props[2] ~= "" then 304 | fun["return"] = { { type = props[2]:lower() } } 305 | end 306 | if props[1] ~= "" then 307 | for _, param in pairs(vim.split(props[1], ",")) do 308 | param = vim.trim(param:gsub("[{}%]%[]", "")) 309 | param = param:gsub("-", "_") 310 | if exclude[param] or tonumber(param) ~= nil then 311 | param = "_" .. param 312 | end 313 | if param:find("%.%.%.") then 314 | param = "..." 315 | end 316 | table.insert(fun.params, { name = param }) 317 | end 318 | end 319 | writer.write(M.emmy(fun)) 320 | end 321 | end 322 | writer.close() 323 | end 324 | 325 | function M.clean() 326 | for _, f in pairs(vim.fn.expand("types/*.lua", false, true)) do 327 | if f ~= "types/vim.lua" then 328 | uv.fs_unlink(f) 329 | end 330 | end 331 | end 332 | 333 | function M.build() 334 | M.clean() 335 | M.functions() 336 | M.options() 337 | -- M.parse("lua.mpack", "vim", { "vim.uri", "vim.inspect" }) 338 | M.parse("api.mpack", "vim.api") 339 | -- M.parse("diagnostic.mpack", "vim.diagnostic") 340 | -- M.parse("lsp.mpack", "vim.lsp", { "vim.lsp" }) 341 | -- M.parse("treesitter.mpack", "vim.treesitter", { "vim.treesitter" }) 342 | end 343 | 344 | M.build() 345 | 346 | return M 347 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /types/options.1.lua: -------------------------------------------------------------------------------- 1 | ---@meta 2 | 3 | --# selene: allow(unused_variable) 4 | ---@diagnostic disable: unused-local 5 | 6 | -- number (default 1) 7 | -- global 8 | -- The minimal height of a window, when it's not the current window. 9 | -- This is a hard minimum, windows will never become smaller. 10 | -- When set to zero, windows may be "squashed" to zero lines (i.e. just a 11 | -- status bar) if necessary. They will return to at least one line when 12 | -- they become active (since the cursor has to have somewhere to go.) 13 | -- Use 'winheight' to set the minimal height of the current window. 14 | -- This option is only checked when making a window smaller. Don't use a 15 | -- large number, it will cause errors when opening more than a few 16 | -- windows. A value of 0 to 3 is reasonable. 17 | vim.o.winminheight = "1" 18 | -- number (default 1) 19 | -- global 20 | -- The minimal width of a window, when it's not the current window. 21 | -- This is a hard minimum, windows will never become smaller. 22 | -- When set to zero, windows may be "squashed" to zero columns (i.e. just 23 | -- a vertical separator) if necessary. They will return to at least one 24 | -- line when they become active (since the cursor has to have somewhere 25 | -- to go.) 26 | -- Use 'winwidth' to set the minimal width of the current window. 27 | -- This option is only checked when making a window smaller. Don't use a 28 | -- large number, it will cause errors when opening more than a few 29 | -- windows. A value of 0 to 12 is reasonable. 30 | vim.o.winminwidth = "1" 31 | -- number (default 20) 32 | -- global 33 | -- Minimal number of columns for the current window. This is not a hard 34 | -- minimum, Vim will use fewer columns if there is not enough room. If 35 | -- the current window is smaller, its size is increased, at the cost of 36 | -- the width of other windows. Set it to 999 to make the current window 37 | -- always fill the screen. Set it to a small number for normal editing. 38 | -- The width is not adjusted after one of the commands to change the 39 | -- width of the current window. 40 | -- 'winwidth' applies to the current window. Use 'winminwidth' to set 41 | -- the minimal width for other windows. 42 | vim.o.winwidth = "20" 43 | -- boolean (default on) *E384* *E385* 44 | -- global 45 | -- Searches wrap around the end of the file. Also applies to |]s| and 46 | -- |[s|, searching for spelling mistakes. 47 | vim.o.wrapscan = "true" 48 | -- boolean (default on) 49 | -- global 50 | -- Allows writing files. When not set, writing a file is not allowed. 51 | -- Can be used for a view-only mode, where modifications to the text are 52 | -- still allowed. Can be reset with the |-m| or |-M| command line 53 | -- argument. Filtering text is still possible, even though this requires 54 | -- writing a temporary file. 55 | vim.o.write = "true" 56 | -- boolean (default off) 57 | -- global 58 | -- Allows writing to any file with no need for "!" override. 59 | vim.o.writeany = "false" 60 | -- boolean (default on with |+writebackup| feature, off 61 | -- otherwise) 62 | -- global 63 | -- Make a backup before overwriting a file. The backup is removed after 64 | -- the file was successfully written, unless the 'backup' option is 65 | -- also on. 66 | -- WARNING: Switching this option off means that when Vim fails to write 67 | -- your buffer correctly and then, for whatever reason, Vim exits, you 68 | -- lose both the original file and what you were writing. Only reset 69 | -- this option if your file system is almost full and it makes the write 70 | -- fail (and make sure not to exit Vim until the write was successful). 71 | -- See |backup-table| for another explanation. 72 | -- When the 'backupskip' pattern matches, a backup is not made anyway. 73 | vim.o.writebackup = "true" 74 | -- number (default 0) 75 | -- global 76 | -- The number of milliseconds to wait for each character sent to the 77 | -- screen. When positive, characters are sent to the UI one by one. 78 | -- See 'redrawdebug' for more options. For debugging purposes. 79 | vim.o.writedelay = "0" 80 | -- boolean (default off) 81 | -- local to window 82 | -- This option can be set to start editing Arabic text. 83 | -- Setting this option will: 84 | -- - Set the 'rightleft' option, unless 'termbidi' is set. 85 | -- - Set the 'arabicshape' option, unless 'termbidi' is set. 86 | -- - Set the 'keymap' option to "arabic"; in Insert mode CTRL-^ toggles 87 | -- between typing English and Arabic key mapping. 88 | -- - Set the 'delcombine' option 89 | vim.wo.arabic = "false" 90 | -- boolean (default off) 91 | -- local to window 92 | -- Every wrapped line will continue visually indented (same amount of 93 | -- space as the beginning of that line), thus preserving horizontal blocks 94 | -- of text. 95 | vim.wo.breakindent = "false" 96 | -- string (default empty) 97 | -- local to window 98 | -- Settings for 'breakindent'. It can consist of the following optional 99 | -- items and must be separated by a comma: 100 | -- min:{n} Minimum text width that will be kept after 101 | -- applying 'breakindent', even if the resulting 102 | -- text should normally be narrower. This prevents 103 | -- text indented almost to the right window border 104 | -- occupying lot of vertical space when broken. 105 | -- shift:{n} After applying 'breakindent', the wrapped line's 106 | -- beginning will be shifted by the given number of 107 | -- characters. It permits dynamic French paragraph 108 | -- indentation (negative) or emphasizing the line 109 | -- continuation (positive). 110 | -- sbr Display the 'showbreak' value before applying the 111 | -- additional indent. 112 | -- The default value for min is 20 and shift is 0. 113 | vim.wo.breakindentopt = "" 114 | -- string (default "") 115 | -- local to window 116 | -- 'colorcolumn' is a comma separated list of screen columns that are 117 | -- highlighted with ColorColumn |hl-ColorColumn|. Useful to align 118 | -- text. Will make screen redrawing slower. 119 | -- The screen column can be an absolute number, or a number preceded with 120 | -- '+' or '-', which is added to or subtracted from 'textwidth'. > 121 | vim.wo.colorcolumn = "" 122 | -- string (default: "") 123 | -- local to window 124 | -- Sets the modes in which text in the cursor line can also be concealed. 125 | -- When the current mode is listed then concealing happens just like in 126 | -- other lines. 127 | -- n Normal mode 128 | -- v Visual mode 129 | -- i Insert mode 130 | -- c Command line editing, for 'incsearch' 131 | vim.wo.concealcursor = "" 132 | -- number (default 0) 133 | -- local to window 134 | -- Determine how text with the "conceal" syntax attribute |:syn-conceal| 135 | -- is shown: 136 | vim.wo.conceallevel = "0" 137 | -- boolean (default off) 138 | -- local to window 139 | -- When this option is set, as the cursor in the current 140 | -- window moves other cursorbound windows (windows that also have 141 | -- this option set) move their cursors to the corresponding line and 142 | -- column. This option is useful for viewing the 143 | -- differences between two versions of a file (see 'diff'); in diff mode, 144 | -- inserted and deleted lines (though not characters within a line) are 145 | -- taken into account. 146 | vim.wo.cursorbind = "false" 147 | -- boolean (default off) 148 | -- local to window 149 | -- Highlight the screen column of the cursor with CursorColumn 150 | -- |hl-CursorColumn|. Useful to align text. Will make screen redrawing 151 | -- slower. 152 | -- If you only want the highlighting in the current window you can use 153 | -- these autocommands: > 154 | -- au WinLeave * set nocursorline nocursorcolumn 155 | -- au WinEnter * set cursorline cursorcolumn 156 | -- < 157 | vim.wo.cursorcolumn = "false" 158 | -- boolean (default off) 159 | -- local to window 160 | -- Highlight the screen line of the cursor with CursorLine 161 | -- |hl-CursorLine|. Useful to easily spot the cursor. Will make screen 162 | -- redrawing slower. 163 | -- When Visual mode is active the highlighting isn't used to make it 164 | -- easier to see the selected text. 165 | vim.wo.cursorline = "false" 166 | -- string (default: "number,line") 167 | -- local to window 168 | -- {not available when compiled without the |+syntax| 169 | -- feature} 170 | -- Comma separated list of settings for how 'cursorline' is displayed. 171 | -- Valid values: 172 | -- "line" Highlight the text line of the cursor with 173 | -- CursorLine |hl-CursorLine|. 174 | -- "screenline" Highlight only the screen line of the cursor with 175 | -- CursorLine |hl-CursorLine|. 176 | -- "number" Highlight the line number of the cursor with 177 | -- CursorLineNr |hl-CursorLineNr|. 178 | vim.wo.cursorlineopt = "both" 179 | -- boolean (default off) 180 | -- local to window 181 | -- Join the current window in the group of windows that shows differences 182 | -- between files. See |diff-mode|. 183 | vim.wo.diff = "false" 184 | -- string (default "") 185 | -- global or local to window |global-local| 186 | -- Characters to fill the statuslines and vertical separators. 187 | -- It is a comma separated list of items: 188 | vim.wo.fillchars = "" 189 | -- string (default "0") 190 | -- local to window 191 | -- When and how to draw the foldcolumn. Valid values are: 192 | -- "auto": resize to the maximum amount of folds to display. 193 | -- "auto:[1-9]": resize to accommodate multiple folds up to the 194 | -- selected level 195 | -- 0: to disable foldcolumn 196 | -- "[1-9]": to display a fixed number of columns 197 | -- See |folding|. 198 | vim.wo.foldcolumn = "0" 199 | -- boolean (default on) 200 | -- local to window 201 | -- When off, all folds are open. This option can be used to quickly 202 | -- switch between showing all text unfolded and viewing the text with 203 | -- folds (including manually opened or closed folds). It can be toggled 204 | -- with the |zi| command. The 'foldcolumn' will remain blank when 205 | -- 'foldenable' is off. 206 | -- This option is set by commands that create a new fold or close a fold. 207 | -- See |folding|. 208 | vim.wo.foldenable = "true" 209 | -- string (default: "0") 210 | -- local to window 211 | -- The expression used for when 'foldmethod' is "expr". It is evaluated 212 | -- for each line to obtain its fold level. See |fold-expr|. 213 | vim.wo.foldexpr = "0" 214 | -- string (default: "#") 215 | -- local to window 216 | -- Used only when 'foldmethod' is "indent". Lines starting with 217 | -- characters in 'foldignore' will get their fold level from surrounding 218 | -- lines. White space is skipped before checking for this character. 219 | -- The default "#" works well for C programs. See |fold-indent|. 220 | vim.wo.foldignore = "#" 221 | -- number (default: 0) 222 | -- local to window 223 | -- Sets the fold level: Folds with a higher level will be closed. 224 | -- Setting this option to zero will close all folds. Higher numbers will 225 | -- close fewer folds. 226 | -- This option is set by commands like |zm|, |zM| and |zR|. 227 | -- See |fold-foldlevel|. 228 | vim.wo.foldlevel = "0" 229 | -- string (default: "{{{,}}}") 230 | -- local to window 231 | -- The start and end marker used when 'foldmethod' is "marker". There 232 | -- must be one comma, which separates the start and end marker. The 233 | -- marker is a literal string (a regular expression would be too slow). 234 | -- See |fold-marker|. 235 | vim.wo.foldmarker = "{{{,}}}" 236 | -- string (default: "manual") 237 | -- local to window 238 | -- The kind of folding used for the current window. Possible values: 239 | -- |fold-manual| manual Folds are created manually. 240 | -- |fold-indent| indent Lines with equal indent form a fold. 241 | -- |fold-expr| expr 'foldexpr' gives the fold level of a line. 242 | -- |fold-marker| marker Markers are used to specify folds. 243 | -- |fold-syntax| syntax Syntax highlighting items specify folds. 244 | -- |fold-diff| diff Fold text that is not changed. 245 | vim.wo.foldmethod = "manual" 246 | -- number (default: 1) 247 | -- local to window 248 | -- Sets the number of screen lines above which a fold can be displayed 249 | -- closed. Also for manually closed folds. With the default value of 250 | -- one a fold can only be closed if it takes up two or more screen lines. 251 | -- Set to zero to be able to close folds of just one screen line. 252 | -- Note that this only has an effect on what is displayed. After using 253 | -- "zc" to close a fold, which is displayed open because it's smaller 254 | -- than 'foldminlines', a following "zc" may close a containing fold. 255 | vim.wo.foldminlines = "1" 256 | -- number (default: 20) 257 | -- local to window 258 | -- Sets the maximum nesting of folds for the "indent" and "syntax" 259 | -- methods. This avoids that too many folds will be created. Using more 260 | -- than 20 doesn't work, because the internal limit is 20. 261 | vim.wo.foldnestmax = "20" 262 | -- string (default: "foldtext()") 263 | -- local to window 264 | -- An expression which is used to specify the text displayed for a closed 265 | -- fold. See |fold-foldtext|. 266 | vim.wo.foldtext = "foldtext()" 267 | -- boolean (default off) 268 | -- local to window 269 | -- If on, Vim will wrap long lines at a character in 'breakat' rather 270 | -- than at the last character that fits on the screen. Unlike 271 | -- 'wrapmargin' and 'textwidth', this does not insert s in the file, 272 | -- it only affects the way the file is displayed, not its contents. 273 | -- If 'breakindent' is set, line is visually indented. Then, the value 274 | -- of 'showbreak' is used to put in front of wrapped lines. This option 275 | -- is not used when the 'wrap' option is off. 276 | -- Note that characters after an are mostly not displayed 277 | -- with the right amount of white space. 278 | vim.wo.linebreak = "false" 279 | -- boolean (default off) 280 | -- local to window 281 | -- List mode: Show tabs as CTRL-I is displayed, display $ after end of 282 | -- line. Useful to see the difference between tabs and spaces and for 283 | -- trailing blanks. Further changed by the 'listchars' option. 284 | vim.wo.list = "false" 285 | -- string (default: "tab:> ,trail:-,nbsp:+" 286 | -- Vi default: "eol:$") 287 | -- global or local to window |global-local| 288 | -- Strings to use in 'list' mode and for the |:list| command. It is a 289 | -- comma separated list of string settings. 290 | vim.wo.listchars = "tab:> ,trail:-,nbsp:+" 291 | -- boolean (default off) 292 | -- local to window 293 | -- Print the line number in front of each line. When the 'n' option is 294 | -- excluded from 'cpoptions' a wrapped line will not use the column of 295 | -- line numbers. 296 | -- Use the 'numberwidth' option to adjust the room for the line number. 297 | -- When a long, wrapped line doesn't start with the first character, '-' 298 | -- characters are put before the number. 299 | -- For highlighting see |hl-LineNr|, |hl-CursorLineNr|, and the 300 | -- |:sign-define| "numhl" argument. 301 | -- *number_relativenumber* 302 | -- The 'relativenumber' option changes the displayed number to be 303 | -- relative to the cursor. Together with 'number' there are these 304 | -- four combinations (cursor in line 3): 305 | vim.wo.number = "false" 306 | -- number (Vim default: 4 Vi default: 8) 307 | -- local to window 308 | -- Minimal number of columns to use for the line number. Only relevant 309 | -- when the 'number' or 'relativenumber' option is set or printing lines 310 | -- with a line number. Since one space is always between the number and 311 | -- the text, there is one less character for the number itself. 312 | -- The value is the minimum width. A bigger width is used when needed to 313 | -- fit the highest line number in the buffer respectively the number of 314 | -- rows in the window, depending on whether 'number' or 'relativenumber' 315 | -- is set. Thus with the Vim default of 4 there is room for a line number 316 | -- up to 999. When the buffer has 1000 lines five columns will be used. 317 | -- The minimum value is 1, the maximum value is 20. 318 | vim.wo.numberwidth = "4" 319 | -- boolean (default off) 320 | -- local to window 321 | -- Identifies the preview window. Only one window can have this option 322 | -- set. It's normally not set directly, but by using one of the commands 323 | -- |:ptag|, |:pedit|, etc. 324 | vim.wo.previewwindow = "false" 325 | -- boolean (default off) 326 | -- local to window 327 | -- Show the line number relative to the line with the cursor in front of 328 | -- each line. Relative line numbers help you use the |count| you can 329 | -- precede some vertical motion commands (e.g. j k + -) with, without 330 | -- having to calculate it yourself. Especially useful in combination with 331 | -- other commands (e.g. y d c < > gq gw =). 332 | -- When the 'n' option is excluded from 'cpoptions' a wrapped 333 | -- line will not use the column of line numbers. 334 | -- The 'numberwidth' option can be used to set the room used for the line 335 | -- number. 336 | -- When a long, wrapped line doesn't start with the first character, '-' 337 | -- characters are put before the number. 338 | -- See |hl-LineNr| and |hl-CursorLineNr| for the highlighting used for 339 | -- the number. 340 | vim.wo.relativenumber = "false" 341 | -- boolean (default off) 342 | -- local to window 343 | -- When on, display orientation becomes right-to-left, i.e., characters 344 | -- that are stored in the file appear from the right to the left. 345 | -- Using this option, it is possible to edit files for languages that 346 | -- are written from the right to the left such as Hebrew and Arabic. 347 | -- This option is per window, so it is possible to edit mixed files 348 | -- simultaneously, or to view the same file in both ways (this is 349 | -- useful whenever you have a mixed text file with both right-to-left 350 | -- and left-to-right strings so that both sets are displayed properly 351 | -- in different windows). Also see |rileft.txt|. 352 | vim.wo.rightleft = "false" 353 | -- string (default "search") 354 | -- local to window 355 | -- Each word in this option enables the command line editing to work in 356 | -- right-to-left mode for a group of commands: 357 | vim.wo.rightleftcmd = "search" 358 | -- number (default: half the window height) 359 | -- local to window 360 | -- Number of lines to scroll with CTRL-U and CTRL-D commands. Will be 361 | -- set to half the number of lines in the window when the window size 362 | -- changes. If you give a count to the CTRL-U or CTRL-D command it will 363 | -- be used as the new value for 'scroll'. Reset to half the window 364 | -- height with ":set scroll=0". 365 | vim.wo.scroll = "0" 366 | -- boolean (default off) 367 | -- local to window 368 | -- See also |scroll-binding|. When this option is set, the current 369 | -- window scrolls as other scrollbind windows (windows that also have 370 | -- this option set) scroll. This option is useful for viewing the 371 | -- differences between two versions of a file, see 'diff'. 372 | -- See |'scrollopt'| for options that determine how this option should be 373 | -- interpreted. 374 | -- This option is mostly reset when splitting a window to edit another 375 | -- file. This means that ":split | edit file" results in two windows 376 | -- with scroll-binding, but ":split file" does not. 377 | vim.wo.scrollbind = "false" 378 | -- number (default 0) 379 | -- global or local to window |global-local| 380 | -- Minimal number of screen lines to keep above and below the cursor. 381 | -- This will make some context visible around where you are working. If 382 | -- you set it to a very large value (999) the cursor line will always be 383 | -- in the middle of the window (except at the start or end of the file or 384 | -- when long lines wrap). 385 | -- After using the local value, go back the global value with one of 386 | -- these two: > 387 | -- setlocal scrolloff< 388 | -- setlocal scrolloff=-1 389 | -- < For scrolling horizontally see 'sidescrolloff'. 390 | vim.wo.scrolloff = "0" 391 | -- string (default "") 392 | -- global 393 | -- String to put at the start of lines that have been wrapped. Useful 394 | -- values are "> " or "+++ ": > 395 | -- :set showbreak=>\ 396 | -- < Note the backslash to escape the trailing space. It's easier like 397 | -- this: > 398 | -- :let &showbreak = '+++ ' 399 | -- < Only printable single-cell characters are allowed, excluding and 400 | -- comma (in a future version the comma might be used to separate the 401 | -- part that is shown at the end and at the start of a line). 402 | -- The |hl-NonText| highlight group determines the highlighting. 403 | -- Note that tabs after the showbreak will be displayed differently. 404 | -- If you want the 'showbreak' to appear in between line numbers, add the 405 | -- "n" flag to 'cpoptions'. 406 | vim.wo.showbreak = "" 407 | -- number (default 0) 408 | -- global or local to window |global-local| 409 | -- The minimal number of screen columns to keep to the left and to the 410 | -- right of the cursor if 'nowrap' is set. Setting this option to a 411 | -- value greater than 0 while having |'sidescroll'| also at a non-zero 412 | -- value makes some context visible in the line you are scrolling in 413 | -- horizontally (except at beginning of the line). Setting this option 414 | -- to a large value (like 999) has the effect of keeping the cursor 415 | -- horizontally centered in the window, as long as one does not come too 416 | -- close to the beginning of the line. 417 | -- After using the local value, go back the global value with one of 418 | -- these two: > 419 | -- setlocal sidescrolloff< 420 | -- setlocal sidescrolloff=-1 421 | -- < 422 | -- Example: Try this together with 'sidescroll' and 'listchars' as 423 | -- in the following example to never allow the cursor to move 424 | -- onto the "extends" character: > 425 | vim.wo.sidescrolloff = "0" 426 | -- string (default "auto") 427 | -- local to window 428 | -- When and how to draw the signcolumn. Valid values are: 429 | -- "auto" only when there is a sign to display 430 | -- "auto:[1-9]" resize to accommodate multiple signs up to the 431 | -- given number (maximum 9), e.g. "auto:4" 432 | -- "no" never 433 | -- "yes" always 434 | -- "yes:[1-9]" always, with fixed space for signs up to the given 435 | -- number (maximum 9), e.g. "yes:3" 436 | vim.wo.signcolumn = "auto" 437 | -- boolean (default off) 438 | -- local to window 439 | -- When on spell checking will be done. See |spell|. 440 | -- The languages are specified with 'spelllang'. 441 | vim.wo.spell = "false" 442 | -- string (default empty) 443 | -- global or local to window |global-local| 444 | -- When nonempty, this option determines the content of the status line. 445 | -- Also see |status-line|. 446 | vim.wo.statusline = "" 447 | -- string (default "") 448 | -- global 449 | -- A comma separated list of these words: 450 | -- block Allow virtual editing in Visual block mode. 451 | -- insert Allow virtual editing in Insert mode. 452 | -- all Allow virtual editing in all modes. 453 | -- onemore Allow the cursor to move just past the end of the line 454 | vim.wo.virtualedit = "" 455 | vim.wo.winbar = "" 456 | -- number (default 0) 457 | -- local to window 458 | -- Enables pseudo-transparency for a floating window. Valid values are in 459 | -- the range of 0 for fully opaque window (disabled) to 100 for fully 460 | -- transparent background. Values between 0-30 are typically most useful. 461 | vim.wo.winblend = "0" 462 | -- boolean (default off) 463 | -- local to window 464 | -- Keep the window height when windows are opened or closed and 465 | -- 'equalalways' is set. Also for |CTRL-W_=|. Set by default for the 466 | -- |preview-window| and |quickfix-window|. 467 | -- The height may be changed anyway when running out of room. 468 | vim.wo.winfixheight = "false" 469 | -- boolean (default off) 470 | -- local to window 471 | -- Keep the window width when windows are opened or closed and 472 | -- 'equalalways' is set. Also for |CTRL-W_=|. 473 | -- The width may be changed anyway when running out of room. 474 | vim.wo.winfixwidth = "false" 475 | -- string (default empty) 476 | -- local to window 477 | -- Window-local highlights. Comma-delimited list of highlight 478 | -- |group-name| pairs "{hl-builtin}:{hl},..." where each {hl-builtin} is 479 | -- a built-in |highlight-groups| item to be overridden by {hl} group in 480 | -- the window. Only built-in |highlight-groups| are supported, not 481 | -- syntax highlighting (use |:ownsyntax| for that). 482 | vim.wo.winhighlight = "" 483 | -- boolean (default on) 484 | -- local to window 485 | -- This option changes how text is displayed. It doesn't change the text 486 | -- in the buffer, see 'textwidth' for that. 487 | -- When on, lines longer than the width of the window will wrap and 488 | -- displaying continues on the next line. When off lines will not wrap 489 | -- and only part of long lines will be displayed. When the cursor is 490 | -- moved to a part that is not shown, the screen will scroll 491 | -- horizontally. 492 | -- The line will be broken in the middle of a word if necessary. See 493 | -- 'linebreak' to get the break at a word boundary. 494 | -- To make scrolling horizontally a bit more useful, try this: > 495 | -- :set sidescroll=5 496 | -- :set listchars+=precedes:<,extends:> 497 | -- < See 'sidescroll', 'listchars' and |wrap-off|. 498 | -- This option can't be set from a |modeline| when the 'diff' option is 499 | -- on. 500 | vim.wo.wrap = "true" 501 | -------------------------------------------------------------------------------- /types/api.lua: -------------------------------------------------------------------------------- 1 | ---@meta 2 | 3 | --# selene: allow(unused_variable) 4 | ---@diagnostic disable: unused-local 5 | 6 | --- @param buffer buffer 7 | --- @param first integer 8 | --- @param last integer 9 | function vim.api.nvim__buf_redraw_range(buffer, first, last) end 10 | 11 | --- @param buffer buffer 12 | function vim.api.nvim__buf_stats(buffer) end 13 | 14 | --- @param ns_id integer 15 | function vim.api.nvim__get_hl_defs(ns_id) end 16 | 17 | function vim.api.nvim__get_lib_dir() end 18 | 19 | -- Find files in runtime directories 20 | --- @param pat array # pattern of files to search for 21 | --- @param all boolean # whether to return all matches or only the first 22 | --- @param opts? dict # is_lua: only search lua subdirs 23 | --- @return any # list of absolute paths to the found files 24 | function vim.api.nvim__get_runtime(pat, all, opts) end 25 | 26 | -- Returns object given as argument. 27 | -- 28 | -- This API function is used for testing. One should not rely on its presence 29 | -- in plugins. 30 | --- @param obj object # Object to return. 31 | --- @return any # its argument. 32 | function vim.api.nvim__id(obj) end 33 | 34 | -- Returns array given as argument. 35 | -- 36 | -- This API function is used for testing. One should not rely on its presence 37 | -- in plugins. 38 | --- @param arr array # Array to return. 39 | --- @return any # its argument. 40 | function vim.api.nvim__id_array(arr) end 41 | 42 | -- Returns dictionary given as argument. 43 | -- 44 | -- This API function is used for testing. One should not rely on its presence 45 | -- in plugins. 46 | --- @param dct dictionary # Dictionary to return. 47 | --- @return any # its argument. 48 | function vim.api.nvim__id_dictionary(dct) end 49 | 50 | -- Returns floating-point value given as argument. 51 | -- 52 | -- This API function is used for testing. One should not rely on its presence 53 | -- in plugins. 54 | --- @param flt float # Value to return. 55 | --- @return any # its argument. 56 | function vim.api.nvim__id_float(flt) end 57 | 58 | --- @param grid integer 59 | --- @param row integer 60 | --- @param col integer 61 | function vim.api.nvim__inspect_cell(grid, row, col) end 62 | 63 | function vim.api.nvim__runtime_inspect() end 64 | 65 | --- @param path string 66 | function vim.api.nvim__screenshot(path) end 67 | 68 | -- Gets internal stats. 69 | --- @return any # Map of various internal stats. 70 | function vim.api.nvim__stats() end 71 | 72 | --- @param str string 73 | function vim.api.nvim__unpack(str) end 74 | 75 | -- Adds a highlight to buffer. 76 | -- 77 | -- Useful for plugins that dynamically generate highlights to a buffer (like 78 | -- a semantic highlighter or linter). The function adds a single highlight to 79 | -- a buffer. Unlike |matchaddpos()| highlights follow changes to line 80 | -- numbering (as lines are inserted/removed above the highlighted line), like 81 | -- signs and marks do. 82 | -- 83 | -- Namespaces are used for batch deletion/updating of a set of highlights. To 84 | -- create a namespace, use |nvim_create_namespace()| which returns a 85 | -- namespace id. Pass it in to this function as `ns_id` to add highlights to 86 | -- the namespace. All highlights in the same namespace can then be cleared 87 | -- with single call to |nvim_buf_clear_namespace()|. If the highlight never 88 | -- will be deleted by an API call, pass `ns_id = -1`. 89 | -- 90 | -- As a shorthand, `ns_id = 0` can be used to create a new namespace for the 91 | -- highlight, the allocated id is then returned. If `hl_group` is the empty 92 | -- string no highlight is added, but a new `ns_id` is still returned. This is 93 | -- supported for backwards compatibility, new code should use 94 | -- |nvim_create_namespace()| to create a new empty namespace. 95 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 96 | --- @param ns_id integer # namespace to use or -1 for ungrouped highlight 97 | --- @param hl_group string # Name of the highlight group to use 98 | --- @param line integer # Line to highlight (zero-indexed) 99 | --- @param col_start integer # Start of (byte-indexed) column range to highlight 100 | --- @param col_end integer # End of (byte-indexed) column range to highlight, or -1 to 101 | -- highlight to end of line 102 | --- @return any # The ns_id that was used 103 | function vim.api.nvim_buf_add_highlight(buffer, ns_id, hl_group, line, col_start, col_end) end 104 | 105 | -- Activates buffer-update events on a channel, or as Lua callbacks. 106 | -- 107 | -- Example (Lua): capture buffer updates in a global `events` variable (use "print(vim.inspect(events))" to see its contents): 108 | -- ```lua 109 | -- events = {} 110 | -- vim.api.nvim_buf_attach(0, false, { 111 | -- on_lines=function(...) table.insert(events, {...}) end}) 112 | -- 113 | -- ``` 114 | --- @see |nvim_buf_detach()| 115 | --- @see |api-buffer-updates-lua| 116 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 117 | --- @param send_buffer boolean # True if the initial notification should contain the 118 | -- whole buffer: first notification will be 119 | -- `nvim_buf_lines_event`. Else the first notification 120 | -- will be `nvim_buf_changedtick_event`. Not for Lua 121 | -- callbacks. 122 | --- @param opts table # Optional parameters. 123 | -- • on_lines: Lua callback invoked on change. Return `true` to detach. Args: 124 | -- • the string "lines" 125 | -- • buffer handle 126 | -- • b:changedtick 127 | -- • first line that changed (zero-indexed) 128 | -- • last line that was changed 129 | -- • last line in the updated range 130 | -- • byte count of previous contents 131 | -- • deleted_codepoints (if `utf_sizes` is true) 132 | -- • deleted_codeunits (if `utf_sizes` is true) 133 | -- 134 | -- • on_bytes: lua callback invoked on change. This 135 | -- callback receives more granular information about the 136 | -- change compared to on_lines. Return `true` to detach. Args: 137 | -- • the string "bytes" 138 | -- • buffer handle 139 | -- • b:changedtick 140 | -- • start row of the changed text (zero-indexed) 141 | -- • start column of the changed text 142 | -- • byte offset of the changed text (from the start of 143 | -- the buffer) 144 | -- • old end row of the changed text 145 | -- • old end column of the changed text 146 | -- • old end byte length of the changed text 147 | -- • new end row of the changed text 148 | -- • new end column of the changed text 149 | -- • new end byte length of the changed text 150 | -- 151 | -- • on_changedtick: Lua callback invoked on changedtick 152 | -- increment without text change. Args: 153 | -- • the string "changedtick" 154 | -- • buffer handle 155 | -- • b:changedtick 156 | -- 157 | -- • on_detach: Lua callback invoked on detach. Args: 158 | -- • the string "detach" 159 | -- • buffer handle 160 | -- 161 | -- • on_reload: Lua callback invoked on reload. The entire 162 | -- buffer content should be considered changed. Args: 163 | -- • the string "reload" 164 | -- • buffer handle 165 | -- 166 | -- • utf_sizes: include UTF-32 and UTF-16 size of the 167 | -- replaced region, as args to `on_lines`. 168 | -- • preview: also attach to command preview (i.e. 169 | -- 'inccommand') events. 170 | --- @return any # False if attach failed (invalid parameter, or buffer isn't loaded); 171 | -- otherwise True. TODO: LUA_API_NO_EVAL 172 | function vim.api.nvim_buf_attach(buffer, send_buffer, opts) end 173 | 174 | -- call a function with buffer as temporary current buffer 175 | -- 176 | -- This temporarily switches current buffer to "buffer". If the current 177 | -- window already shows "buffer", the window is not switched If a window 178 | -- inside the current tabpage (including a float) already shows the buffer 179 | -- One of these windows will be set as current window temporarily. Otherwise 180 | -- a temporary scratch window (called the "autocmd window" for historical 181 | -- reasons) will be used. 182 | -- 183 | -- This is useful e.g. to call vimL functions that only work with the current 184 | -- buffer/window currently, like |termopen()|. 185 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 186 | --- @param fun luaref # Function to call inside the buffer (currently lua callable 187 | -- only) 188 | --- @return any # Return value of function. NB: will deepcopy lua values currently, use 189 | -- upvalues to send lua references in and out. 190 | function vim.api.nvim_buf_call(buffer, fun) end 191 | 192 | -- Clears namespaced objects (highlights, extmarks, virtual text) from a 193 | -- region. 194 | -- 195 | -- Lines are 0-indexed. |api-indexing| To clear the namespace in the entire 196 | -- buffer, specify line_start=0 and line_end=-1. 197 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 198 | --- @param ns_id integer # Namespace to clear, or -1 to clear all namespaces. 199 | --- @param line_start integer # Start of range of lines to clear 200 | --- @param line_end integer # End of range of lines to clear (exclusive) or -1 to 201 | -- clear to end of buffer. 202 | function vim.api.nvim_buf_clear_namespace(buffer, ns_id, line_start, line_end) end 203 | 204 | -- Create a new user command |user-commands| in the given buffer. 205 | --- @see nvim_create_user_command 206 | --- @param buffer buffer # Buffer handle, or 0 for current buffer. 207 | --- @param name string 208 | --- @param command object 209 | --- @param opts? dict 210 | function vim.api.nvim_buf_create_user_command(buffer, name, command, opts) end 211 | 212 | -- Removes an extmark. 213 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 214 | --- @param ns_id integer # Namespace id from |nvim_create_namespace()| 215 | --- @param id integer # Extmark id 216 | --- @return any # true if the extmark was found, else false 217 | function vim.api.nvim_buf_del_extmark(buffer, ns_id, id) end 218 | 219 | -- Unmaps a buffer-local |mapping| for the given mode. 220 | --- @see |nvim_del_keymap()| 221 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 222 | --- @param mode string 223 | --- @param lhs string 224 | function vim.api.nvim_buf_del_keymap(buffer, mode, lhs) end 225 | 226 | -- Deletes a named mark in the buffer. See |mark-motions|. 227 | -- 228 | -- 229 | -- Note: 230 | -- only deletes marks set in the buffer, if the mark is not set in the 231 | -- buffer it will return false. 232 | --- @see |nvim_buf_set_mark()| 233 | --- @see |nvim_del_mark()| 234 | --- @param buffer buffer # Buffer to set the mark on 235 | --- @param name string # Mark name 236 | --- @return any # true if the mark was deleted, else false. 237 | function vim.api.nvim_buf_del_mark(buffer, name) end 238 | 239 | -- Delete a buffer-local user-defined command. 240 | -- 241 | -- Only commands created with |:command-buffer| or 242 | -- |nvim_buf_create_user_command()| can be deleted with this function. 243 | --- @param buffer buffer # Buffer handle, or 0 for current buffer. 244 | --- @param name string # Name of the command to delete. 245 | function vim.api.nvim_buf_del_user_command(buffer, name) end 246 | 247 | -- Removes a buffer-scoped (b:) variable 248 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 249 | --- @param name string # Variable name 250 | function vim.api.nvim_buf_del_var(buffer, name) end 251 | 252 | -- Deletes the buffer. See |:bwipeout| 253 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 254 | --- @param opts dictionary # Optional parameters. Keys: 255 | -- • force: Force deletion and ignore unsaved changes. 256 | -- • unload: Unloaded only, do not delete. See |:bunload| 257 | function vim.api.nvim_buf_delete(buffer, opts) end 258 | 259 | -- Deactivates buffer-update events on the channel. 260 | --- @see |nvim_buf_attach()| 261 | --- @see |api-lua-detach| for detaching Lua callbacks 262 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 263 | --- @return any # False if detach failed (because the buffer isn't loaded); otherwise 264 | -- True. 265 | function vim.api.nvim_buf_detach(buffer) end 266 | 267 | -- Gets a changed tick of a buffer 268 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 269 | --- @return any # `b:changedtick` value. 270 | function vim.api.nvim_buf_get_changedtick(buffer) end 271 | 272 | -- Gets a map of buffer-local |user-commands|. 273 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 274 | --- @param opts? dict # Optional parameters. Currently not used. 275 | --- @return any # Map of maps describing commands. 276 | function vim.api.nvim_buf_get_commands(buffer, opts) end 277 | 278 | -- Gets the position (0-indexed) of an extmark. 279 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 280 | --- @param ns_id integer # Namespace id from |nvim_create_namespace()| 281 | --- @param id integer # Extmark id 282 | --- @param opts dictionary # Optional parameters. Keys: 283 | -- • details: Whether to include the details dict 284 | --- @return any # 0-indexed (row, col) tuple or empty list () if extmark id was absent 285 | function vim.api.nvim_buf_get_extmark_by_id(buffer, ns_id, id, opts) end 286 | 287 | -- Gets extmarks in "traversal order" from a |charwise| region defined by 288 | -- buffer positions (inclusive, 0-indexed |api-indexing|). 289 | -- 290 | -- Region can be given as (row,col) tuples, or valid extmark ids (whose 291 | -- positions define the bounds). 0 and -1 are understood as (0,0) and (-1,-1) 292 | -- respectively, thus the following are equivalent: 293 | -- 294 | -- 295 | -- ```lua 296 | -- nvim_buf_get_extmarks(0, my_ns, 0, -1, {}) 297 | -- nvim_buf_get_extmarks(0, my_ns, [0,0], [-1,-1], {}) 298 | -- 299 | -- ``` 300 | -- 301 | -- If `end` is less than `start`, traversal works backwards. (Useful with 302 | -- `limit`, to get the first marks prior to a given position.) 303 | -- 304 | -- Example: 305 | -- 306 | -- 307 | -- ```lua 308 | -- local a = vim.api 309 | -- local pos = a.nvim_win_get_cursor(0) 310 | -- local ns = a.nvim_create_namespace('my-plugin') 311 | -- -- Create new extmark at line 1, column 1. 312 | -- local m1 = a.nvim_buf_set_extmark(0, ns, 0, 0, {}) 313 | -- -- Create new extmark at line 3, column 1. 314 | -- local m2 = a.nvim_buf_set_extmark(0, ns, 0, 2, {}) 315 | -- -- Get extmarks only from line 3. 316 | -- local ms = a.nvim_buf_get_extmarks(0, ns, {2,0}, {2,0}, {}) 317 | -- -- Get all marks in this buffer + namespace. 318 | -- local all = a.nvim_buf_get_extmarks(0, ns, 0, -1, {}) 319 | -- print(vim.inspect(ms)) 320 | -- 321 | -- ``` 322 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 323 | --- @param ns_id integer # Namespace id from |nvim_create_namespace()| 324 | --- @param start object # Start of range: a 0-indexed (row, col) or valid extmark id 325 | -- (whose position defines the bound). |api-indexing| 326 | --- @param end_ object # End of range (inclusive): a 0-indexed (row, col) or valid 327 | -- extmark id (whose position defines the bound). 328 | -- |api-indexing| 329 | --- @param opts dictionary # Optional parameters. Keys: 330 | -- • limit: Maximum number of marks to return 331 | -- • details Whether to include the details dict 332 | --- @return any # List of [extmark_id, row, col] tuples in "traversal order". 333 | function vim.api.nvim_buf_get_extmarks(buffer, ns_id, start, end_, opts) end 334 | 335 | -- Gets a list of buffer-local |mapping| definitions. 336 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 337 | --- @param mode string # Mode short-name ("n", "i", "v", ...) 338 | --- @return any # Array of |maparg()|-like dictionaries describing mappings. The 339 | -- "buffer" key holds the associated buffer handle. 340 | function vim.api.nvim_buf_get_keymap(buffer, mode) end 341 | 342 | -- Gets a line-range from the buffer. 343 | -- 344 | -- Indexing is zero-based, end-exclusive. Negative indices are interpreted as 345 | -- length+1+index: -1 refers to the index past the end. So to get the last 346 | -- element use start=-2 and end=-1. 347 | -- 348 | -- Out-of-bounds indices are clamped to the nearest valid value, unless 349 | -- `strict_indexing` is set. 350 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 351 | --- @param start integer # First line index 352 | --- @param end_ integer # Last line index, exclusive 353 | --- @param strict_indexing boolean # Whether out-of-bounds should be an error. 354 | --- @return any # Array of lines, or empty array for unloaded buffer. 355 | function vim.api.nvim_buf_get_lines(buffer, start, end_, strict_indexing) end 356 | 357 | -- Returns a tuple (row,col) representing the position of the named mark. See 358 | -- |mark-motions|. 359 | -- 360 | -- Marks are (1,0)-indexed. |api-indexing| 361 | --- @see |nvim_buf_set_mark()| 362 | --- @see |nvim_buf_del_mark()| 363 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 364 | --- @param name string # Mark name 365 | --- @return any # (row, col) tuple, (0, 0) if the mark is not set, or is an 366 | -- uppercase/file mark set in another buffer. 367 | function vim.api.nvim_buf_get_mark(buffer, name) end 368 | 369 | -- Gets the full file name for the buffer 370 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 371 | --- @return any # Buffer name 372 | function vim.api.nvim_buf_get_name(buffer) end 373 | 374 | -- Returns the byte offset of a line (0-indexed). |api-indexing| 375 | -- 376 | -- Line 1 (index=0) has offset 0. UTF-8 bytes are counted. EOL is one byte. 377 | -- 'fileformat' and 'fileencoding' are ignored. The line index just after the 378 | -- last line gives the total byte-count of the buffer. A final EOL byte is 379 | -- counted if it would be written, see 'eol'. 380 | -- 381 | -- Unlike |line2byte()|, throws error for out-of-bounds indexing. Returns -1 382 | -- for unloaded buffer. 383 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 384 | --- @param index integer # Line index 385 | --- @return any # Integer byte offset, or -1 for unloaded buffer. 386 | function vim.api.nvim_buf_get_offset(buffer, index) end 387 | 388 | -- Gets a buffer option value 389 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 390 | --- @param name string # Option name 391 | --- @return any # Option value 392 | function vim.api.nvim_buf_get_option(buffer, name) end 393 | 394 | -- Gets a range from the buffer. 395 | -- 396 | -- This differs from |nvim_buf_get_lines()| in that it allows retrieving only 397 | -- portions of a line. 398 | -- 399 | -- Indexing is zero-based. Row indices are end-inclusive, and column indices 400 | -- are end-exclusive. 401 | -- 402 | -- Prefer |nvim_buf_get_lines()| when retrieving entire lines. 403 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 404 | --- @param start_row integer # First line index 405 | --- @param start_col integer # Starting column (byte offset) on first line 406 | --- @param end_row integer # Last line index, inclusive 407 | --- @param end_col integer # Ending column (byte offset) on last line, exclusive 408 | --- @param opts dictionary # Optional parameters. Currently unused. 409 | --- @return any # Array of lines, or empty array for unloaded buffer. 410 | function vim.api.nvim_buf_get_text(buffer, start_row, start_col, end_row, end_col, opts) end 411 | 412 | -- Gets a buffer-scoped (b:) variable. 413 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 414 | --- @param name string # Variable name 415 | --- @return any # Variable value 416 | function vim.api.nvim_buf_get_var(buffer, name) end 417 | 418 | -- Checks if a buffer is valid and loaded. See |api-buffer| for more info 419 | -- about unloaded buffers. 420 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 421 | --- @return any # true if the buffer is valid and loaded, false otherwise. 422 | function vim.api.nvim_buf_is_loaded(buffer) end 423 | 424 | -- Checks if a buffer is valid. 425 | -- 426 | -- 427 | -- Note: 428 | -- Even if a buffer is valid it may have been unloaded. See |api-buffer| 429 | -- for more info about unloaded buffers. 430 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 431 | --- @return any # true if the buffer is valid, false otherwise. 432 | function vim.api.nvim_buf_is_valid(buffer) end 433 | 434 | -- Returns the number of lines in the given buffer. 435 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 436 | --- @return any # Line count, or 0 for unloaded buffer. |api-buffer| 437 | function vim.api.nvim_buf_line_count(buffer) end 438 | 439 | -- Creates or updates an extmark. 440 | -- 441 | -- By default a new extmark is created when no id is passed in, but it is 442 | -- also possible to create a new mark by passing in a previously unused id or 443 | -- move an existing mark by passing in its id. The caller must then keep 444 | -- track of existing and unused ids itself. (Useful over RPC, to avoid 445 | -- waiting for the return value.) 446 | -- 447 | -- Using the optional arguments, it is possible to use this to highlight a 448 | -- range of text, and also to associate virtual text to the mark. 449 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 450 | --- @param ns_id integer # Namespace id from |nvim_create_namespace()| 451 | --- @param line integer # Line where to place the mark, 0-based. |api-indexing| 452 | --- @param col integer # Column where to place the mark, 0-based. |api-indexing| 453 | --- @param opts? dict # Optional parameters. 454 | -- • id : id of the extmark to edit. 455 | -- • end_row : ending line of the mark, 0-based inclusive. 456 | -- • end_col : ending col of the mark, 0-based exclusive. 457 | -- • hl_group : name of the highlight group used to highlight 458 | -- this mark. 459 | -- • hl_eol : when true, for a multiline highlight covering the 460 | -- EOL of a line, continue the highlight for the rest of the 461 | -- screen line (just like for diff and cursorline highlight). 462 | -- • virt_text : virtual text to link to this mark. A list of 463 | -- [text, highlight] tuples, each representing a text chunk 464 | -- with specified highlight. `highlight` element can either 465 | -- be a single highlight group, or an array of multiple 466 | -- highlight groups that will be stacked (highest priority 467 | -- last). A highlight group can be supplied either as a 468 | -- string or as an integer, the latter which can be obtained 469 | -- using |nvim_get_hl_id_by_name()|. 470 | -- • virt_text_pos : position of virtual text. Possible values: 471 | -- • "eol": right after eol character (default) 472 | -- • "overlay": display over the specified column, without 473 | -- shifting the underlying text. 474 | -- • "right_align": display right aligned in the window. 475 | -- 476 | -- • virt_text_win_col : position the virtual text at a fixed 477 | -- window column (starting from the first text column) 478 | -- • virt_text_hide : hide the virtual text when the background 479 | -- text is selected or hidden due to horizontal scroll 480 | -- 'nowrap' 481 | -- • hl_mode : control how highlights are combined with the 482 | -- highlights of the text. Currently only affects virt_text 483 | -- highlights, but might affect `hl_group` in later versions. 484 | -- • "replace": only show the virt_text color. This is the 485 | -- default 486 | -- • "combine": combine with background text color 487 | -- • "blend": blend with background text color. 488 | -- 489 | -- • virt_lines : virtual lines to add next to this mark This 490 | -- should be an array over lines, where each line in turn is 491 | -- an array over [text, highlight] tuples. In general, buffer 492 | -- and window options do not affect the display of the text. 493 | -- In particular 'wrap' and 'linebreak' options do not take 494 | -- effect, so the number of extra screen lines will always 495 | -- match the size of the array. However the 'tabstop' buffer 496 | -- option is still used for hard tabs. By default lines are 497 | -- placed below the buffer line containing the mark. 498 | -- • virt_lines_above: place virtual lines above instead. 499 | -- • virt_lines_leftcol: Place extmarks in the leftmost column 500 | -- of the window, bypassing sign and number columns. 501 | -- • ephemeral : for use with |nvim_set_decoration_provider()| 502 | -- callbacks. The mark will only be used for the current 503 | -- redraw cycle, and not be permantently stored in the 504 | -- buffer. 505 | -- • right_gravity : boolean that indicates the direction the 506 | -- extmark will be shifted in when new text is inserted (true 507 | -- for right, false for left). defaults to true. 508 | -- • end_right_gravity : boolean that indicates the direction 509 | -- the extmark end position (if it exists) will be shifted in 510 | -- when new text is inserted (true for right, false for 511 | -- left). Defaults to false. 512 | -- • priority: a priority value for the highlight group or sign 513 | -- attribute. For example treesitter highlighting uses a 514 | -- value of 100. 515 | -- • strict: boolean that indicates extmark should not be 516 | -- placed if the line or column value is past the end of the 517 | -- buffer or end of the line respectively. Defaults to true. 518 | -- • sign_text: string of length 1-2 used to display in the 519 | -- sign column. Note: ranges are unsupported and decorations 520 | -- are only applied to start_row 521 | -- • sign_hl_group: name of the highlight group used to 522 | -- highlight the sign column text. Note: ranges are 523 | -- unsupported and decorations are only applied to start_row 524 | -- • number_hl_group: name of the highlight group used to 525 | -- highlight the number column. Note: ranges are unsupported 526 | -- and decorations are only applied to start_row 527 | -- • line_hl_group: name of the highlight group used to 528 | -- highlight the whole line. Note: ranges are unsupported and 529 | -- decorations are only applied to start_row 530 | -- • cursorline_hl_group: name of the highlight group used to 531 | -- highlight the line when the cursor is on the same line as 532 | -- the mark and 'cursorline' is enabled. Note: ranges are 533 | -- unsupported and decorations are only applied to start_row 534 | -- • conceal: string which should be either empty or a single 535 | -- character. Enable concealing similar to |:syn-conceal|. 536 | -- When a character is supplied it is used as |:syn-cchar|. 537 | -- "hl_group" is used as highlight for the cchar if provided, 538 | -- otherwise it defaults to |hl-Conceal|. 539 | -- • spell: boolean indicating that spell checking should be 540 | -- performed within this extmark 541 | -- • ui_watched: boolean that indicates the mark should be 542 | -- drawn by a UI. When set, the UI will receive win_extmark 543 | -- events. Note: the mark is positioned by virt_text 544 | -- attributes. Can be used together with virt_text. 545 | --- @return any # Id of the created/updated extmark 546 | function vim.api.nvim_buf_set_extmark(buffer, ns_id, line, col, opts) end 547 | 548 | -- Sets a buffer-local |mapping| for the given mode. 549 | --- @see |nvim_set_keymap()| 550 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 551 | --- @param mode string 552 | --- @param lhs string 553 | --- @param rhs string 554 | --- @param opts? dict 555 | function vim.api.nvim_buf_set_keymap(buffer, mode, lhs, rhs, opts) end 556 | 557 | -- Sets (replaces) a line-range in the buffer. 558 | -- 559 | -- Indexing is zero-based, end-exclusive. Negative indices are interpreted as 560 | -- length+1+index: -1 refers to the index past the end. So to change or 561 | -- delete the last element use start=-2 and end=-1. 562 | -- 563 | -- To insert lines at a given index, set `start` and `end` to the same index. 564 | -- To delete a range of lines, set `replacement` to an empty array. 565 | -- 566 | -- Out-of-bounds indices are clamped to the nearest valid value, unless 567 | -- `strict_indexing` is set. 568 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 569 | --- @param start integer # First line index 570 | --- @param end_ integer # Last line index, exclusive 571 | --- @param strict_indexing boolean # Whether out-of-bounds should be an error. 572 | --- @param replacement string[] # Array of lines to use as replacement 573 | function vim.api.nvim_buf_set_lines(buffer, start, end_, strict_indexing, replacement) end 574 | 575 | -- Sets a named mark in the given buffer, all marks are allowed 576 | -- file/uppercase, visual, last change, etc. See |mark-motions|. 577 | -- 578 | -- Marks are (1,0)-indexed. |api-indexing| 579 | -- 580 | -- 581 | -- Note: 582 | -- Passing 0 as line deletes the mark 583 | --- @see |nvim_buf_del_mark()| 584 | --- @see |nvim_buf_get_mark()| 585 | --- @param buffer buffer # Buffer to set the mark on 586 | --- @param name string # Mark name 587 | --- @param line integer # Line number 588 | --- @param col integer # Column/row number 589 | --- @param opts dictionary # Optional parameters. Reserved for future use. 590 | --- @return any # true if the mark was set, else false. 591 | function vim.api.nvim_buf_set_mark(buffer, name, line, col, opts) end 592 | 593 | -- Sets the full file name for a buffer 594 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 595 | --- @param name string # Buffer name 596 | function vim.api.nvim_buf_set_name(buffer, name) end 597 | 598 | -- Sets a buffer option value. Passing `nil` as value deletes the option 599 | -- (only works if there's a global fallback) 600 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 601 | --- @param name string # Option name 602 | --- @param value object # Option value 603 | function vim.api.nvim_buf_set_option(buffer, name, value) end 604 | 605 | -- Sets (replaces) a range in the buffer 606 | -- 607 | -- This is recommended over |nvim_buf_set_lines()| when only modifying parts 608 | -- of a line, as extmarks will be preserved on non-modified parts of the 609 | -- touched lines. 610 | -- 611 | -- Indexing is zero-based. Row indices are end-inclusive, and column indices 612 | -- are end-exclusive. 613 | -- 614 | -- To insert text at a given `(row, column)` location, use `start_row = 615 | -- end_row = row` and `start_col = end_col = col`. To delete the text in a 616 | -- range, use `replacement = {}`. 617 | -- 618 | -- Prefer |nvim_buf_set_lines()| if you are only adding or deleting entire 619 | -- lines. 620 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 621 | --- @param start_row integer # First line index 622 | --- @param start_col integer # Starting column (byte offset) on first line 623 | --- @param end_row integer # Last line index, inclusive 624 | --- @param end_col integer # Ending column (byte offset) on last line, exclusive 625 | --- @param replacement string[] # Array of lines to use as replacement 626 | function vim.api.nvim_buf_set_text(buffer, start_row, start_col, end_row, end_col, replacement) end 627 | 628 | -- Sets a buffer-scoped (b:) variable 629 | --- @param buffer buffer # Buffer handle, or 0 for current buffer 630 | --- @param name string # Variable name 631 | --- @param value object # Variable value 632 | function vim.api.nvim_buf_set_var(buffer, name, value) end 633 | 634 | -- Calls many API methods atomically. 635 | -- 636 | -- This has two main usages: 637 | -- 1. To perform several requests from an async context atomically, i.e. 638 | -- without interleaving redraws, RPC requests from other clients, or user 639 | -- interactions (however API methods may trigger autocommands or event 640 | -- processing which have such side effects, e.g. |:sleep| may wake 641 | -- timers). 642 | -- 2. To minimize RPC overhead (roundtrips) of a sequence of many requests. 643 | --- @param calls array # an array of calls, where each call is described by an array 644 | -- with two elements: the request name, and an array of 645 | -- arguments. 646 | --- @return any # Array of two elements. The first is an array of return values. The 647 | -- second is NIL if all calls succeeded. If a call resulted in an error, 648 | -- it is a three-element array with the zero-based index of the call 649 | -- which resulted in an error, the error type and the error message. If 650 | -- an error occurred, the values from all preceding calls will still be 651 | -- returned. 652 | function vim.api.nvim_call_atomic(calls) end 653 | 654 | -- Calls a VimL |Dictionary-function| with the given arguments. 655 | -- 656 | -- On execution error: fails with VimL error, updates v:errmsg. 657 | --- @param dict object # Dictionary, or String evaluating to a VimL |self| dict 658 | --- @param fn string # Name of the function defined on the VimL dict 659 | --- @param args array # Function arguments packed in an Array 660 | --- @return any # Result of the function call 661 | function vim.api.nvim_call_dict_function(dict, fn, args) end 662 | 663 | -- Calls a VimL function with the given arguments. 664 | -- 665 | -- On execution error: fails with VimL error, updates v:errmsg. 666 | --- @param fn string # Function to call 667 | --- @param args array # Function arguments packed in an Array 668 | --- @return any # Result of the function call 669 | function vim.api.nvim_call_function(fn, args) end 670 | 671 | -- Send data to channel `id`. For a job, it writes it to the stdin of the 672 | -- process. For the stdio channel |channel-stdio|, it writes to Nvim's 673 | -- stdout. For an internal terminal instance (|nvim_open_term()|) it writes 674 | -- directly to terminal output. See |channel-bytes| for more information. 675 | -- 676 | -- This function writes raw data, not RPC messages. If the channel was 677 | -- created with `rpc=true` then the channel expects RPC messages, use 678 | -- |vim.rpcnotify()| and |vim.rpcrequest()| instead. 679 | --- @param chan integer # id of the channel 680 | --- @param data string # data to write. 8-bit clean: can contain NUL bytes. 681 | function vim.api.nvim_chan_send(chan, data) end 682 | 683 | -- Clear all autocommands that match the corresponding {opts}. To delete a 684 | -- particular autocmd, see |nvim_del_autocmd()|. 685 | --- @param opts? dict # Parameters 686 | -- • event: (string|table) Examples: 687 | -- • event: "pat1" 688 | -- • event: { "pat1" } 689 | -- • event: { "pat1", "pat2", "pat3" } 690 | -- 691 | -- • pattern: (string|table) 692 | -- • pattern or patterns to match exactly. 693 | -- • For example, if you have `*.py` as that pattern for the 694 | -- autocmd, you must pass `*.py` exactly to clear it. 695 | -- `test.py` will not match the pattern. 696 | -- 697 | -- • defaults to clearing all patterns. 698 | -- • NOTE: Cannot be used with {buffer} 699 | -- 700 | -- • buffer: (bufnr) 701 | -- • clear only |autocmd-buflocal| autocommands. 702 | -- • NOTE: Cannot be used with {pattern} 703 | -- 704 | -- • group: (string|int) The augroup name or id. 705 | -- • NOTE: If not passed, will only delete autocmds not in any group. 706 | function vim.api.nvim_clear_autocmds(opts) end 707 | 708 | -- Executes an Ex command. 709 | -- 710 | -- Unlike |nvim_command()| this command takes a structured Dictionary instead 711 | -- of a String. This allows for easier construction and manipulation of an Ex 712 | -- command. This also allows for things such as having spaces inside a 713 | -- command argument, expanding filenames in a command that otherwise doesn't 714 | -- expand filenames, etc. Command arguments may also be Number, Boolean or 715 | -- String. 716 | -- 717 | -- The first argument may also be used instead of count for commands that 718 | -- support it in order to make their usage simpler with |vim.cmd()|. For 719 | -- example, instead of `vim.cmd.bdelete{ count = 2 }`, you may do 720 | -- `vim.cmd.bdelete(2)`. 721 | -- 722 | -- On execution error: fails with VimL error, updates v:errmsg. 723 | --- @see |nvim_exec()| 724 | --- @see |nvim_command()| 725 | --- @param cmd? dict # Command to execute. Must be a Dictionary that can contain the 726 | -- same values as the return value of |nvim_parse_cmd()| except 727 | -- "addr", "nargs" and "nextcmd" which are ignored if provided. 728 | -- All values except for "cmd" are optional. 729 | --- @param opts? dict # Optional parameters. 730 | -- • output: (boolean, default false) Whether to return command 731 | -- output. 732 | --- @return any # Command output (non-error, non-shell |:!|) if `output` is true, else 733 | -- empty string. 734 | function vim.api.nvim_cmd(cmd, opts) end 735 | 736 | -- Executes an Ex command. 737 | -- 738 | -- On execution error: fails with VimL error, updates v:errmsg. 739 | -- 740 | -- Prefer using |nvim_cmd()| or |nvim_exec()| over this. To evaluate multiple 741 | -- lines of Vim script or an Ex command directly, use |nvim_exec()|. To 742 | -- construct an Ex command using a structured format and then execute it, use 743 | -- |nvim_cmd()|. To modify an Ex command before evaluating it, use 744 | -- |nvim_parse_cmd()| in conjunction with |nvim_cmd()|. 745 | --- @param command string # Ex command string 746 | function vim.api.nvim_command(command) end 747 | 748 | -- Create or get an autocommand group |autocmd-groups|. 749 | -- 750 | -- To get an existing group id, do: 751 | -- ```lua 752 | -- local id = vim.api.nvim_create_augroup("MyGroup", { 753 | -- clear = false 754 | -- }) 755 | -- 756 | -- ``` 757 | --- @see |autocmd-groups| 758 | --- @param name string # String: The name of the group 759 | --- @param opts? dict # Dictionary Parameters 760 | -- • clear (bool) optional: defaults to true. Clear existing 761 | -- commands if the group already exists |autocmd-groups|. 762 | --- @return any # Integer id of the created group. 763 | function vim.api.nvim_create_augroup(name, opts) end 764 | 765 | -- Create an |autocommand| 766 | -- 767 | -- The API allows for two (mutually exclusive) types of actions to be 768 | -- executed when the autocommand triggers: a callback function (Lua or 769 | -- Vimscript), or a command (like regular autocommands). 770 | -- 771 | -- Example using callback: 772 | -- ```lua 773 | -- -- Lua function 774 | -- local myluafun = function() print("This buffer enters") end 775 | -- 776 | -- -- Vimscript function name (as a string) 777 | -- local myvimfun = "g:MyVimFunction" 778 | -- 779 | -- vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, { 780 | -- pattern = {"*.c", "*.h"}, 781 | -- callback = myluafun, -- Or myvimfun 782 | -- }) 783 | -- 784 | -- ``` 785 | -- 786 | -- Lua functions receive a table with information about the autocmd event as 787 | -- an argument. To use a function which itself accepts another (optional) 788 | -- parameter, wrap the function in a lambda: 789 | -- 790 | -- 791 | -- ```lua 792 | -- -- Lua function with an optional parameter. 793 | -- -- The autocmd callback would pass a table as argument but this 794 | -- -- function expects number|nil 795 | -- local myluafun = function(bufnr) bufnr = bufnr or vim.api.nvim_get_current_buf() end 796 | -- 797 | -- vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, { 798 | -- pattern = {"*.c", "*.h"}, 799 | -- callback = function() myluafun() end, 800 | -- }) 801 | -- 802 | -- ``` 803 | -- 804 | -- Example using command: 805 | -- ```lua 806 | -- vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, { 807 | -- pattern = {"*.c", "*.h"}, 808 | -- command = "echo 'Entering a C or C++ file'", 809 | -- }) 810 | -- 811 | -- ``` 812 | -- 813 | -- Example values for pattern: 814 | -- ```lua 815 | -- pattern = "*.py" 816 | -- pattern = { "*.py", "*.pyi" } 817 | -- 818 | -- ``` 819 | -- 820 | -- Example values for event: 821 | -- ```lua 822 | -- "BufWritePre" 823 | -- {"CursorHold", "BufWritePre", "BufWritePost"} 824 | -- 825 | -- ``` 826 | --- @see |autocommand| 827 | --- @see |nvim_del_autocmd()| 828 | --- @param event object # (string|array) The event or events to register this 829 | -- autocommand 830 | --- @param opts? dict # Dictionary of autocommand options: 831 | -- • group (string|integer) optional: the autocommand group name 832 | -- or id to match against. 833 | -- • pattern (string|array) optional: pattern or patterns to 834 | -- match against |autocmd-pattern|. 835 | -- • buffer (integer) optional: buffer number for buffer local 836 | -- autocommands |autocmd-buflocal|. Cannot be used with 837 | -- {pattern}. 838 | -- • desc (string) optional: description of the autocommand. 839 | -- • callback (function|string) optional: if a string, the name 840 | -- of a Vimscript function to call when this autocommand is 841 | -- triggered. Otherwise, a Lua function which is called when 842 | -- this autocommand is triggered. Cannot be used with 843 | -- {command}. Lua callbacks can return true to delete the 844 | -- autocommand; in addition, they accept a single table 845 | -- argument with the following keys: 846 | -- • id: (number) the autocommand id 847 | -- • event: (string) the name of the event that triggered the 848 | -- autocommand |autocmd-events| 849 | -- • group: (number|nil) the autocommand group id, if it 850 | -- exists 851 | -- • match: (string) the expanded value of || 852 | -- • buf: (number) the expanded value of || 853 | -- • file: (string) the expanded value of || 854 | -- • data: (any) arbitrary data passed to 855 | -- |nvim_exec_autocmds()| 856 | -- 857 | -- • command (string) optional: Vim command to execute on event. 858 | -- Cannot be used with {callback} 859 | -- • once (boolean) optional: defaults to false. Run the 860 | -- autocommand only once |autocmd-once|. 861 | -- • nested (boolean) optional: defaults to false. Run nested 862 | -- autocommands |autocmd-nested|. 863 | --- @return any # Integer id of the created autocommand. 864 | function vim.api.nvim_create_autocmd(event, opts) end 865 | 866 | -- Creates a new, empty, unnamed buffer. 867 | --- @see buf_open_scratch 868 | --- @param listed boolean # Sets 'buflisted' 869 | --- @param scratch boolean # Creates a "throwaway" |scratch-buffer| for temporary work 870 | -- (always 'nomodified'). Also sets 'nomodeline' on the 871 | -- buffer. 872 | --- @return any # Buffer handle, or 0 on error 873 | function vim.api.nvim_create_buf(listed, scratch) end 874 | 875 | -- Creates a new *namespace* or gets an existing one. 876 | -- 877 | -- Namespaces are used for buffer highlights and virtual text, see 878 | -- |nvim_buf_add_highlight()| and |nvim_buf_set_extmark()|. 879 | -- 880 | -- Namespaces can be named or anonymous. If `name` matches an existing 881 | -- namespace, the associated id is returned. If `name` is an empty string a 882 | -- new, anonymous namespace is created. 883 | --- @param name string # Namespace name or empty string 884 | --- @return any # Namespace id 885 | function vim.api.nvim_create_namespace(name) end 886 | 887 | -- Create a new user command |user-commands| 888 | -- 889 | -- {name} is the name of the new command. The name must begin with an 890 | -- uppercase letter. 891 | -- 892 | -- {command} is the replacement text or Lua function to execute. 893 | -- 894 | -- Example: 895 | -- ```lua 896 | -- :call nvim_create_user_command('SayHello', 'echo "Hello world!"', {}) 897 | -- :SayHello 898 | -- Hello world! 899 | -- 900 | -- ``` 901 | --- @param name string # Name of the new user command. Must begin with an uppercase 902 | -- letter. 903 | --- @param command object # Replacement command to execute when this user command is 904 | -- executed. When called from Lua, the command can also be a 905 | -- Lua function. The function is called with a single table 906 | -- argument that contains the following keys: 907 | -- • args: (string) The args passed to the command, if any 908 | -- || 909 | -- • fargs: (table) The args split by unescaped whitespace 910 | -- (when more than one argument is allowed), if any 911 | -- || 912 | -- • bang: (boolean) "true" if the command was executed with a 913 | -- ! modifier || 914 | -- • line1: (number) The starting line of the command range 915 | -- || 916 | -- • line2: (number) The final line of the command range 917 | -- || 918 | -- • range: (number) The number of items in the command range: 919 | -- 0, 1, or 2 || 920 | -- • count: (number) Any count supplied || 921 | -- • reg: (string) The optional register, if specified || 922 | -- • mods: (string) Command modifiers, if any || 923 | -- • smods: (table) Command modifiers in a structured format. 924 | -- Has the same structure as the "mods" key of 925 | -- |nvim_parse_cmd()|. 926 | --- @param opts? dict # Optional command attributes. See |command-attributes| for 927 | -- more details. To use boolean attributes (such as 928 | -- |:command-bang| or |:command-bar|) set the value to "true". 929 | -- In addition to the string options listed in 930 | -- |:command-complete|, the "complete" key also accepts a Lua 931 | -- function which works like the "customlist" completion mode 932 | -- |:command-completion-customlist|. Additional parameters: 933 | -- • desc: (string) Used for listing the command when a Lua 934 | -- function is used for {command}. 935 | -- • force: (boolean, default true) Override any previous 936 | -- definition. 937 | -- • preview: (function) Preview callback for 'inccommand' 938 | -- |:command-preview| 939 | function vim.api.nvim_create_user_command(name, command, opts) end 940 | 941 | -- Delete an autocommand group by id. 942 | -- 943 | -- To get a group id one can use |nvim_get_autocmds()|. 944 | -- 945 | -- NOTE: behavior differs from |:augroup-delete|. When deleting a group, 946 | -- autocommands contained in this group will also be deleted and cleared. 947 | -- This group will no longer exist. 948 | --- @see |nvim_del_augroup_by_name()| 949 | --- @see |nvim_create_augroup()| 950 | --- @param id integer # Integer The id of the group. 951 | function vim.api.nvim_del_augroup_by_id(id) end 952 | 953 | -- Delete an autocommand group by name. 954 | -- 955 | -- NOTE: behavior differs from |:augroup-delete|. When deleting a group, 956 | -- autocommands contained in this group will also be deleted and cleared. 957 | -- This group will no longer exist. 958 | --- @see |autocmd-groups| 959 | --- @param name string # String The name of the group. 960 | function vim.api.nvim_del_augroup_by_name(name) end 961 | 962 | -- Delete an autocommand by id. 963 | -- 964 | -- NOTE: Only autocommands created via the API have an id. 965 | --- @see |nvim_create_autocmd()| 966 | --- @param id integer # Integer The id returned by nvim_create_autocmd 967 | function vim.api.nvim_del_autocmd(id) end 968 | 969 | -- Deletes the current line. 970 | function vim.api.nvim_del_current_line() end 971 | 972 | -- Unmaps a global |mapping| for the given mode. 973 | -- 974 | -- To unmap a buffer-local mapping, use |nvim_buf_del_keymap()|. 975 | --- @see |nvim_set_keymap()| 976 | --- @param mode string 977 | --- @param lhs string 978 | function vim.api.nvim_del_keymap(mode, lhs) end 979 | 980 | -- Deletes an uppercase/file named mark. See |mark-motions|. 981 | -- 982 | -- 983 | -- Note: 984 | -- fails with error if a lowercase or buffer local named mark is used. 985 | --- @see |nvim_buf_del_mark()| 986 | --- @see |nvim_get_mark()| 987 | --- @param name string # Mark name 988 | --- @return any # true if the mark was deleted, else false. 989 | function vim.api.nvim_del_mark(name) end 990 | 991 | -- Delete a user-defined command. 992 | --- @param name string # Name of the command to delete. 993 | function vim.api.nvim_del_user_command(name) end 994 | 995 | -- Removes a global (g:) variable. 996 | --- @param name string # Variable name 997 | function vim.api.nvim_del_var(name) end 998 | 999 | -- Echo a message. 1000 | --- @param chunks array # A list of [text, hl_group] arrays, each representing a text 1001 | -- chunk with specified highlight. `hl_group` element can be 1002 | -- omitted for no highlight. 1003 | --- @param history boolean # if true, add to |message-history|. 1004 | --- @param opts dictionary # Optional parameters. Reserved for future use. 1005 | function vim.api.nvim_echo(chunks, history, opts) end 1006 | 1007 | -- Writes a message to the Vim error buffer. Does not append "\n", the 1008 | -- message is buffered (won't display) until a linefeed is written. 1009 | --- @param str string # Message 1010 | function vim.api.nvim_err_write(str) end 1011 | 1012 | -- Writes a message to the Vim error buffer. Appends "\n", so the buffer is 1013 | -- flushed (and displayed). 1014 | --- @see nvim_err_write() 1015 | --- @param str string # Message 1016 | function vim.api.nvim_err_writeln(str) end 1017 | 1018 | --- @param lvl integer 1019 | --- @param data string 1020 | function vim.api.nvim_error_event(lvl, data) end 1021 | 1022 | -- Evaluates a VimL |expression|. Dictionaries and Lists are recursively 1023 | -- expanded. 1024 | -- 1025 | -- On execution error: fails with VimL error, updates v:errmsg. 1026 | --- @param expr string # VimL expression string 1027 | --- @return any # Evaluation result or expanded object 1028 | function vim.api.nvim_eval(expr) end 1029 | 1030 | -- Evaluates statusline string. 1031 | --- @param str string # Statusline string (see 'statusline'). 1032 | --- @param opts? dict # Optional parameters. 1033 | -- • winid: (number) |window-ID| of the window to use as context 1034 | -- for statusline. 1035 | -- • maxwidth: (number) Maximum width of statusline. 1036 | -- • fillchar: (string) Character to fill blank spaces in the 1037 | -- statusline (see 'fillchars'). Treated as single-width even 1038 | -- if it isn't. 1039 | -- • highlights: (boolean) Return highlight information. 1040 | -- • use_winbar: (boolean) Evaluate winbar instead of statusline. 1041 | -- • use_tabline: (boolean) Evaluate tabline instead of 1042 | -- statusline. When true, {winid} is ignored. Mutually 1043 | -- exclusive with {use_winbar}. 1044 | --- @return any # Dictionary containing statusline information, with these keys: 1045 | -- • str: (string) Characters that will be displayed on the statusline. 1046 | -- • width: (number) Display width of the statusline. 1047 | -- • highlights: Array containing highlight information of the 1048 | -- statusline. Only included when the "highlights" key in {opts} is 1049 | -- true. Each element of the array is a |Dictionary| with these keys: 1050 | -- • start: (number) Byte index (0-based) of first character that uses 1051 | -- the highlight. 1052 | -- • group: (string) Name of highlight group. 1053 | function vim.api.nvim_eval_statusline(str, opts) end 1054 | 1055 | -- Executes Vimscript (multiline block of Ex commands), like anonymous 1056 | -- |:source|. 1057 | -- 1058 | -- Unlike |nvim_command()| this function supports heredocs, script-scope 1059 | -- (s:), etc. 1060 | -- 1061 | -- On execution error: fails with VimL error, updates v:errmsg. 1062 | --- @see |execute()| 1063 | --- @see |nvim_command()| 1064 | --- @see |nvim_cmd()| 1065 | --- @param src string # Vimscript code 1066 | --- @param output boolean # Capture and return all (non-error, non-shell |:!|) output 1067 | --- @return any # Output (non-error, non-shell |:!|) if `output` is true, else empty 1068 | -- string. 1069 | function vim.api.nvim_exec(src, output) end 1070 | 1071 | -- Execute all autocommands for {event} that match the corresponding {opts} 1072 | -- |autocmd-execute|. 1073 | --- @see |:doautocmd| 1074 | --- @param event object # (String|Array) The event or events to execute 1075 | --- @param opts? dict # Dictionary of autocommand options: 1076 | -- • group (string|integer) optional: the autocommand group name 1077 | -- or id to match against. |autocmd-groups|. 1078 | -- • pattern (string|array) optional: defaults to "*" 1079 | -- |autocmd-pattern|. Cannot be used with {buffer}. 1080 | -- • buffer (integer) optional: buffer number 1081 | -- |autocmd-buflocal|. Cannot be used with {pattern}. 1082 | -- • modeline (bool) optional: defaults to true. Process the 1083 | -- modeline after the autocommands ||. 1084 | -- • data (any): arbitrary data to send to the autocommand 1085 | -- callback. See |nvim_create_autocmd()| for details. 1086 | function vim.api.nvim_exec_autocmds(event, opts) end 1087 | 1088 | -- Execute Lua code. Parameters (if any) are available as `...` inside the 1089 | -- chunk. The chunk can return a value. 1090 | -- 1091 | -- Only statements are executed. To evaluate an expression, prefix it with 1092 | -- `return`: return my_function(...) 1093 | --- @param code string # Lua code to execute 1094 | --- @param args array # Arguments to the code 1095 | --- @return any # Return value of Lua code if present or NIL. 1096 | function vim.api.nvim_exec_lua(code, args) end 1097 | 1098 | -- Sends input-keys to Nvim, subject to various quirks controlled by `mode` 1099 | -- flags. This is a blocking call, unlike |nvim_input()|. 1100 | -- 1101 | -- On execution error: does not fail, but updates v:errmsg. 1102 | -- 1103 | -- To input sequences like use |nvim_replace_termcodes()| (typically 1104 | -- with escape_ks=false) to replace |keycodes|, then pass the result to 1105 | -- nvim_feedkeys(). 1106 | -- 1107 | -- Example: 1108 | -- ```lua 1109 | -- :let key = nvim_replace_termcodes("", v:true, v:false, v:true) 1110 | -- :call nvim_feedkeys(key, 'n', v:false) 1111 | -- 1112 | -- ``` 1113 | --- @see feedkeys() 1114 | --- @see vim_strsave_escape_ks 1115 | --- @param keys string # to be typed 1116 | --- @param mode string # behavior flags, see |feedkeys()| 1117 | --- @param escape_ks boolean # If true, escape K_SPECIAL bytes in `keys` This should be 1118 | -- false if you already used |nvim_replace_termcodes()|, and 1119 | -- true otherwise. 1120 | function vim.api.nvim_feedkeys(keys, mode, escape_ks) end 1121 | 1122 | -- Gets the option information for all options. 1123 | -- 1124 | -- The dictionary has the full option names as keys and option metadata 1125 | -- dictionaries as detailed at |nvim_get_option_info()|. 1126 | --- @return any # dictionary of all options 1127 | function vim.api.nvim_get_all_options_info() end 1128 | 1129 | -- Returns a 2-tuple (Array), where item 0 is the current channel id and item 1130 | -- 1 is the |api-metadata| map (Dictionary). 1131 | --- @return any # 2-tuple [{channel-id}, {api-metadata}] 1132 | function vim.api.nvim_get_api_info() end 1133 | 1134 | -- Get all autocommands that match the corresponding {opts}. 1135 | -- 1136 | -- These examples will get autocommands matching ALL the given criteria: 1137 | -- ```lua 1138 | -- -- Matches all criteria 1139 | -- autocommands = vim.api.nvim_get_autocmds({ 1140 | -- group = "MyGroup", 1141 | -- event = {"BufEnter", "BufWinEnter"}, 1142 | -- pattern = {"*.c", "*.h"} 1143 | -- }) 1144 | -- 1145 | -- -- All commands from one group 1146 | -- autocommands = vim.api.nvim_get_autocmds({ 1147 | -- group = "MyGroup", 1148 | -- }) 1149 | -- 1150 | -- ``` 1151 | -- 1152 | -- NOTE: When multiple patterns or events are provided, it will find all the 1153 | -- autocommands that match any combination of them. 1154 | --- @param opts? dict # Dictionary with at least one of the following: 1155 | -- • group (string|integer): the autocommand group name or id to 1156 | -- match against. 1157 | -- • event (string|array): event or events to match against 1158 | -- |autocmd-events|. 1159 | -- • pattern (string|array): pattern or patterns to match against 1160 | -- |autocmd-pattern|. Cannot be used with {buffer} 1161 | -- • buffer: Buffer number or list of buffer numbers for buffer 1162 | -- local autocommands |autocmd-buflocal|. Cannot be used with 1163 | -- {pattern} 1164 | --- @return any # Array of autocommands matching the criteria, with each item containing 1165 | -- the following fields: 1166 | -- • id (number): the autocommand id (only when defined with the API). 1167 | -- • group (integer): the autocommand group id. 1168 | -- • group_name (string): the autocommand group name. 1169 | -- • desc (string): the autocommand description. 1170 | -- • event (string): the autocommand event. 1171 | -- • command (string): the autocommand command. Note: this will be empty 1172 | -- if a callback is set. 1173 | -- • callback (function|string|nil): Lua function or name of a Vim script 1174 | -- function which is executed when this autocommand is triggered. 1175 | -- • once (boolean): whether the autocommand is only run once. 1176 | -- • pattern (string): the autocommand pattern. If the autocommand is 1177 | -- buffer local |autocmd-buffer-local|: 1178 | -- • buflocal (boolean): true if the autocommand is buffer local. 1179 | -- • buffer (number): the buffer number. 1180 | function vim.api.nvim_get_autocmds(opts) end 1181 | 1182 | -- Gets information about a channel. 1183 | --- @param chan integer 1184 | --- @return any # Dictionary describing a channel, with these keys: 1185 | -- • "id" Channel id. 1186 | -- • "argv" (optional) Job arguments list. 1187 | -- • "stream" Stream underlying the channel. 1188 | -- • "stdio" stdin and stdout of this Nvim instance 1189 | -- • "stderr" stderr of this Nvim instance 1190 | -- • "socket" TCP/IP socket or named pipe 1191 | -- • "job" Job with communication over its stdio. 1192 | -- 1193 | -- • "mode" How data received on the channel is interpreted. 1194 | -- • "bytes" Send and receive raw bytes. 1195 | -- • "terminal" |terminal| instance interprets ASCII sequences. 1196 | -- • "rpc" |RPC| communication on the channel is active. 1197 | -- 1198 | -- • "pty" (optional) Name of pseudoterminal. On a POSIX system this is a 1199 | -- device path like "/dev/pts/1". If the name is unknown, the key will 1200 | -- still be present if a pty is used (e.g. for conpty on Windows). 1201 | -- • "buffer" (optional) Buffer with connected |terminal| instance. 1202 | -- • "client" (optional) Info about the peer (client on the other end of 1203 | -- the RPC channel), if provided by it via |nvim_set_client_info()|. 1204 | function vim.api.nvim_get_chan_info(chan) end 1205 | 1206 | -- Returns the 24-bit RGB value of a |nvim_get_color_map()| color name or 1207 | -- "#rrggbb" hexadecimal string. 1208 | -- 1209 | -- Example: 1210 | -- ```lua 1211 | -- :echo nvim_get_color_by_name("Pink") 1212 | -- :echo nvim_get_color_by_name("#cbcbcb") 1213 | -- 1214 | -- ``` 1215 | --- @param name string # Color name or "#rrggbb" string 1216 | --- @return any # 24-bit RGB value, or -1 for invalid argument. 1217 | function vim.api.nvim_get_color_by_name(name) end 1218 | 1219 | -- Returns a map of color names and RGB values. 1220 | -- 1221 | -- Keys are color names (e.g. "Aqua") and values are 24-bit RGB color values 1222 | -- (e.g. 65535). 1223 | --- @return any # Map of color names and RGB values. 1224 | function vim.api.nvim_get_color_map() end 1225 | 1226 | -- Gets a map of global (non-buffer-local) Ex commands. 1227 | -- 1228 | -- Currently only |user-commands| are supported, not builtin Ex commands. 1229 | --- @param opts? dict # Optional parameters. Currently only supports {"builtin":false} 1230 | --- @return any # Map of maps describing commands. 1231 | function vim.api.nvim_get_commands(opts) end 1232 | 1233 | -- Gets a map of the current editor state. 1234 | --- @param opts? dict # Optional parameters. 1235 | -- • types: List of |context-types| ("regs", "jumps", "bufs", 1236 | -- "gvars", …) to gather, or empty for "all". 1237 | --- @return any # map of global |context|. 1238 | function vim.api.nvim_get_context(opts) end 1239 | 1240 | -- Gets the current buffer. 1241 | --- @return any # Buffer handle 1242 | function vim.api.nvim_get_current_buf() end 1243 | 1244 | -- Gets the current line. 1245 | --- @return any # Current line string 1246 | function vim.api.nvim_get_current_line() end 1247 | 1248 | -- Gets the current tabpage. 1249 | --- @return any # Tabpage handle 1250 | function vim.api.nvim_get_current_tabpage() end 1251 | 1252 | -- Gets the current window. 1253 | --- @return any # Window handle 1254 | function vim.api.nvim_get_current_win() end 1255 | 1256 | -- Gets a highlight definition by id. |hlID()| 1257 | --- @see nvim_get_hl_by_name 1258 | --- @param hl_id integer # Highlight id as returned by |hlID()| 1259 | --- @param rgb boolean # Export RGB colors 1260 | --- @return any # Highlight definition map 1261 | function vim.api.nvim_get_hl_by_id(hl_id, rgb) end 1262 | 1263 | -- Gets a highlight definition by name. 1264 | --- @see nvim_get_hl_by_id 1265 | --- @param name string # Highlight group name 1266 | --- @param rgb boolean # Export RGB colors 1267 | --- @return any # Highlight definition map 1268 | function vim.api.nvim_get_hl_by_name(name, rgb) end 1269 | 1270 | -- Gets a highlight group by name 1271 | -- 1272 | -- similar to |hlID()|, but allocates a new ID if not present. 1273 | --- @param name string 1274 | function vim.api.nvim_get_hl_id_by_name(name) end 1275 | 1276 | -- Gets a list of global (non-buffer-local) |mapping| definitions. 1277 | --- @param mode string # Mode short-name ("n", "i", "v", ...) 1278 | --- @return any # Array of |maparg()|-like dictionaries describing mappings. The 1279 | -- "buffer" key is always zero. 1280 | function vim.api.nvim_get_keymap(mode) end 1281 | 1282 | -- Return a tuple (row, col, buffer, buffername) representing the position of 1283 | -- the uppercase/file named mark. See |mark-motions|. 1284 | -- 1285 | -- Marks are (1,0)-indexed. |api-indexing| 1286 | -- 1287 | -- 1288 | -- Note: 1289 | -- fails with error if a lowercase or buffer local named mark is used. 1290 | --- @see |nvim_buf_set_mark()| 1291 | --- @see |nvim_del_mark()| 1292 | --- @param name string # Mark name 1293 | --- @param opts dictionary # Optional parameters. Reserved for future use. 1294 | --- @return any # 4-tuple (row, col, buffer, buffername), (0, 0, 0, '') if the mark is 1295 | -- not set. 1296 | function vim.api.nvim_get_mark(name, opts) end 1297 | 1298 | -- Gets the current mode. |mode()| "blocking" is true if Nvim is waiting for 1299 | -- input. 1300 | --- @return any # Dictionary { "mode": String, "blocking": Boolean } 1301 | function vim.api.nvim_get_mode() end 1302 | 1303 | -- Gets existing, non-anonymous namespaces. 1304 | --- @return any # dict that maps from names to namespace ids. 1305 | function vim.api.nvim_get_namespaces() end 1306 | 1307 | -- Gets the global value of an option. 1308 | --- @param name string # Option name 1309 | --- @return any # Option value (global) 1310 | function vim.api.nvim_get_option(name) end 1311 | 1312 | -- Gets the option information for one option 1313 | -- 1314 | -- Resulting dictionary has keys: 1315 | -- • name: Name of the option (like 'filetype') 1316 | -- • shortname: Shortened name of the option (like 'ft') 1317 | -- • type: type of option ("string", "number" or "boolean") 1318 | -- • default: The default value for the option 1319 | -- • was_set: Whether the option was set. 1320 | -- • last_set_sid: Last set script id (if any) 1321 | -- • last_set_linenr: line number where option was set 1322 | -- • last_set_chan: Channel where option was set (0 for local) 1323 | -- • scope: one of "global", "win", or "buf" 1324 | -- • global_local: whether win or buf option has a global value 1325 | -- • commalist: List of comma separated values 1326 | -- • flaglist: List of single char flags 1327 | --- @param name string # Option name 1328 | --- @return any # Option Information 1329 | function vim.api.nvim_get_option_info(name) end 1330 | 1331 | -- Gets the value of an option. The behavior of this function matches that of 1332 | -- |:set|: the local value of an option is returned if it exists; otherwise, 1333 | -- the global value is returned. Local values always correspond to the 1334 | -- current buffer or window, unless "buf" or "win" is set in {opts}. 1335 | --- @param name string # Option name 1336 | --- @param opts? dict # Optional parameters 1337 | -- • scope: One of "global" or "local". Analogous to |:setglobal| 1338 | -- and |:setlocal|, respectively. 1339 | -- • win: |window-ID|. Used for getting window local options. 1340 | -- • buf: Buffer number. Used for getting buffer local options. 1341 | -- Implies {scope} is "local". 1342 | --- @return any # Option value 1343 | function vim.api.nvim_get_option_value(name, opts) end 1344 | 1345 | -- Gets info describing process `pid`. 1346 | --- @param pid integer 1347 | --- @return any # Map of process properties, or NIL if process not found. 1348 | function vim.api.nvim_get_proc(pid) end 1349 | 1350 | -- Gets the immediate children of process `pid`. 1351 | --- @param pid integer 1352 | --- @return any # Array of child process ids, empty if process not found. 1353 | function vim.api.nvim_get_proc_children(pid) end 1354 | 1355 | -- Find files in runtime directories 1356 | -- 1357 | -- "name" can contain wildcards. For example 1358 | -- nvim_get_runtime_file("colors/*.vim", true) will return all color scheme 1359 | -- files. Always use forward slashes (/) in the search pattern for 1360 | -- subdirectories regardless of platform. 1361 | -- 1362 | -- It is not an error to not find any files. An empty array is returned then. 1363 | --- @param name string # pattern of files to search for 1364 | --- @param all boolean # whether to return all matches or only the first 1365 | --- @return any # list of absolute paths to the found files 1366 | function vim.api.nvim_get_runtime_file(name, all) end 1367 | 1368 | -- Gets a global (g:) variable. 1369 | --- @param name string # Variable name 1370 | --- @return any # Variable value 1371 | function vim.api.nvim_get_var(name) end 1372 | 1373 | -- Gets a v: variable. 1374 | --- @param name string # Variable name 1375 | --- @return any # Variable value 1376 | function vim.api.nvim_get_vvar(name) end 1377 | 1378 | -- Queues raw user-input. Unlike |nvim_feedkeys()|, this uses a low-level 1379 | -- input buffer and the call is non-blocking (input is processed 1380 | -- asynchronously by the eventloop). 1381 | -- 1382 | -- On execution error: does not fail, but updates v:errmsg. 1383 | -- 1384 | -- 1385 | -- Note: 1386 | -- |keycodes| like are translated, so "<" is special. To input a 1387 | -- literal "<", send . 1388 | -- 1389 | -- Note: 1390 | -- For mouse events use |nvim_input_mouse()|. The pseudokey form 1391 | -- "" is deprecated since |api-level| 6. 1392 | --- @param keys string # to be typed 1393 | --- @return any # Number of bytes actually written (can be fewer than requested if the 1394 | -- buffer becomes full). 1395 | function vim.api.nvim_input(keys) end 1396 | 1397 | -- Send mouse event from GUI. 1398 | -- 1399 | -- Non-blocking: does not wait on any result, but queues the event to be 1400 | -- processed soon by the event loop. 1401 | -- 1402 | -- 1403 | -- Note: 1404 | -- Currently this doesn't support "scripting" multiple mouse events by 1405 | -- calling it multiple times in a loop: the intermediate mouse positions 1406 | -- will be ignored. It should be used to implement real-time mouse input 1407 | -- in a GUI. The deprecated pseudokey form ("") of 1408 | -- |nvim_input()| has the same limitation. 1409 | --- @param button string # Mouse button: one of "left", "right", "middle", "wheel", 1410 | -- "move". 1411 | --- @param action string # For ordinary buttons, one of "press", "drag", "release". 1412 | -- For the wheel, one of "up", "down", "left", "right". 1413 | -- Ignored for "move". 1414 | --- @param modifier string # String of modifiers each represented by a single char. The 1415 | -- same specifiers are used as for a key press, except that 1416 | -- the "-" separator is optional, so "C-A-", "c-a" and "CA" 1417 | -- can all be used to specify Ctrl+Alt+click. 1418 | --- @param grid integer # Grid number if the client uses |ui-multigrid|, else 0. 1419 | --- @param row integer # Mouse row-position (zero-based, like redraw events) 1420 | --- @param col integer # Mouse column-position (zero-based, like redraw events) 1421 | function vim.api.nvim_input_mouse(button, action, modifier, grid, row, col) end 1422 | 1423 | -- Gets the current list of buffer handles 1424 | -- 1425 | -- Includes unlisted (unloaded/deleted) buffers, like `:ls!`. Use 1426 | -- |nvim_buf_is_loaded()| to check if a buffer is loaded. 1427 | --- @return any # List of buffer handles 1428 | function vim.api.nvim_list_bufs() end 1429 | 1430 | -- Get information about all open channels. 1431 | --- @return any # Array of Dictionaries, each describing a channel with the format 1432 | -- specified at |nvim_get_chan_info()|. 1433 | function vim.api.nvim_list_chans() end 1434 | 1435 | -- Gets the paths contained in 'runtimepath'. 1436 | --- @return any # List of paths 1437 | function vim.api.nvim_list_runtime_paths() end 1438 | 1439 | -- Gets the current list of tabpage handles. 1440 | --- @return any # List of tabpage handles 1441 | function vim.api.nvim_list_tabpages() end 1442 | 1443 | -- Gets a list of dictionaries representing attached UIs. 1444 | --- @return any # Array of UI dictionaries, each with these keys: 1445 | -- • "height" Requested height of the UI 1446 | -- • "width" Requested width of the UI 1447 | -- • "rgb" true if the UI uses RGB colors (false implies |cterm-colors|) 1448 | -- • "ext_..." Requested UI extensions, see |ui-option| 1449 | -- • "chan" Channel id of remote UI (not present for TUI) 1450 | function vim.api.nvim_list_uis() end 1451 | 1452 | -- Gets the current list of window handles. 1453 | --- @return any # List of window handles 1454 | function vim.api.nvim_list_wins() end 1455 | 1456 | -- Sets the current editor state from the given |context| map. 1457 | --- @param dict dictionary # |Context| map. 1458 | function vim.api.nvim_load_context(dict) end 1459 | 1460 | -- Notify the user with a message 1461 | -- 1462 | -- Relays the call to vim.notify . By default forwards your message in the 1463 | -- echo area but can be overridden to trigger desktop notifications. 1464 | --- @param msg string # Message to display to the user 1465 | --- @param log_level integer # The log level 1466 | --- @param opts dictionary # Reserved for future use. 1467 | function vim.api.nvim_notify(msg, log_level, opts) end 1468 | 1469 | -- Open a terminal instance in a buffer 1470 | -- 1471 | -- By default (and currently the only option) the terminal will not be 1472 | -- connected to an external process. Instead, input send on the channel will 1473 | -- be echoed directly by the terminal. This is useful to display ANSI 1474 | -- terminal sequences returned as part of a rpc message, or similar. 1475 | -- 1476 | -- Note: to directly initiate the terminal using the right size, display the 1477 | -- buffer in a configured window before calling this. For instance, for a 1478 | -- floating display, first create an empty buffer using |nvim_create_buf()|, 1479 | -- then display it using |nvim_open_win()|, and then call this function. Then 1480 | -- |nvim_chan_send()| can be called immediately to process sequences in a 1481 | -- virtual terminal having the intended size. 1482 | --- @param buffer buffer # the buffer to use (expected to be empty) 1483 | --- @param opts table # Optional parameters. 1484 | -- • on_input: lua callback for input sent, i e keypresses in 1485 | -- terminal mode. Note: keypresses are sent raw as they would 1486 | -- be to the pty master end. For instance, a carriage return 1487 | -- is sent as a "\r", not as a "\n". |textlock| applies. It 1488 | -- is possible to call |nvim_chan_send()| directly in the 1489 | -- callback however. ["input", term, bufnr, data] 1490 | --- @return any # Channel id, or 0 on error 1491 | function vim.api.nvim_open_term(buffer, opts) end 1492 | 1493 | -- Open a new window. 1494 | -- 1495 | -- Currently this is used to open floating and external windows. Floats are 1496 | -- windows that are drawn above the split layout, at some anchor position in 1497 | -- some other window. Floats can be drawn internally or by external GUI with 1498 | -- the |ui-multigrid| extension. External windows are only supported with 1499 | -- multigrid GUIs, and are displayed as separate top-level windows. 1500 | -- 1501 | -- For a general overview of floats, see |api-floatwin|. 1502 | -- 1503 | -- Exactly one of `external` and `relative` must be specified. The `width` 1504 | -- and `height` of the new window must be specified. 1505 | -- 1506 | -- With relative=editor (row=0,col=0) refers to the top-left corner of the 1507 | -- screen-grid and (row=Lines-1,col=Columns-1) refers to the bottom-right 1508 | -- corner. Fractional values are allowed, but the builtin implementation 1509 | -- (used by non-multigrid UIs) will always round down to nearest integer. 1510 | -- 1511 | -- Out-of-bounds values, and configurations that make the float not fit 1512 | -- inside the main editor, are allowed. The builtin implementation truncates 1513 | -- values so floats are fully within the main screen grid. External GUIs 1514 | -- could let floats hover outside of the main window like a tooltip, but this 1515 | -- should not be used to specify arbitrary WM screen positions. 1516 | -- 1517 | -- Example (Lua): window-relative float 1518 | -- ```lua 1519 | -- vim.api.nvim_open_win(0, false, 1520 | -- {relative='win', row=3, col=3, width=12, height=3}) 1521 | -- 1522 | -- ``` 1523 | -- 1524 | -- Example (Lua): buffer-relative float (travels as buffer is scrolled) 1525 | -- ```lua 1526 | -- vim.api.nvim_open_win(0, false, 1527 | -- {relative='win', width=12, height=3, bufpos={100,10}}) 1528 | -- 1529 | -- ``` 1530 | --- @param buffer buffer # Buffer to display, or 0 for current buffer 1531 | --- @param enter boolean # Enter the window (make it the current window) 1532 | --- @param config? dict # Map defining the window configuration. Keys: 1533 | -- • relative: Sets the window layout to "floating", placed at 1534 | -- (row,col) coordinates relative to: 1535 | -- • "editor" The global editor grid 1536 | -- • "win" Window given by the `win` field, or current 1537 | -- window. 1538 | -- • "cursor" Cursor position in current window. 1539 | -- 1540 | -- • win: |window-ID| for relative="win". 1541 | -- • anchor: Decides which corner of the float to place at 1542 | -- (row,col): 1543 | -- • "NW" northwest (default) 1544 | -- • "NE" northeast 1545 | -- • "SW" southwest 1546 | -- • "SE" southeast 1547 | -- 1548 | -- • width: Window width (in character cells). Minimum of 1. 1549 | -- • height: Window height (in character cells). Minimum of 1. 1550 | -- • bufpos: Places float relative to buffer text (only when 1551 | -- relative="win"). Takes a tuple of zero-indexed [line, 1552 | -- column]. `row` and `col` if given are applied relative to this position, else they 1553 | -- default to: 1554 | -- • `row=1` and `col=0` if `anchor` is "NW" or "NE" 1555 | -- • `row=0` and `col=0` if `anchor` is "SW" or "SE" (thus 1556 | -- like a tooltip near the buffer text). 1557 | -- 1558 | -- • row: Row position in units of "screen cell height", may be 1559 | -- fractional. 1560 | -- • col: Column position in units of "screen cell width", may 1561 | -- be fractional. 1562 | -- • focusable: Enable focus by user actions (wincmds, mouse 1563 | -- events). Defaults to true. Non-focusable windows can be 1564 | -- entered by |nvim_set_current_win()|. 1565 | -- • external: GUI should display the window as an external 1566 | -- top-level window. Currently accepts no other positioning 1567 | -- configuration together with this. 1568 | -- • zindex: Stacking order. floats with higher `zindex` go on top on floats with lower indices. Must be larger 1569 | -- than zero. The following screen elements have hard-coded 1570 | -- z-indices: 1571 | -- • 100: insert completion popupmenu 1572 | -- • 200: message scrollback 1573 | -- • 250: cmdline completion popupmenu (when 1574 | -- wildoptions+=pum) The default value for floats are 50. 1575 | -- In general, values below 100 are recommended, unless 1576 | -- there is a good reason to overshadow builtin elements. 1577 | -- 1578 | -- • style: Configure the appearance of the window. Currently 1579 | -- only takes one non-empty value: 1580 | -- • "minimal" Nvim will display the window with many UI 1581 | -- options disabled. This is useful when displaying a 1582 | -- temporary float where the text should not be edited. 1583 | -- Disables 'number', 'relativenumber', 'cursorline', 1584 | -- 'cursorcolumn', 'foldcolumn', 'spell' and 'list' 1585 | -- options. 'signcolumn' is changed to `auto` and 1586 | -- 'colorcolumn' is cleared. The end-of-buffer region is 1587 | -- hidden by setting `eob` flag of 'fillchars' to a space 1588 | -- char, and clearing the |hl-EndOfBuffer| region in 1589 | -- 'winhighlight'. 1590 | -- 1591 | -- • border: Style of (optional) window border. This can either 1592 | -- be a string or an array. The string values are 1593 | -- • "none": No border (default). 1594 | -- • "single": A single line box. 1595 | -- • "double": A double line box. 1596 | -- • "rounded": Like "single", but with rounded corners ("╭" 1597 | -- etc.). 1598 | -- • "solid": Adds padding by a single whitespace cell. 1599 | -- • "shadow": A drop shadow effect by blending with the 1600 | -- background. 1601 | -- • If it is an array, it should have a length of eight or 1602 | -- any divisor of eight. The array will specifify the eight 1603 | -- chars building up the border in a clockwise fashion 1604 | -- starting with the top-left corner. As an example, the 1605 | -- double box style could be specified as [ "╔", "═" ,"╗", 1606 | -- "║", "╝", "═", "╚", "║" ]. If the number of chars are 1607 | -- less than eight, they will be repeated. Thus an ASCII 1608 | -- border could be specified as [ "/", "-", "\\", "|" ], or 1609 | -- all chars the same as [ "x" ]. An empty string can be 1610 | -- used to turn off a specific border, for instance, [ "", 1611 | -- "", "", ">", "", "", "", "<" ] will only make vertical 1612 | -- borders but not horizontal ones. By default, 1613 | -- `FloatBorder` highlight is used, which links to 1614 | -- `WinSeparator` when not defined. It could also be 1615 | -- specified by character: [ {"+", "MyCorner"}, {"x", 1616 | -- "MyBorder"} ]. 1617 | -- 1618 | -- • noautocmd: If true then no buffer-related autocommand 1619 | -- events such as |BufEnter|, |BufLeave| or |BufWinEnter| may 1620 | -- fire from calling this function. 1621 | --- @return any # Window handle, or 0 on error 1622 | function vim.api.nvim_open_win(buffer, enter, config) end 1623 | 1624 | -- Writes a message to the Vim output buffer. Does not append "\n", the 1625 | -- message is buffered (won't display) until a linefeed is written. 1626 | --- @param str string # Message 1627 | function vim.api.nvim_out_write(str) end 1628 | 1629 | -- Parse command line. 1630 | -- 1631 | -- Doesn't check the validity of command arguments. 1632 | --- @param str string # Command line string to parse. Cannot contain "\n". 1633 | --- @param opts dictionary # Optional parameters. Reserved for future use. 1634 | --- @return any # Dictionary containing command information, with these keys: 1635 | -- • cmd: (string) Command name. 1636 | -- • range: (array) (optional) Command range (|| ||). 1637 | -- Omitted if command doesn't accept a range. Otherwise, has no 1638 | -- elements if no range was specified, one element if only a single 1639 | -- range item was specified, or two elements if both range items were 1640 | -- specified. 1641 | -- • count: (number) (optional) Command ||. Omitted if command 1642 | -- cannot take a count. 1643 | -- • reg: (string) (optional) Command ||. Omitted if command 1644 | -- cannot take a register. 1645 | -- • bang: (boolean) Whether command contains a || (!) modifier. 1646 | -- • args: (array) Command arguments. 1647 | -- • addr: (string) Value of |:command-addr|. Uses short name. 1648 | -- • nargs: (string) Value of |:command-nargs|. 1649 | -- • nextcmd: (string) Next command if there are multiple commands 1650 | -- separated by a |:bar|. Empty if there isn't a next command. 1651 | -- • magic: (dictionary) Which characters have special meaning in the 1652 | -- command arguments. 1653 | -- • file: (boolean) The command expands filenames. Which means 1654 | -- characters such as "%", "#" and wildcards are expanded. 1655 | -- • bar: (boolean) The "|" character is treated as a command separator 1656 | -- and the double quote character (") is treated as the start of a 1657 | -- comment. 1658 | -- 1659 | -- • mods: (dictionary) |:command-modifiers|. 1660 | -- • filter: (dictionary) |:filter|. 1661 | -- • pattern: (string) Filter pattern. Empty string if there is no 1662 | -- filter. 1663 | -- • force: (boolean) Whether filter is inverted or not. 1664 | -- 1665 | -- • silent: (boolean) |:silent|. 1666 | -- • emsg_silent: (boolean) |:silent!|. 1667 | -- • unsilent: (boolean) |:unsilent|. 1668 | -- • sandbox: (boolean) |:sandbox|. 1669 | -- • noautocmd: (boolean) |:noautocmd|. 1670 | -- • browse: (boolean) |:browse|. 1671 | -- • confirm: (boolean) |:confirm|. 1672 | -- • hide: (boolean) |:hide|. 1673 | -- • horizontal: (boolean) |:horizontal|. 1674 | -- • keepalt: (boolean) |:keepalt|. 1675 | -- • keepjumps: (boolean) |:keepjumps|. 1676 | -- • keepmarks: (boolean) |:keepmarks|. 1677 | -- • keeppatterns: (boolean) |:keeppatterns|. 1678 | -- • lockmarks: (boolean) |:lockmarks|. 1679 | -- • noswapfile: (boolean) |:noswapfile|. 1680 | -- • tab: (integer) |:tab|. -1 when omitted. 1681 | -- • verbose: (integer) |:verbose|. -1 when omitted. 1682 | -- • vertical: (boolean) |:vertical|. 1683 | -- • split: (string) Split modifier string, is an empty string when 1684 | -- there's no split modifier. If there is a split modifier it can be 1685 | -- one of: 1686 | -- • "aboveleft": |:aboveleft|. 1687 | -- • "belowright": |:belowright|. 1688 | -- • "topleft": |:topleft|. 1689 | -- • "botright": |:botright|. 1690 | function vim.api.nvim_parse_cmd(str, opts) end 1691 | 1692 | -- Parse a VimL expression. 1693 | --- @param expr string # Expression to parse. Always treated as a single line. 1694 | --- @param flags string # Flags: 1695 | -- • "m" if multiple expressions in a row are allowed (only 1696 | -- the first one will be parsed), 1697 | -- • "E" if EOC tokens are not allowed (determines whether 1698 | -- they will stop parsing process or be recognized as an 1699 | -- operator/space, though also yielding an error). 1700 | -- • "l" when needing to start parsing with lvalues for 1701 | -- ":let" or ":for". Common flag sets: 1702 | -- • "m" to parse like for ":echo". 1703 | -- • "E" to parse like for "=". 1704 | -- • empty string for ":call". 1705 | -- • "lm" to parse for ":let". 1706 | --- @param highlight boolean # If true, return value will also include "highlight" key 1707 | -- containing array of 4-tuples (arrays) (Integer, Integer, 1708 | -- Integer, String), where first three numbers define the 1709 | -- highlighted region and represent line, starting column 1710 | -- and ending column (latter exclusive: one should highlight 1711 | -- region [start_col, end_col)). 1712 | --- @return any # 1713 | -- • AST: top-level dictionary with these keys: 1714 | -- • "error": Dictionary with error, present only if parser saw some 1715 | -- error. Contains the following keys: 1716 | -- • "message": String, error message in printf format, translated. 1717 | -- Must contain exactly one "%.*s". 1718 | -- • "arg": String, error message argument. 1719 | -- 1720 | -- • "len": Amount of bytes successfully parsed. With flags equal to "" 1721 | -- that should be equal to the length of expr string. (“Successfully 1722 | -- parsed” here means “participated in AST creation”, not “till the 1723 | -- first error”.) 1724 | -- • "ast": AST, either nil or a dictionary with these keys: 1725 | -- • "type": node type, one of the value names from ExprASTNodeType 1726 | -- stringified without "kExprNode" prefix. 1727 | -- • "start": a pair [line, column] describing where node is 1728 | -- "started" where "line" is always 0 (will not be 0 if you will be 1729 | -- using nvim_parse_viml() on e.g. ":let", but that is not present 1730 | -- yet). Both elements are Integers. 1731 | -- • "len": “length” of the node. This and "start" are there for 1732 | -- debugging purposes primary (debugging parser and providing debug 1733 | -- information). 1734 | -- • "children": a list of nodes described in top/"ast". There always 1735 | -- is zero, one or two children, key will not be present if node 1736 | -- has no children. Maximum number of children may be found in 1737 | -- node_maxchildren array. 1738 | -- 1739 | -- 1740 | -- • Local values (present only for certain nodes): 1741 | -- • "scope": a single Integer, specifies scope for "Option" and 1742 | -- "PlainIdentifier" nodes. For "Option" it is one of ExprOptScope 1743 | -- values, for "PlainIdentifier" it is one of ExprVarScope values. 1744 | -- • "ident": identifier (without scope, if any), present for "Option", 1745 | -- "PlainIdentifier", "PlainKey" and "Environment" nodes. 1746 | -- • "name": Integer, register name (one character) or -1. Only present 1747 | -- for "Register" nodes. 1748 | -- • "cmp_type": String, comparison type, one of the value names from 1749 | -- ExprComparisonType, stringified without "kExprCmp" prefix. Only 1750 | -- present for "Comparison" nodes. 1751 | -- • "ccs_strategy": String, case comparison strategy, one of the value 1752 | -- names from ExprCaseCompareStrategy, stringified without 1753 | -- "kCCStrategy" prefix. Only present for "Comparison" nodes. 1754 | -- • "augmentation": String, augmentation type for "Assignment" nodes. 1755 | -- Is either an empty string, "Add", "Subtract" or "Concat" for "=", 1756 | -- "+=", "-=" or ".=" respectively. 1757 | -- • "invert": Boolean, true if result of comparison needs to be 1758 | -- inverted. Only present for "Comparison" nodes. 1759 | -- • "ivalue": Integer, integer value for "Integer" nodes. 1760 | -- • "fvalue": Float, floating-point value for "Float" nodes. 1761 | -- • "svalue": String, value for "SingleQuotedString" and 1762 | -- "DoubleQuotedString" nodes. 1763 | function vim.api.nvim_parse_expression(expr, flags, highlight) end 1764 | 1765 | -- Pastes at cursor, in any mode. 1766 | -- 1767 | -- Invokes the `vim.paste` handler, which handles each mode appropriately. 1768 | -- Sets redo/undo. Faster than |nvim_input()|. Lines break at LF ("\n"). 1769 | -- 1770 | -- Errors ('nomodifiable', `vim.paste()` failure, …) are reflected in `err` 1771 | -- but do not affect the return value (which is strictly decided by 1772 | -- `vim.paste()`). On error, subsequent calls are ignored ("drained") until 1773 | -- the next paste is initiated (phase 1 or -1). 1774 | --- @param data string # Multiline input. May be binary (containing NUL bytes). 1775 | --- @param crlf boolean # Also break lines at CR and CRLF. 1776 | --- @param phase integer # -1: paste in a single call (i.e. without streaming). To 1777 | -- "stream" a paste, call `nvim_paste` sequentially with these `phase` values: 1778 | -- • 1: starts the paste (exactly once) 1779 | -- • 2: continues the paste (zero or more times) 1780 | -- • 3: ends the paste (exactly once) 1781 | --- @return any # 1782 | -- • true: Client may continue pasting. 1783 | -- • false: Client must cancel the paste. 1784 | function vim.api.nvim_paste(data, crlf, phase) end 1785 | 1786 | -- Puts text at cursor, in any mode. 1787 | -- 1788 | -- Compare |:put| and |p| which are always linewise. 1789 | --- @param lines string[] # |readfile()|-style list of lines. |channel-lines| 1790 | --- @param type string # Edit behavior: any |getregtype()| result, or: 1791 | -- • "b" |blockwise-visual| mode (may include width, e.g. "b3") 1792 | -- • "c" |charwise| mode 1793 | -- • "l" |linewise| mode 1794 | -- • "" guess by contents, see |setreg()| 1795 | --- @param after boolean # If true insert after cursor (like |p|), or before (like 1796 | -- |P|). 1797 | --- @param follow boolean # If true place cursor at end of inserted text. 1798 | function vim.api.nvim_put(lines, type, after, follow) end 1799 | 1800 | -- Replaces terminal codes and |keycodes| (, , ...) in a string with 1801 | -- the internal representation. 1802 | --- @see replace_termcodes 1803 | --- @see cpoptions 1804 | --- @param str string # String to be converted. 1805 | --- @param from_part boolean # Legacy Vim parameter. Usually true. 1806 | --- @param do_lt boolean # Also translate . Ignored if `special` is false. 1807 | --- @param special boolean # Replace |keycodes|, e.g. becomes a "\r" char. 1808 | function vim.api.nvim_replace_termcodes(str, from_part, do_lt, special) end 1809 | 1810 | -- Selects an item in the completion popupmenu. 1811 | -- 1812 | -- If |ins-completion| is not active this API call is silently ignored. 1813 | -- Useful for an external UI using |ui-popupmenu| to control the popupmenu 1814 | -- with the mouse. Can also be used in a mapping; use |:map-cmd| to 1815 | -- ensure the mapping doesn't end completion mode. 1816 | --- @param item integer # Index (zero-based) of the item to select. Value of -1 1817 | -- selects nothing and restores the original text. 1818 | --- @param insert boolean # Whether the selection should be inserted in the buffer. 1819 | --- @param finish boolean # Finish the completion and dismiss the popupmenu. Implies 1820 | -- `insert`. 1821 | --- @param opts dictionary # Optional parameters. Reserved for future use. 1822 | function vim.api.nvim_select_popupmenu_item(item, insert, finish, opts) end 1823 | 1824 | -- Self-identifies the client. 1825 | -- 1826 | -- The client/plugin/application should call this after connecting, to 1827 | -- provide hints about its identity and purpose, for debugging and 1828 | -- orchestration. 1829 | -- 1830 | -- Can be called more than once; the caller should merge old info if 1831 | -- appropriate. Example: library first identifies the channel, then a plugin 1832 | -- using that library later identifies itself. 1833 | -- 1834 | -- 1835 | -- Note: 1836 | -- "Something is better than nothing". You don't need to include all the 1837 | -- fields. 1838 | --- @param name string # Short name for the connected client 1839 | --- @param version dictionary # Dictionary describing the version, with these (optional) 1840 | -- keys: 1841 | -- • "major" major version (defaults to 0 if not set, for 1842 | -- no release yet) 1843 | -- • "minor" minor version 1844 | -- • "patch" patch number 1845 | -- • "prerelease" string describing a prerelease, like 1846 | -- "dev" or "beta1" 1847 | -- • "commit" hash or similar identifier of commit 1848 | --- @param type string # Must be one of the following values. Client libraries 1849 | -- should default to "remote" unless overridden by the 1850 | -- user. 1851 | -- • "remote" remote client connected to Nvim. 1852 | -- • "ui" gui frontend 1853 | -- • "embedder" application using Nvim as a component (for 1854 | -- example, IDE/editor implementing a vim mode). 1855 | -- • "host" plugin host, typically started by nvim 1856 | -- • "plugin" single plugin, started by nvim 1857 | --- @param methods dictionary # Builtin methods in the client. For a host, this does not 1858 | -- include plugin methods which will be discovered later. 1859 | -- The key should be the method name, the values are dicts 1860 | -- with these (optional) keys (more keys may be added in 1861 | -- future versions of Nvim, thus unknown keys are ignored. 1862 | -- Clients must only use keys defined in this or later 1863 | -- versions of Nvim): 1864 | -- • "async" if true, send as a notification. If false or 1865 | -- unspecified, use a blocking request 1866 | -- • "nargs" Number of arguments. Could be a single integer 1867 | -- or an array of two integers, minimum and maximum 1868 | -- inclusive. 1869 | --- @param attributes dictionary # Arbitrary string:string map of informal client 1870 | -- properties. Suggested keys: 1871 | -- • "website": Client homepage URL (e.g. GitHub 1872 | -- repository) 1873 | -- • "license": License description ("Apache 2", "GPLv3", 1874 | -- "MIT", …) 1875 | -- • "logo": URI or path to image, preferably small logo or 1876 | -- icon. .png or .svg format is preferred. 1877 | function vim.api.nvim_set_client_info(name, version, type, methods, attributes) end 1878 | 1879 | -- Sets the current buffer. 1880 | --- @param buffer buffer # Buffer handle 1881 | function vim.api.nvim_set_current_buf(buffer) end 1882 | 1883 | -- Changes the global working directory. 1884 | --- @param dir string # Directory path 1885 | function vim.api.nvim_set_current_dir(dir) end 1886 | 1887 | -- Sets the current line. 1888 | --- @param line string # Line contents 1889 | function vim.api.nvim_set_current_line(line) end 1890 | 1891 | -- Sets the current tabpage. 1892 | --- @param tabpage tabpage # Tabpage handle 1893 | function vim.api.nvim_set_current_tabpage(tabpage) end 1894 | 1895 | -- Sets the current window. 1896 | --- @param window window # Window handle 1897 | function vim.api.nvim_set_current_win(window) end 1898 | 1899 | -- Set or change decoration provider for a namespace 1900 | -- 1901 | -- This is a very general purpose interface for having lua callbacks being 1902 | -- triggered during the redraw code. 1903 | -- 1904 | -- The expected usage is to set extmarks for the currently redrawn buffer. 1905 | -- |nvim_buf_set_extmark()| can be called to add marks on a per-window or 1906 | -- per-lines basis. Use the `ephemeral` key to only use the mark for the 1907 | -- current screen redraw (the callback will be called again for the next 1908 | -- redraw ). 1909 | -- 1910 | -- Note: this function should not be called often. Rather, the callbacks 1911 | -- themselves can be used to throttle unneeded callbacks. the `on_start` 1912 | -- callback can return `false` to disable the provider until the next redraw. 1913 | -- Similarly, return `false` in `on_win` will skip the `on_lines` calls for 1914 | -- that window (but any extmarks set in `on_win` will still be used). A 1915 | -- plugin managing multiple sources of decoration should ideally only set one 1916 | -- provider, and merge the sources internally. You can use multiple `ns_id` 1917 | -- for the extmarks set/modified inside the callback anyway. 1918 | -- 1919 | -- Note: doing anything other than setting extmarks is considered 1920 | -- experimental. Doing things like changing options are not expliticly 1921 | -- forbidden, but is likely to have unexpected consequences (such as 100% CPU 1922 | -- consumption). doing `vim.rpcnotify` should be OK, but `vim.rpcrequest` is 1923 | -- quite dubious for the moment. 1924 | --- @param ns_id integer # Namespace id from |nvim_create_namespace()| 1925 | --- @param opts? dict # Table of callbacks: 1926 | -- • on_start: called first on each screen redraw ["start", 1927 | -- tick] 1928 | -- • on_buf: called for each buffer being redrawn (before window 1929 | -- callbacks) ["buf", bufnr, tick] 1930 | -- • on_win: called when starting to redraw a specific window. 1931 | -- ["win", winid, bufnr, topline, botline_guess] 1932 | -- • on_line: called for each buffer line being redrawn. (The 1933 | -- interaction with fold lines is subject to change) ["win", 1934 | -- winid, bufnr, row] 1935 | -- • on_end: called at the end of a redraw cycle ["end", tick] 1936 | function vim.api.nvim_set_decoration_provider(ns_id, opts) end 1937 | 1938 | -- Sets a highlight group. 1939 | -- 1940 | -- 1941 | -- Note: 1942 | -- Unlike the `:highlight` command which can update a highlight group, 1943 | -- this function completely replaces the definition. For example: 1944 | -- `nvim_set_hl(0, 'Visual', {})` will clear the highlight group 1945 | -- 'Visual'. 1946 | -- 1947 | -- Note: 1948 | -- The fg and bg keys also accept the string values `"fg"` or `"bg"` 1949 | -- which act as aliases to the corresponding foreground and background 1950 | -- values of the Normal group. If the Normal group has not been defined, 1951 | -- using these values results in an error. 1952 | --- @param ns_id integer # Namespace id for this highlight |nvim_create_namespace()|. 1953 | -- Use 0 to set a highlight group globally |:highlight|. 1954 | --- @param name string # Highlight group name, e.g. "ErrorMsg" 1955 | --- @param val? dict # Highlight definition map, accepts the following keys: 1956 | -- • fg (or foreground): color name or "#RRGGBB", see note. 1957 | -- • bg (or background): color name or "#RRGGBB", see note. 1958 | -- • sp (or special): color name or "#RRGGBB" 1959 | -- • blend: integer between 0 and 100 1960 | -- • bold: boolean 1961 | -- • standout: boolean 1962 | -- • underline: boolean 1963 | -- • undercurl: boolean 1964 | -- • underdouble: boolean 1965 | -- • underdotted: boolean 1966 | -- • underdashed: boolean 1967 | -- • strikethrough: boolean 1968 | -- • italic: boolean 1969 | -- • reverse: boolean 1970 | -- • nocombine: boolean 1971 | -- • link: name of another highlight group to link to, see 1972 | -- |:hi-link|. 1973 | -- • default: Don't override existing definition |:hi-default| 1974 | -- • ctermfg: Sets foreground of cterm color |ctermfg| 1975 | -- • ctermbg: Sets background of cterm color |ctermbg| 1976 | -- • cterm: cterm attribute map, like |highlight-args|. If not 1977 | -- set, cterm attributes will match those from the attribute 1978 | -- map documented above. 1979 | function vim.api.nvim_set_hl(ns_id, name, val) end 1980 | 1981 | -- Set active namespace for highlights. This can be set for a single window, 1982 | -- see |nvim_win_set_hl_ns()|. 1983 | --- @param ns_id integer # the namespace to use 1984 | function vim.api.nvim_set_hl_ns(ns_id) end 1985 | 1986 | -- Set active namespace for highlights while redrawing. 1987 | -- 1988 | -- This function meant to be called while redrawing, primarily from 1989 | -- |nvim_set_decoration_provider()| on_win and on_line callbacks, which are 1990 | -- allowed to change the namespace during a redraw cycle. 1991 | --- @param ns_id integer # the namespace to activate 1992 | function vim.api.nvim_set_hl_ns_fast(ns_id) end 1993 | 1994 | -- Sets a global |mapping| for the given mode. 1995 | -- 1996 | -- To set a buffer-local mapping, use |nvim_buf_set_keymap()|. 1997 | -- 1998 | -- Unlike |:map|, leading/trailing whitespace is accepted as part of the 1999 | -- {lhs} or {rhs}. Empty {rhs} is ||. |keycodes| are replaced as usual. 2000 | -- 2001 | -- Example: 2002 | -- ```lua 2003 | -- call nvim_set_keymap('n', ' ', '', {'nowait': v:true}) 2004 | -- 2005 | -- ``` 2006 | -- 2007 | -- is equivalent to: 2008 | -- ```lua 2009 | -- nmap | but including |:noremap| and "desc". 2020 | -- Unknown key is an error. "desc" can be used to give a 2021 | -- description to the mapping. When called from Lua, also accepts 2022 | -- a "callback" key that takes a Lua function to call when the 2023 | -- mapping is executed. When "expr" is true, "replace_keycodes" 2024 | -- (boolean) can be used to replace keycodes in the resulting 2025 | -- string (see |nvim_replace_termcodes()|), and a Lua callback 2026 | -- returning `nil` is equivalent to returning an empty string. 2027 | function vim.api.nvim_set_keymap(mode, lhs, rhs, opts) end 2028 | 2029 | -- Sets the global value of an option. 2030 | --- @param name string # Option name 2031 | --- @param value object # New option value 2032 | function vim.api.nvim_set_option(name, value) end 2033 | 2034 | -- Sets the value of an option. The behavior of this function matches that of 2035 | -- |:set|: for global-local options, both the global and local value are set 2036 | -- unless otherwise specified with {scope}. 2037 | -- 2038 | -- Note the options {win} and {buf} cannot be used together. 2039 | --- @param name string # Option name 2040 | --- @param value object # New option value 2041 | --- @param opts? dict # Optional parameters 2042 | -- • scope: One of "global" or "local". Analogous to 2043 | -- |:setglobal| and |:setlocal|, respectively. 2044 | -- • win: |window-ID|. Used for setting window local option. 2045 | -- • buf: Buffer number. Used for setting buffer local option. 2046 | function vim.api.nvim_set_option_value(name, value, opts) end 2047 | 2048 | -- Sets a global (g:) variable. 2049 | --- @param name string # Variable name 2050 | --- @param value object # Variable value 2051 | function vim.api.nvim_set_var(name, value) end 2052 | 2053 | -- Sets a v: variable, if it is not readonly. 2054 | --- @param name string # Variable name 2055 | --- @param value object # Variable value 2056 | function vim.api.nvim_set_vvar(name, value) end 2057 | 2058 | -- Calculates the number of display cells occupied by `text`. Control 2059 | -- characters including count as one cell. 2060 | --- @param text string # Some text 2061 | --- @return any # Number of cells 2062 | function vim.api.nvim_strwidth(text) end 2063 | 2064 | -- Subscribes to event broadcasts. 2065 | --- @param event string # Event type string 2066 | function vim.api.nvim_subscribe(event) end 2067 | 2068 | -- Removes a tab-scoped (t:) variable 2069 | --- @param tabpage tabpage # Tabpage handle, or 0 for current tabpage 2070 | --- @param name string # Variable name 2071 | function vim.api.nvim_tabpage_del_var(tabpage, name) end 2072 | 2073 | -- Gets the tabpage number 2074 | --- @param tabpage tabpage # Tabpage handle, or 0 for current tabpage 2075 | --- @return any # Tabpage number 2076 | function vim.api.nvim_tabpage_get_number(tabpage) end 2077 | 2078 | -- Gets a tab-scoped (t:) variable 2079 | --- @param tabpage tabpage # Tabpage handle, or 0 for current tabpage 2080 | --- @param name string # Variable name 2081 | --- @return any # Variable value 2082 | function vim.api.nvim_tabpage_get_var(tabpage, name) end 2083 | 2084 | -- Gets the current window in a tabpage 2085 | --- @param tabpage tabpage # Tabpage handle, or 0 for current tabpage 2086 | --- @return any # Window handle 2087 | function vim.api.nvim_tabpage_get_win(tabpage) end 2088 | 2089 | -- Checks if a tabpage is valid 2090 | --- @param tabpage tabpage # Tabpage handle, or 0 for current tabpage 2091 | --- @return any # true if the tabpage is valid, false otherwise 2092 | function vim.api.nvim_tabpage_is_valid(tabpage) end 2093 | 2094 | -- Gets the windows in a tabpage 2095 | --- @param tabpage tabpage # Tabpage handle, or 0 for current tabpage 2096 | --- @return any # List of windows in `tabpage` 2097 | function vim.api.nvim_tabpage_list_wins(tabpage) end 2098 | 2099 | -- Sets a tab-scoped (t:) variable 2100 | --- @param tabpage tabpage # Tabpage handle, or 0 for current tabpage 2101 | --- @param name string # Variable name 2102 | --- @param value object # Variable value 2103 | function vim.api.nvim_tabpage_set_var(tabpage, name, value) end 2104 | 2105 | -- Activates UI events on the channel. 2106 | -- 2107 | -- Entry point of all UI clients. Allows |--embed| to continue startup. 2108 | -- Implies that the client is ready to show the UI. Adds the client to the 2109 | -- list of UIs. |nvim_list_uis()| 2110 | -- 2111 | -- 2112 | -- Note: 2113 | -- If multiple UI clients are attached, the global screen dimensions 2114 | -- degrade to the smallest client. E.g. if client A requests 80x40 but 2115 | -- client B requests 200x100, the global screen has size 80x40. 2116 | --- @param width integer # Requested screen columns 2117 | --- @param height integer # Requested screen rows 2118 | --- @param options dictionary # |ui-option| map 2119 | function vim.api.nvim_ui_attach(width, height, options) end 2120 | 2121 | -- Deactivates UI events on the channel. 2122 | -- 2123 | -- Removes the client from the list of UIs. |nvim_list_uis()| 2124 | function vim.api.nvim_ui_detach() end 2125 | 2126 | -- Tells Nvim the geometry of the popupmenu, to align floating windows with 2127 | -- an external popup menu. 2128 | -- 2129 | -- Note that this method is not to be confused with 2130 | -- |nvim_ui_pum_set_height()|, which sets the number of visible items in the 2131 | -- popup menu, while this function sets the bounding box of the popup menu, 2132 | -- including visual elements such as borders and sliders. Floats need not use 2133 | -- the same font size, nor be anchored to exact grid corners, so one can set 2134 | -- floating-point numbers to the popup menu geometry. 2135 | --- @param width float # Popupmenu width. 2136 | --- @param height float # Popupmenu height. 2137 | --- @param row float # Popupmenu row. 2138 | --- @param col float # Popupmenu height. 2139 | function vim.api.nvim_ui_pum_set_bounds(width, height, row, col) end 2140 | 2141 | -- Tells Nvim the number of elements displaying in the popupmenu, to decide 2142 | -- and movement. 2143 | --- @param height integer # Popupmenu height, must be greater than zero. 2144 | function vim.api.nvim_ui_pum_set_height(height) end 2145 | 2146 | --- @param name string 2147 | --- @param value object 2148 | function vim.api.nvim_ui_set_option(name, value) end 2149 | 2150 | --- @param width integer 2151 | --- @param height integer 2152 | function vim.api.nvim_ui_try_resize(width, height) end 2153 | 2154 | -- Tell Nvim to resize a grid. Triggers a grid_resize event with the 2155 | -- requested grid size or the maximum size if it exceeds size limits. 2156 | -- 2157 | -- On invalid grid handle, fails with error. 2158 | --- @param grid integer # The handle of the grid to be changed. 2159 | --- @param width integer # The new requested width. 2160 | --- @param height integer # The new requested height. 2161 | function vim.api.nvim_ui_try_resize_grid(grid, width, height) end 2162 | 2163 | -- Unsubscribes to event broadcasts. 2164 | --- @param event string # Event type string 2165 | function vim.api.nvim_unsubscribe(event) end 2166 | 2167 | -- Calls a function with window as temporary current window. 2168 | --- @see |win_execute()| 2169 | --- @see |nvim_buf_call()| 2170 | --- @param window window # Window handle, or 0 for current window 2171 | --- @param fun luaref # Function to call inside the window (currently lua callable 2172 | -- only) 2173 | --- @return any # Return value of function. NB: will deepcopy lua values currently, use 2174 | -- upvalues to send lua references in and out. 2175 | function vim.api.nvim_win_call(window, fun) end 2176 | 2177 | -- Closes the window (like |:close| with a |window-ID|). 2178 | --- @param window window # Window handle, or 0 for current window 2179 | --- @param force boolean # Behave like `:close!` The last window of a buffer with 2180 | -- unwritten changes can be closed. The buffer will become 2181 | -- hidden, even if 'hidden' is not set. 2182 | function vim.api.nvim_win_close(window, force) end 2183 | 2184 | -- Removes a window-scoped (w:) variable 2185 | --- @param window window # Window handle, or 0 for current window 2186 | --- @param name string # Variable name 2187 | function vim.api.nvim_win_del_var(window, name) end 2188 | 2189 | -- Gets the current buffer in a window 2190 | --- @param window window # Window handle, or 0 for current window 2191 | --- @return any # Buffer handle 2192 | function vim.api.nvim_win_get_buf(window) end 2193 | 2194 | -- Gets window configuration. 2195 | -- 2196 | -- The returned value may be given to |nvim_open_win()|. 2197 | -- 2198 | -- `relative` is empty for normal windows. 2199 | --- @param window window # Window handle, or 0 for current window 2200 | --- @return any # Map defining the window configuration, see |nvim_open_win()| 2201 | function vim.api.nvim_win_get_config(window) end 2202 | 2203 | -- Gets the (1,0)-indexed cursor position in the window. |api-indexing| 2204 | --- @param window window # Window handle, or 0 for current window 2205 | --- @return any # (row, col) tuple 2206 | function vim.api.nvim_win_get_cursor(window) end 2207 | 2208 | -- Gets the window height 2209 | --- @param window window # Window handle, or 0 for current window 2210 | --- @return any # Height as a count of rows 2211 | function vim.api.nvim_win_get_height(window) end 2212 | 2213 | -- Gets the window number 2214 | --- @param window window # Window handle, or 0 for current window 2215 | --- @return any # Window number 2216 | function vim.api.nvim_win_get_number(window) end 2217 | 2218 | -- Gets a window option value 2219 | --- @param window window # Window handle, or 0 for current window 2220 | --- @param name string # Option name 2221 | --- @return any # Option value 2222 | function vim.api.nvim_win_get_option(window, name) end 2223 | 2224 | -- Gets the window position in display cells. First position is zero. 2225 | --- @param window window # Window handle, or 0 for current window 2226 | --- @return any # (row, col) tuple with the window position 2227 | function vim.api.nvim_win_get_position(window) end 2228 | 2229 | -- Gets the window tabpage 2230 | --- @param window window # Window handle, or 0 for current window 2231 | --- @return any # Tabpage that contains the window 2232 | function vim.api.nvim_win_get_tabpage(window) end 2233 | 2234 | -- Gets a window-scoped (w:) variable 2235 | --- @param window window # Window handle, or 0 for current window 2236 | --- @param name string # Variable name 2237 | --- @return any # Variable value 2238 | function vim.api.nvim_win_get_var(window, name) end 2239 | 2240 | -- Gets the window width 2241 | --- @param window window # Window handle, or 0 for current window 2242 | --- @return any # Width as a count of columns 2243 | function vim.api.nvim_win_get_width(window) end 2244 | 2245 | -- Closes the window and hide the buffer it contains (like |:hide| with a 2246 | -- |window-ID|). 2247 | -- 2248 | -- Like |:hide| the buffer becomes hidden unless another window is editing 2249 | -- it, or 'bufhidden' is `unload`, `delete` or `wipe` as opposed to |:close| 2250 | -- or |nvim_win_close()|, which will close the buffer. 2251 | --- @param window window # Window handle, or 0 for current window 2252 | function vim.api.nvim_win_hide(window) end 2253 | 2254 | -- Checks if a window is valid 2255 | --- @param window window # Window handle, or 0 for current window 2256 | --- @return any # true if the window is valid, false otherwise 2257 | function vim.api.nvim_win_is_valid(window) end 2258 | 2259 | -- Sets the current buffer in a window, without side effects 2260 | --- @param window window # Window handle, or 0 for current window 2261 | --- @param buffer buffer # Buffer handle 2262 | function vim.api.nvim_win_set_buf(window, buffer) end 2263 | 2264 | -- Configures window layout. Currently only for floating and external windows 2265 | -- (including changing a split window to those layouts). 2266 | -- 2267 | -- When reconfiguring a floating window, absent option keys will not be 2268 | -- changed. `row`/`col` and `relative` must be reconfigured together. 2269 | --- @see |nvim_open_win()| 2270 | --- @param window window # Window handle, or 0 for current window 2271 | --- @param config? dict # Map defining the window configuration, see |nvim_open_win()| 2272 | function vim.api.nvim_win_set_config(window, config) end 2273 | 2274 | -- Sets the (1,0)-indexed cursor position in the window. |api-indexing| This 2275 | -- scrolls the window even if it is not the current one. 2276 | --- @param window window # Window handle, or 0 for current window 2277 | --- @param pos number[] # (row, col) tuple representing the new position 2278 | function vim.api.nvim_win_set_cursor(window, pos) end 2279 | 2280 | -- Sets the window height. 2281 | --- @param window window # Window handle, or 0 for current window 2282 | --- @param height integer # Height as a count of rows 2283 | function vim.api.nvim_win_set_height(window, height) end 2284 | 2285 | -- Set highlight namespace for a window. This will use highlights defined in 2286 | -- this namespace, but fall back to global highlights (ns=0) when missing. 2287 | -- 2288 | -- This takes precedence over the 'winhighlight' option. 2289 | --- @param window window 2290 | --- @param ns_id integer # the namespace to use 2291 | function vim.api.nvim_win_set_hl_ns(window, ns_id) end 2292 | 2293 | -- Sets a window option value. Passing `nil` as value deletes the option 2294 | -- (only works if there's a global fallback) 2295 | --- @param window window # Window handle, or 0 for current window 2296 | --- @param name string # Option name 2297 | --- @param value object # Option value 2298 | function vim.api.nvim_win_set_option(window, name, value) end 2299 | 2300 | -- Sets a window-scoped (w:) variable 2301 | --- @param window window # Window handle, or 0 for current window 2302 | --- @param name string # Variable name 2303 | --- @param value object # Variable value 2304 | function vim.api.nvim_win_set_var(window, name, value) end 2305 | 2306 | -- Sets the window width. This will only succeed if the screen is split 2307 | -- vertically. 2308 | --- @param window window # Window handle, or 0 for current window 2309 | --- @param width integer # Width as a count of columns 2310 | function vim.api.nvim_win_set_width(window, width) end 2311 | 2312 | --------------------------------------------------------------------------------