npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@gkzhb/lua-types-nvim

v0.0.7

Published

TypeScript definitions for Neovim Lua APIs

Downloads

19

Readme

Lua Types for Neovim Lua APIs

GitHub workflow npm version GitHub stars GitHub issues GitHub license

@gkzhb/lua-types-nvim provides TypeScript definitions of Neovim(v0.7.2) Lua APIs for TypeScriptToLua projects.

Now this project provides types for

  • vim.api
  • vim.lsp
  • vim.treesitter
  • vim.diagnostic
  • vim.fn
  • vim.opt, vim.go, vim.bo, etc

Inspired by hrsh7th/deno-nvim-types: The Nvim API type definition for TypeScript and folke/lua-dev.nvim. And thanks for folke/lua-dev.nvim's data files.

Usage

  1. Add this npm package to your dev dependencies:
npm install -D @gkzhb/lua-types-nvim
  1. Add this package in your tsconfig.json of TypeScriptToLua:
{
  "compilerOptions": {
    ...
    "types": [
      ...
      "@gkzhb/lua-types-nvim"
    ],
    ...
  }
}

TODO

  • [ ] Replace TypeScript types with Lua types.
  • [ ] Manually add function parameter types for vim.fn which are not provided in any strctured data.
  • [ ] Generate types/index.d.ts by code

Development

TypeScript files in src/ are node.js code that are executed to generate ts definition files from Neovim mpack API metadata.

While .d.ts files in types/ are type definitions for Neovim Lua APIs in TypeScriptToLua.

yarn scripts:

  • Use yarn to install dependencies
  • yarn build to compile TypeScript in src
  • yarn dev to watch for ts file changes and compile to JS
  • yarn parse-nearley to build parser required to process vim.fn documentations
  • And yarn build-dts to run the compiled js file to generate Neovim API type definitions.
  • yarn --silent preview [module] to output JSON format content of mpack data, like
yarn --silent preview lua

will output JSON format from data/lua.mpack.

  • Use yarn in-one-go to install dependencies, compile TS and run JS to generate types in one command.

This project uses TypeScript factory to generate ASTs and print them to files.

Refer to docs.md for more about development.

APIs

The structure data about APIs are in data/ folder.

api.mpack, lsp.mpack, lua.mpack, diagnostic.mpack, treesitter.mpack and builtin-docs.json are from folke/lua-dev.nvim. Data in these mpack files are the same type NvimApiFunctions.

builtin-api.mpack is from Neovim command line

nvim --api-info

The data type is NvimCliApiFunctions.

builtin.txt is from Neovim documentation file in $VIMRUNTIME which contains vim.fn summary information in Section 1 Overview.

From this file and builtin-docs.json I get vim function name, parameter names, return type and not only brief but also detailed documentations.

References