|
| 1 | +{ |
| 2 | + lib, |
| 3 | + config, |
| 4 | + ... |
| 5 | +}: |
| 6 | +let |
| 7 | + inherit (lib.nixvim) defaultNullOpts; |
| 8 | + inherit (lib) types; |
| 9 | +in |
| 10 | +lib.nixvim.neovim-plugin.mkNeovimPlugin { |
| 11 | + name = "persisted"; |
| 12 | + originalName = "persisted.nvim"; |
| 13 | + package = "persisted-nvim"; |
| 14 | + |
| 15 | + maintainers = [ lib.maintainers.GaetanLepage ]; |
| 16 | + |
| 17 | + extraOptions = { |
| 18 | + enableTelescope = lib.mkEnableOption "persisted-nvim telescope integration"; |
| 19 | + }; |
| 20 | + |
| 21 | + extraConfig = cfg: { |
| 22 | + warnings = lib.optional (cfg.enableTelescope && (!config.plugins.telescope.enable)) '' |
| 23 | + Telescope support for `plugins.persisted` is enabled but the telescope plugin is not. |
| 24 | + ''; |
| 25 | + |
| 26 | + plugins.telescope.enabledExtensions = lib.mkIf cfg.enableTelescope [ "persisted" ]; |
| 27 | + }; |
| 28 | + |
| 29 | + settingsOptions = { |
| 30 | + autostart = defaultNullOpts.mkBool true '' |
| 31 | + Whether to automatically start the plugin on load. |
| 32 | + ''; |
| 33 | + |
| 34 | + should_save = |
| 35 | + defaultNullOpts.mkRaw |
| 36 | + '' |
| 37 | + function() |
| 38 | + return true |
| 39 | + end |
| 40 | + '' |
| 41 | + '' |
| 42 | + Function to determine if a session should be saved. |
| 43 | +
|
| 44 | + ```lua |
| 45 | + @type fun(): boolean |
| 46 | + ``` |
| 47 | + ''; |
| 48 | + |
| 49 | + save_dir = defaultNullOpts.mkStr (lib.nixvim.literalLua "vim.fn.expand(vim.fn.stdpath('data') .. '/sessions/')") '' |
| 50 | + Directory where session files are saved. |
| 51 | + ''; |
| 52 | + |
| 53 | + follow_cwd = defaultNullOpts.mkBool true '' |
| 54 | + Whether to change the session file to match any change in the cwd. |
| 55 | + ''; |
| 56 | + |
| 57 | + use_git_branch = defaultNullOpts.mkBool false '' |
| 58 | + Whether to include the git branch in the session file name. |
| 59 | + ''; |
| 60 | + |
| 61 | + autoload = defaultNullOpts.mkBool false '' |
| 62 | + Whether to automatically load the session for the cwd on Neovim startup. |
| 63 | + ''; |
| 64 | + |
| 65 | + on_autoload_no_session = defaultNullOpts.mkRaw "function() end" '' |
| 66 | +
|
| 67 | + Function to run when `autoload = true` but there is no session to load. |
| 68 | +
|
| 69 | + ```lua |
| 70 | + @type fun(): any |
| 71 | + ``` |
| 72 | + ''; |
| 73 | + |
| 74 | + allowed_dirs = defaultNullOpts.mkListOf types.str [ ] '' |
| 75 | + List of dirs that the plugin will start and autoload from. |
| 76 | + ''; |
| 77 | + |
| 78 | + ignored_dirs = defaultNullOpts.mkListOf types.str [ ] '' |
| 79 | + List of dirs that are ignored for starting and autoloading. |
| 80 | + ''; |
| 81 | + |
| 82 | + telescope = { |
| 83 | + mappings = |
| 84 | + defaultNullOpts.mkAttrsOf types.str |
| 85 | + { |
| 86 | + copy_session = "<C-c>"; |
| 87 | + change_branch = "<C-b>"; |
| 88 | + delete_session = "<C-d>"; |
| 89 | + } |
| 90 | + '' |
| 91 | + Mappings for managing sessions in Telescope. |
| 92 | + ''; |
| 93 | + |
| 94 | + icons = |
| 95 | + defaultNullOpts.mkAttrsOf types.str |
| 96 | + { |
| 97 | + selected = " "; |
| 98 | + dir = " "; |
| 99 | + branch = " "; |
| 100 | + } |
| 101 | + '' |
| 102 | + Icons displayed in the Telescope picker. |
| 103 | + ''; |
| 104 | + }; |
| 105 | + }; |
| 106 | + |
| 107 | + settingsExample = { |
| 108 | + use_git_branch = true; |
| 109 | + autoload = true; |
| 110 | + on_autoload_no_session.__raw = '' |
| 111 | + function() |
| 112 | + vim.notify("No existing session to load.") |
| 113 | + end |
| 114 | + ''; |
| 115 | + }; |
| 116 | +} |
0 commit comments