Mark parsers with NPM dependency

This commit is contained in:
Stephan Seitz 2021-03-07 17:05:16 +01:00 committed by Kiyan
parent fcb6d74b6b
commit 532a369b32
3 changed files with 43 additions and 17 deletions

View file

@ -174,6 +174,19 @@ local function run_install(cache_folder, install_folder, lang, repo, with_sync,
vim.list_extend(command_list, shell.select_download_commands(repo, project_name, cache_folder, revision)) vim.list_extend(command_list, shell.select_download_commands(repo, project_name, cache_folder, revision))
end end
if generate_from_grammar then if generate_from_grammar then
if repo.generate_requires_npm then
vim.list_extend(command_list, {
{
cmd = 'npm',
info = 'Installing NPM dependencies of '..lang..' parser',
err = 'Error during `npm install` (required for parser generation of '..lang..' with npm dependencies)',
opts = {
args = {'install'},
cwd = compile_location
}
}
})
end
vim.list_extend(command_list, { vim.list_extend(command_list, {
{ {
cmd = 'tree-sitter', cmd = 'tree-sitter',

View file

@ -58,7 +58,8 @@ list.clojure = {
list.cpp = { list.cpp = {
install_info = { install_info = {
url = "https://github.com/tree-sitter/tree-sitter-cpp", url = "https://github.com/tree-sitter/tree-sitter-cpp",
files = { "src/parser.c", "src/scanner.cc" } files = { "src/parser.c", "src/scanner.cc" },
generate_requires_npm = true,
}, },
used_by = { "cuda" }, used_by = { "cuda" },
maintainers = {"@theHamsta"}, maintainers = {"@theHamsta"},
@ -148,14 +149,16 @@ list.java = {
maintainers = {"@p00f"}, maintainers = {"@p00f"},
} }
list.kotlin = { ---Parser generation from source does not terminate in reasonable time
install_info = { --list.kotlin = {
url = "https://github.com/QthCN/tree-sitter-kotlin", --install_info = {
files = { "src/parser.c" }, --url = "https://github.com/QthCN/tree-sitter-kotlin",
requires_generate_from_grammar = true, --files = { "src/parser.c" },
}, --requires_generate_from_grammar = true,
maintainers = {"@tormodatt"}, --generate_requires_npm = true,
} --},
--maintainers = {"@tormodatt"},
--}
list.html = { list.html = {
install_info = { install_info = {
@ -249,7 +252,8 @@ list.typescript = {
install_info = { install_info = {
url = "https://github.com/tree-sitter/tree-sitter-typescript", url = "https://github.com/tree-sitter/tree-sitter-typescript",
files = { "src/parser.c", "src/scanner.c" }, files = { "src/parser.c", "src/scanner.c" },
location = "tree-sitter-typescript/typescript" location = "tree-sitter-typescript/typescript",
generate_requires_npm = true,
}, },
maintainers = {"@steelsojka"}, maintainers = {"@steelsojka"},
} }
@ -258,7 +262,8 @@ list.tsx = {
install_info = { install_info = {
url = "https://github.com/tree-sitter/tree-sitter-typescript", url = "https://github.com/tree-sitter/tree-sitter-typescript",
files = { "src/parser.c", "src/scanner.c" }, files = { "src/parser.c", "src/scanner.c" },
location = "tree-sitter-tsx/tsx" location = "tree-sitter-tsx/tsx",
generate_requires_npm = true,
}, },
used_by = { "typescript.tsx" }, used_by = { "typescript.tsx" },
filetype = 'typescriptreact' filetype = 'typescriptreact'
@ -302,6 +307,7 @@ list.toml = {
url = "https://github.com/ikatyang/tree-sitter-toml", url = "https://github.com/ikatyang/tree-sitter-toml",
files = { "src/parser.c", "src/scanner.c" }, files = { "src/parser.c", "src/scanner.c" },
requires_generate_from_grammar = true, requires_generate_from_grammar = true,
generate_requires_npm = true,
}, },
maintainers = {"@tk-shirasaka"}, maintainers = {"@tk-shirasaka"},
} }
@ -332,6 +338,7 @@ list.jsonc = {
url = "https://gitlab.com/WhyNotHugo/tree-sitter-jsonc.git", url = "https://gitlab.com/WhyNotHugo/tree-sitter-jsonc.git",
files = { "src/parser.c" }, files = { "src/parser.c" },
requires_generate_from_grammar = true, requires_generate_from_grammar = true,
generate_requires_npm = true,
}, },
readme_name = "JSON with comments", readme_name = "JSON with comments",
maintainers = {"@WhyNotHugo"}, maintainers = {"@WhyNotHugo"},
@ -404,14 +411,18 @@ list.ql = {
maintainers = {'@pwntester'}, maintainers = {'@pwntester'},
} }
---Parser generation from source takes a looong time!
list.verilog = { list.verilog = {
install_info = { install_info = {
url = "https://github.com/tree-sitter/tree-sitter-verilog", url = "https://github.com/tree-sitter/tree-sitter-verilog",
files = { "src/parser.c" }, files = { "src/parser.c" },
requires_generate_from_grammar = true,
generate_requires_npm = true,
}, },
used_by = { "systemverilog" }, used_by = { "systemverilog" },
maintainers = { "@zegervdv" }, maintainers = { "@zegervdv" },
} }
-- Parsers for injections -- Parsers for injections
list.regex = { list.regex = {
install_info = { install_info = {
@ -491,8 +502,9 @@ list.devicetree = {
list.svelte = { list.svelte = {
install_info = { install_info = {
url = "https://github.com/Himujjal/tree-sitter-svelte", url = "https://github.com/Himujjal/tree-sitter-svelte",
files = { "src/parser.c", "src/scanner.cc" }, files = { "src/parser.c", "src/scanner.c" },
branch = "master", branch = "master",
requires_generate_from_grammar = true,
}, },
maintainers = { "@elianiva" }, maintainers = { "@elianiva" },
} }

View file

@ -54,9 +54,10 @@
name: (scoped_identifier name: (scoped_identifier
name: (identifier) @definition.function)) @scope name: (identifier) @definition.function)) @scope
(function_declarator ;; TODO!!
declarator: (scoped_identifier ;(function_declarator
name: (type_identifier) @definition.function)) @scope ;declarator: (scoped_identifier
;name: (type_identifier) @definition.function)) @scope
(field_declaration (field_declaration
declarator: (function_declarator declarator: (function_declarator
@ -70,5 +71,5 @@
(catch_clause) @scope (catch_clause) @scope
(destructor_name ;(destructor_name
name: (_) @constructor) ;name: (_) @constructor)