From 823b022bb36ce42957ac9a9e650df0836ed8f82d Mon Sep 17 00:00:00 2001 From: odrling Date: Thu, 29 Sep 2022 15:35:18 +0200 Subject: [PATCH] [nvim] add perfanno --- .config/nvim/fnl/config/packer.fnl | 2 ++ .config/nvim/fnl/profiling.lua | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 .config/nvim/fnl/profiling.lua diff --git a/.config/nvim/fnl/config/packer.fnl b/.config/nvim/fnl/config/packer.fnl index 10212e6..ea5627f 100644 --- a/.config/nvim/fnl/config/packer.fnl +++ b/.config/nvim/fnl/config/packer.fnl @@ -122,6 +122,8 @@ ;; profiling (use! :stevearc/profile.nvim) + (use! :t-troebst/perfanno.nvim + :config #(setup :perfanno)) ; Interface (use! :projekt0n/github-nvim-theme) diff --git a/.config/nvim/fnl/profiling.lua b/.config/nvim/fnl/profiling.lua new file mode 100644 index 0000000..f0e22c5 --- /dev/null +++ b/.config/nvim/fnl/profiling.lua @@ -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("", "", toggle_profile)