perf: add caching system for fast graph loading
Major performance improvements for graph visualization: Cache System: - Add cache.lua module that stores parsed links/tags per file - Only re-parse files that have been modified (mtime check) - Cache stored in .ideadrop-graph-cache.json in idea_dir - Fast file scanning using vim.fs.find when available Layout Optimizations: - Reduce max iterations from 300 to 100 - Faster convergence with adjusted parameters - Barnes-Hut approximation for large graphs (100+ nodes) - Cache math functions locally for speed - Skip distant node pairs in repulsion calculation - Reuse visible_nodes array across iterations New Commands: - :IdeaGraph rebuild - Force full cache rebuild - :IdeaGraphClearCache - Clear cache file This makes opening the graph nearly instant for previously scanned vaults, similar to Obsidian's behavior.
This commit is contained in:
@@ -250,17 +250,27 @@ function M.setup(user_opts)
|
||||
graph.refresh()
|
||||
elseif arg == "animate" then
|
||||
graph.open({ animate = true })
|
||||
elseif arg == "rebuild" then
|
||||
graph.open({ force_rebuild = true })
|
||||
else
|
||||
graph.open()
|
||||
end
|
||||
end, {
|
||||
nargs = "?",
|
||||
complete = function()
|
||||
return { "close", "refresh", "animate" }
|
||||
return { "close", "refresh", "animate", "rebuild" }
|
||||
end,
|
||||
desc = "Open Obsidian-style graph visualization of notes and links",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command("IdeaGraphClearCache", function()
|
||||
local cache = require("ideaDrop.ui.graph.cache")
|
||||
cache.clear()
|
||||
vim.notify("🗑️ Graph cache cleared", vim.log.levels.INFO)
|
||||
end, {
|
||||
desc = "Clear the graph cache to force full rebuild",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command("IdeaGraphFilter", function(opts)
|
||||
local args = vim.split(opts.args, " ", { trimempty = true })
|
||||
|
||||
|
||||
Reference in New Issue
Block a user