feat/refacto: add configs.lua, setup install

- configs.lua holds the `repositories` data
- install health moved to health.lua
- plugins loads _root.setup() on startup
- install and list command are available through vim
> use them with `:TSInstall lang` and `:TSInstallInfo`
This commit is contained in:
kiyan42 2020-04-21 23:40:23 +02:00
parent 37932fc3d3
commit 62ce7744db
5 changed files with 170 additions and 121 deletions

View file

@ -1,8 +1,9 @@
local api = vim.api
local fn = vim.fn
local install = require'nvim-treesitter.install'
local queries = require'nvim-treesitter.query'
local locals = require'nvim-treesitter.locals'
local configs = require'nvim-treesitter.configs'
local health_start = vim.fn["health#report_start"]
local health_ok = vim.fn['health#report_ok']
@ -12,15 +13,36 @@ local health_error = vim.fn['health#report_error']
local M = {}
local function configs_health()
if fn.executable('git') == 0 then
health_error('`git` executable not found.', {
'Install it with your package manager.',
'Check that your `$PATH` is set correctly.'
})
else
health_ok('`git` executable found.')
end
if fn.executable('cc') == 0 then
health_error('`cc` executable not found.', {
'Install `gcc` with your package manager.',
'Install `clang` with your package manager.',
'Check that your `$PATH` is set correctly.'
})
else
health_ok('`cc` executable found.')
end
end
-- TODO(vigoux): Maybe we should move each check to be perform in its own module
function M.checkhealth()
-- Installation dependency checks
health_start('Installation')
install.checkhealth()
configs_health()
local missing_parsers = {}
-- Parser installation checks
for parser_name, repo in pairs(install.repositories) do
for parser_name in pairs(configs.repositories) do
local installed = #api.nvim_get_runtime_file('parser/'..parser_name..'.so', false)
-- Only print informations about installed parsers
@ -42,7 +64,7 @@ function M.checkhealth()
-- TODO(vigoux): The installation command should be changed so that its easier to find
health_warn('Some parsers are not installed:\n' .. table.concat(missing_parsers, '\n'), {
"Install them using `:lua require'nvim-treesitter'.install_parser('language')`"})
"Install them using `:TSInstall language"})
end
end