Skip to content

Commit

Permalink
Nvim: added profile.nvim
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-matsui committed Dec 18, 2024
1 parent 5389deb commit 0c4f9ca
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .config/nvim/lua/plugins/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,36 @@ return {
{ "<c-s>", 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("", "<Leader>P", toggle_profile)
end,
},
}

0 comments on commit 0c4f9ca

Please sign in to comment.