From 0fbcf1ca6f6bb6eb7b2aa779559c294d8b0b9951 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 26 Jan 2025 13:45:58 +0300 Subject: [PATCH] utility/yanky-nvim: init --- configuration.nix | 1 + docs/release-notes/rl-0.8.md | 4 +++ flake.lock | 17 ++++++++++ flake.nix | 5 +++ modules/plugins/utility/default.nix | 16 +++++----- modules/plugins/utility/yanky-nvim/config.nix | 32 +++++++++++++++++++ .../plugins/utility/yanky-nvim/default.nix | 6 ++++ .../plugins/utility/yanky-nvim/yanky-nvim.nix | 28 ++++++++++++++++ 8 files changed, 101 insertions(+), 8 deletions(-) create mode 100644 modules/plugins/utility/yanky-nvim/config.nix create mode 100644 modules/plugins/utility/yanky-nvim/default.nix create mode 100644 modules/plugins/utility/yanky-nvim/yanky-nvim.nix diff --git a/configuration.nix b/configuration.nix index 2159edc83..594e292f0 100644 --- a/configuration.nix +++ b/configuration.nix @@ -175,6 +175,7 @@ isMaximal: { icon-picker.enable = isMaximal; surround.enable = isMaximal; diffview-nvim.enable = true; + yanky-nvim.enable = false; motion = { hop.enable = true; leap.enable = true; diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index f5e9d0a04..661aee1d6 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -4,6 +4,7 @@ [typst-preview.nvim]: https://github.com/chomosuke/typst-preview.nvim [render-markdown.nvim]: https://github.com/MeanderingProgrammer/render-markdown.nvim +[yanky.nvim]: https://github.com/gbprod/yanky.nvim - Add [typst-preview.nvim] under `languages.typst.extensions.typst-preview-nvim`. @@ -33,10 +34,13 @@ - Add [](#opt-vim.lsp.lightbulb.autocmd.enable) for manually managing the previously managed lightbulb autocommand. + - A warning will occur if [](#opt-vim.lsp.lightbulb.autocmd.enable) and `vim.lsp.lightbulb.setupOpts.autocmd.enabled` are both set at the same time. Pick only one. +- Add [yanky.nvim] to available plugins, under `vim.utility.yanky-nvim`. + [amadaluzia](https://github.com/amadaluzia): [haskell-tools.nvim]: https://github.com/MrcJkb/haskell-tools.nvim diff --git a/flake.lock b/flake.lock index ee19b7c8e..2b0136fd6 100644 --- a/flake.lock +++ b/flake.lock @@ -2761,6 +2761,22 @@ "type": "github" } }, + "plugin-yanky-nvim": { + "flake": false, + "locked": { + "lastModified": 1737126873, + "narHash": "sha256-Gt8kb6sZoNIM2SDWUPyAF5Tw99qMZl+ltUCfyMXgJsU=", + "owner": "gbprod", + "repo": "yanky.nvim", + "rev": "d2696b30e389dced94d5acab728f524a25f308d2", + "type": "github" + }, + "original": { + "owner": "gbprod", + "repo": "yanky.nvim", + "type": "github" + } + }, "root": { "inputs": { "flake-parts": "flake-parts", @@ -2934,6 +2950,7 @@ "plugin-vim-repeat": "plugin-vim-repeat", "plugin-vim-startify": "plugin-vim-startify", "plugin-which-key": "plugin-which-key", + "plugin-yanky-nvim": "plugin-yanky-nvim", "systems": "systems_2" } }, diff --git a/flake.nix b/flake.nix index 5d4728f66..52635132c 100644 --- a/flake.nix +++ b/flake.nix @@ -590,6 +590,11 @@ flake = false; }; + plugin-yanky-nvim = { + url = "github:gbprod/yanky.nvim"; + flake = false; + }; + # Note-taking plugin-obsidian-nvim = { url = "github:epwalsh/obsidian.nvim"; diff --git a/modules/plugins/utility/default.nix b/modules/plugins/utility/default.nix index 8b25ea8f4..65ef86803 100644 --- a/modules/plugins/utility/default.nix +++ b/modules/plugins/utility/default.nix @@ -1,19 +1,19 @@ { imports = [ - ./outline ./binds ./ccc + ./diffview + ./fzf-lua ./gestures - ./motion - ./new-file-template - ./telescope ./icon-picker ./images + ./motion + ./new-file-template + ./outline + ./preview + ./surround ./telescope - ./diffview ./wakatime - ./surround - ./preview - ./fzf-lua + ./yanky-nvim ]; } diff --git a/modules/plugins/utility/yanky-nvim/config.nix b/modules/plugins/utility/yanky-nvim/config.nix new file mode 100644 index 000000000..138fd07d0 --- /dev/null +++ b/modules/plugins/utility/yanky-nvim/config.nix @@ -0,0 +1,32 @@ +{ + config, + pkgs, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.lists) optionals concatLists; + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.nvim.dag) entryAnywhere; + + cfg = config.vim.utility.yanky-nvim; + usingSqlite = cfg.setupOpts.ring.storage == "sqlite"; +in { + config = mkIf cfg.enable { + vim = { + # TODO: this could probably be lazyloaded. I'm not yet sure which event is + # ideal, so it's loaded normally for now. + startPlugins = concatLists [ + ["yanky-nvim"] + + # If using the sqlite backend, sqlite-lua must be loaded + # alongside yanky. + (optionals usingSqlite [pkgs.vimPlugins.sqlite-lua]) + ]; + + pluginRC.yanky-nvim = entryAnywhere '' + require("yanky").setup(${toLuaObject cfg.setupOpts}); + ''; + }; + }; +} diff --git a/modules/plugins/utility/yanky-nvim/default.nix b/modules/plugins/utility/yanky-nvim/default.nix new file mode 100644 index 000000000..05cb2bea7 --- /dev/null +++ b/modules/plugins/utility/yanky-nvim/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.nix + ./yanky-nvim.nix + ]; +} diff --git a/modules/plugins/utility/yanky-nvim/yanky-nvim.nix b/modules/plugins/utility/yanky-nvim/yanky-nvim.nix new file mode 100644 index 000000000..95d6a2113 --- /dev/null +++ b/modules/plugins/utility/yanky-nvim/yanky-nvim.nix @@ -0,0 +1,28 @@ +{lib, ...}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) enum; +in { + options.vim.utility.yanky-nvim = { + enable = mkEnableOption '' + improved Yank and Put functionalities for Neovim [yanky-nvim] + ''; + + setupOpts = { + ring.storage = mkOption { + type = enum ["shada" "sqlite" "memory"]; + default = "shada"; + example = "sqlite"; + description = '' + storage mode for ring values. + + - shada: this will save pesistantly using Neovim ShaDa feature. + This means that history will be persisted between each session of Neovim. + - memory: each Neovim instance will have his own history and it will be + lost between sessions. + - sqlite: more reliable than `shada`, requires `sqlite.lua` as a dependency. + nvf will add this dependency to `PATH` automatically. + ''; + }; + }; + }; +}