[nvim] add perfanno

This commit is contained in:
odrling 2022-09-29 15:35:18 +02:00
parent 74d8559617
commit 823b022bb3
No known key found for this signature in database
GPG key ID: A0145F975F9F8B75
2 changed files with 27 additions and 0 deletions

View file

@ -122,6 +122,8 @@
;; profiling
(use! :stevearc/profile.nvim)
(use! :t-troebst/perfanno.nvim
:config #(setup :perfanno))
; Interface
(use! :projekt0n/github-nvim-theme)

View file

@ -0,0 +1,25 @@
local should_profile = os.getenv("NVIM_PROFILE")
if should_profile then
require("profile").instrument_autocmds()
if should_profile:lower():match("^start") then
require("profile").start("*")
else
require("profile").instrument("*")
end
end
local function toggle_profile()
local prof = require("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
prof.start("*")
end
end
vim.keymap.set("", "<f1>", toggle_profile)