{"id":25516207,"url":"https://github.com/gkzhb/lua-types-nvim","last_synced_at":"2025-04-10T21:10:46.318Z","repository":{"id":44458037,"uuid":"512436282","full_name":"gkzhb/lua-types-nvim","owner":"gkzhb","description":"TS types for Neovim Lua API with TSToLua","archived":false,"fork":false,"pushed_at":"2023-02-08T03:12:51.000Z","size":557,"stargazers_count":20,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-19T06:04:20.743Z","etag":null,"topics":["lua","neovim","typescript","typescripttolua"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gkzhb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-10T13:01:32.000Z","updated_at":"2025-01-06T01:00:44.000Z","dependencies_parsed_at":"2022-09-26T21:21:39.969Z","dependency_job_id":null,"html_url":"https://github.com/gkzhb/lua-types-nvim","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gkzhb%2Flua-types-nvim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gkzhb%2Flua-types-nvim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gkzhb%2Flua-types-nvim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gkzhb%2Flua-types-nvim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gkzhb","download_url":"https://codeload.github.com/gkzhb/lua-types-nvim/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248298316,"owners_count":21080320,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lua","neovim","typescript","typescripttolua"],"created_at":"2025-02-19T14:18:23.458Z","updated_at":"2025-04-10T21:10:46.301Z","avatar_url":"https://github.com/gkzhb.png","language":"TypeScript","readme":"# Lua Types for Neovim Lua APIs\n\n[![GitHub workflow](https://github.com/gkzhb/lua-types-nvim/actions/workflows/npm-publish.yml/badge.svg?branch=main)](https://github.com/gkzhb/lua-types-nvim/actions/workflows/npm-publish.yml)\n[![npm version](https://img.shields.io/npm/v/@gkzhb/lua-types-nvim)](https://www.npmjs.com/package/@gkzhb/lua-types-nvim)\n[![GitHub stars](https://img.shields.io/github/stars/gkzhb/lua-types-nvim)](https://github.com/gkzhb/lua-types-nvim/stargazers)\n[![GitHub issues](https://img.shields.io/github/issues/gkzhb/lua-types-nvim)](https://github.com/gkzhb/lua-types-nvim/issues)\n[![GitHub license](https://img.shields.io/github/license/gkzhb/lua-types-nvim)](https://github.com/gkzhb/lua-types-nvim/blob/main/LICENSE)\n\n[@gkzhb/lua-types-nvim](https://www.npmjs.com/package/@gkzhb/lua-types-nvim)\nprovides TypeScript definitions of Neovim(v0.7.2) Lua APIs for\n[TypeScriptToLua](https://typescripttolua.github.io/) projects.\n\nNow this project provides types for\n\n* `vim.api`\n* `vim.lsp`\n* `vim.treesitter`\n* `vim.diagnostic`\n* `vim.fn`\n* `vim.opt`, `vim.go`, `vim.bo`, etc\n\nInspired by [hrsh7th/deno-nvim-types: The Nvim API type definition for TypeScript](https://github.com/hrsh7th/deno-nvim-types)\nand [folke/lua-dev.nvim](https://github.com/folke/lua-dev.nvim).\nAnd thanks for [folke/lua-dev.nvim](https://github.com/folke/lua-dev.nvim)'s\n`data` files.\n\n## Usage\n\n1. Add this npm package to your dev dependencies:\n\n```bash\nnpm install -D @gkzhb/lua-types-nvim\n```\n\n2. Add this package in your `tsconfig.json` of TypeScriptToLua:\n\n```json\n{\n  \"compilerOptions\": {\n    ...\n    \"types\": [\n      ...\n      \"@gkzhb/lua-types-nvim\"\n    ],\n    ...\n  }\n}\n```\n\n## TODO\n\n* [ ] Replace TypeScript types with Lua types.\n* [ ] Manually add function parameter types for `vim.fn` which are not provided\nin any strctured data.\n* [ ] Generate `types/index.d.ts` by code\n\n## Development\n\nTypeScript files in `src/` are node.js code that are executed to generate ts definition\nfiles from Neovim mpack API metadata.\n\nWhile `.d.ts` files in `types/` are type definitions for Neovim Lua APIs in TypeScriptToLua.\n\n`yarn` scripts:\n\n* Use `yarn` to install dependencies\n* `yarn build` to compile TypeScript in `src`\n* `yarn dev` to watch for ts file changes and compile to JS\n* `yarn parse-nearley` to build parser required to process `vim.fn` documentations\n* And `yarn build-dts` to run the compiled js file to generate Neovim API\ntype definitions.\n  * `yarn build-api-dts` to process mpack files\n  * `yarn build-fn-dts` to generate definitions for `vim.fn` from\n[`builtin-docs.json`](./data/builtin-docs.json) and [`builtin.txt`](./data/builtin.txt)\n* `yarn --silent preview [module]` to output JSON format content of mpack\n  data, like\n\n```bash\nyarn --silent preview lua\n```\n\n  will output JSON format from `data/lua.mpack`.\n* Use `yarn in-one-go` to install dependencies, compile TS and run JS to\ngenerate types in one command.\n\nThis project uses TypeScript `factory` to generate ASTs and print them to files.\n\nRefer to [docs.md](./docs.md) for more about development.\n\n### APIs\n\nThe structure data about APIs are in `data/` folder.\n\n[`api.mpack`](./data/api.mpack), [`lsp.mpack`](./data/lsp.mpack),\n[`lua.mpack`](./data/lua.mpack), [`diagnostic.mpack`](./data/diagnostic.mpack),\n[`treesitter.mpack`](./data/treesitter.mpack) and\n[`builtin-docs.json`](./data/builtin-docs.json) are from\n[folke/lua-dev.nvim](https://github.com/folke/lua-dev.nvim).\nData in these mpack files are the same type `NvimApiFunctions`.\n\n[`builtin-api.mpack`](./data/builtin-api.mpack) is from Neovim command line\n\n```bash\nnvim --api-info\n```\n\nThe data type is `NvimCliApiFunctions`.\n\n[`builtin.txt`](./data/builtin.txt) is from Neovim documentation file in\n`$VIMRUNTIME` which contains `vim.fn` summary information in Section 1 Overview.\n\nFrom this file and [`builtin-docs.json`](./data/builtin-docs.json) I get vim\nfunction name, parameter names, return type and not only brief but also detailed\ndocumentations.\n\n### References\n\n* [factory.createSourceFile doesn't accept JSDoc node (typings issue) · Issue #44151 · microsoft/TypeScript](https://github.com/microsoft/TypeScript/issues/44151)\n* [Add capability of transforming and emitting JSDoc comments · Issue #17146 · microsoft/TypeScript](https://github.com/microsoft/TypeScript/issues/17146)\n* Thank [TypeScript AST Viewer](https://ts-ast-viewer.com/#) so much for the\nuseful tool that helps to develop with Typescript AST.\n* Also thank [Nearley Parser Playground](https://omrelli.ug/nearley-playground/)\nfor the great DX with [nearley.js - JS Parsing Toolkit](https://nearley.js.org/).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgkzhb%2Flua-types-nvim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgkzhb%2Flua-types-nvim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgkzhb%2Flua-types-nvim/lists"}