1
0
Fork 0
mirror of https://github.com/pnx/dotfiles synced 2026-06-16 03:14:55 +02:00

nvim/lua/user/plugins/editor/treesitter.lua: add treesitter alias mapping

This commit is contained in:
Henrik Hautakoski 2026-05-17 22:36:13 +02:00
parent 5c9e937fbb
commit f64fddee32

View file

@ -9,7 +9,7 @@ return {
build = function()
require("nvim-treesitter.install").update({ with_sync = true })
end,
opts_extend = { "install" },
opts_extend = { "install", "alias" },
opts = {
-- Default parsers.
install = {
@ -42,6 +42,9 @@ return {
"printf",
"nginx",
},
alias = {
dotenv = "env"
}
},
config = function(_, opts)
local ts = require("nvim-treesitter")
@ -61,24 +64,22 @@ return {
-- ['%.env%..+'] = 'dotenv',
-- }
-- })
vim.treesitter.language.register('dotenv', { 'env' })
-- 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
-- local all_langs = vim.treesitter.language._complete()
-- local lang = vim.treesitter.language.get_lang(ev.match)
-- vim.print(ev.match, all_langs, vim.tbl_contains(all_langs, lang))
-- if vim.tbl_contains(all_langs, lang) then
-- vim.treesitter.start(ev.buf)
-- end
end,
})