feat!: track parser revision in Lua

Problem: Tracking parser revision in lockfile and allowing override
through the parsers module complicates the code. In addition, only
revision changes are handled robustly, not changes to other installation
info.

Solution: Track parser revision in the parsers module directly. Reload
parser table on every install or update call. Support modifying parser
table in a `User TSUpdate` autocommand.
This commit is contained in:
Christian Clason 2024-04-14 16:25:28 +02:00
parent 054080bf59
commit c17de56890
21 changed files with 1007 additions and 995 deletions

View file

@ -0,0 +1,47 @@
---@meta
error('Cannot require a meta file')
---@class InstallInfo
---
---URL of parser repo (Github/Gitlab)
---@field url string
---
---Commit hash of parser to download (compatible with queries)
---@field revision string
---
---Files to include when compiling (`src/parser.c` and optionally `src/scanner.c')
---@field files string[]
---
---Branch of parser repo to download (if not default branch)
---@field branch? string
---
---Location of `grammar.js` in repo (if not at root, e.g., in a monorepo)
---@field location? string
---
---Repo does not contain a `parser.c`; must be generated from grammar first
---@field generate? boolean
---
---Parser needs to be generated from `grammar.json` (generating from `grammar.js` requires npm)
---@field generate_from_json? boolean
---
---Parser repo is a local directory; overrides `url`, `revision`, and `branch`
---@field path? string
---@class ParserInfo
---
---Information necessary to build and install the parser (empty for query-only language)
---@field install_info? InstallInfo
---
---List of Github users maintaining the queries for Neovim
---@field maintainers? string[]
---
---List of other languages to install (e.g., if queries inherit from them)
---@field requires? string[]
---
---Language support tier, maps to "core", "stable", "community", "unmaintained"
---@field tier integer
---
---Explanatory footnote text to add in SUPPORTED_LANGUAGES.md
---@field readme_note? string
---@alias nvim-ts.parsers table<string,ParserInfo>