From 646da9d37a7c0497b568a333fa33b0d23344717f Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sun, 6 Oct 2024 16:03:21 +0200 Subject: [PATCH 01/14] Docs/map rewrite (#403) * doc: fix formatting * docs: update keymaps section --- docs/manual/hacking/keybinds.md | 27 ++++++++------------------- modules/neovim/mappings/options.nix | 4 ++-- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/docs/manual/hacking/keybinds.md b/docs/manual/hacking/keybinds.md index f4a51499..63a05d64 100644 --- a/docs/manual/hacking/keybinds.md +++ b/docs/manual/hacking/keybinds.md @@ -7,37 +7,26 @@ section contains a general overview to how you may utilize said functions. ## Custom Key Mappings Support for a Plugin {#sec-custom-key-mappings} -To set a mapping, you should define it in `vim.maps.<>`. -The available modes are: - -- normal -- insert -- select -- visual -- terminal -- normalVisualOp -- visualOnly -- operator -- insertCommand -- lang -- command +To set a mapping, you should define it in `vim.keymaps`. An example, simple keybinding, can look like this: ```nix { - vim.maps.normal = { - "wq" = { + vim.keymaps = [ + { + key = "wq"; + mode = ["n"]; action = ":wq"; silent = true; desc = "Save file and quit"; - }; - }; + } + ]; } ``` There are many settings available in the options. Please refer to the -[documentation](https://notashelf.github.io/nvf/options.html#opt-vim.maps.command._name_.action) +[documentation](https://notashelf.github.io/nvf/options.html#opt-vim.keymaps) to see a list of them. **nvf** provides a list of helper commands, so that you don't have to write the diff --git a/modules/neovim/mappings/options.nix b/modules/neovim/mappings/options.nix index f05de21b..8f0e8ebf 100644 --- a/modules/neovim/mappings/options.nix +++ b/modules/neovim/mappings/options.nix @@ -1,5 +1,5 @@ {lib, ...}: let - inherit (lib.options) mkOption; + inherit (lib.options) mkOption literalMD; inherit (lib.types) either str listOf attrsOf nullOr submodule; inherit (lib.nvim.config) mkBool; @@ -42,7 +42,7 @@ See `:help map-modes` for a list of modes. ''; - example = ''`["n" "v" "c"]` for normal, visual and command mode''; + example = literalMD ''`["n" "v" "c"]` for normal, visual and command mode''; }; }; }; From 47b5d51f5c184547090de9548e63801119edd2ed Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 6 Oct 2024 22:51:31 +0300 Subject: [PATCH 02/14] nvimWebDevicons: rename to nvim-web-devicons; switch to setupOpts --- modules/plugins/visuals/config.nix | 4 -- modules/plugins/visuals/default.nix | 6 ++- .../visuals/nvim-web-devicons/config.nix | 21 ++++++++ .../visuals/nvim-web-devicons/default.nix | 6 +++ .../nvim-web-devicons/nvim-web-devicons.nix | 48 +++++++++++++++++++ modules/plugins/visuals/visuals.nix | 2 - 6 files changed, 79 insertions(+), 8 deletions(-) create mode 100644 modules/plugins/visuals/nvim-web-devicons/config.nix create mode 100644 modules/plugins/visuals/nvim-web-devicons/default.nix create mode 100644 modules/plugins/visuals/nvim-web-devicons/nvim-web-devicons.nix diff --git a/modules/plugins/visuals/config.nix b/modules/plugins/visuals/config.nix index 1457ff3a..f8904d9b 100644 --- a/modules/plugins/visuals/config.nix +++ b/modules/plugins/visuals/config.nix @@ -31,10 +31,6 @@ in { ''; }) - (mkIf cfg.nvimWebDevicons.enable { - vim.startPlugins = ["nvim-web-devicons"]; - }) - (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 3c977cba..c096d651 100644 --- a/modules/plugins/visuals/default.nix +++ b/modules/plugins/visuals/default.nix @@ -1,7 +1,9 @@ -{...}: { +{ imports = [ + ./fidget + ./nvim-web-devicons + ./config.nix ./visuals.nix - ./fidget ]; } diff --git a/modules/plugins/visuals/nvim-web-devicons/config.nix b/modules/plugins/visuals/nvim-web-devicons/config.nix new file mode 100644 index 00000000..9c8e9418 --- /dev/null +++ b/modules/plugins/visuals/nvim-web-devicons/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-web-devicons; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = ["nvim-web-devicons"]; + + pluginRC.nvim-web-devicons = entryAnywhere '' + require("nvim-web-devicons").setup(${toLuaObject cfg.setupOpts}) + ''; + }; + }; +} diff --git a/modules/plugins/visuals/nvim-web-devicons/default.nix b/modules/plugins/visuals/nvim-web-devicons/default.nix new file mode 100644 index 00000000..57a3dbc1 --- /dev/null +++ b/modules/plugins/visuals/nvim-web-devicons/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.nix + ./nvim-web-devicons.nix + ]; +} diff --git a/modules/plugins/visuals/nvim-web-devicons/nvim-web-devicons.nix b/modules/plugins/visuals/nvim-web-devicons/nvim-web-devicons.nix new file mode 100644 index 00000000..f88dfaf1 --- /dev/null +++ b/modules/plugins/visuals/nvim-web-devicons/nvim-web-devicons.nix @@ -0,0 +1,48 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkRenamedOptionModule; + inherit (lib.options) mkEnableOption mkOption literalExpression; + inherit (lib.types) nullOr attrsOf attrs enum; + inherit (lib.nvim.types) mkPluginSetupOption; +in { + imports = [ + (mkRenamedOptionModule ["vim" "visuals" "nvimWebDevicons"] ["vim" "visuals" "nvim-web-devicons"]) + ]; + + options.vim.visuals.nvim-web-devicons = { + enable = mkEnableOption "Neovim dev icons [nvim-web-devicons]"; + + setupOpts = mkPluginSetupOption "nvim-web-devicons" { + color_icons = mkEnableOption "different highlight colors per icon"; + variant = mkOption { + type = nullOr (enum ["light" "dark"]); + default = null; + description = "Set the light or dark variant manually, instead of relying on `background`"; + }; + + override = mkOption { + type = attrsOf attrs; + default = {}; + example = literalExpression '' + { + zsh = { + name = "Zsh"; + icon = ""; + color = "#428850"; + cterm_color = "65"; + }; + } + ''; + description = '' + Your personal icon overrides. + + You can specify color or cterm_color instead of specifying + both of them. DevIcon will be appended to `name` + ''; + }; + }; + }; +} diff --git a/modules/plugins/visuals/visuals.nix b/modules/plugins/visuals/visuals.nix index d3cfac1c..07c2f5d0 100644 --- a/modules/plugins/visuals/visuals.nix +++ b/modules/plugins/visuals/visuals.nix @@ -12,8 +12,6 @@ in { options.vim.visuals = { enable = mkEnableOption "Visual enhancements."; - nvimWebDevicons.enable = mkEnableOption "dev icons. Required for certain plugins [nvim-web-devicons]."; - scrollBar.enable = mkEnableOption "scrollbar [scrollbar.nvim]"; smoothScroll.enable = mkEnableOption "smooth scrolling [cinnamon-nvim]"; From db54345de1547adaa497790648c5a04e955541a5 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 6 Oct 2024 23:48:12 +0300 Subject: [PATCH 03/14] 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 f8904d9b..851762a1 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 c096d651..66ff44b9 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 00000000..b1f1bab8 --- /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 00000000..b09014dd --- /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 00000000..17d937c5 --- /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 f88dfaf1..7883486c 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 07c2f5d0..450f6e91 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]"; From 95b09bc3a4def0f743c21f0e56b208a6f043d8ad Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 7 Oct 2024 00:30:18 +0300 Subject: [PATCH 04/14] 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"; + }; + }; + }; +} From 781fde66a9a9c5743cd02f4eef322ac4c092ae81 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 7 Oct 2024 01:06:52 +0300 Subject: [PATCH 05/14] visuals: move indent-blankline to its own module --- modules/plugins/visuals/config.nix | 7 - modules/plugins/visuals/default.nix | 1 + .../visuals/indent-blankline/config.nix | 21 ++ .../visuals/indent-blankline/default.nix | 6 + .../indent-blankline/indent-blankline.nix | 195 ++++++++++++++++++ modules/plugins/visuals/visuals.nix | 183 ---------------- 6 files changed, 223 insertions(+), 190 deletions(-) create mode 100644 modules/plugins/visuals/indent-blankline/config.nix create mode 100644 modules/plugins/visuals/indent-blankline/default.nix create mode 100644 modules/plugins/visuals/indent-blankline/indent-blankline.nix diff --git a/modules/plugins/visuals/config.nix b/modules/plugins/visuals/config.nix index 783a4cab..7fca2407 100644 --- a/modules/plugins/visuals/config.nix +++ b/modules/plugins/visuals/config.nix @@ -12,13 +12,6 @@ cfg = config.vim.visuals; in { config = mkIf cfg.enable (mkMerge [ - (mkIf cfg.indentBlankline.enable { - vim.startPlugins = ["indent-blankline"]; - vim.pluginRC.indent-blankline = entryAnywhere '' - require("ibl").setup(${toLuaObject cfg.indentBlankline.setupOpts}) - ''; - }) - (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 7b15341d..2c69947f 100644 --- a/modules/plugins/visuals/default.nix +++ b/modules/plugins/visuals/default.nix @@ -1,6 +1,7 @@ { imports = [ ./fidget + ./indent-blankline ./nvim-cursorline ./nvim-scrollbar ./nvim-web-devicons diff --git a/modules/plugins/visuals/indent-blankline/config.nix b/modules/plugins/visuals/indent-blankline/config.nix new file mode 100644 index 00000000..581bd136 --- /dev/null +++ b/modules/plugins/visuals/indent-blankline/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.indent-blankline; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = ["indent-blankline"]; + + pluginRC.indent-blankline = entryAnywhere '' + require("ibl").setup(${toLuaObject cfg.setupOpts}) + ''; + }; + }; +} diff --git a/modules/plugins/visuals/indent-blankline/default.nix b/modules/plugins/visuals/indent-blankline/default.nix new file mode 100644 index 00000000..57ebc6ac --- /dev/null +++ b/modules/plugins/visuals/indent-blankline/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.nix + ./indent-blankline.nix + ]; +} diff --git a/modules/plugins/visuals/indent-blankline/indent-blankline.nix b/modules/plugins/visuals/indent-blankline/indent-blankline.nix new file mode 100644 index 00000000..ff9bccc7 --- /dev/null +++ b/modules/plugins/visuals/indent-blankline/indent-blankline.nix @@ -0,0 +1,195 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkRenamedOptionModule; + inherit (lib.options) mkOption mkEnableOption literalExpression; + inherit (lib.types) int bool str nullOr either listOf attrsOf; + + cfg = config.vim.visuals; +in { + imports = [ + (mkRenamedOptionModule ["vim" "visuals" "indentBlankline"] ["vim" "visuals" "indent-blankline"]) + ]; + + options.vim.visuals.indent-blankline = { + enable = mkEnableOption "indentation guides [indent-blankline]"; + setupOpts = { + debounce = mkOption { + type = int; + description = "Debounce time in milliseconds"; + default = 200; + }; + + viewport_buffer = { + min = mkOption { + type = int; + description = "Number of lines above and below of what is currently + visible in the window"; + default = 30; + }; + + max = mkOption { + type = int; + description = "Number of lines above and below of what is currently + visible in the window"; + default = 500; + }; + }; + + indent = { + char = mkOption { + type = either str (listOf str); + description = "Character(s) for indentation guide"; + default = "│"; + }; + + tab_char = mkOption { + type = nullOr (either str (listOf str)); + description = '' + Character(s) for tab indentation guide. + + See `:help ibl.config.indent.tab_char`. + ''; + default = null; + }; + + highlight = mkOption { + type = nullOr (either str (listOf str)); + description = '' + The highlight group(s) applied to the indentation guide. + + See `:help ibl.config.indent.highlight`. + ''; + default = null; + }; + + smart_indent_cap = mkOption { + type = bool; + description = "Caps the number of indentation levels based on surrounding code"; + default = true; + }; + + priority = mkOption { + type = int; + description = "Virtual text priority for the indentation guide"; + default = 1; + }; + + repeat_linebreak = mkOption { + type = bool; + description = "Repeat indentation guides on wrapped lines"; + default = true; + }; + }; + + whitespace = { + highlight = mkOption { + type = nullOr (either str (listOf str)); + description = '' + The highlight group(s) applied to whitespace. + + See `:help ibl.config.whitespace.highlight`. + ''; + default = null; + }; + + remove_blankline_trail = mkOption { + type = bool; + description = "Remove trailing whitespace on blanklines"; + default = true; + }; + }; + + scope = { + enabled = mkOption { + description = "Highlight current scope from treesitter"; + type = bool; + default = config.vim.treesitter.enable; + defaultText = literalExpression "config.vim.treesitter.enable"; + }; + + char = mkOption { + type = either str (listOf str); + description = "The character(s) for the scope indentation guide"; + default = cfg.indent-blankline.setupOpts.indent.char; + defaultText = literalExpression "config.vim.visuals.indent-blankline.setupOpts.indent.char"; + }; + + show_start = mkOption { + type = bool; + description = "Show an underline on the first line of the scope"; + default = false; + }; + + show_end = mkOption { + type = bool; + description = "Show an underline on the last line of the scope"; + default = false; + }; + + show_exact_scope = mkOption { + type = bool; + description = "Show the scope underline at the exact start of the scope, even if that's to the right of the indentation guide"; + default = false; + }; + + injected_languages = mkOption { + type = bool; + description = "Check for injected languages (treesitter)"; + default = config.vim.treesitter.enable; + defaultText = literalExpression "config.vim.treesitter.enable"; + }; + + highlight = mkOption { + type = nullOr (either str (listOf str)); + description = '' + The highlight group(s) applied to the scope. + + See `:help `ibl.config.scope.highlight`. + ''; + default = null; + }; + + priority = mkOption { + type = int; + description = "Virtual text priority for the scope"; + default = 1024; + }; + + include.node_type = mkOption { + type = attrsOf (listOf str); + description = "Additional nodes to be used for scope checking, per language"; + default = {}; + }; + + exclude = { + language = mkOption { + type = listOf str; + description = '' + The list of treesitter languages to disable scope for. + + `*` can be used as a wildcard for every language/node type. + ''; + default = []; + }; + + node_type = mkOption { + type = attrsOf (listOf str); + description = '' + Nodes to ignore in scope checking, per language. + + `*` can be used as a wildcard for every language. + ''; + default = { + "*" = ["source_file" "program"]; + lua = ["chunk"]; + python = ["module"]; + }; + }; + }; + }; + }; + }; +} diff --git a/modules/plugins/visuals/visuals.nix b/modules/plugins/visuals/visuals.nix index 450f6e91..0e7b357f 100644 --- a/modules/plugins/visuals/visuals.nix +++ b/modules/plugins/visuals/visuals.nix @@ -12,8 +12,6 @@ in { options.vim.visuals = { enable = mkEnableOption "Visual enhancements."; - scrollBar.enable = mkEnableOption "scrollbar [scrollbar.nvim]"; - smoothScroll.enable = mkEnableOption "smooth scrolling [cinnamon-nvim]"; cellularAutomaton = { @@ -24,187 +22,6 @@ in { }; }; - indentBlankline = { - enable = mkEnableOption "indentation guides [indent-blankline]"; - - setupOpts = { - debounce = mkOption { - type = int; - description = "Debounce time in milliseconds"; - default = 200; - }; - - viewport_buffer = { - min = mkOption { - type = int; - description = "Number of lines above and below of what is currently - visible in the window"; - default = 30; - }; - - max = mkOption { - type = int; - description = "Number of lines above and below of what is currently - visible in the window"; - default = 500; - }; - }; - - indent = { - char = mkOption { - type = either str (listOf str); - description = "Character(s) for indentation guide"; - default = "│"; - }; - - tab_char = mkOption { - type = nullOr (either str (listOf str)); - description = '' - Character(s) for tab indentation guide. - - See `:help ibl.config.indent.tab_char`. - ''; - default = null; - }; - - highlight = mkOption { - type = nullOr (either str (listOf str)); - description = '' - The highlight group(s) applied to the indentation guide. - - See `:help ibl.config.indent.highlight`. - ''; - default = null; - }; - - smart_indent_cap = mkOption { - type = bool; - description = "Caps the number of indentation levels based on surrounding code"; - default = true; - }; - - priority = mkOption { - type = int; - description = "Virtual text priority for the indentation guide"; - default = 1; - }; - - repeat_linebreak = mkOption { - type = bool; - description = "Repeat indentation guides on wrapped lines"; - default = true; - }; - }; - - whitespace = { - highlight = mkOption { - type = nullOr (either str (listOf str)); - description = '' - The highlight group(s) applied to whitespace. - - See `:help ibl.config.whitespace.highlight`. - ''; - default = null; - }; - - remove_blankline_trail = mkOption { - type = bool; - description = "Remove trailing whitespace on blanklines"; - default = true; - }; - }; - - scope = { - enabled = mkOption { - description = "Highlight current scope from treesitter"; - type = bool; - default = config.vim.treesitter.enable; - defaultText = literalExpression "config.vim.treesitter.enable"; - }; - - char = mkOption { - type = either str (listOf str); - description = "The character(s) for the scope indentation guide"; - default = cfg.indentBlankline.setupOpts.indent.char; - defaultText = literalExpression "config.vim.visuals.indentBlankline.setuopOpts.indent.char"; - }; - - show_start = mkOption { - type = bool; - description = "Show an underline on the first line of the scope"; - default = false; - }; - - show_end = mkOption { - type = bool; - description = "Show an underline on the last line of the scope"; - default = false; - }; - - show_exact_scope = mkOption { - type = bool; - description = "Show the scope underline at the exact start of the scope, even if that's to the right of the indentation guide"; - default = false; - }; - - injected_languages = mkOption { - type = bool; - description = "Check for injected languages (treesitter)"; - default = config.vim.treesitter.enable; - defaultText = literalExpression "config.vim.treesitter.enable"; - }; - - highlight = mkOption { - type = nullOr (either str (listOf str)); - description = '' - The highlight group(s) applied to the scope. - - See `:help `ibl.config.scope.highlight`. - ''; - default = null; - }; - - priority = mkOption { - type = int; - description = "Virtual text priority for the scope"; - default = 1024; - }; - - include.node_type = mkOption { - type = attrsOf (listOf str); - description = "Additional nodes to be used for scope checking, per language"; - default = {}; - }; - - exclude = { - language = mkOption { - type = listOf str; - description = '' - The list of treesitter languages to disable scope for. - - `*` can be used as a wildcard for every language/node type. - ''; - default = []; - }; - - node_type = mkOption { - type = attrsOf (listOf str); - description = '' - Nodes to ignore in scope checking, per language. - - `*` can be used as a wildcard for every language. - ''; - default = { - "*" = ["source_file" "program"]; - lua = ["chunk"]; - python = ["module"]; - }; - }; - }; - }; - }; - }; - highlight-undo = { enable = mkEnableOption "highlight undo [highlight-undo]"; From 688a41b621623f11d03e873e63359ef4afff41a2 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 7 Oct 2024 01:31:10 +0300 Subject: [PATCH 06/14] visuals: rename fidget to fidget-nvim This matches the naming convention in the fidget module options. --- modules/plugins/visuals/{fidget => fidget-nvim}/config.nix | 0 modules/plugins/visuals/{fidget => fidget-nvim}/default.nix | 0 modules/plugins/visuals/{fidget => fidget-nvim}/fidget.nix | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename modules/plugins/visuals/{fidget => fidget-nvim}/config.nix (100%) rename modules/plugins/visuals/{fidget => fidget-nvim}/default.nix (100%) rename modules/plugins/visuals/{fidget => fidget-nvim}/fidget.nix (100%) diff --git a/modules/plugins/visuals/fidget/config.nix b/modules/plugins/visuals/fidget-nvim/config.nix similarity index 100% rename from modules/plugins/visuals/fidget/config.nix rename to modules/plugins/visuals/fidget-nvim/config.nix diff --git a/modules/plugins/visuals/fidget/default.nix b/modules/plugins/visuals/fidget-nvim/default.nix similarity index 100% rename from modules/plugins/visuals/fidget/default.nix rename to modules/plugins/visuals/fidget-nvim/default.nix diff --git a/modules/plugins/visuals/fidget/fidget.nix b/modules/plugins/visuals/fidget-nvim/fidget.nix similarity index 100% rename from modules/plugins/visuals/fidget/fidget.nix rename to modules/plugins/visuals/fidget-nvim/fidget.nix From 658d38023280ff79293800a8bb0e5cd47d855630 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 7 Oct 2024 01:31:54 +0300 Subject: [PATCH 07/14] visuals: move cinnamon-nvim to its own module; deprecate smoothScroll The option visuals.smoothScroll was confusing as there can be more than one backend. --- .../visuals/cinnamon-nvim/cinnamon-nvim.nix | 38 +++++++++++++++++++ .../plugins/visuals/cinnamon-nvim/config.nix | 21 ++++++++++ .../plugins/visuals/cinnamon-nvim/default.nix | 6 +++ modules/plugins/visuals/default.nix | 3 +- modules/plugins/visuals/visuals.nix | 6 +-- 5 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 modules/plugins/visuals/cinnamon-nvim/cinnamon-nvim.nix create mode 100644 modules/plugins/visuals/cinnamon-nvim/config.nix create mode 100644 modules/plugins/visuals/cinnamon-nvim/default.nix diff --git a/modules/plugins/visuals/cinnamon-nvim/cinnamon-nvim.nix b/modules/plugins/visuals/cinnamon-nvim/cinnamon-nvim.nix new file mode 100644 index 00000000..1d3ee7f5 --- /dev/null +++ b/modules/plugins/visuals/cinnamon-nvim/cinnamon-nvim.nix @@ -0,0 +1,38 @@ +{lib, ...}: let + inherit (lib.modules) mkRemovedOptionModule; + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) submodule attrs; + inherit (lib.nvim.types) mkPluginSetupOption; +in { + imports = [ + (mkRemovedOptionModule ["vim" "visuals" "smoothScroll"] '' + `vim.visuals.smoothScroll` has been removed. You may consider enabling the + option `vim.visuals.cinnamon-nvim` to repliace previous smooth scrolling + behaviour. + '') + ]; + + options.vim.visuals.cinnamon-nvim = { + enable = mkEnableOption "smooth scrolling for ANY command [cinnamon-nvim]"; + setupOpts = mkPluginSetupOption "cinnamon.nvim" { + options = mkOption { + type = attrs; + default = { + # Defaults provided for the sake of documentation only! + # Who would've guessed setupOpts.options would be confusing? + mode = "cursor"; + count_only = false; + }; + description = "Scroll options"; + }; + + keymaps = mkOption { + description = "Keymap options for Cinnamon. Please see documentation before enablg"; + type = submodule { + basic = mkEnableOption "basic animation keymaps"; + extra = mkEnableOption "extra animation keymaps"; + }; + }; + }; + }; +} diff --git a/modules/plugins/visuals/cinnamon-nvim/config.nix b/modules/plugins/visuals/cinnamon-nvim/config.nix new file mode 100644 index 00000000..8e420221 --- /dev/null +++ b/modules/plugins/visuals/cinnamon-nvim/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.cinnamon-nvim; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = ["cinnamon-nvim"]; + + pluginRC.cursorline = entryAnywhere '' + require("cinnamon").setup(${toLuaObject cfg.setupOpts}) + ''; + }; + }; +} diff --git a/modules/plugins/visuals/cinnamon-nvim/default.nix b/modules/plugins/visuals/cinnamon-nvim/default.nix new file mode 100644 index 00000000..29ced8e8 --- /dev/null +++ b/modules/plugins/visuals/cinnamon-nvim/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.nix + ./cinnamon-nvim.nix + ]; +} diff --git a/modules/plugins/visuals/default.nix b/modules/plugins/visuals/default.nix index 2c69947f..57eb3295 100644 --- a/modules/plugins/visuals/default.nix +++ b/modules/plugins/visuals/default.nix @@ -1,6 +1,7 @@ { imports = [ - ./fidget + ./cinnamon-nvim + ./fidget-nvim ./indent-blankline ./nvim-cursorline ./nvim-scrollbar diff --git a/modules/plugins/visuals/visuals.nix b/modules/plugins/visuals/visuals.nix index 0e7b357f..8ce416db 100644 --- a/modules/plugins/visuals/visuals.nix +++ b/modules/plugins/visuals/visuals.nix @@ -3,8 +3,8 @@ lib, ... }: let - inherit (lib.options) mkEnableOption mkOption literalExpression; - inherit (lib.types) int bool str nullOr either listOf attrsOf; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) int bool str; inherit (lib.nvim.binds) mkMappingOption; cfg = config.vim.visuals; @@ -12,8 +12,6 @@ in { options.vim.visuals = { enable = mkEnableOption "Visual enhancements."; - smoothScroll.enable = mkEnableOption "smooth scrolling [cinnamon-nvim]"; - cellularAutomaton = { enable = mkEnableOption "cellular automaton [cellular-automaton]"; From b4de3442532f68a58a9b472203f749a69cbb1efe Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 7 Oct 2024 01:56:29 +0300 Subject: [PATCH 08/14] cinnamon-nvim: get rid of submodule in setupOpts --- .../plugins/visuals/cinnamon-nvim/cinnamon-nvim.nix | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/modules/plugins/visuals/cinnamon-nvim/cinnamon-nvim.nix b/modules/plugins/visuals/cinnamon-nvim/cinnamon-nvim.nix index 1d3ee7f5..109b06f0 100644 --- a/modules/plugins/visuals/cinnamon-nvim/cinnamon-nvim.nix +++ b/modules/plugins/visuals/cinnamon-nvim/cinnamon-nvim.nix @@ -1,7 +1,7 @@ {lib, ...}: let inherit (lib.modules) mkRemovedOptionModule; inherit (lib.options) mkOption mkEnableOption; - inherit (lib.types) submodule attrs; + inherit (lib.types) submodule attrs attrsOf; inherit (lib.nvim.types) mkPluginSetupOption; in { imports = [ @@ -26,12 +26,9 @@ in { description = "Scroll options"; }; - keymaps = mkOption { - description = "Keymap options for Cinnamon. Please see documentation before enablg"; - type = submodule { - basic = mkEnableOption "basic animation keymaps"; - extra = mkEnableOption "extra animation keymaps"; - }; + keymaps = { + basic = mkEnableOption "basic animation keymaps"; + extra = mkEnableOption "extra animation keymaps"; }; }; }; From ccd0582d09dbbda4cf81c003794921d4ca61efe2 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 7 Oct 2024 02:10:20 +0300 Subject: [PATCH 09/14] visuals: move cellular-automaton to its own module Scuffed impl. --- .../cellular-automaton/cellular-automaton.nix | 60 +++++++++++++++++++ .../visuals/cellular-automaton/config.nix | 39 ++++++++++++ .../visuals/cellular-automaton/default.nix | 6 ++ modules/plugins/visuals/config.nix | 31 ---------- modules/plugins/visuals/default.nix | 1 + modules/plugins/visuals/visuals.nix | 9 --- 6 files changed, 106 insertions(+), 40 deletions(-) create mode 100644 modules/plugins/visuals/cellular-automaton/cellular-automaton.nix create mode 100644 modules/plugins/visuals/cellular-automaton/config.nix create mode 100644 modules/plugins/visuals/cellular-automaton/default.nix diff --git a/modules/plugins/visuals/cellular-automaton/cellular-automaton.nix b/modules/plugins/visuals/cellular-automaton/cellular-automaton.nix new file mode 100644 index 00000000..6d432e7b --- /dev/null +++ b/modules/plugins/visuals/cellular-automaton/cellular-automaton.nix @@ -0,0 +1,60 @@ +{lib, ...}: let + inherit (lib.modules) mkRenamedOptionModule; + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.nvim.types) luaInline; + inherit (lib.nvim.binds) mkMappingOption; + inherit (lib.generators) mkLuaInline; +in { + imports = [ + (mkRenamedOptionModule ["vim" "visuals" "cellularAutomaton"] ["vim" "visuals" "cellular-automaton"]) + ]; + + options.vim.visuals.cellular-automaton = { + enable = mkEnableOption "cellular-automaton to help you cope with stubborn code [cellular-automaton]"; + + mappings = { + makeItRain = mkMappingOption "Make it rain [cellular-automaton]" "fml"; + }; + + animation = { + register = mkEnableOption "registering configured animation(s) automatically" // {default = true;}; + setup = mkOption { + type = luaInline; + default = mkLuaInline '' + local ca_config = { + fps = 50, + name = 'slide', + } + + -- init function is invoked only once at the start + -- config.init = function (grid) + -- + -- end + + -- update function + ca_config.update = function (grid) + for i = 1, #grid do + local prev = grid[i][#(grid[i])] + for j = 1, #(grid[i]) do + grid[i][j], prev = prev, grid[i][j] + end + end + return true + end + ''; + description = '' + Configuration used to generate an animation to be registered. + + The final value for `ca_config` will be used to register a new + animation using `require("cellular-automaton").register_animation(ca_config)` + + ::: {.warning} + `ca_config` **must** eval to a valid Lua table. nvf does not and cannot + perform any kind of validation on your Lua code, so bogus values will + result in errors when the animation is registered. + ::: + ''; + }; + }; + }; +} diff --git a/modules/plugins/visuals/cellular-automaton/config.nix b/modules/plugins/visuals/cellular-automaton/config.nix new file mode 100644 index 00000000..2c0c4669 --- /dev/null +++ b/modules/plugins/visuals/cellular-automaton/config.nix @@ -0,0 +1,39 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.strings) optionalString; + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.nvim.dag) entryAnywhere entryAfter; + inherit (lib.nvim.binds) mkBinding; + + cfg = config.vim.visuals.cellular-automaton; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = ["cellular-automaton"]; + + maps.normal = mkBinding cfg.mappings.makeItRain "CellularAutomaton make_it_rain" "Make it rain"; + + pluginRC = { + # XXX: This has no error handling. User can set + # `animation.setup` to a bogus value, and we would + # have an error in our hands. I don't think there + # is a good way to check for errors, so I'm leaving + # it like this under the assumption that the user + # will not mess it up for no reason. + cellular-automaton-anim = entryAnywhere (optionalString cfg.animation.register '' + -- Coerce user animation config into pluginRC + ${toLuaObject cfg.animation.setup} + ''); + + cellular-automaton = entryAfter ["cellular-automaton-anim"] '' + -- Register the animation + require("cellular-automaton").register_animation(ca_config) + ''; + }; + }; + }; +} diff --git a/modules/plugins/visuals/cellular-automaton/default.nix b/modules/plugins/visuals/cellular-automaton/default.nix new file mode 100644 index 00000000..4bb43af7 --- /dev/null +++ b/modules/plugins/visuals/cellular-automaton/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.nix + ./cellular-automaton.nix + ]; +} diff --git a/modules/plugins/visuals/config.nix b/modules/plugins/visuals/config.nix index 7fca2407..79222fbe 100644 --- a/modules/plugins/visuals/config.nix +++ b/modules/plugins/visuals/config.nix @@ -19,37 +19,6 @@ in { ''; }) - (mkIf cfg.cellularAutomaton.enable { - vim.startPlugins = ["cellular-automaton"]; - - vim.maps.normal = mkBinding cfg.cellularAutomaton.mappings.makeItRain "CellularAutomaton make_it_rain" "Make it rain"; - - vim.pluginRC.cellularAUtomaton = entryAnywhere '' - local config = { - fps = 50, - name = 'slide', - } - - -- init function is invoked only once at the start - -- config.init = function (grid) - -- - -- end - - -- update function - config.update = function (grid) - for i = 1, #grid do - local prev = grid[i][#(grid[i])] - for j = 1, #(grid[i]) do - grid[i][j], prev = prev, grid[i][j] - end - end - return true - end - - require("cellular-automaton").register_animation(config) - ''; - }) - (mkIf cfg.highlight-undo.enable { vim.startPlugins = ["highlight-undo"]; vim.pluginRC.highlight-undo = entryAnywhere '' diff --git a/modules/plugins/visuals/default.nix b/modules/plugins/visuals/default.nix index 57eb3295..2fecef28 100644 --- a/modules/plugins/visuals/default.nix +++ b/modules/plugins/visuals/default.nix @@ -1,5 +1,6 @@ { imports = [ + ./cellular-automaton ./cinnamon-nvim ./fidget-nvim ./indent-blankline diff --git a/modules/plugins/visuals/visuals.nix b/modules/plugins/visuals/visuals.nix index 8ce416db..90558ac1 100644 --- a/modules/plugins/visuals/visuals.nix +++ b/modules/plugins/visuals/visuals.nix @@ -5,21 +5,12 @@ }: let inherit (lib.options) mkEnableOption mkOption; inherit (lib.types) int bool str; - inherit (lib.nvim.binds) mkMappingOption; cfg = config.vim.visuals; in { options.vim.visuals = { enable = mkEnableOption "Visual enhancements."; - cellularAutomaton = { - enable = mkEnableOption "cellular automaton [cellular-automaton]"; - - mappings = { - makeItRain = mkMappingOption "Make it rain [cellular-automaton]" "fml"; - }; - }; - highlight-undo = { enable = mkEnableOption "highlight undo [highlight-undo]"; From dad69f8af9bac7232c9b8dd19b554804009826b3 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 7 Oct 2024 02:59:33 +0300 Subject: [PATCH 10/14] visuals/nvim-cursorline: also modify option name to match module dir --- modules/plugins/visuals/nvim-cursorline/config.nix | 4 ++-- .../visuals/nvim-cursorline/nvim-cursorline.nix | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/plugins/visuals/nvim-cursorline/config.nix b/modules/plugins/visuals/nvim-cursorline/config.nix index b1f1bab8..487c9af4 100644 --- a/modules/plugins/visuals/nvim-cursorline/config.nix +++ b/modules/plugins/visuals/nvim-cursorline/config.nix @@ -7,13 +7,13 @@ inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.dag) entryAnywhere; - cfg = config.vim.visuals.cursorline; + cfg = config.vim.visuals.nvim-cursorline; in { config = mkIf cfg.enable { vim = { startPlugins = ["nvim-cursorline"]; - pluginRC.cursorline = entryAnywhere '' + pluginRC.nvim-cursorline = entryAnywhere '' require("nvim-cursorline").setup(${toLuaObject cfg.setupOpts}) ''; }; diff --git a/modules/plugins/visuals/nvim-cursorline/nvim-cursorline.nix b/modules/plugins/visuals/nvim-cursorline/nvim-cursorline.nix index 17d937c5..5aacc368 100644 --- a/modules/plugins/visuals/nvim-cursorline/nvim-cursorline.nix +++ b/modules/plugins/visuals/nvim-cursorline/nvim-cursorline.nix @@ -5,15 +5,16 @@ 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. + (mkRenamedOptionModule ["vim" "visuals" "cursorline"] ["vim" "visuals" "nvim-cursorline"]) + (mkRenamedOptionModule ["vim" "visuals" "nvim-cursorline" "lineTimeout"] ["vim" "visuals" "nvim-cursorline" "setupOpts" "line_timeout"]) + (mkRemovedOptionModule ["vim" "visuals" "nvim-cursorline" "lineNumbersOnly"] '' + `vim.visuals.nvim-cursorline.lineNumbersOnly` has been removed. Use `vim.visuals.nvim-cursorline.number` instead. '') ]; - options.vim.visuals.cursorline = { + options.vim.visuals.nvim-cursorline = { enable = mkEnableOption "cursor word and line highlighting [nvim-cursorline]"; - setupOpts = mkPluginSetupOption "cursorline" { + setupOpts = mkPluginSetupOption "nvim-cursorline" { cursorline = { enable = mkEnableOption "cursor line highlighting"; timeout = mkOption { From 901038145d8b10de73732fb4888902a20580a5ae Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 7 Oct 2024 03:00:01 +0300 Subject: [PATCH 11/14] visuals: move highlight-undo to its own module; deprecate old opts Upstream cucked us. --- modules/plugins/visuals/config.nix | 47 ------------------ modules/plugins/visuals/default.nix | 13 +++-- .../plugins/visuals/highlight-undo/config.nix | 21 ++++++++ .../visuals/highlight-undo/default.nix | 6 +++ .../visuals/highlight-undo/highlight-undo.nix | 32 ++++++++++++ modules/plugins/visuals/visuals.nix | 49 ------------------- 6 files changed, 68 insertions(+), 100 deletions(-) delete mode 100644 modules/plugins/visuals/config.nix create mode 100644 modules/plugins/visuals/highlight-undo/config.nix create mode 100644 modules/plugins/visuals/highlight-undo/default.nix create mode 100644 modules/plugins/visuals/highlight-undo/highlight-undo.nix delete mode 100644 modules/plugins/visuals/visuals.nix diff --git a/modules/plugins/visuals/config.nix b/modules/plugins/visuals/config.nix deleted file mode 100644 index 79222fbe..00000000 --- a/modules/plugins/visuals/config.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ - config, - lib, - ... -}: let - inherit (lib.modules) mkIf mkMerge; - inherit (lib.trivial) boolToString; - inherit (lib.nvim.binds) mkBinding; - inherit (lib.nvim.dag) entryAnywhere; - inherit (lib.nvim.lua) toLuaObject; - - cfg = config.vim.visuals; -in { - config = mkIf cfg.enable (mkMerge [ - (mkIf cfg.smoothScroll.enable { - vim.startPlugins = ["cinnamon-nvim"]; - vim.pluginRC.smoothScroll = entryAnywhere '' - require('cinnamon').setup() - ''; - }) - - (mkIf cfg.highlight-undo.enable { - vim.startPlugins = ["highlight-undo"]; - vim.pluginRC.highlight-undo = entryAnywhere '' - require('highlight-undo').setup({ - duration = ${toString cfg.highlight-undo.duration}, - highlight_for_count = ${boolToString cfg.highlight-undo.highlightForCount}, - undo = { - hlgroup = ${cfg.highlight-undo.undo.hlGroup}, - mode = 'n', - lhs = 'u', - map = 'undo', - opts = {} - }, - - redo = { - hlgroup = ${cfg.highlight-undo.redo.hlGroup}, - mode = 'n', - lhs = '', - map = 'redo', - opts = {} - }, - }) - ''; - }) - ]); -} diff --git a/modules/plugins/visuals/default.nix b/modules/plugins/visuals/default.nix index 2fecef28..7b413c30 100644 --- a/modules/plugins/visuals/default.nix +++ b/modules/plugins/visuals/default.nix @@ -1,14 +1,19 @@ -{ +{lib, ...}: let + inherit (lib.modules) mkRemovedOptionModule; +in { imports = [ + (mkRemovedOptionModule ["vim" "visuals" "enable"] '' + As top-level toggles are being deprecated, you are encouraged + to handle plugin toggles under individual options. + '') + ./cellular-automaton ./cinnamon-nvim ./fidget-nvim + ./highlight-undo ./indent-blankline ./nvim-cursorline ./nvim-scrollbar ./nvim-web-devicons - - ./config.nix - ./visuals.nix ]; } diff --git a/modules/plugins/visuals/highlight-undo/config.nix b/modules/plugins/visuals/highlight-undo/config.nix new file mode 100644 index 00000000..d41c6a69 --- /dev/null +++ b/modules/plugins/visuals/highlight-undo/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.highlight-undo; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = ["highlight-undo"]; + + pluginRC.highlight-undo = entryAnywhere '' + require("highlight-undo").setup(${toLuaObject cfg.setupOpts}) + ''; + }; + }; +} diff --git a/modules/plugins/visuals/highlight-undo/default.nix b/modules/plugins/visuals/highlight-undo/default.nix new file mode 100644 index 00000000..b8624889 --- /dev/null +++ b/modules/plugins/visuals/highlight-undo/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.nix + ./highlight-undo.nix + ]; +} diff --git a/modules/plugins/visuals/highlight-undo/highlight-undo.nix b/modules/plugins/visuals/highlight-undo/highlight-undo.nix new file mode 100644 index 00000000..fc5d7226 --- /dev/null +++ b/modules/plugins/visuals/highlight-undo/highlight-undo.nix @@ -0,0 +1,32 @@ +{lib, ...}: let + inherit (lib.modules) mkRemovedOptionModule; + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) int; + inherit (lib.nvim.types) mkPluginSetupOption; + + checkDocsMsg = '' + highlight-undo.nvim has deprecated previously used configuration options in + a recent update, so previous values will no longer work as expected. + + Please use `vim.visuals.highlight-undo.setupOpts` with upstream instructions + ''; +in { + imports = [ + # This gives a lot of error messages for those with default values set or modified. Could + # there be a better way to handle his? Perhaps an assertion? + (mkRemovedOptionModule ["vim" "visuals" "highlight-undo" "highlightForCount"] checkDocsMsg) + (mkRemovedOptionModule ["vim" "visuals" "highlight-undo" "undo" "hlGroup"] checkDocsMsg) + (mkRemovedOptionModule ["vim" "visuals" "highlight-undo" "redo" "hlGroup"] checkDocsMsg) + ]; + + options.vim.visuals.highlight-undo = { + enable = mkEnableOption "highlight undo [highlight-undo]"; + setupOpts = mkPluginSetupOption "highlight-undo" { + duration = mkOption { + type = int; + default = 500; + description = "Duration of the highlight"; + }; + }; + }; +} diff --git a/modules/plugins/visuals/visuals.nix b/modules/plugins/visuals/visuals.nix deleted file mode 100644 index 90558ac1..00000000 --- a/modules/plugins/visuals/visuals.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ - config, - lib, - ... -}: let - inherit (lib.options) mkEnableOption mkOption; - inherit (lib.types) int bool str; - - cfg = config.vim.visuals; -in { - options.vim.visuals = { - enable = mkEnableOption "Visual enhancements."; - - highlight-undo = { - enable = mkEnableOption "highlight undo [highlight-undo]"; - - highlightForCount = mkOption { - type = bool; - default = true; - description = '' - Enable support for highlighting when a is provided before the key - If set to false it will only highlight when the mapping is not prefixed with a - ''; - }; - - duration = mkOption { - type = int; - description = "Duration of highlight"; - default = 500; - }; - - undo = { - hlGroup = mkOption { - type = str; - description = "Highlight group for undo"; - default = "HighlightUndo"; - }; - }; - - redo = { - hlGroup = mkOption { - type = str; - description = "Highlight group for redo"; - default = "HighlightUndo"; - }; - }; - }; - }; -} From 65c9bed260c45cbe545db6fed6a14142f40ed916 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 7 Oct 2024 03:06:42 +0300 Subject: [PATCH 12/14] treesitter: minor syntax fix --- modules/plugins/treesitter/config.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/plugins/treesitter/config.nix b/modules/plugins/treesitter/config.nix index 618da88e..e3636a63 100644 --- a/modules/plugins/treesitter/config.nix +++ b/modules/plugins/treesitter/config.nix @@ -82,7 +82,6 @@ in { node_incremental = false, scope_incremental = false, node_decremental = false, - }, }, } From ccdc229eee405cdfe052c7f985b00386266050db Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 7 Oct 2024 03:09:46 +0300 Subject: [PATCH 13/14] treewide: find and replace deprecated options --- configuration.nix | 19 ++++++++----------- .../tabline/nvim-bufferline/config.nix | 6 +++++- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/configuration.nix b/configuration.nix index b21b26aa..e0809805 100644 --- a/configuration.nix +++ b/configuration.nix @@ -75,20 +75,17 @@ isMaximal: { }; visuals = { - enable = true; - nvimWebDevicons.enable = true; - scrollBar.enable = isMaximal; - smoothScroll.enable = true; - cellularAutomaton.enable = false; + nvim-scrollbar.enable = isMaximal; + nvim-web-devicons.enable = true; + nvim-cursorline.enable = true; + cinnamon-nvim.enable = true; fidget-nvim.enable = true; + highlight-undo.enable = true; + indent-blankline.enable = true; - indentBlankline.enable = true; - - cursorline = { - enable = true; - lineTimeout = 0; - }; + # Fun + cellular-automaton.enable = false; }; statusline = { diff --git a/modules/plugins/tabline/nvim-bufferline/config.nix b/modules/plugins/tabline/nvim-bufferline/config.nix index fe54efbe..4989e991 100644 --- a/modules/plugins/tabline/nvim-bufferline/config.nix +++ b/modules/plugins/tabline/nvim-bufferline/config.nix @@ -15,10 +15,14 @@ in { config = mkIf cfg.enable { vim = { startPlugins = [ - (assert config.vim.visuals.nvimWebDevicons.enable; "nvim-bufferline-lua") + "nvim-bufferline-lua" "bufdelete-nvim" ]; + # Soft-dependency for bufferline. + # Recommended by upstream, so enabled here. + visuals.nvim-web-devicons.enable = true; + maps.normal = mkMerge [ (mkLuaBinding cfg.mappings.closeCurrent "require(\"bufdelete\").bufdelete" mappings.closeCurrent.description) (mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext" mappings.cycleNext.description) From a8491b5aa1911b4abb92c6f9af065386554f7514 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 7 Oct 2024 03:26:22 +0300 Subject: [PATCH 14/14] nvim-cursorline: fix docs --- .../visuals/nvim-cursorline/nvim-cursorline.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/plugins/visuals/nvim-cursorline/nvim-cursorline.nix b/modules/plugins/visuals/nvim-cursorline/nvim-cursorline.nix index 5aacc368..7e9e1242 100644 --- a/modules/plugins/visuals/nvim-cursorline/nvim-cursorline.nix +++ b/modules/plugins/visuals/nvim-cursorline/nvim-cursorline.nix @@ -14,17 +14,25 @@ in { options.vim.visuals.nvim-cursorline = { enable = mkEnableOption "cursor word and line highlighting [nvim-cursorline]"; + + # Upstream has **zero** documentation whatsoever. I'm making wild assumptions + # on what goes into description based don the source code. I'm sorry. Not. setupOpts = mkPluginSetupOption "nvim-cursorline" { cursorline = { enable = mkEnableOption "cursor line highlighting"; timeout = mkOption { type = int; default = 1000; + description = "Cursorline timeout"; }; number = mkOption { type = bool; default = false; + description = '' + If true, `vim.wo.cursorlineopt` will be set to "number" + when the trigger conditions are met. + ''; }; }; @@ -33,16 +41,23 @@ in { timeout = mkOption { type = int; default = 1000; + description = "Cursorword timeout"; }; min_length = mkOption { type = int; default = 3; + description = '' + The min_length option defines the minimum number of characters + a word must have to be highlighted as a "cursor word." Any word + shorter than this value will be ignored and not highlighted. + ''; }; hl.underline = mkOption { type = bool; default = true; + description = "Whether to underline matching cursorword"; }; }; };