From f64fddee326fea61133160cd4ee4c48f8416692a Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sun, 17 May 2026 22:36:13 +0200 Subject: [PATCH] nvim/lua/user/plugins/editor/treesitter.lua: add treesitter alias mapping --- nvim/lua/user/plugins/editor/treesitter.lua | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/nvim/lua/user/plugins/editor/treesitter.lua b/nvim/lua/user/plugins/editor/treesitter.lua index 314f4c8..63ebf31 100644 --- a/nvim/lua/user/plugins/editor/treesitter.lua +++ b/nvim/lua/user/plugins/editor/treesitter.lua @@ -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, })