mirror of
https://github.com/pnx/dotfiles
synced 2026-06-16 03:14:55 +02:00
89 lines
2.4 KiB
Lua
89 lines
2.4 KiB
Lua
return {
|
|
"nvim-treesitter/nvim-treesitter",
|
|
commit = "4916d6592ede8c07973490d9322f187e07dfefac",
|
|
pin = true,
|
|
dependencies = {
|
|
'windwp/nvim-ts-autotag',
|
|
'nvim-treesitter/nvim-treesitter-textobjects'
|
|
},
|
|
build = function()
|
|
require("nvim-treesitter.install").update({ with_sync = true })
|
|
end,
|
|
opts_extend = { "install", "alias" },
|
|
opts = {
|
|
-- Default parsers.
|
|
install = {
|
|
-- VIM stuff
|
|
"vim",
|
|
"vimdoc",
|
|
"query",
|
|
|
|
-- Common config languages
|
|
"json",
|
|
"yaml",
|
|
"toml",
|
|
"xml",
|
|
"kdl",
|
|
|
|
-- git
|
|
"git_rebase",
|
|
"git_config",
|
|
"gitattributes",
|
|
"gitignore",
|
|
|
|
-- misc
|
|
"comment",
|
|
"regex",
|
|
"re2c",
|
|
"xresources",
|
|
"sql",
|
|
"csv",
|
|
"ssh_config",
|
|
"printf",
|
|
"nginx",
|
|
},
|
|
alias = {
|
|
dotenv = "env"
|
|
}
|
|
},
|
|
config = function(_, opts)
|
|
local ts = require("nvim-treesitter")
|
|
vim.api.nvim_create_autocmd('User', { pattern = 'TSUpdate', callback = function ()
|
|
require("nvim-treesitter.parsers").dotenv = {
|
|
install_info = {
|
|
url = "https://github.com/pnx/tree-sitter-dotenv",
|
|
branch = "main",
|
|
files = { "src/parser.c", "src/scanner.c" },
|
|
}
|
|
}
|
|
end})
|
|
|
|
-- vim.filetype.add({
|
|
-- pattern = {
|
|
-- ['%.env'] = 'dotenv',
|
|
-- ['%.env%..+'] = 'dotenv',
|
|
-- }
|
|
-- })
|
|
-- vim.treesitter.language.register('dotenv', { 'env' })
|
|
|
|
for _, value in pairs(opts.install) do
|
|
vim.treesitter.language.register(value, value)
|
|
end
|
|
|
|
for k, v in pairs(opts.alias) do
|
|
vim.treesitter.language.register(v, k)
|
|
end
|
|
|
|
vim.api.nvim_create_autocmd('FileType', {
|
|
callback = function(ev)
|
|
local lang = vim.treesitter.language.get_lang(ev.match)
|
|
if vim.list_contains(ts.get_installed(), lang) then
|
|
vim.treesitter.start(ev.buf)
|
|
end
|
|
end,
|
|
})
|
|
|
|
ts.install(opts.install)
|
|
ts.setup(opts)
|
|
end
|
|
}
|