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-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-18 19:32:51 +02:00
|
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
|
|
|
|
|
-- 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-19 14:20:23 +02:00
|
|
|
if locals.is_supported(lang) then
|
|
|
|
|
print("Locals setup for", lang)
|
|
|
|
|
api.nvim_command(string.format([[
|
|
|
|
|
autocmd NvimTreesitter FileType %s lua vim.api.nvim_buf_attach(0, true, {on_lines=require'nvim-treesitter.locals'.on_lines})
|
|
|
|
|
]], lang))
|
|
|
|
|
end
|
2020-04-19 09:45:54 +02:00
|
|
|
end
|
2020-04-18 19:32:51 +02:00
|
|
|
end
|
|
|
|
|
|
2020-04-19 14:43:55 +02:00
|
|
|
-- To install, run `:lua require'nvim-treesitter'.install_parser('language')`
|
|
|
|
|
-- we should add a vim layer over the lua function
|
|
|
|
|
M.install_parser = install.install_parser
|
|
|
|
|
|
2020-04-18 19:32:51 +02:00
|
|
|
return M
|