From cbbb18df638711c7cee5b15355d0d73592e29322 Mon Sep 17 00:00:00 2001 From: Joshua Finch Date: Tue, 30 Jan 2024 11:42:31 -0600 Subject: [PATCH] Verified that the treesitter reload autocmd is required to rebuild the tree after major tree changes or else the folds won't work. Future work will be needed to verify if this can be replaced, is a known bug, etc. --- init.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index fd80091..9fcd71a 100644 --- a/init.lua +++ b/init.lua @@ -282,13 +282,12 @@ vim.api.nvim_create_autocmd({ 'BufWritePost' }, { command = "source % | PackerCompile" }) --- Fix for treesitter folds --- TODO: Determine if this is required --- vim.api.nvim_create_autocmd({ 'BufEnter', 'BufNew', 'BufWinEnter' }, { --- pattern = '*', --- group = vim.api.nvim_create_augroup('telescope_fold_workaround', { clear = true }), --- command = 'set foldexpr=nvim_treesitter#foldexpr()', --- }) +-- Fix for treesitter folds, as folds are not recalculated upon buffer changes (especially when pasting text) +vim.api.nvim_create_autocmd({ 'BufEnter', 'BufNew', 'BufWinEnter' }, { + pattern = '*', + group = vim.api.nvim_create_augroup('telescope_fold_workaround', { clear = true }), + command = 'set foldexpr=nvim_treesitter#foldexpr()', +}) -- Create a new copy of capabilities and enable the snippetSupport local capabilities = vim.lsp.protocol.make_client_capabilities()