From 95b09bc3a4def0f743c21f0e56b208a6f043d8ad Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 7 Oct 2024 00:30:18 +0300 Subject: [PATCH] visuals: move nvim-scrollbar to its own module; switch to setupOpts --- flake.lock | 34 +++++++++---------- flake.nix | 2 +- modules/plugins/visuals/config.nix | 17 ---------- modules/plugins/visuals/default.nix | 1 + .../plugins/visuals/nvim-scrollbar/config.nix | 21 ++++++++++++ .../visuals/nvim-scrollbar/default.nix | 6 ++++ .../visuals/nvim-scrollbar/scrollbar-nvim.nix | 21 ++++++++++++ 7 files changed, 67 insertions(+), 35 deletions(-) create mode 100644 modules/plugins/visuals/nvim-scrollbar/config.nix create mode 100644 modules/plugins/visuals/nvim-scrollbar/default.nix create mode 100644 modules/plugins/visuals/nvim-scrollbar/scrollbar-nvim.nix diff --git a/flake.lock b/flake.lock index aa5763e3..9d0deb00 100644 --- a/flake.lock +++ b/flake.lock @@ -1278,6 +1278,22 @@ "type": "github" } }, + "plugin-nvim-scrollbar": { + "flake": false, + "locked": { + "lastModified": 1717406282, + "narHash": "sha256-Y5qCD2pjfs9fodH9Y1waefVuj/m33kx4ExMmAa/qoP4=", + "owner": "petertriho", + "repo": "nvim-scrollbar", + "rev": "d09f14aa16c9f2748e77008f9da7b1f76e4e7b85", + "type": "github" + }, + "original": { + "owner": "petertriho", + "repo": "nvim-scrollbar", + "type": "github" + } + }, "plugin-nvim-session-manager": { "flake": false, "locked": { @@ -1534,22 +1550,6 @@ "type": "github" } }, - "plugin-scrollbar-nvim": { - "flake": false, - "locked": { - "lastModified": 1684886154, - "narHash": "sha256-zLBexSxQCn9HPY04a9w/UCJP1F5ShI2X12I9xE9H0cM=", - "owner": "petertriho", - "repo": "nvim-scrollbar", - "rev": "35f99d559041c7c0eff3a41f9093581ceea534e8", - "type": "github" - }, - "original": { - "owner": "petertriho", - "repo": "nvim-scrollbar", - "type": "github" - } - }, "plugin-smartcolumn": { "flake": false, "locked": { @@ -1920,6 +1920,7 @@ "plugin-nvim-neoclip": "plugin-nvim-neoclip", "plugin-nvim-nio": "plugin-nvim-nio", "plugin-nvim-notify": "plugin-nvim-notify", + "plugin-nvim-scrollbar": "plugin-nvim-scrollbar", "plugin-nvim-session-manager": "plugin-nvim-session-manager", "plugin-nvim-surround": "plugin-nvim-surround", "plugin-nvim-tree-lua": "plugin-nvim-tree-lua", @@ -1936,7 +1937,6 @@ "plugin-registers": "plugin-registers", "plugin-rose-pine": "plugin-rose-pine", "plugin-rustaceanvim": "plugin-rustaceanvim", - "plugin-scrollbar-nvim": "plugin-scrollbar-nvim", "plugin-smartcolumn": "plugin-smartcolumn", "plugin-sqls-nvim": "plugin-sqls-nvim", "plugin-tabular": "plugin-tabular", diff --git a/flake.nix b/flake.nix index 994477af..5816938a 100644 --- a/flake.nix +++ b/flake.nix @@ -418,7 +418,7 @@ flake = false; }; - plugin-scrollbar-nvim = { + plugin-nvim-scrollbar = { url = "github:petertriho/nvim-scrollbar"; flake = false; }; diff --git a/modules/plugins/visuals/config.nix b/modules/plugins/visuals/config.nix index 851762a1..783a4cab 100644 --- a/modules/plugins/visuals/config.nix +++ b/modules/plugins/visuals/config.nix @@ -19,23 +19,6 @@ in { ''; }) - (mkIf cfg.scrollBar.enable { - vim.startPlugins = ["scrollbar-nvim"]; - vim.pluginRC.scrollBar = entryAnywhere '' - require('scrollbar').setup{ - excluded_filetypes = { - 'prompt', - 'TelescopePrompt', - 'noice', - 'NvimTree', - 'alpha', - 'notify', - 'Navbuddy' - }, - } - ''; - }) - (mkIf cfg.smoothScroll.enable { vim.startPlugins = ["cinnamon-nvim"]; vim.pluginRC.smoothScroll = entryAnywhere '' diff --git a/modules/plugins/visuals/default.nix b/modules/plugins/visuals/default.nix index 66ff44b9..7b15341d 100644 --- a/modules/plugins/visuals/default.nix +++ b/modules/plugins/visuals/default.nix @@ -2,6 +2,7 @@ imports = [ ./fidget ./nvim-cursorline + ./nvim-scrollbar ./nvim-web-devicons ./config.nix diff --git a/modules/plugins/visuals/nvim-scrollbar/config.nix b/modules/plugins/visuals/nvim-scrollbar/config.nix new file mode 100644 index 00000000..1d0ebc76 --- /dev/null +++ b/modules/plugins/visuals/nvim-scrollbar/config.nix @@ -0,0 +1,21 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.nvim.dag) entryAnywhere; + + cfg = config.vim.visuals.nvim-scrollbar; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = ["nvim-scrollbar"]; + + pluginRC.cursorline = entryAnywhere '' + require("scrollbar").setup(${toLuaObject cfg.setupOpts}) + ''; + }; + }; +} diff --git a/modules/plugins/visuals/nvim-scrollbar/default.nix b/modules/plugins/visuals/nvim-scrollbar/default.nix new file mode 100644 index 00000000..3341c65e --- /dev/null +++ b/modules/plugins/visuals/nvim-scrollbar/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.nix + ./scrollbar-nvim.nix + ]; +} diff --git a/modules/plugins/visuals/nvim-scrollbar/scrollbar-nvim.nix b/modules/plugins/visuals/nvim-scrollbar/scrollbar-nvim.nix new file mode 100644 index 00000000..bdf48cb4 --- /dev/null +++ b/modules/plugins/visuals/nvim-scrollbar/scrollbar-nvim.nix @@ -0,0 +1,21 @@ +{lib, ...}: let + inherit (lib.modules) mkRenamedOptionModule; + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) listOf str; + inherit (lib.nvim.types) mkPluginSetupOption; +in { + imports = [ + (mkRenamedOptionModule ["vim" "visuals" "scrollBar"] ["vim" "visuals" "nvim-scrollbar"]) + ]; + + options.vim.visuals.nvim-scrollbar = { + enable = mkEnableOption "extensible Neovim Scrollbar [nvim-scrollbar]"; + setupOpts = mkPluginSetupOption "scrollbar-nvim" { + excluded_filetypes = mkOption { + type = listOf str; + default = ["prompt" "TelescopePrompt" "noice" "noice" "NvimTree" "neo-tree" "alpha" "notify" "Navbuddy"]; + description = "Filetypes to hide the scrollbar on"; + }; + }; + }; +}