From a6996bb0860c4e7b3ed7131b1061c237c7acd7cd Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Mon, 19 Feb 2024 07:08:54 -0600 Subject: [PATCH] refactor(nvim): improve treesitter lazy loading --- .../.config/nvim/lua/plugins/configs/treesitter.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dots/.config/nvim/lua/plugins/configs/treesitter.lua b/dots/.config/nvim/lua/plugins/configs/treesitter.lua index 52de33a2..94dbc2ac 100644 --- a/dots/.config/nvim/lua/plugins/configs/treesitter.lua +++ b/dots/.config/nvim/lua/plugins/configs/treesitter.lua @@ -121,6 +121,19 @@ return { "nvim-treesitter/nvim-treesitter-textobjects", "RRethy/nvim-treesitter-endwise", }, + init = function() + vim.api.nvim_create_autocmd("BufEnter", { + group = vim.api.nvim_create_augroup("NeoTreeInit", { clear = true }), + callback = function() + local f = vim.fn.expand("%:p") + if vim.fn.isdirectory(f) == 0 then + require("neo-tree") + -- neo-tree is loaded now, delete the init autocmd + return true + end + end, + }) + end, config = function() local parser_config = require("nvim-treesitter.parsers").get_parser_configs() parser_config.typst = {