2020-04-18 19:32:51 +02:00
|
|
|
local api = vim.api
|
2020-04-19 09:45:54 +02:00
|
|
|
local parsers = require'nvim-treesitter.parsers'
|
2020-04-21 23:40:23 +02:00
|
|
|
local configs = require 'nvim-treesitter.configs'
|
2020-04-19 14:43:55 +02:00
|
|
|
local install = require'nvim-treesitter.install'
|
2020-04-19 14:20:23 +02:00
|
|
|
local locals = require'nvim-treesitter.locals'
|
2020-04-20 16:18:02 +02:00
|
|
|
local highlight = require'nvim-treesitter.highlight'
|
2020-04-18 19:32:51 +02:00
|
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
|
2020-04-21 23:40:23 +02:00
|
|
|
function M.available_parsers()
|
|
|
|
|
return vim.tbl_keys(configs.repositories)
|
|
|
|
|
end
|
|
|
|
|
|
2020-04-18 19:32:51 +02:00
|
|
|
-- This function sets up everythin needed for a given language
|
|
|
|
|
-- this is the main interface through the plugin
|
|
|
|
|
function M.setup(lang)
|
2020-04-19 09:45:54 +02:00
|
|
|
if parsers.has_parser(lang) then
|
2020-04-20 16:18:02 +02:00
|
|
|
local autocmd = "autocmd NvimTreesitter FileType %s lua require'nvim-treesitter.highlight'.setup()"
|
|
|
|
|
api.nvim_command(string.format(autocmd, lang))
|
2020-04-19 09:45:54 +02:00
|
|
|
end
|
2020-04-18 19:32:51 +02:00
|
|
|
end
|
|
|
|
|
|
2020-04-21 23:40:23 +02:00
|
|
|
-- This function initialize the plugin
|
|
|
|
|
-- it is run at startup
|
|
|
|
|
M._root = {}
|
|
|
|
|
function M._root.setup()
|
|
|
|
|
install.setup()
|
|
|
|
|
end
|
2020-04-19 14:43:55 +02:00
|
|
|
|
2020-04-18 19:32:51 +02:00
|
|
|
return M
|