fix: install dependencies

This commit is contained in:
Christian Clason 2023-05-31 09:19:16 +02:00
parent 9c0a99819c
commit cd2c826972
8 changed files with 207 additions and 131 deletions

View file

@ -58,13 +58,14 @@ Language | Tier | Queries | CLI | NPM | Maintainer
[dtd](https://github.com/tree-sitter-grammars/tree-sitter-xml) | stable | `HF JL` | | | @ObserverOfTime [dtd](https://github.com/tree-sitter-grammars/tree-sitter-xml) | stable | `HF JL` | | | @ObserverOfTime
[earthfile](https://github.com/glehmann/tree-sitter-earthfile) | community | `H  J ` | | | @glehmann [earthfile](https://github.com/glehmann/tree-sitter-earthfile) | community | `H  J ` | | | @glehmann
[ebnf](https://github.com/RubixDev/ebnf) | unstable | `H    ` | | | @RubixDev [ebnf](https://github.com/RubixDev/ebnf) | unstable | `H    ` | | | @RubixDev
ecma (queries only)[^ecma] | | `HFIJL` | | | @steelsojka
[eds](https://github.com/uyha/tree-sitter-eds) | community | `HF   ` | | | @uyha [eds](https://github.com/uyha/tree-sitter-eds) | community | `HF   ` | | | @uyha
[eex](https://github.com/connorlay/tree-sitter-eex) | | `H  J ` | | | @connorlay [eex](https://github.com/connorlay/tree-sitter-eex) | | `H  J ` | | | @connorlay
[elixir](https://github.com/elixir-lang/tree-sitter-elixir) | | `HFIJL` | | | @connorlay [elixir](https://github.com/elixir-lang/tree-sitter-elixir) | | `HFIJL` | | | @connorlay
[elm](https://github.com/elm-tooling/tree-sitter-elm) | | `H  J ` | | | @zweimach [elm](https://github.com/elm-tooling/tree-sitter-elm) | | `H  J ` | | | @zweimach
[elsa](https://github.com/glapa-grossklag/tree-sitter-elsa) | | `HFIJL` | | | @glapa-grossklag, @amaanq [elsa](https://github.com/glapa-grossklag/tree-sitter-elsa) | | `HFIJL` | | | @glapa-grossklag, @amaanq
[elvish](https://github.com/elves/tree-sitter-elvish) | | `H  J ` | | | @elves [elvish](https://github.com/elves/tree-sitter-elvish) | | `H  J ` | | | @elves
[embedded_template](https://github.com/tree-sitter/tree-sitter-embedded-template) | | `H  J ` | | | [embedded_template](https://github.com/tree-sitter/tree-sitter-embedded-template) | unstable | `H  J ` | | |
[erlang](https://github.com/WhatsApp/tree-sitter-erlang) | | `HF   ` | | | @filmor [erlang](https://github.com/WhatsApp/tree-sitter-erlang) | | `HF   ` | | | @filmor
[facility](https://github.com/FacilityApi/tree-sitter-facility) | community | `HFIJ ` | | | @bryankenote [facility](https://github.com/FacilityApi/tree-sitter-facility) | community | `HFIJ ` | | | @bryankenote
[faust](https://github.com/khiner/tree-sitter-faust) | community | `H  J ` | | | @khiner [faust](https://github.com/khiner/tree-sitter-faust) | community | `H  J ` | | | @khiner
@ -100,9 +101,9 @@ Language | Tier | Queries | CLI | NPM | Maintainer
[graphql](https://github.com/bkegley/tree-sitter-graphql) | | `H IJ ` | | | @bkegley [graphql](https://github.com/bkegley/tree-sitter-graphql) | | `H IJ ` | | | @bkegley
[groovy](https://github.com/murtaza64/tree-sitter-groovy) | community | `HFIJL` | | | @murtaza64 [groovy](https://github.com/murtaza64/tree-sitter-groovy) | community | `HFIJL` | | | @murtaza64
[gstlaunch](https://github.com/theHamsta/tree-sitter-gstlaunch) | stable | `H    ` | | | @theHamsta [gstlaunch](https://github.com/theHamsta/tree-sitter-gstlaunch) | stable | `H    ` | | | @theHamsta
[hack](https://github.com/slackhq/tree-sitter-hack) | | `H    ` | | | [hack](https://github.com/slackhq/tree-sitter-hack) | unstable | `H    ` | | |
[hare](https://github.com/amaanq/tree-sitter-hare) | | `HFIJL` | | | @amaanq [hare](https://github.com/amaanq/tree-sitter-hare) | | `HFIJL` | | | @amaanq
[haskell](https://github.com/tree-sitter/tree-sitter-haskell) | | `HF J ` | | | @mrcjkb [haskell](https://github.com/tree-sitter/tree-sitter-haskell) | community | `HF J ` | | | @mrcjkb
[haskell_persistent](https://github.com/MercuryTechnologies/tree-sitter-haskell-persistent) | | `HF   ` | | | @lykahb [haskell_persistent](https://github.com/MercuryTechnologies/tree-sitter-haskell-persistent) | | `HF   ` | | | @lykahb
[hcl](https://github.com/MichaHoffmann/tree-sitter-hcl) | | `HFIJ ` | | | @MichaHoffmann [hcl](https://github.com/MichaHoffmann/tree-sitter-hcl) | | `HFIJ ` | | | @MichaHoffmann
[heex](https://github.com/connorlay/tree-sitter-heex) | | `HFIJL` | | | @connorlay [heex](https://github.com/connorlay/tree-sitter-heex) | | `HFIJL` | | | @connorlay
@ -113,6 +114,7 @@ Language | Tier | Queries | CLI | NPM | Maintainer
[hocon](https://github.com/antosha417/tree-sitter-hocon) | | `HF J ` | | ✓ | @antosha417 [hocon](https://github.com/antosha417/tree-sitter-hocon) | | `HF J ` | | ✓ | @antosha417
[hoon](https://github.com/urbit-pilled/tree-sitter-hoon) | unstable | `HF  L` | | | @urbit-pilled [hoon](https://github.com/urbit-pilled/tree-sitter-hoon) | unstable | `HF  L` | | | @urbit-pilled
[html](https://github.com/tree-sitter/tree-sitter-html) | | `HFIJL` | | | @TravonteD [html](https://github.com/tree-sitter/tree-sitter-html) | | `HFIJL` | | | @TravonteD
html_tags (queries only)[^html_tags] | | `H IJ ` | | | @TravonteD
[htmldjango](https://github.com/interdependence/tree-sitter-htmldjango) | unstable | `HFIJ ` | | | @ObserverOfTime [htmldjango](https://github.com/interdependence/tree-sitter-htmldjango) | unstable | `HFIJ ` | | | @ObserverOfTime
[http](https://github.com/rest-nvim/tree-sitter-http) | | `H  J ` | | | @amaanq, @NTBBloodbath [http](https://github.com/rest-nvim/tree-sitter-http) | | `H  J ` | | | @amaanq, @NTBBloodbath
[hurl](https://github.com/pfeiferj/tree-sitter-hurl) | community | `HFIJ ` | | | @pfeiferj [hurl](https://github.com/pfeiferj/tree-sitter-hurl) | community | `HFIJ ` | | | @pfeiferj
@ -128,8 +130,9 @@ Language | Tier | Queries | CLI | NPM | Maintainer
[jsdoc](https://github.com/tree-sitter/tree-sitter-jsdoc) | | `H    ` | | | @steelsojka [jsdoc](https://github.com/tree-sitter/tree-sitter-jsdoc) | | `H    ` | | | @steelsojka
[json](https://github.com/tree-sitter/tree-sitter-json) | | `HFI L` | | | @steelsojka [json](https://github.com/tree-sitter/tree-sitter-json) | | `HFI L` | | | @steelsojka
[json5](https://github.com/Joakker/tree-sitter-json5) | | `H  J ` | | | @Joakker [json5](https://github.com/Joakker/tree-sitter-json5) | | `H  J ` | | | @Joakker
[jsonc](https://gitlab.com/WhyNotHugo/tree-sitter-jsonc.git)[^jsonc] | | `HFIJL` | | ✓ | @WhyNotHugo [jsonc](https://gitlab.com/WhyNotHugo/tree-sitter-jsonc.git) | | `HFIJL` | | ✓ | @WhyNotHugo
[jsonnet](https://github.com/sourcegraph/tree-sitter-jsonnet) | | `HF  L` | | | @nawordar [jsonnet](https://github.com/sourcegraph/tree-sitter-jsonnet) | | `HF  L` | | | @nawordar
jsx (queries only)[^jsx] | | `HFIJ ` | | | @steelsojka
[julia](https://github.com/tree-sitter/tree-sitter-julia) | community | `HFIJL` | | | @theHamsta [julia](https://github.com/tree-sitter/tree-sitter-julia) | community | `HFIJL` | | | @theHamsta
[just](https://github.com/IndianBoy42/tree-sitter-just) | community | `HFIJL` | | | @Hubro [just](https://github.com/IndianBoy42/tree-sitter-just) | community | `HFIJL` | | | @Hubro
[kconfig](https://github.com/amaanq/tree-sitter-kconfig) | stable | `HFIJL` | | | @amaanq [kconfig](https://github.com/amaanq/tree-sitter-kconfig) | stable | `HFIJL` | | | @amaanq
@ -160,7 +163,7 @@ Language | Tier | Queries | CLI | NPM | Maintainer
[mlir](https://github.com/artagnon/tree-sitter-mlir) | unstable | `H   L` | ✓ | | @artagnon [mlir](https://github.com/artagnon/tree-sitter-mlir) | unstable | `H   L` | ✓ | | @artagnon
[muttrc](https://github.com/neomutt/tree-sitter-muttrc) | community | `H  J ` | | | @Freed-Wu [muttrc](https://github.com/neomutt/tree-sitter-muttrc) | community | `H  J ` | | | @Freed-Wu
[nasm](https://github.com/naclsn/tree-sitter-nasm) | stable | `H  J ` | | | @ObserverOfTime [nasm](https://github.com/naclsn/tree-sitter-nasm) | stable | `H  J ` | | | @ObserverOfTime
[nickel](https://github.com/nickel-lang/tree-sitter-nickel) | | `H I  ` | | | [nickel](https://github.com/nickel-lang/tree-sitter-nickel) | unstable | `H I  ` | | |
[nim](https://github.com/alaviss/tree-sitter-nim) | community | `HF JL` | | | @aMOPel [nim](https://github.com/alaviss/tree-sitter-nim) | community | `HF JL` | | | @aMOPel
[nim_format_string](https://github.com/aMOPel/tree-sitter-nim-format-string) | community | `H  J ` | | | @aMOPel [nim_format_string](https://github.com/aMOPel/tree-sitter-nim-format-string) | community | `H  J ` | | | @aMOPel
[ninja](https://github.com/alemuller/tree-sitter-ninja) | | `HFI  ` | | | @alemuller [ninja](https://github.com/alemuller/tree-sitter-ninja) | | `HFI  ` | | | @alemuller
@ -173,7 +176,7 @@ Language | Tier | Queries | CLI | NPM | Maintainer
[ocaml_interface](https://github.com/tree-sitter/tree-sitter-ocaml) | | `HFIJL` | | | @undu [ocaml_interface](https://github.com/tree-sitter/tree-sitter-ocaml) | | `HFIJL` | | | @undu
[ocamllex](https://github.com/atom-ocaml/tree-sitter-ocamllex) | | `H  J ` | ✓ | | @undu [ocamllex](https://github.com/atom-ocaml/tree-sitter-ocamllex) | | `H  J ` | ✓ | | @undu
[odin](https://github.com/amaanq/tree-sitter-odin) | | `HFIJL` | | | @amaanq [odin](https://github.com/amaanq/tree-sitter-odin) | | `HFIJL` | | | @amaanq
[org](https://github.com/milisims/tree-sitter-org) | | `     ` | | | [org](https://github.com/milisims/tree-sitter-org) | unstable | `     ` | | |
[pascal](https://github.com/Isopod/tree-sitter-pascal.git) | | `HFIJL` | | | @Isopod [pascal](https://github.com/Isopod/tree-sitter-pascal.git) | | `HFIJL` | | | @Isopod
[passwd](https://github.com/ath3/tree-sitter-passwd) | | `H    ` | | | @amaanq [passwd](https://github.com/ath3/tree-sitter-passwd) | | `H    ` | | | @amaanq
[pem](https://github.com/ObserverOfTime/tree-sitter-pem) | stable | `HF J ` | | | @ObserverOfTime [pem](https://github.com/ObserverOfTime/tree-sitter-pem) | stable | `HF J ` | | | @ObserverOfTime
@ -221,7 +224,7 @@ Language | Tier | Queries | CLI | NPM | Maintainer
[scala](https://github.com/tree-sitter/tree-sitter-scala) | | `HF JL` | | | @stevanmilic [scala](https://github.com/tree-sitter/tree-sitter-scala) | | `HF JL` | | | @stevanmilic
[scfg](https://git.sr.ht/~rockorager/tree-sitter-scfg) | community | `H  J ` | ✓ | | @WhyNotHugo [scfg](https://git.sr.ht/~rockorager/tree-sitter-scfg) | community | `H  J ` | ✓ | | @WhyNotHugo
[scheme](https://github.com/6cdh/tree-sitter-scheme) | unstable | `HF J ` | | | [scheme](https://github.com/6cdh/tree-sitter-scheme) | unstable | `HF J ` | | |
[scss](https://github.com/serenadeai/tree-sitter-scss) | | `HFI  ` | | | @elianiva [scss](https://github.com/serenadeai/tree-sitter-scss) | community | `HFI  ` | | | @elianiva
[slang](https://github.com/theHamsta/tree-sitter-slang)[^slang] | unstable | `HFIJL` | | ✓ | @theHamsta [slang](https://github.com/theHamsta/tree-sitter-slang)[^slang] | unstable | `HFIJL` | | ✓ | @theHamsta
[slint](https://github.com/slint-ui/tree-sitter-slint) | community | `HFIJL` | | | @hunger [slint](https://github.com/slint-ui/tree-sitter-slint) | community | `HFIJL` | | | @hunger
[smali](https://github.com/tree-sitter-grammars/tree-sitter-smali) | community | `HFIJL` | | | @amaanq [smali](https://github.com/tree-sitter-grammars/tree-sitter-smali) | community | `HFIJL` | | | @amaanq
@ -249,7 +252,7 @@ Language | Tier | Queries | CLI | NPM | Maintainer
[tcl](https://github.com/tree-sitter-grammars/tree-sitter-tcl) | stable | `HFI  ` | | | @lewis6991 [tcl](https://github.com/tree-sitter-grammars/tree-sitter-tcl) | stable | `HFI  ` | | | @lewis6991
[teal](https://github.com/euclidianAce/tree-sitter-teal) | | `HFIJL` | ✓ | | @euclidianAce [teal](https://github.com/euclidianAce/tree-sitter-teal) | | `HFIJL` | ✓ | | @euclidianAce
[templ](https://github.com/vrischmann/tree-sitter-templ) | community | `H  J ` | | | @vrischmann [templ](https://github.com/vrischmann/tree-sitter-templ) | community | `H  J ` | | | @vrischmann
[terraform](https://github.com/MichaHoffmann/tree-sitter-hcl) | | `HFIJ ` | | | @MichaHoffmann [terraform](https://github.com/MichaHoffmann/tree-sitter-hcl) | community | `HFIJ ` | | | @MichaHoffmann
[textproto](https://github.com/PorterAtGoogle/tree-sitter-textproto) | community | `HFI  ` | | | @Porter [textproto](https://github.com/PorterAtGoogle/tree-sitter-textproto) | community | `HFI  ` | | | @Porter
[thrift](https://github.com/duskmoon314/tree-sitter-thrift) | | `HFIJL` | | | @amaanq, @duskmoon314 [thrift](https://github.com/duskmoon314/tree-sitter-thrift) | | `HFIJL` | | | @amaanq, @duskmoon314
[tiger](https://github.com/ambroisie/tree-sitter-tiger) | | `HFIJL` | | | @ambroisie [tiger](https://github.com/ambroisie/tree-sitter-tiger) | | `HFIJL` | | | @ambroisie
@ -288,11 +291,13 @@ Language | Tier | Queries | CLI | NPM | Maintainer
[yuck](https://github.com/Philipp-M/tree-sitter-yuck) | | `HFIJL` | | | @Philipp-M, @amaanq [yuck](https://github.com/Philipp-M/tree-sitter-yuck) | | `HFIJL` | | | @Philipp-M, @amaanq
[zathurarc](https://github.com/Freed-Wu/tree-sitter-zathurarc) | community | `H  J ` | | | @Freed-Wu [zathurarc](https://github.com/Freed-Wu/tree-sitter-zathurarc) | community | `H  J ` | | | @Freed-Wu
[zig](https://github.com/maxxnino/tree-sitter-zig) | | `HFIJL` | | | @maxxnino [zig](https://github.com/maxxnino/tree-sitter-zig) | | `HFIJL` | | | @maxxnino
[^ecma]: queries required by javascript, typescript, tsx, qmljs
[^gdscript]: Godot [^gdscript]: Godot
[^git_config]: git_config [^git_config]: git_config
[^glimmer]: Glimmer and Ember [^glimmer]: Glimmer and Ember
[^godot_resource]: Godot Resources [^godot_resource]: Godot Resources
[^jsonc]: JSON with comments [^html_tags]: queries required by html, astro, vue, svelte
[^jsx]: queries required by javascript, tsx
[^luap]: Lua patterns [^luap]: Lua patterns
[^markdown]: basic highlighting [^markdown]: basic highlighting
[^markdown_inline]: needed for full highlighting [^markdown_inline]: needed for full highlighting

View file

@ -5,14 +5,9 @@ This document lists the planned and finished changes in this rewrite towards [Nv
## TODO ## TODO
- [ ] **`query_predicates.lua`:** upstream/remove - [ ] **`query_predicates.lua`:** upstream/remove
- [ ] **`parsers.lua`:** add dependencies (and "query-only" langs like ecma, jsx, html_tags, ...)
- [ ] **`parsers.lua`:** assign tiers - [ ] **`parsers.lua`:** assign tiers
- [ ] **`parsers.lua`:** modularize? - [ ] **`parsers.lua`:** modularize?
- [ ] **`install.lua`:** simplify compilation: - [ ] **`install.lua`:** drop norg (and makefile); document c++11 requirement
- hardcode one compiler + args per platform
- provide `install.compile_command` for overriding (function that takes files, ...?)
- allow using repo makefile (norg!)?
- ...or switch to makefile completely?
- [ ] **`locals.lua`:** move to `nvim-treesitter-refactor`? - [ ] **`locals.lua`:** move to `nvim-treesitter-refactor`?
- [ ] **update-lockfile:** allow specifying version in addition to commit hash (for Tier 1) - [ ] **update-lockfile:** allow specifying version in addition to commit hash (for Tier 1)
- [ ] **update-lockfile:** one commit per parser/tier? - [ ] **update-lockfile:** one commit per parser/tier?

View file

@ -74,12 +74,11 @@ end
---@return string[] ---@return string[]
function M.installed_parsers() function M.installed_parsers()
local install_dir = M.get_install_dir('parser') local install_dir = M.get_install_dir('queries')
local installed = {} --- @type string[] local installed = {} --- @type string[]
for f in vim.fs.dir(install_dir) do for f in vim.fs.dir(install_dir) do
local lang = assert(f:match('(.*)%..*')) installed[#installed + 1] = f
installed[#installed + 1] = lang
end end
return installed return installed
@ -139,6 +138,14 @@ function M.norm_languages(languages, skip)
end, languages) --[[@as string[] ]] end, languages) --[[@as string[] ]]
end end
if not (skip and skip.dependencies) then
for _, lang in pairs(languages) do
if parsers.configs[lang].requires then
vim.list_extend(languages, parsers.configs[lang].requires)
end
end
end
return languages return languages
end end

View file

@ -1,4 +1,5 @@
local install = require('nvim-treesitter.install') local install = require('nvim-treesitter.install')
local parsers = require('nvim-treesitter.parsers')
local config = require('nvim-treesitter.config') local config = require('nvim-treesitter.config')
local util = require('nvim-treesitter.util') local util = require('nvim-treesitter.util')
local tsq = vim.treesitter.query local tsq = vim.treesitter.query
@ -123,14 +124,25 @@ function M.check()
-- Installation dependency checks -- Installation dependency checks
install_health() install_health()
-- Parser installation checks -- Parser installation checks
local languages = config.installed_parsers()
local parser_installation = { 'Parser/Features' .. string.rep(' ', 9) .. 'H L F I J' } local parser_installation = { 'Parser/Features' .. string.rep(' ', 9) .. 'H L F I J' }
for _, parser_name in pairs(config.installed_parsers()) do for _, lang in pairs(languages) do
local out = ' - ' .. parser_name .. string.rep(' ', 20 - #parser_name) local parser = parsers.configs[lang]
for _, query_group in pairs(M.bundled_queries) do local out = ' - ' .. lang .. string.rep(' ', 20 - #lang)
local status, err = query_status(parser_name, query_group) if parser.install_info then
out = out .. status .. ' ' for _, query_group in pairs(M.bundled_queries) do
if err then local status, err = query_status(lang, query_group)
table.insert(error_collection, { parser_name, query_group, err }) out = out .. status .. ' '
if err then
table.insert(error_collection, { lang, query_group, err })
end
end
end
if parser.requires then
for _, p in pairs(parser.requires) do
if not vim.list_contains(languages, p) then
table.insert(error_collection, { lang, 'queries', 'dependency ' .. p .. ' missing' })
end
end end
end end
table.insert(parser_installation, vim.fn.trim(out, ' ', 2)) table.insert(parser_installation, vim.fn.trim(out, ' ', 2))

View file

@ -449,74 +449,76 @@ local function install_lang(lang, cache_dir, install_dir, force, generate_from_g
end end
end end
local cc = M.select_executable(M.compilers) local logger = log.new('install/' .. lang)
if not cc then local err
cc_err()
return
end
local repo = get_parser_install_info(lang) local repo = get_parser_install_info(lang)
if repo then
local project_name = 'tree-sitter-' .. lang local cc = M.select_executable(M.compilers)
if not cc then
local logger = log.new('install/' .. lang) cc_err()
return
generate_from_grammar = repo.requires_generate_from_grammar or generate_from_grammar
if generate_from_grammar and vim.fn.executable('tree-sitter') ~= 1 then
logger:error('tree-sitter CLI not found: `tree-sitter` is not executable')
end
if generate_from_grammar and vim.fn.executable('node') ~= 1 then
logger:error('Node JS not found: `node` is not executable')
end
local revision = repo.revision or get_target_revision(lang)
local maybe_local_path = fs.normalize(repo.url)
local from_local_path = vim.fn.isdirectory(maybe_local_path) == 1
if from_local_path then
repo.url = maybe_local_path
end
if not from_local_path then
util.delete(fs.joinpath(cache_dir, project_name))
local project_dir = fs.joinpath(cache_dir, project_name)
revision = revision or repo.branch or 'master'
if can_download_tar(repo) then
do_download_tar(logger, repo, project_name, cache_dir, revision, project_dir)
else
do_download_git(logger, repo, project_name, cache_dir, revision, project_dir)
end end
end
local compile_location = get_compile_location(repo, cache_dir, project_name, from_local_path) local project_name = 'tree-sitter-' .. lang
if generate_from_grammar then generate_from_grammar = repo.requires_generate_from_grammar or generate_from_grammar
do_generate_from_grammar(logger, repo, compile_location)
end
logger:info('Compiling parser') if generate_from_grammar and vim.fn.executable('tree-sitter') ~= 1 then
local r = do_compile(repo, cc, compile_location) logger:error('tree-sitter CLI not found: `tree-sitter` is not executable')
if r.exit_code > 0 then end
logger:error('Error during compilation: ' .. vim.inspect(r.stderr))
end
local parser_lib_name = fs.joinpath(install_dir, lang) .. '.so' if generate_from_grammar and vim.fn.executable('node') ~= 1 then
logger:error('Node JS not found: `node` is not executable')
end
local err = uv_copyfile(fs.joinpath(compile_location, 'parser.so'), parser_lib_name) local revision = repo.revision or get_target_revision(lang)
a.main()
if err then
logger:error(err)
end
local revfile = fs.joinpath(config.get_install_dir('parser-info') or '', lang .. '.revision') local maybe_local_path = fs.normalize(repo.url)
util.write_file(revfile, revision or '') local from_local_path = vim.fn.isdirectory(maybe_local_path) == 1
if from_local_path then
repo.url = maybe_local_path
end
if not from_local_path then if not from_local_path then
util.delete(fs.joinpath(cache_dir, project_name)) util.delete(fs.joinpath(cache_dir, project_name))
local project_dir = fs.joinpath(cache_dir, project_name)
revision = revision or repo.branch or 'master'
if can_download_tar(repo) then
do_download_tar(logger, repo, project_name, cache_dir, revision, project_dir)
else
do_download_git(logger, repo, project_name, cache_dir, revision, project_dir)
end
end
local compile_location = get_compile_location(repo, cache_dir, project_name, from_local_path)
if generate_from_grammar then
do_generate_from_grammar(logger, repo, compile_location)
end
logger:info('Compiling parser')
local r = do_compile(repo, cc, compile_location)
if r.exit_code > 0 then
logger:error('Error during compilation: ' .. vim.inspect(r.stderr))
end
local parser_lib_name = fs.joinpath(install_dir, lang) .. '.so'
err = uv_copyfile(fs.joinpath(compile_location, 'parser.so'), parser_lib_name)
a.main()
if err then
logger:error(err)
end
local revfile = fs.joinpath(config.get_install_dir('parser-info') or '', lang .. '.revision')
util.write_file(revfile, revision or '')
if not from_local_path then
util.delete(fs.joinpath(cache_dir, project_name))
end
end end
local queries = fs.joinpath(config.get_install_dir('queries'), lang) local queries = fs.joinpath(config.get_install_dir('queries'), lang)
@ -527,7 +529,7 @@ local function install_lang(lang, cache_dir, install_dir, force, generate_from_g
if err then if err then
logger:error(err) logger:error(err)
end end
logger:info('Parser installed') logger:info('Language installed')
end end
--- Throttles a function using the first argument as an ID --- Throttles a function using the first argument as an ID
@ -617,7 +619,7 @@ local function install(languages, options, _callback)
a.join(max_jobs, nil, tasks) a.join(max_jobs, nil, tasks)
if #tasks > 1 then if #tasks > 1 then
a.main() a.main()
log.info('Installed %d/%d parsers', done, #tasks) log.info('Installed %d/%d languages', done, #tasks)
end end
end end
@ -650,34 +652,35 @@ end, 2)
local function uninstall_lang(lang, parser, queries) local function uninstall_lang(lang, parser, queries)
local logger = log.new('uninstall/' .. lang) local logger = log.new('uninstall/' .. lang)
logger:debug('Uninstalling ' .. lang) logger:debug('Uninstalling ' .. lang)
if vim.fn.filereadable(parser) ~= 1 then
return if vim.fn.filereadable(parser) == 1 then
logger:debug('Unlinking ' .. parser)
local perr = uv_unlink(parser)
a.main()
if perr then
log.error(perr)
end
end end
logger:debug('Unlinking ' .. parser) if vim.fn.isdirectory(queries) == 1 then
local perr = uv_unlink(parser) logger:debug('Unlinking ' .. queries)
a.main() local qerr = uv_unlink(queries)
a.main()
if perr then if qerr then
log.error(perr) logger:error(qerr)
end
end end
logger:debug('Unlinking ' .. queries) logger:info('Language uninstalled')
local qerr = uv_unlink(queries)
a.main()
if qerr then
logger:error(qerr)
end
logger:info('Parser uninstalled')
end end
--- @param languages string[]|string --- @param languages string[]|string
--- @param _options? UpdateOptions --- @param _options? UpdateOptions
--- @param _callback fun() --- @param _callback fun()
M.uninstall = a.sync(function(languages, _options, _callback) M.uninstall = a.sync(function(languages, _options, _callback)
languages = config.norm_languages(languages or 'all', { missing = true }) languages = config.norm_languages(languages or 'all', { missing = true, dependencies = true })
local parser_dir = config.get_install_dir('parser') local parser_dir = config.get_install_dir('parser')
local query_dir = config.get_install_dir('queries') local query_dir = config.get_install_dir('queries')
@ -701,7 +704,7 @@ M.uninstall = a.sync(function(languages, _options, _callback)
a.join(max_jobs, nil, tasks) a.join(max_jobs, nil, tasks)
if #tasks > 1 then if #tasks > 1 then
a.main() a.main()
log.info('Uninstalled %d/%d parsers', done, #tasks) log.info('Uninstalled %d/%d languages', done, #tasks)
end end
end, 2) end, 2)

View file

@ -12,6 +12,7 @@
---@field install_info InstallInfo ---@field install_info InstallInfo
---@field filetype string[] ---@field filetype string[]
---@field maintainers string[] ---@field maintainers string[]
---@field requires string[]
---@field tier integer|nil ---@field tier integer|nil
---@field readme_note string|nil ---@field readme_note string|nil
@ -44,6 +45,7 @@ M.configs = {
generate_requires_npm = true, generate_requires_npm = true,
}, },
maintainers = { '@dlvandenberg' }, maintainers = { '@dlvandenberg' },
requires = { 'html', 'html_tags' },
tier = 4, tier = 4,
}, },
@ -63,6 +65,7 @@ M.configs = {
files = { 'src/parser.c', 'src/scanner.c' }, files = { 'src/parser.c', 'src/scanner.c' },
}, },
maintainers = { '@ObserverOfTime' }, maintainers = { '@ObserverOfTime' },
requires = { 'cpp' },
}, },
asm = { asm = {
@ -80,6 +83,7 @@ M.configs = {
files = { 'src/parser.c', 'src/scanner.c' }, files = { 'src/parser.c', 'src/scanner.c' },
}, },
maintainers = { '@virchau13' }, maintainers = { '@virchau13' },
requires = { 'html', 'html_tags' },
}, },
authzed = { authzed = {
@ -309,6 +313,7 @@ M.configs = {
generate_requires_npm = true, generate_requires_npm = true,
}, },
maintainers = { '@theHamsta' }, maintainers = { '@theHamsta' },
requires = { 'c' },
}, },
css = { css = {
@ -326,6 +331,7 @@ M.configs = {
location = 'csv', location = 'csv',
}, },
maintainers = { '@amaanq' }, maintainers = { '@amaanq' },
requires = { 'tsv' },
tier = 2, tier = 2,
}, },
@ -336,6 +342,7 @@ M.configs = {
generate_requires_npm = true, generate_requires_npm = true,
}, },
maintainers = { '@theHamsta' }, maintainers = { '@theHamsta' },
requires = { 'cpp' },
}, },
cue = { cue = {
@ -476,6 +483,12 @@ M.configs = {
tier = 4, tier = 4,
}, },
ecma = {
maintainers = { '@steelsojka' },
readme_note = 'queries required by javascript, typescript, tsx, qmljs',
tier = 3,
},
editorconfig = { editorconfig = {
install_info = { install_info = {
url = 'https://github.com/ValdezFOmar/tree-sitter-editorconfig', url = 'https://github.com/ValdezFOmar/tree-sitter-editorconfig',
@ -539,6 +552,7 @@ M.configs = {
url = 'https://github.com/tree-sitter/tree-sitter-embedded-template', url = 'https://github.com/tree-sitter/tree-sitter-embedded-template',
files = { 'src/parser.c' }, files = { 'src/parser.c' },
}, },
tier = 4,
}, },
enforce = { enforce = {
@ -796,6 +810,7 @@ M.configs = {
generate_requires_npm = true, generate_requires_npm = true,
}, },
maintainers = { '@theHamsta' }, maintainers = { '@theHamsta' },
requires = { 'c' },
}, },
gn = { gn = {
@ -925,6 +940,7 @@ M.configs = {
url = 'https://github.com/slackhq/tree-sitter-hack', url = 'https://github.com/slackhq/tree-sitter-hack',
files = { 'src/parser.c', 'src/scanner.c' }, files = { 'src/parser.c', 'src/scanner.c' },
}, },
tier = 4,
}, },
hare = { hare = {
@ -941,6 +957,7 @@ M.configs = {
files = { 'src/parser.c', 'src/scanner.c' }, files = { 'src/parser.c', 'src/scanner.c' },
}, },
maintainers = { '@mrcjkb' }, maintainers = { '@mrcjkb' },
tier = 3,
}, },
haskell_persistent = { haskell_persistent = {
@ -985,6 +1002,7 @@ M.configs = {
generate_requires_npm = true, generate_requires_npm = true,
}, },
maintainers = { '@winston0410' }, maintainers = { '@winston0410' },
requires = { 'json' },
}, },
hlsl = { hlsl = {
@ -994,6 +1012,7 @@ M.configs = {
generate_requires_npm = true, generate_requires_npm = true,
}, },
maintainers = { '@theHamsta' }, maintainers = { '@theHamsta' },
requires = { 'cpp' },
}, },
hlsplaylist = { hlsplaylist = {
@ -1023,12 +1042,18 @@ M.configs = {
tier = 4, tier = 4,
}, },
html_tags = {
maintainers = { '@TravonteD' },
readme_note = 'queries required by html, astro, vue, svelte',
},
html = { html = {
install_info = { install_info = {
url = 'https://github.com/tree-sitter/tree-sitter-html', url = 'https://github.com/tree-sitter/tree-sitter-html',
files = { 'src/parser.c', 'src/scanner.c' }, files = { 'src/parser.c', 'src/scanner.c' },
}, },
maintainers = { '@TravonteD' }, maintainers = { '@TravonteD' },
requires = { 'html_tags' },
}, },
htmldjango = { htmldjango = {
@ -1118,6 +1143,7 @@ M.configs = {
generate_requires_npm = true, generate_requires_npm = true,
}, },
maintainers = { '@fab4100' }, maintainers = { '@fab4100' },
requires = { 'c' },
}, },
janet_simple = { janet_simple = {
@ -1151,6 +1177,7 @@ M.configs = {
files = { 'src/parser.c', 'src/scanner.c' }, files = { 'src/parser.c', 'src/scanner.c' },
}, },
maintainers = { '@steelsojka' }, maintainers = { '@steelsojka' },
requires = { 'ecma', 'jsx' },
}, },
jinja = { jinja = {
@ -1214,7 +1241,7 @@ M.configs = {
generate_requires_npm = true, generate_requires_npm = true,
}, },
maintainers = { '@WhyNotHugo' }, maintainers = { '@WhyNotHugo' },
readme_note = 'JSON with comments', requires = { 'json' },
}, },
jsonnet = { jsonnet = {
@ -1225,6 +1252,11 @@ M.configs = {
maintainers = { '@nawordar' }, maintainers = { '@nawordar' },
}, },
jsx = {
maintainers = { '@steelsojka' },
readme_note = 'queries required by javascript, tsx',
},
julia = { julia = {
install_info = { install_info = {
url = 'https://github.com/tree-sitter/tree-sitter-julia', url = 'https://github.com/tree-sitter/tree-sitter-julia',
@ -1370,8 +1402,8 @@ M.configs = {
url = 'https://github.com/MunifTanjim/tree-sitter-lua', url = 'https://github.com/MunifTanjim/tree-sitter-lua',
files = { 'src/parser.c', 'src/scanner.c' }, files = { 'src/parser.c', 'src/scanner.c' },
}, },
tier = 1,
maintainers = { '@muniftanjim' }, maintainers = { '@muniftanjim' },
tier = 1,
}, },
luadoc = { luadoc = {
@ -1397,6 +1429,7 @@ M.configs = {
files = { 'src/parser.c', 'src/scanner.c' }, files = { 'src/parser.c', 'src/scanner.c' },
}, },
maintainers = { '@amaanq' }, maintainers = { '@amaanq' },
requires = { 'lua' },
}, },
m68k = { m68k = {
@ -1423,6 +1456,7 @@ M.configs = {
}, },
maintainers = { '@MDeiml' }, maintainers = { '@MDeiml' },
readme_note = 'basic highlighting', readme_note = 'basic highlighting',
requires = { 'markdown_inline' },
tier = 1, tier = 1,
}, },
@ -1475,8 +1509,8 @@ M.configs = {
files = { 'src/parser.c' }, files = { 'src/parser.c' },
requires_generate_from_grammar = true, requires_generate_from_grammar = true,
}, },
tier = 4,
maintainers = { '@artagnon' }, maintainers = { '@artagnon' },
tier = 4,
}, },
muttrc = { muttrc = {
@ -1511,6 +1545,7 @@ M.configs = {
url = 'https://github.com/nickel-lang/tree-sitter-nickel', url = 'https://github.com/nickel-lang/tree-sitter-nickel',
files = { 'src/parser.c', 'src/scanner.c' }, files = { 'src/parser.c', 'src/scanner.c' },
}, },
tier = 4,
}, },
nim = { nim = {
@ -1519,6 +1554,7 @@ M.configs = {
files = { 'src/parser.c', 'src/scanner.c' }, files = { 'src/parser.c', 'src/scanner.c' },
}, },
maintainers = { '@aMOPel' }, maintainers = { '@aMOPel' },
requires = { 'nim_format_string' },
tier = 3, tier = 3,
}, },
@ -1553,8 +1589,8 @@ M.configs = {
files = { 'src/parser.c', 'src/scanner.cc' }, files = { 'src/parser.c', 'src/scanner.cc' },
use_makefile = true, use_makefile = true,
}, },
tier = 4,
maintainers = { '@JoeyGrajciar', '@vhyrro' }, maintainers = { '@JoeyGrajciar', '@vhyrro' },
tier = 4,
}, },
nqc = { nqc = {
@ -1581,6 +1617,7 @@ M.configs = {
files = { 'src/parser.c' }, files = { 'src/parser.c' },
}, },
maintainers = { '@amaanq' }, maintainers = { '@amaanq' },
requires = { 'c' },
}, },
objdump = { objdump = {
@ -1608,6 +1645,7 @@ M.configs = {
location = 'grammars/interface', location = 'grammars/interface',
}, },
maintainers = { '@undu' }, maintainers = { '@undu' },
requires = { 'ocaml' },
}, },
ocamllex = { ocamllex = {
@ -1826,6 +1864,7 @@ M.configs = {
location = 'psv', location = 'psv',
}, },
maintainers = { '@amaanq' }, maintainers = { '@amaanq' },
requires = { 'tsv' },
tier = 2, tier = 2,
}, },
@ -1895,6 +1934,7 @@ M.configs = {
files = { 'src/parser.c', 'src/scanner.c' }, files = { 'src/parser.c', 'src/scanner.c' },
}, },
maintainers = { '@Decodetalkers' }, maintainers = { '@Decodetalkers' },
requires = { 'ecma' },
}, },
query = { query = {
@ -2120,6 +2160,8 @@ M.configs = {
files = { 'src/parser.c', 'src/scanner.c' }, files = { 'src/parser.c', 'src/scanner.c' },
}, },
maintainers = { '@elianiva' }, maintainers = { '@elianiva' },
requires = { 'css' },
tier = 3,
}, },
sflog = { sflog = {
@ -2314,6 +2356,7 @@ M.configs = {
files = { 'src/parser.c', 'src/scanner.c' }, files = { 'src/parser.c', 'src/scanner.c' },
}, },
maintainers = { '@amaanq' }, maintainers = { '@amaanq' },
requires = { 'html_tags' },
tier = 2, tier = 2,
}, },
@ -2421,6 +2464,8 @@ M.configs = {
location = 'dialects/terraform', location = 'dialects/terraform',
}, },
maintainers = { '@MichaHoffmann' }, maintainers = { '@MichaHoffmann' },
requires = { 'hcl' },
tier = 3,
}, },
textproto = { textproto = {
@ -2501,6 +2546,7 @@ M.configs = {
generate_requires_npm = true, generate_requires_npm = true,
}, },
maintainers = { '@steelsojka' }, maintainers = { '@steelsojka' },
requires = { 'ecma', 'jsx', 'typescript' },
}, },
turtle = { turtle = {
@ -2527,6 +2573,7 @@ M.configs = {
generate_requires_npm = true, generate_requires_npm = true,
}, },
maintainers = { '@steelsojka' }, maintainers = { '@steelsojka' },
requires = { 'ecma' },
}, },
typespec = { typespec = {
@ -2684,6 +2731,7 @@ M.configs = {
branch = 'main', branch = 'main',
}, },
maintainers = { '@WhyNotHugo', '@lucario387' }, maintainers = { '@WhyNotHugo', '@lucario387' },
requires = { 'html_tags' },
tier = 2, tier = 2,
}, },
@ -2737,6 +2785,7 @@ M.configs = {
location = 'xml', location = 'xml',
}, },
maintainers = { '@ObserverOfTime' }, maintainers = { '@ObserverOfTime' },
requires = { 'dtd' },
tier = 2, tier = 2,
}, },

View file

@ -21,21 +21,12 @@ end)
-- check for new revisions -- check for new revisions
for _, v in ipairs(sorted_parsers) do for _, v in ipairs(sorted_parsers) do
if skip_langs and not vim.list_contains(skip_langs, v.name) then if not vim.list_contains(skip_langs, v.name) and v.parser.install_info then
local sha ---@type string local cmd = 'git ls-remote ' .. v.parser.install_info.url
if v.parser.install_info.branch then if v.parser.install_info.branch then
sha = vim.split( cmd = cmd .. ' | grep refs/heads/' .. v.parser.install_info.branch
vim.fn.systemlist(
'git ls-remote '
.. v.parser.install_info.url
.. ' | grep refs/heads/'
.. v.parser.install_info.branch
)[1],
'\t'
)[1]
else
sha = vim.split(vim.fn.systemlist('git ls-remote ' .. v.parser.install_info.url)[1], '\t')[1]
end end
local sha = vim.split(vim.fn.systemlist(cmd)[1], '\t')[1]
lockfile[v.name] = { revision = sha } lockfile[v.name] = { revision = sha }
print(v.name .. ': ' .. sha) print(v.name .. ': ' .. sha)
else else
@ -43,5 +34,8 @@ for _, v in ipairs(sorted_parsers) do
end end
end end
lockfile = vim.fn.system('jq --sort-keys', vim.json.encode(lockfile)) lockfile = vim.json.encode(lockfile)
if vim.fn.executable('jq') == 1 then
lockfile = vim.fn.system('jq --sort-keys', lockfile)
end
util.write_file(filename, lockfile) util.write_file(filename, lockfile)

View file

@ -23,14 +23,23 @@ local footnotes = ''
for _, v in ipairs(sorted_parsers) do for _, v in ipairs(sorted_parsers) do
local p = v.parser local p = v.parser
-- language -- language
generated_text = generated_text if p.install_info then
.. '[' generated_text = generated_text
.. v.name .. '['
.. '](' .. v.name
.. p.install_info.url .. ']('
.. ')' .. p.install_info.url
.. (p.readme_note and '[^' .. v.name .. ']' or '') .. ')'
.. ' | ' .. (p.readme_note and '[^' .. v.name .. ']' or '')
.. ' | '
else
generated_text = generated_text
.. v.name
.. ' (queries only)'
.. (p.readme_note and '[^' .. v.name .. ']' or '')
.. ' | '
end
if p.readme_note then if p.readme_note then
footnotes = footnotes .. '[^' .. v.name .. ']: ' .. p.readme_note .. '\n' footnotes = footnotes .. '[^' .. v.name .. ']: ' .. p.readme_note .. '\n'
end end
@ -50,11 +59,13 @@ for _, v in ipairs(sorted_parsers) do
-- CLI -- CLI
generated_text = generated_text generated_text = generated_text
.. (p.install_info.requires_generate_from_grammar and '' or '') .. (p.install_info and p.install_info.requires_generate_from_grammar and '' or '')
.. ' | ' .. ' | '
-- NPM -- NPM
generated_text = generated_text .. (p.install_info.generate_requires_npm and '' or '') .. ' | ' generated_text = generated_text
.. (p.install_info and p.install_info.generate_requires_npm and '' or '')
.. ' | '
-- Maintainer -- Maintainer
generated_text = generated_text generated_text = generated_text