62 lines
1.8 KiB
Nix
62 lines
1.8 KiB
Nix
{ pkgs, ... }:
|
|
{
|
|
programs.nixvim = {
|
|
extraPlugins = [
|
|
(pkgs.vimUtils.buildVimPlugin {
|
|
# https://github.com/stevearc/profile.nvim
|
|
name = "profile";
|
|
src = pkgs.fetchFromGitHub {
|
|
owner = "stevearc";
|
|
repo = "profile.nvim";
|
|
rev = "f2d2cf5eae9ba3b9ca6bc148507d153f3e6ae282";
|
|
sha256 = "sha256-xnScKSrlm1N3cw+hPmUd97b1gjue7FG+1f9genzw5yM=";
|
|
};
|
|
})
|
|
];
|
|
extraConfigLuaPre = # lua
|
|
''
|
|
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
|
|
|
|
vim.g.toggle_profile = function()
|
|
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
|
|
vim.ui.select({ "yes", "no" }, { prompt = "Would you like to start profiling?", format_item = function(item)
|
|
return item
|
|
end,
|
|
}, function(choice)
|
|
if choice == "yes" then
|
|
prof.start("*")
|
|
end
|
|
end)
|
|
end
|
|
end
|
|
'';
|
|
keymaps = [
|
|
{
|
|
mode = "n";
|
|
key = "<leader>p";
|
|
action = "<CMD>lua vim.g.toggle_profile()<CR>";
|
|
options = {
|
|
desc = "Toggle Profiling";
|
|
silent = true;
|
|
};
|
|
}
|
|
];
|
|
};
|
|
}
|