From 0c4f9cae39fa0761c2a158de3040d5b1437c6eca Mon Sep 17 00:00:00 2001 From: Ken Matsui <26405363+ken-matsui@users.noreply.github.com> Date: Tue, 17 Dec 2024 20:38:40 -0500 Subject: [PATCH] Nvim: added profile.nvim --- .config/nvim/lua/plugins/ui.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.config/nvim/lua/plugins/ui.lua b/.config/nvim/lua/plugins/ui.lua index 49c87f3..26e9542 100644 --- a/.config/nvim/lua/plugins/ui.lua +++ b/.config/nvim/lua/plugins/ui.lua @@ -329,4 +329,36 @@ return { { "", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" }, }, }, + + { + "stevearc/profile.nvim", + cond = function() + return os.getenv("NVIM_PROFILE") + end, + config = function() + local prof = require("profile") + + prof.instrument_autocmds() + prof.instrument("*") + + local function toggle_profile() + if prof.is_recording() then + prof.stop() + vim.ui.input( + { prompt = "Save profile to: ", completion = "file", default = "profile.json" }, + function(filename) + if filename then + prof.export(filename) + vim.notify(string.format("Wrote %s", filename)) + end + end + ) + else + vim.notify("Profiling started") + prof.start("*") + end + end + vim.keymap.set("", "P", toggle_profile) + end, + }, }