From 2c29d12fa29a5dad318871dc4eff0b9136629fbf Mon Sep 17 00:00:00 2001 From: jghauser Date: Sun, 16 Jun 2024 15:03:11 +0200 Subject: [PATCH] ci: add profile.nvim to nvim-test --- nix/ci-overlay.nix | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/nix/ci-overlay.nix b/nix/ci-overlay.nix index 60142cd..2208ec9 100644 --- a/nix/ci-overlay.nix +++ b/nix/ci-overlay.nix @@ -5,6 +5,16 @@ }: final: prev: let mkNvimMinimal = nvim: with final; let + profile-nvim = pkgs.vimUtils.buildVimPlugin { + name = "profile.nvim"; + src = pkgs.fetchFromGitHub { + owner = "stevearc"; + repo = "profile.nvim"; + rev = "0ee32b7aba31d84b0ca76aaff2ffcb11f8f5449f"; + hash = "sha256-usyy1kST8hq/3j0sp7Tpf/1mld6RtcVABPo/ygeqzbU="; + }; + }; + neovimConfig = neovimUtils.makeNeovimConfig { withPython3 = true; viAlias = true; @@ -19,6 +29,7 @@ with ps; [ tree-sitter-yaml ])) + profile-nvim ]; }; runtimeDeps = [ @@ -49,7 +60,34 @@ -- be loaded from the current directory vim.opt.runtimepath:prepend(vim.fn.getcwd()) - -- setup dependencies + -- profile.nvim + 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("*papis") + 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 + vim.notify("Starting profiling") + prof.start("*papis") + end + end + vim.keymap.set("", "", toggle_profile) + + -- cmp local cmp = require("cmp") cmp.setup({ mapping = cmp.mapping.preset.insert({ @@ -63,6 +101,8 @@ { name = "papis" }, }), }) + + -- telescope local telescope = require("telescope") telescope.setup({ defaults = {