From db54345de1547adaa497790648c5a04e955541a5 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 6 Oct 2024 23:48:12 +0300 Subject: [PATCH] visuals: move nvim-cursorline to its own module; switch to setupOpts --- modules/plugins/visuals/config.nix | 12 ----- modules/plugins/visuals/default.nix | 1 + .../visuals/nvim-cursorline/config.nix | 21 ++++++++ .../visuals/nvim-cursorline/default.nix | 6 +++ .../nvim-cursorline/nvim-cursorline.nix | 49 +++++++++++++++++++ .../nvim-web-devicons/nvim-web-devicons.nix | 2 +- modules/plugins/visuals/visuals.nix | 16 ------ 7 files changed, 78 insertions(+), 29 deletions(-) create mode 100644 modules/plugins/visuals/nvim-cursorline/config.nix create mode 100644 modules/plugins/visuals/nvim-cursorline/default.nix create mode 100644 modules/plugins/visuals/nvim-cursorline/nvim-cursorline.nix diff --git a/modules/plugins/visuals/config.nix b/modules/plugins/visuals/config.nix index f8904d9..851762a 100644 --- a/modules/plugins/visuals/config.nix +++ b/modules/plugins/visuals/config.nix @@ -19,18 +19,6 @@ in { ''; }) - (mkIf cfg.cursorline.enable { - vim.startPlugins = ["nvim-cursorline"]; - vim.pluginRC.cursorline = entryAnywhere '' - require('nvim-cursorline').setup { - cursorline = { - timeout = ${toString cfg.cursorline.lineTimeout}, - number = ${boolToString (!cfg.cursorline.lineNumbersOnly)}, - } - } - ''; - }) - (mkIf cfg.scrollBar.enable { vim.startPlugins = ["scrollbar-nvim"]; vim.pluginRC.scrollBar = entryAnywhere '' diff --git a/modules/plugins/visuals/default.nix b/modules/plugins/visuals/default.nix index c096d65..66ff44b 100644 --- a/modules/plugins/visuals/default.nix +++ b/modules/plugins/visuals/default.nix @@ -1,6 +1,7 @@ { imports = [ ./fidget + ./nvim-cursorline ./nvim-web-devicons ./config.nix diff --git a/modules/plugins/visuals/nvim-cursorline/config.nix b/modules/plugins/visuals/nvim-cursorline/config.nix new file mode 100644 index 0000000..b1f1bab --- /dev/null +++ b/modules/plugins/visuals/nvim-cursorline/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.cursorline; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = ["nvim-cursorline"]; + + pluginRC.cursorline = entryAnywhere '' + require("nvim-cursorline").setup(${toLuaObject cfg.setupOpts}) + ''; + }; + }; +} diff --git a/modules/plugins/visuals/nvim-cursorline/default.nix b/modules/plugins/visuals/nvim-cursorline/default.nix new file mode 100644 index 0000000..b09014d --- /dev/null +++ b/modules/plugins/visuals/nvim-cursorline/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.nix + ./nvim-cursorline.nix + ]; +} diff --git a/modules/plugins/visuals/nvim-cursorline/nvim-cursorline.nix b/modules/plugins/visuals/nvim-cursorline/nvim-cursorline.nix new file mode 100644 index 0000000..17d937c --- /dev/null +++ b/modules/plugins/visuals/nvim-cursorline/nvim-cursorline.nix @@ -0,0 +1,49 @@ +{lib, ...}: let + inherit (lib.modules) mkRenamedOptionModule mkRemovedOptionModule; + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) int bool; + inherit (lib.nvim.types) mkPluginSetupOption; +in { + imports = [ + (mkRenamedOptionModule ["vim" "visuals" "cursorline" "lineTimeout"] ["vim" "visuals" "cursorline" "setupOpts" "line_timeout"]) + (mkRemovedOptionModule ["vim" "visuals" "cursorline" "lineNumbersOnly"] '' + `vim.visuals.cursorline.lineNumbersOnly` has been removed. Use `vim.visuals.cursorline.number` instead. + '') + ]; + + options.vim.visuals.cursorline = { + enable = mkEnableOption "cursor word and line highlighting [nvim-cursorline]"; + setupOpts = mkPluginSetupOption "cursorline" { + cursorline = { + enable = mkEnableOption "cursor line highlighting"; + timeout = mkOption { + type = int; + default = 1000; + }; + + number = mkOption { + type = bool; + default = false; + }; + }; + + cursorword = { + enable = mkEnableOption "cursor word highlighting"; + timeout = mkOption { + type = int; + default = 1000; + }; + + min_length = mkOption { + type = int; + default = 3; + }; + + hl.underline = mkOption { + type = bool; + default = true; + }; + }; + }; + }; +} diff --git a/modules/plugins/visuals/nvim-web-devicons/nvim-web-devicons.nix b/modules/plugins/visuals/nvim-web-devicons/nvim-web-devicons.nix index f88dfaf..7883486 100644 --- a/modules/plugins/visuals/nvim-web-devicons/nvim-web-devicons.nix +++ b/modules/plugins/visuals/nvim-web-devicons/nvim-web-devicons.nix @@ -4,7 +4,7 @@ ... }: let inherit (lib.modules) mkRenamedOptionModule; - inherit (lib.options) mkEnableOption mkOption literalExpression; + inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.types) nullOr attrsOf attrs enum; inherit (lib.nvim.types) mkPluginSetupOption; in { diff --git a/modules/plugins/visuals/visuals.nix b/modules/plugins/visuals/visuals.nix index 07c2f5d..450f6e9 100644 --- a/modules/plugins/visuals/visuals.nix +++ b/modules/plugins/visuals/visuals.nix @@ -24,22 +24,6 @@ in { }; }; - cursorline = { - enable = mkEnableOption "line hightlighting on the cursor [nvim-cursorline]"; - - lineTimeout = mkOption { - type = int; - description = "Time in milliseconds for cursorline to appear"; - default = 0; - }; - - lineNumbersOnly = mkOption { - type = bool; - description = "Hightlight only in the presence of line numbers"; - default = true; - }; - }; - indentBlankline = { enable = mkEnableOption "indentation guides [indent-blankline]";