From d844d4f82efd6934f8014a9b00858aa0ee836652 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Sun, 4 Feb 2024 01:37:37 -0600 Subject: [PATCH] fix(nvim): allow orgmode to properly parse treesitter for file HACK: This is done by re-editing the buffer after a timeout. Shit way to fix this, still need to do root-cause analysis. --- dots/.config/nvim/after/ftplugin/org.lua | 8 ++++++++ dots/.config/nvim/lua/plugins/configs/org-mode.lua | 3 --- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dots/.config/nvim/after/ftplugin/org.lua b/dots/.config/nvim/after/ftplugin/org.lua index e3cd2a4a..d088657f 100644 --- a/dots/.config/nvim/after/ftplugin/org.lua +++ b/dots/.config/nvim/after/ftplugin/org.lua @@ -2,3 +2,11 @@ vim.opt_local.shiftwidth = 2 vim.opt_local.modeline = true vim.opt_local.wrap = false vim.opt_local.conceallevel = 1 +-- HACK: Correctly handle treesitter attachment. Without this folds and reformatting fall out of +-- sync and treesitter can fail to properly parse the buffer on content modifications. +if not vim.b.org_did_edit then + vim.b.org_did_edit = true + vim.defer_fn(vim.schedule_wrap(function() + vim.cmd.edit() + end), 10) +end diff --git a/dots/.config/nvim/lua/plugins/configs/org-mode.lua b/dots/.config/nvim/lua/plugins/configs/org-mode.lua index dddf76b8..dcf080af 100644 --- a/dots/.config/nvim/lua/plugins/configs/org-mode.lua +++ b/dots/.config/nvim/lua/plugins/configs/org-mode.lua @@ -66,9 +66,6 @@ return { vim.api.nvim_set_hl(0, "org_bold_delimiter", { link = "@punctuation.delimiter" }) vim.api.nvim_set_hl(0, "org_underline_delimiter", { link = "@punctuation.delimiter" }) vim.api.nvim_set_hl(0, "org_strikethrough_delimiter", { link = "@punctuation.delimiter" }) - if vim.bo.filetype == "org" then - vim.cmd.doautocmd("FileType org") - end end, }, }