From c8a1e079cefd567da79f92246f4860bcfc4970c0 Mon Sep 17 00:00:00 2001 From: Matt Anderson Date: Mon, 17 Aug 2026 15:53:57 -0500 Subject: [PATCH] fix folding performance in medium or large sized org files by changing foldmethod --- nvim/.config/nvim/lua/plugins.lua | 40 ++++++++++++++++-------------- nvim/.config/nvim/lua/settings.lua | 13 ++++++++++ 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index 8024547..8ff8db0 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -54,13 +54,27 @@ require('lazy').setup({ org_default_notes_file = '~/doc/org/scratch.org', org_startup_indented = true, org_deadline_warning_days = 0, + ui = { + folds = { + colored = false, + }, + }, org_agenda_custom_commands = { - i = { - description = "Independent", + o = { + description = "Owned", types = { { type = 'agenda', - org_agenda_tag_filter_preset = 'independent' + org_agenda_tag_filter_preset = 'owned' + } + } + }, + a = { + description = "Assigned", + types = { + { + type = 'agenda', + org_agenda_tag_filter_preset = 'assigned' } } }, @@ -73,30 +87,20 @@ require('lazy').setup({ } } }, - w = { - description = "Work", + h = { + description = "Habits", types = { { type = 'agenda', - org_agenda_tag_filter_preset = 'work' + org_agenda_tag_filter_preset = 'habits' } } }, - m = { - description = "Milestones", + l = { + description = "Agenda", types = { { type = 'agenda', - org_agenda_tag_filter_preset = 'milestone' - } - } - }, - s = { - description = "Social", - types = { - { - type = 'agenda', - org_agenda_tag_filter_preset = 'social' } } }, diff --git a/nvim/.config/nvim/lua/settings.lua b/nvim/.config/nvim/lua/settings.lua index e46494c..3526503 100644 --- a/nvim/.config/nvim/lua/settings.lua +++ b/nvim/.config/nvim/lua/settings.lua @@ -13,6 +13,19 @@ vim.o.splitright = true vim.o.maxmempattern = 100000 vim.g.clipboard = "osc52" +function _G.org_foldexpr() + local stars = vim.fn.getline(vim.v.lnum):match("^(%*+)%s") + return stars and (">" .. #stars) or "=" +end + +vim.api.nvim_create_autocmd("FileType", { + pattern = "org", + callback = function() + vim.opt_local.foldmethod = "expr" + vim.opt_local.foldexpr = "v:lua.org_foldexpr()" + end, +}) + vim.cmd([[ autocmd ColorScheme * highlight Statement cterm=NONE ctermfg=5 autocmd ColorScheme * highlight Keyword ctermfg=5