forked from nvim-treesitter/nvim-treesitter-context
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_parsers.lua
33 lines (29 loc) · 893 Bytes
/
install_parsers.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
local function get_langs()
local f = assert(io.open('README.md', 'r'))
local readme_langs = {} --- @type table<string,true>
for l in f:lines() do
--- @type string?
local lang = l:match('%- %[x%] `([^`]+)`')
if lang then
readme_langs[lang] = true
end
end
f:close()
f = assert(io.open('nvim-treesitter/lockfile.json', 'r'))
local txt = f:read('*a')
local j = vim.json.decode(txt)
local langs = {} --- @type string[]
for k in pairs(j) do
if readme_langs[k] then
langs[#langs+1] = k
readme_langs[k] = nil
end
end
print('Invalid languages:', table.concat(vim.tbl_keys(readme_langs), ', '))
return langs
end
vim.cmd [[set runtimepath+=.,./nvim-treesitter]]
require'nvim-treesitter.install'.prefer_git = false
require("nvim-treesitter").setup()
require'nvim-treesitter.install'.ensure_installed_sync(get_langs())
vim.cmd.quit()