diff --git a/configuration.nix b/configuration.nix index 1875eaae..8420bbfa 100644 --- a/configuration.nix +++ b/configuration.nix @@ -178,10 +178,14 @@ inputs: let hop.enable = true; leap.enable = true; }; + + images = { + image-nvim.enable = false; + }; }; vim.notes = { - obsidian.enable = false; # FIXME neovim fails to build if obsidian is enabled + obsidian.enable = false; # FIXME: neovim fails to build if obsidian is enabled orgmode.enable = false; mind-nvim.enable = isMaximal; todo-comments.enable = true; diff --git a/docs/release-notes/rl-0.6.md b/docs/release-notes/rl-0.6.md index 01fbe62f..c162ac02 100644 --- a/docs/release-notes/rl-0.6.md +++ b/docs/release-notes/rl-0.6.md @@ -49,6 +49,10 @@ Release notes for release 0.6 - Added rose-pine theme -[frothymarrow](https://github.com/frothymarrow) +[frothymarrow](https://github.com/frothymarrow): - Added option `vim.luaPackages` to wrap neovim with extra Lua packages. + +- Rewrote the entire `fidget.nvim` module to include extensive configuration options. Option `vim.fidget-nvim.align.bottom` has + been removed in favor of [vim.fidget-nvim.notification.window.align](vim.fidget-nvim.notification.window.align), which now supports + `top` and `bottom` values. `vim.fidget-nvim.align.right` has no longer any equivalent and also has been removed. diff --git a/flake.lock b/flake.lock index 44d96fad..7ad4c537 100644 --- a/flake.lock +++ b/flake.lock @@ -388,16 +388,15 @@ "fidget-nvim": { "flake": false, "locked": { - "lastModified": 1699509702, - "narHash": "sha256-8Gl2Ck4YJGReSEq1Xeh1dpdRq4eImmrxvIHrfxdem3Q=", + "lastModified": 1707329128, + "narHash": "sha256-mMLAhAbIs33RoU9c8COchbWRr2NM231zJn6TtwJmI+4=", "owner": "j-hui", "repo": "fidget.nvim", - "rev": "2f7c08f45639a64a5c0abcf67321d52c3f499ae6", + "rev": "ad8873c16faa123fe3f9fd6539c41dfb0f97a9e9", "type": "github" }, "original": { "owner": "j-hui", - "ref": "legacy", "repo": "fidget.nvim", "type": "github" } @@ -597,6 +596,22 @@ "type": "github" } }, + "image-nvim": { + "flake": false, + "locked": { + "lastModified": 1707861531, + "narHash": "sha256-mh3J3lW2Co2uA7YJzSGum0ZmpJBP0ZzBWUvJLAI9bHw=", + "owner": "3rd", + "repo": "image.nvim", + "rev": "4c6cb5ad93ee93d8d7b7c84e1eb291cee99f0a0e", + "type": "github" + }, + "original": { + "owner": "3rd", + "repo": "image.nvim", + "type": "github" + } + }, "indent-blankline": { "flake": false, "locked": { @@ -852,11 +867,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1705856552, - "narHash": "sha256-JXfnuEf5Yd6bhMs/uvM67/joxYKoysyE3M2k6T3eWbg=", + "lastModified": 1708807242, + "narHash": "sha256-sRTRkhMD4delO/hPxxi+XwLqPn8BuUq6nnj4JqLwOu0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "612f97239e2cc474c13c9dafa0df378058c5ad8d", + "rev": "73de017ef2d18a04ac4bfd0c02650007ccb31c2a", "type": "github" }, "original": { @@ -1517,6 +1532,7 @@ "highlight-undo": "highlight-undo", "hop-nvim": "hop-nvim", "icon-picker-nvim": "icon-picker-nvim", + "image-nvim": "image-nvim", "indent-blankline": "indent-blankline", "kommentary": "kommentary", "leap-nvim": "leap-nvim", diff --git a/flake.nix b/flake.nix index 67b65777..25bf39ed 100644 --- a/flake.nix +++ b/flake.nix @@ -28,9 +28,7 @@ homeManagerModules = { neovim-flake = { - imports = [ - (import ./lib/module self.packages inputs) - ]; + imports = [(import ./flake/modules/home-manager.nix self.packages inputs)]; }; default = self.homeManagerModules.neovim-flake; @@ -164,6 +162,11 @@ flake = false; }; + image-nvim = { + url = "github:3rd/image.nvim"; + flake = false; + }; + # Tidal cycles tidalcycles = { url = "github:mitchmindtree/tidalcycles.nix"; @@ -398,7 +401,7 @@ }; fidget-nvim = { - url = "github:j-hui/fidget.nvim?ref=legacy"; + url = "github:j-hui/fidget.nvim"; flake = false; }; diff --git a/lib/module/default.nix b/flake/modules/home-manager.nix similarity index 100% rename from lib/module/default.nix rename to flake/modules/home-manager.nix diff --git a/lib/binds.nix b/lib/binds.nix new file mode 100644 index 00000000..c52e255a --- /dev/null +++ b/lib/binds.nix @@ -0,0 +1,70 @@ +{lib}: let + inherit (lib.options) mkOption; + inherit (lib.modules) mkIf; + inherit (lib.types) nullOr str; + inherit (lib.attrsets) isAttrs mapAttrs; + + binds = rec { + mkLuaBinding = key: action: desc: + mkIf (key != null) { + "${key}" = { + inherit action desc; + lua = true; + silent = true; + }; + }; + + mkExprBinding = key: action: desc: + mkIf (key != null) { + "${key}" = { + inherit action desc; + lua = true; + silent = true; + expr = true; + }; + }; + + mkBinding = key: action: desc: + mkIf (key != null) { + "${key}" = { + inherit action desc; + silent = true; + }; + }; + + mkMappingOption = description: default: + mkOption { + type = nullOr str; + inherit default description; + }; + + # Utility function that takes two attrsets: + # { someKey = "some_value" } and + # { someKey = { description = "Some Description"; }; } + # and merges them into + # { someKey = { value = "some_value"; description = "Some Description"; }; } + addDescriptionsToMappings = actualMappings: mappingDefinitions: + mapAttrs (name: value: let + isNested = isAttrs value; + returnedValue = + if isNested + then addDescriptionsToMappings actualMappings."${name}" mappingDefinitions."${name}" + else { + inherit value; + inherit (mappingDefinitions."${name}") description; + }; + in + returnedValue) + actualMappings; + + mkSetBinding = binding: action: + mkBinding binding.value action binding.description; + + mkSetExprBinding = binding: action: + mkExprBinding binding.value action binding.description; + + mkSetLuaBinding = binding: action: + mkLuaBinding binding.value action binding.description; + }; +in + binds diff --git a/lib/default.nix b/lib/default.nix index d82ea5f7..94db90bb 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,7 +1,9 @@ {lib}: { - dag = import ./dag.nix {inherit lib;}; types = import ./types {inherit lib;}; + + binds = import ./binds.nix {inherit lib;}; + dag = import ./dag.nix {inherit lib;}; languages = import ./languages.nix {inherit lib;}; lua = import ./lua.nix {inherit lib;}; - vim = import ./vim.nix {inherit lib;}; + vim = import ./vim.nix; } diff --git a/lib/nmd.nix b/lib/nmd.nix deleted file mode 100644 index fd945f1c..00000000 --- a/lib/nmd.nix +++ /dev/null @@ -1,17 +0,0 @@ -# Copied from nmd master: https://gitlab.com/rycee/nmd/-/blob/master/default.nix?ref_type=heads -# Allows asciiDoc in options. It is easier to copy & keep updated then figure out how to pass the nmd input -# along to user modules -{ - # Indicates that the given text should be interpreted as AsciiDoc markup. - asciiDoc = text: { - _type = "asciiDoc"; - inherit text; - }; - - # Indicates that the given text should be interpreted as AsciiDoc markup and - # used in a literal context. - literalAsciiDoc = text: { - _type = "literalAsciiDoc"; - inherit text; - }; -} diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index f20a9144..4db75421 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -98,6 +98,7 @@ with lib; let "vim-dirtytalk" "highlight-undo" "nvim-docs-view" + "image-nvim" ]; # You can either use the name of the plugin or a package. pluginType = with types; @@ -116,11 +117,13 @@ with lib; let type = pluginType; description = "Plugin Package."; }; + after = mkOption { type = listOf str; default = []; description = "Setup this plugin after the following ones."; }; + setup = mkOption { type = lines; default = ""; diff --git a/lib/vim.nix b/lib/vim.nix index b00d7cad..c81dcc3b 100644 --- a/lib/vim.nix +++ b/lib/vim.nix @@ -1,4 +1,4 @@ -{lib}: let +let inherit (builtins) isInt isBool toJSON; in rec { # yes? no. diff --git a/modules/assistant/copilot/config.nix b/modules/assistant/copilot/config.nix index 18f540dd..5cfe9553 100644 --- a/modules/assistant/copilot/config.nix +++ b/modules/assistant/copilot/config.nix @@ -1,11 +1,14 @@ { - pkgs, config, lib, ... }: let inherit (builtins) toJSON; - inherit (lib) mkIf nvim mkLuaBinding mkMerge; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.lists) optionals; + inherit (lib.trivial) boolToString; + inherit (lib.nvim.binds) mkLuaBinding; cfg = config.vim.assistant.copilot; @@ -27,16 +30,16 @@ in { "copilot-lua" cfg.copilotNodePackage ] - ++ lib.optionals (cfg.cmp.enable) [ + ++ optionals (cfg.cmp.enable) [ "copilot-cmp" ]; - vim.luaConfigRC.copilot = nvim.dag.entryAnywhere '' + vim.luaConfigRC.copilot = entryAnywhere '' require("copilot").setup({ -- available options: https://github.com/zbirenbaum/copilot.lua copilot_node_command = "${cfg.copilotNodeCommand}", panel = { - enabled = ${lib.boolToString (!cfg.cmp.enable)}, + enabled = ${boolToString (!cfg.cmp.enable)}, keymap = { jump_prev = false, jump_next = false, @@ -50,7 +53,7 @@ in { }, }, suggestion = { - enabled = ${lib.boolToString (!cfg.cmp.enable)}, + enabled = ${boolToString (!cfg.cmp.enable)}, keymap = { accept = false, accept_word = false, diff --git a/modules/assistant/copilot/copilot.nix b/modules/assistant/copilot/copilot.nix index 85838694..283a0b6e 100644 --- a/modules/assistant/copilot/copilot.nix +++ b/modules/assistant/copilot/copilot.nix @@ -1,10 +1,12 @@ { - pkgs, config, + pkgs, lib, ... }: let - inherit (lib) mkEnableOption mkOption types; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) enum float nullOr str package; + inherit (lib.meta) getExe; cfg = config.vim.assistant.copilot; in { @@ -14,7 +16,7 @@ in { panel = { position = mkOption { - type = types.enum [ + type = enum [ "bottom" "top" "left" @@ -24,7 +26,7 @@ in { description = "Panel position"; }; ratio = mkOption { - type = types.float; + type = float; default = 0.4; description = "Panel size"; }; @@ -33,59 +35,68 @@ in { mappings = { panel = { jumpPrev = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = "[["; description = "Jump to previous suggestion"; }; + jumpNext = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = "]]"; description = "Jump to next suggestion"; }; + accept = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = ""; description = "Accept suggestion"; }; + refresh = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = "gr"; description = "Refresh suggestions"; }; + open = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = ""; description = "Open suggestions"; }; }; suggestion = { accept = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = ""; description = "Accept suggetion"; }; + acceptWord = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = null; description = "Accept next word"; }; + acceptLine = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = null; description = "Accept next line"; }; + prev = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = ""; description = "Previous suggestion"; }; + next = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = ""; description = "Next suggestion"; }; + dismiss = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = ""; description = "Dismiss suggestion"; }; @@ -93,8 +104,8 @@ in { }; copilotNodeCommand = mkOption { - type = types.str; - default = "${lib.getExe cfg.copilotNodePackage}"; + type = str; + default = "${getExe cfg.copilotNodePackage}"; description = '' The command that will be executed to initiate nodejs for GitHub Copilot. Recommended to leave as default. @@ -102,7 +113,7 @@ in { }; copilotNodePackage = mkOption { - type = with types; nullOr package; + type = nullOr package; default = pkgs.nodejs-slim; description = '' The nodeJS package that will be used for GitHub Copilot. If you are using a custom node command diff --git a/modules/assistant/copilot/default.nix b/modules/assistant/copilot/default.nix index fb291bdf..2b890451 100644 --- a/modules/assistant/copilot/default.nix +++ b/modules/assistant/copilot/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./copilot.nix ./config.nix diff --git a/modules/assistant/default.nix b/modules/assistant/default.nix index a8096c8a..3521c526 100644 --- a/modules/assistant/default.nix +++ b/modules/assistant/default.nix @@ -1,6 +1,5 @@ -_: { +{ imports = [ ./copilot - # ./tabnine.nix # removed until I find a way around the initialisation script the plugin requires ]; } diff --git a/modules/assistant/tabnine/config.nix b/modules/assistant/tabnine/config.nix deleted file mode 100644 index e9cc209e..00000000 --- a/modules/assistant/tabnine/config.nix +++ /dev/null @@ -1,54 +0,0 @@ -{ - config, - lib, - ... -}: let - inherit (builtins) toJSON; - inherit (lib) mkIf mkMerge mkExprBinding boolToString nvim; - - cfg = config.vim.assistant.tabnine; -in { - config = mkIf cfg.enable { - vim.startPlugins = ["tabnine-nvim"]; - - vim.maps.insert = mkMerge [ - (mkExprBinding cfg.mappings.accept '' - function() - local state = require("tabnine.state") - local completion = require("tabnine.completion") - - if not state.completions_cache then - return "${toJSON cfg.mappings.accept}" - end - - vim.schedule(completion.accept) - end - '' "orzel") - (mkExprBinding cfg.mappings.dismiss '' - function() - local state = require("tabnine.state") - local completion = require("tabnine.completion") - - if not state.completions_cache then - return "${toJSON cfg.mappings.dismiss}" - end - - vim.schedule(function() - completion.clear() - state.completions_cache = nil - end) - end - '' "orzel") - ]; - - vim.luaConfigRC.tabnine-nvim = nvim.dag.entryAnywhere '' - require('tabnine').setup({ - disable_auto_comment = ${boolToString cfg.disable_auto_comment}, - accept_keymap = null, - dismiss_keymap = null, - debounce_ms = ${cfg.debounce_ms}, - exclude_filetypes = ${cfg.exclude_filetypes}, - }) - ''; - }; -} diff --git a/modules/assistant/tabnine/tabnine.nix b/modules/assistant/tabnine/tabnine.nix deleted file mode 100644 index 949a6b17..00000000 --- a/modules/assistant/tabnine/tabnine.nix +++ /dev/null @@ -1,30 +0,0 @@ -{lib, ...}: let - inherit (lib) mkEnableOption mkOption types mkMappingOption; -in { - options.vim.assistant.tabnine = { - enable = mkEnableOption "Tabnine assistant"; - - disable_auto_comment = mkOption { - type = types.bool; - default = true; - description = "Disable auto comment"; - }; - - mappings = { - accept = mkMappingOption "Accept [Tabnine]" ""; - dismiss = mkMappingOption "Dismiss [Tabnine]" ""; - }; - - debounce_ms = mkOption { - type = types.int; - default = 800; - description = "Debounce ms"; - }; - - exclude_filetypes = mkOption { - type = types.listOf types.str; - default = ["TelescopePrompt" "NvimTree" "alpha"]; - description = "Exclude filetypes"; - }; - }; -} diff --git a/modules/autopairs/default.nix b/modules/autopairs/default.nix index 742665c7..cc2f69c6 100644 --- a/modules/autopairs/default.nix +++ b/modules/autopairs/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./nvim-autopairs ]; diff --git a/modules/autopairs/nvim-autopairs/config.nix b/modules/autopairs/nvim-autopairs/config.nix index 0aceca5d..1502db84 100644 --- a/modules/autopairs/nvim-autopairs/config.nix +++ b/modules/autopairs/nvim-autopairs/config.nix @@ -1,26 +1,28 @@ { - lib, config, + lib, ... }: let - inherit (lib) mkIf nvim optionalString boolToString; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.strings) optionalString; + inherit (lib.trivial) boolToString; cfg = config.vim.autopairs; in { - config = - mkIf (cfg.enable) - { - vim.startPlugins = ["nvim-autopairs"]; + config = mkIf cfg.enable { + vim.startPlugins = ["nvim-autopairs"]; - vim.luaConfigRC.autopairs = nvim.dag.entryAnywhere '' - require("nvim-autopairs").setup{} - ${optionalString (config.vim.autocomplete.type == "nvim-compe") '' - require('nvim-autopairs.completion.compe').setup({ - map_cr = ${boolToString cfg.nvim-compe.map_cr}, - map_complete = ${boolToString cfg.nvim-compe.map_complete}, - auto_select = ${boolToString cfg.nvim-compe.auto_select}, - }) - ''} - ''; - }; + vim.luaConfigRC.autopairs = entryAnywhere '' + require("nvim-autopairs").setup{} + ${optionalString (config.vim.autocomplete.type == "nvim-compe") '' + -- nvim-compe integration + require('nvim-autopairs.completion.compe').setup({ + map_cr = ${boolToString cfg.nvim-compe.map_cr}, + map_complete = ${boolToString cfg.nvim-compe.map_complete}, + auto_select = ${boolToString cfg.nvim-compe.auto_select}, + }) + ''} + ''; + }; } diff --git a/modules/autopairs/nvim-autopairs/default.nix b/modules/autopairs/nvim-autopairs/default.nix index f2283310..70980494 100644 --- a/modules/autopairs/nvim-autopairs/default.nix +++ b/modules/autopairs/nvim-autopairs/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./nvim-autopairs.nix diff --git a/modules/autopairs/nvim-autopairs/nvim-autopairs.nix b/modules/autopairs/nvim-autopairs/nvim-autopairs.nix index 330d1186..940a60c7 100644 --- a/modules/autopairs/nvim-autopairs/nvim-autopairs.nix +++ b/modules/autopairs/nvim-autopairs/nvim-autopairs.nix @@ -1,31 +1,32 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkOption types; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) enum bool; in { options.vim = { autopairs = { enable = mkEnableOption "autopairs" // {default = false;}; type = mkOption { - type = types.enum ["nvim-autopairs"]; + type = enum ["nvim-autopairs"]; default = "nvim-autopairs"; description = "Set the autopairs type. Options: nvim-autopairs [nvim-autopairs]"; }; nvim-compe = { map_cr = mkOption { - type = types.bool; + type = bool; default = true; description = ''map on insert mode''; }; map_complete = mkOption { - type = types.bool; + type = bool; default = true; description = "auto insert `(` after select function or method item"; }; auto_select = mkOption { - type = types.bool; + type = bool; default = false; description = "auto select first item"; }; diff --git a/modules/comments/comment-nvim/comment-nvim.nix b/modules/comments/comment-nvim/comment-nvim.nix index 13ca4753..61a91715 100644 --- a/modules/comments/comment-nvim/comment-nvim.nix +++ b/modules/comments/comment-nvim/comment-nvim.nix @@ -1,5 +1,6 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkMappingOption; + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.binds) mkMappingOption; in { options.vim.comments.comment-nvim = { enable = mkEnableOption "smart and powerful comment plugin for neovim comment-nvim"; diff --git a/modules/comments/comment-nvim/config.nix b/modules/comments/comment-nvim/config.nix index ea2f1e19..40ccb0ab 100644 --- a/modules/comments/comment-nvim/config.nix +++ b/modules/comments/comment-nvim/config.nix @@ -3,13 +3,13 @@ lib, ... }: let - inherit (lib) mkIf mkMerge mkExprBinding mkBinding nvim; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.binds) mkExprBinding mkBinding; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.comments.comment-nvim; - self = import ./comment-nvim.nix { - inherit lib; - }; - mappings = self.options.vim.comments.comment-nvim.mappings; + self = import ./comment-nvim.nix {inherit lib;}; + inherit (self.options.vim.comments.comment-nvim) mappings; in { config = mkIf cfg.enable { vim.startPlugins = [ @@ -41,7 +41,7 @@ in { (mkBinding cfg.mappings.toggleSelectedBlock "(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description) ]; - vim.luaConfigRC.comment-nvim = nvim.dag.entryAnywhere '' + vim.luaConfigRC.comment-nvim = entryAnywhere '' require('Comment').setup({ mappings = { basic = false, extra = false, }, }) diff --git a/modules/comments/comment-nvim/default.nix b/modules/comments/comment-nvim/default.nix index db4eb424..6a6dbcb6 100644 --- a/modules/comments/comment-nvim/default.nix +++ b/modules/comments/comment-nvim/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./comment-nvim.nix diff --git a/modules/comments/default.nix b/modules/comments/default.nix index cb6ac191..afc1a879 100644 --- a/modules/comments/default.nix +++ b/modules/comments/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./comment-nvim ]; diff --git a/modules/completion/default.nix b/modules/completion/default.nix index 77d51b41..0cae45f6 100644 --- a/modules/completion/default.nix +++ b/modules/completion/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./nvim-cmp ]; diff --git a/modules/completion/nvim-cmp/config.nix b/modules/completion/nvim-cmp/config.nix index b20f71b7..142a1189 100644 --- a/modules/completion/nvim-cmp/config.nix +++ b/modules/completion/nvim-cmp/config.nix @@ -4,8 +4,11 @@ ... }: let inherit (builtins) toJSON; - inherit (lib) addDescriptionsToMappings concatMapStringsSep attrNames concatStringsSep mapAttrsToList mkIf mkSetLuaBinding mkMerge optionalString; - inherit (lib.nvim) dag; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.attrsets) attrNames mapAttrsToList; + inherit (lib.strings) concatMapStringsSep concatStringsSep optionalString; + inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding; + inherit (lib.nvim.dag) entryAnywhere entryAfter; cfg = config.vim.autocomplete; lspkindEnabled = config.vim.lsp.enable && config.vim.lsp.lspkind.enable; @@ -33,8 +36,8 @@ dagPlacement = if lspkindEnabled - then dag.entryAfter ["lspkind"] - else dag.entryAnywhere; + then entryAfter ["lspkind"] + else entryAnywhere; in { config = mkIf cfg.enable { vim.startPlugins = [ @@ -195,7 +198,7 @@ in { local cmp = require'cmp' cmp.setup({ - ${optionalString (config.vim.ui.borders.enable) '' + ${optionalString config.vim.ui.borders.enable '' -- explicitly enabled by setting ui.borders.enable = true -- TODO: try to get nvim-cmp to follow global border style window = { diff --git a/modules/completion/nvim-cmp/nvim-cmp.nix b/modules/completion/nvim-cmp/nvim-cmp.nix index 38c86198..59c32db1 100644 --- a/modules/completion/nvim-cmp/nvim-cmp.nix +++ b/modules/completion/nvim-cmp/nvim-cmp.nix @@ -1,5 +1,7 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkMappingOption mkOption types; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.nvim.binds) mkMappingOption; + inherit (lib.types) enum attrsOf nullOr str; in { options.vim = { autocomplete = { @@ -16,7 +18,7 @@ in { }; type = mkOption { - type = types.enum ["nvim-cmp"]; + type = enum ["nvim-cmp"]; default = "nvim-cmp"; description = "Set the autocomplete plugin. Options: [nvim-cmp]"; }; @@ -31,7 +33,7 @@ in { Note: only use a single attribute name per attribute set ''; - type = with types; attrsOf (nullOr str); + type = attrsOf (nullOr str); default = {}; example = '' {nvim-cmp = null; buffer = "[Buffer]";} @@ -48,7 +50,7 @@ in { Default is to call the menu mapping function. ''; - type = types.str; + type = str; default = "nvim_cmp_menu_map"; example = lib.literalMD '' ```lua diff --git a/modules/dashboard/alpha/alpha.nix b/modules/dashboard/alpha/alpha.nix index 3c43e15f..d5329cc7 100644 --- a/modules/dashboard/alpha/alpha.nix +++ b/modules/dashboard/alpha/alpha.nix @@ -1,11 +1,7 @@ -{ - config, - lib, - ... -}: let - inherit (lib) mkEnableOption; +{lib, ...}: let + inherit (lib.options) mkEnableOption; in { options.vim.dashboard.alpha = { - enable = mkEnableOption "dashboard via alpha.nvim"; + enable = mkEnableOption "fast and fully programmable greeter for neovim [alpha.mvim]"; }; } diff --git a/modules/dashboard/alpha/config.nix b/modules/dashboard/alpha/config.nix index a2ee14b4..12072e34 100644 --- a/modules/dashboard/alpha/config.nix +++ b/modules/dashboard/alpha/config.nix @@ -3,7 +3,8 @@ lib, ... }: let - inherit (lib) mkIf nvim; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.dashboard.alpha; in { @@ -15,7 +16,7 @@ in { # the entire credit for this dashboard configuration to https://github.com/Rishabh672003 # honestly, excellent work - vim.luaConfigRC.alpha = nvim.dag.entryAnywhere '' + vim.luaConfigRC.alpha = entryAnywhere '' local alpha = require("alpha") local plenary_path = require("plenary.path") local dashboard = require("alpha.themes.dashboard") diff --git a/modules/dashboard/alpha/default.nix b/modules/dashboard/alpha/default.nix index 16496c63..913b32b7 100644 --- a/modules/dashboard/alpha/default.nix +++ b/modules/dashboard/alpha/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./alpha.nix ./config.nix diff --git a/modules/dashboard/dashboard-nvim/config.nix b/modules/dashboard/dashboard-nvim/config.nix index 13c08e64..9d827a4e 100644 --- a/modules/dashboard/dashboard-nvim/config.nix +++ b/modules/dashboard/dashboard-nvim/config.nix @@ -3,7 +3,8 @@ lib, ... }: let - inherit (lib) mkIf nvim; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.dashboard.dashboard-nvim; in { @@ -12,7 +13,7 @@ in { "dashboard-nvim" ]; - vim.luaConfigRC.dashboard-nvim = nvim.dag.entryAnywhere '' + vim.luaConfigRC.dashboard-nvim = entryAnywhere '' require("dashboard").setup{} ''; }; diff --git a/modules/dashboard/dashboard-nvim/dashboard-nvim.nix b/modules/dashboard/dashboard-nvim/dashboard-nvim.nix index 78264ca3..62333918 100644 --- a/modules/dashboard/dashboard-nvim/dashboard-nvim.nix +++ b/modules/dashboard/dashboard-nvim/dashboard-nvim.nix @@ -1,11 +1,7 @@ -{ - config, - lib, - ... -}: let +{lib, ...}: let inherit (lib) mkEnableOption; in { options.vim.dashboard.dashboard-nvim = { - enable = mkEnableOption "dashboard via dashboard.nvim"; + enable = mkEnableOption "Fancy and Blazing Fast start screen plugin of neovim [dashboard.nvim]"; }; } diff --git a/modules/dashboard/dashboard-nvim/default.nix b/modules/dashboard/dashboard-nvim/default.nix index 5bc4473a..14837498 100644 --- a/modules/dashboard/dashboard-nvim/default.nix +++ b/modules/dashboard/dashboard-nvim/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./dashboard-nvim.nix ./config.nix diff --git a/modules/dashboard/default.nix b/modules/dashboard/default.nix index c63ad3ef..365ea8d0 100644 --- a/modules/dashboard/default.nix +++ b/modules/dashboard/default.nix @@ -1,4 +1,4 @@ -{...}: { +{ imports = [ ./alpha ./dashboard-nvim diff --git a/modules/dashboard/startify/config.nix b/modules/dashboard/startify/config.nix index 447f385f..7e9a0f4a 100644 --- a/modules/dashboard/startify/config.nix +++ b/modules/dashboard/startify/config.nix @@ -4,8 +4,8 @@ lib, ... }: let - inherit (lib) mkIf nvim; - inherit (nvim.vim) mkVimBool; + inherit (lib.modules) mkIf; + inherit (lib.nvim.vim) mkVimBool; cfg = config.vim.dashboard.startify; in { diff --git a/modules/dashboard/startify/startify.nix b/modules/dashboard/startify/startify.nix index 36118f44..fa70a4dd 100644 --- a/modules/dashboard/startify/startify.nix +++ b/modules/dashboard/startify/startify.nix @@ -3,7 +3,8 @@ lib, ... }: let - inherit (lib) mkEnableOption mkOption types; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) listOf attrs bool enum str oneOf int; in { options.vim.dashboard.startify = { enable = mkEnableOption "dashboard via vim-startify"; @@ -11,38 +12,38 @@ in { bookmarks = mkOption { default = []; description = ''List of book marks to disaply on start page''; - type = with types; listOf attrs; + type = listOf attrs; example = {"c" = "~/.vimrc";}; }; changeToDir = mkOption { default = true; description = "Should vim change to the directory of the file you open"; - type = types.bool; + type = bool; }; changeToVCRoot = mkOption { default = false; description = "Should vim change to the version control root when opening a file"; - type = types.bool; + type = bool; }; changeDirCmd = mkOption { default = "lcd"; description = "Command to change the current window with. Can be cd, lcd or tcd"; - type = types.enum ["cd" "lcd" "tcd"]; + type = enum ["cd" "lcd" "tcd"]; }; customHeader = mkOption { default = []; description = "Text to place in the header"; - type = with types; listOf str; + type = listOf str; }; customFooter = mkOption { default = []; description = "Text to place in the footer"; - type = with types; listOf str; + type = listOf str; }; lists = mkOption { @@ -69,121 +70,121 @@ in { } ]; description = "Specify the lists and in what order they are displayed on startify."; - type = with types; listOf attrs; + type = listOf attrs; }; skipList = mkOption { default = []; description = "List of regex patterns to exclude from MRU lists"; - type = with types; listOf str; + type = listOf str; }; updateOldFiles = mkOption { default = false; description = "Set if you want startify to always update and not just when neovim closes"; - type = types.bool; + type = bool; }; sessionAutoload = mkOption { default = false; description = "Make startify auto load Session.vim files from the current directory"; - type = types.bool; + type = bool; }; commands = mkOption { default = []; description = "Commands that are presented to the user on startify page"; - type = with types; listOf (oneOf [str attrs (listOf str)]); + type = listOf (oneOf [str attrs (listOf str)]); }; filesNumber = mkOption { default = 10; description = "How many files to list"; - type = types.int; + type = int; }; customIndices = mkOption { default = []; description = "Specify a list of default charecters to use instead of numbers"; - type = with types; listOf str; + type = listOf str; }; disableOnStartup = mkOption { default = false; description = "Prevent startify from opening on startup but can be called with :Startify"; - type = types.bool; + type = bool; }; unsafe = mkOption { default = false; description = "Turns on unsafe mode for Startify. Stops resolving links, checking files are readable and filtering bookmark list"; - type = types.bool; + type = bool; }; paddingLeft = mkOption { default = 3; description = "Number of spaces used for left padding."; - type = types.int; + type = int; }; useEnv = mkOption { default = false; description = "Show environment variables in path if name is shorter than value"; - type = types.bool; + type = bool; }; sessionBeforeSave = mkOption { default = []; description = "Commands to run before saving a session"; - type = with types; listOf str; + type = listOf str; }; sessionPersistence = mkOption { default = false; description = "Persist session before leaving vim or switching session"; - type = types.bool; + type = bool; }; sessionDeleteBuffers = mkOption { default = true; description = "Delete all buffers when loading or closing a session"; - type = types.bool; + type = bool; }; sessionDir = mkOption { default = "~/.vim/session"; description = "Directory to save and load sessions from"; - type = types.str; + type = str; }; skipListServer = mkOption { default = []; description = "List of vim servers to not load startify for"; - type = with types; listOf str; + type = listOf str; }; sessionRemoveLines = mkOption { default = []; description = "Patterns to remove from session files"; - type = with types; listOf str; + type = listOf str; }; sessionSavevars = mkOption { default = []; description = "List of variables to save into a session file."; - type = with types; listOf str; + type = listOf str; }; sessionSavecmds = mkOption { default = []; description = "List of commands to run when loading a session."; - type = with types; listOf str; + type = listOf str; }; sessionSort = mkOption { default = false; description = "Set if you want items sorted by date rather than alphabetically"; - type = types.bool; + type = bool; }; }; } diff --git a/modules/debugger/default.nix b/modules/debugger/default.nix index f882196e..a34e0591 100644 --- a/modules/debugger/default.nix +++ b/modules/debugger/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./nvim-dap ]; diff --git a/modules/debugger/nvim-dap/config.nix b/modules/debugger/nvim-dap/config.nix index db9558df..cc04c268 100644 --- a/modules/debugger/nvim-dap/config.nix +++ b/modules/debugger/nvim-dap/config.nix @@ -3,12 +3,14 @@ lib, ... }: let - inherit (lib) addDescriptionsToMappings mkMerge mkIf mapAttrs nvim mkSetLuaBinding optionalString; + inherit (lib.strings) optionalString; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.attrsets) mapAttrs; + inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding; + inherit (lib.nvim.dag) entryAnywhere entryAfter; cfg = config.vim.debugger.nvim-dap; - self = import ./nvim-dap.nix { - inherit lib; - }; + self = import ./nvim-dap.nix {inherit lib;}; mappingDefinitions = self.options.vim.debugger.nvim-dap.mappings; mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; in { @@ -19,12 +21,12 @@ in { vim.luaConfigRC = { # TODO customizable keymaps - nvim-dap = nvim.dag.entryAnywhere '' + nvim-dap = entryAnywhere '' local dap = require("dap") vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "ErrorMsg", linehl = "", numhl = "" }) ''; } - // mapAttrs (_: v: (nvim.dag.entryAfter ["nvim-dap"] v)) cfg.sources; + // mapAttrs (_: v: (entryAfter ["nvim-dap"] v)) cfg.sources; vim.maps.normal = mkMerge [ (mkSetLuaBinding mappings.continue "require('dap').continue") @@ -49,7 +51,7 @@ in { (mkIf (cfg.enable && cfg.ui.enable) { vim.startPlugins = ["nvim-dap-ui"]; - vim.luaConfigRC.nvim-dap-ui = nvim.dag.entryAfter ["nvim-dap"] ('' + vim.luaConfigRC.nvim-dap-ui = entryAfter ["nvim-dap"] ('' local dapui = require("dapui") dapui.setup() '' diff --git a/modules/debugger/nvim-dap/default.nix b/modules/debugger/nvim-dap/default.nix index 083220bb..a921e26b 100644 --- a/modules/debugger/nvim-dap/default.nix +++ b/modules/debugger/nvim-dap/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./nvim-dap.nix diff --git a/modules/debugger/nvim-dap/nvim-dap.nix b/modules/debugger/nvim-dap/nvim-dap.nix index ade007a4..3fab33ae 100644 --- a/modules/debugger/nvim-dap/nvim-dap.nix +++ b/modules/debugger/nvim-dap/nvim-dap.nix @@ -1,5 +1,7 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkOption types mkMappingOption; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) bool attrsOf str; + inherit (lib.nvim.binds) mkMappingOption; in { options.vim.debugger.nvim-dap = { enable = mkEnableOption "debugging via nvim-dap"; @@ -7,7 +9,7 @@ in { ui = { enable = mkEnableOption "UI extension for nvim-dap"; autoStart = mkOption { - type = types.bool; + type = bool; default = true; description = "Automatically Opens and Closes DAP-UI upon starting/closing a debugging session"; }; @@ -16,7 +18,7 @@ in { sources = mkOption { default = {}; description = "List of debuggers to install"; - type = with types; attrsOf str; + type = attrsOf str; }; mappings = { diff --git a/modules/filetree/default.nix b/modules/filetree/default.nix index fdceb6ae..1441b4f5 100644 --- a/modules/filetree/default.nix +++ b/modules/filetree/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./nvimtree ]; diff --git a/modules/filetree/nvimtree/config.nix b/modules/filetree/nvimtree/config.nix index 5f11c5ab..684be7ac 100644 --- a/modules/filetree/nvimtree/config.nix +++ b/modules/filetree/nvimtree/config.nix @@ -4,14 +4,16 @@ pkgs, ... }: let - inherit (lib) mkIf mkMerge mkBinding nvim boolToString; + inherit (lib.strings) optionalString; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.trivial) boolToString; + inherit (lib.nvim.binds) mkBinding; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) listToLuaTable expToLua; cfg = config.vim.filetree.nvimTree; - self = import ./nvimtree.nix { - inherit pkgs; - lib = lib; - }; - mappings = self.options.vim.filetree.nvimTree.mappings; + self = import ./nvimtree.nix {inherit pkgs lib;}; + inherit (self.options.vim.filetree.nvimTree) mappings; in { config = mkIf cfg.enable { vim.startPlugins = ["nvim-tree-lua"]; @@ -23,9 +25,9 @@ in { (mkBinding cfg.mappings.focus ":NvimTreeFocus" mappings.focus.description) ]; - vim.luaConfigRC.nvimtreelua = nvim.dag.entryAnywhere '' + vim.luaConfigRC.nvimtreelua = entryAnywhere '' ${ - lib.optionalString (cfg.disableNetrw) '' + lib.optionalString cfg.disableNetrw '' -- disable netrew completely vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 @@ -44,7 +46,7 @@ in { hijack_unnamed_buffer_when_opening = ${boolToString cfg.hijackUnnamedBufferWhenOpening}, hijack_cursor = ${boolToString cfg.hijackCursor}, - root_dirs = ${nvim.lua.listToLuaTable cfg.rootDirs}, + root_dirs = ${listToLuaTable cfg.rootDirs}, prefer_startup_root = ${boolToString cfg.preferStartupRoot}, sync_root_with_cwd = ${boolToString cfg.syncRootWithCwd}, reload_on_bufenter = ${boolToString cfg.reloadOnBufEnter}, @@ -58,12 +60,12 @@ in { update_focused_file = { enable = ${boolToString cfg.updateFocusedFile.enable}, update_root = ${boolToString cfg.updateFocusedFile.updateRoot}, - ignore_list = ${nvim.lua.listToLuaTable cfg.updateFocusedFile.ignoreList}, + ignore_list = ${listToLuaTable cfg.updateFocusedFile.ignoreList}, }, system_open = { cmd = "${cfg.systemOpen.cmd}", - args = ${nvim.lua.listToLuaTable cfg.systemOpen.args}, + args = ${listToLuaTable cfg.systemOpen.args}, }, diagnostics = { @@ -85,7 +87,7 @@ in { enable = ${boolToString cfg.git.enable}, show_on_dirs = ${boolToString cfg.git.showOnDirs}, show_on_open_dirs = ${boolToString cfg.git.showOnOpenDirs}, - disable_for_dirs = ${nvim.lua.listToLuaTable cfg.git.disableForDirs}, + disable_for_dirs = ${listToLuaTable cfg.git.disableForDirs}, timeout = ${toString cfg.git.timeout}, }, @@ -98,7 +100,7 @@ in { filesystem_watchers = { enable = ${boolToString cfg.filesystemWatchers.enable}, debounce_delay = ${toString cfg.filesystemWatchers.debounceDelay}, - ignore_dirs = ${nvim.lua.listToLuaTable cfg.filesystemWatchers.ignoreDirs}, + ignore_dirs = ${listToLuaTable cfg.filesystemWatchers.ignoreDirs}, }, select_prompts = ${boolToString cfg.selectPrompts}, @@ -107,7 +109,7 @@ in { centralize_selection = ${boolToString cfg.view.centralizeSelection}, cursorline = ${boolToString cfg.view.cursorline}, debounce_delay = ${toString cfg.view.debounceDelay}, - width = ${nvim.lua.expToLua cfg.view.width}, + width = ${expToLua cfg.view.width}, side = "${cfg.view.side}", preserve_window_proportions = ${boolToString cfg.view.preserveWindowProportions}, number = ${boolToString cfg.view.number}, @@ -134,15 +136,15 @@ in { highlight_git = ${boolToString cfg.renderer.highlightGit}, highlight_opened_files = ${cfg.renderer.highlightOpenedFiles}, highlight_modified = ${cfg.renderer.highlightModified}, - root_folder_label = ${nvim.lua.expToLua cfg.renderer.rootFolderLabel}, + root_folder_label = ${expToLua cfg.renderer.rootFolderLabel}, indent_width = ${toString cfg.renderer.indentWidth}, indent_markers = { enable = ${boolToString cfg.renderer.indentMarkers.enable}, inline_arrows = ${boolToString cfg.renderer.indentMarkers.inlineArrows}, - icons = ${nvim.lua.expToLua cfg.renderer.indentMarkers.icons}, + icons = ${expToLua cfg.renderer.indentMarkers.icons}, }, - special_files = ${nvim.lua.listToLuaTable cfg.renderer.specialFiles}, + special_files = ${listToLuaTable cfg.renderer.specialFiles}, symlink_destination = ${boolToString cfg.renderer.symlinkDestination}, icons = { @@ -194,7 +196,7 @@ in { dotfiles = ${boolToString cfg.filters.dotfiles}, git_clean = ${boolToString cfg.filters.gitClean}, no_buffer = ${boolToString cfg.filters.noBuffer}, - exclude = ${nvim.lua.listToLuaTable cfg.filters.exclude}, + exclude = ${listToLuaTable cfg.filters.exclude}, }, trash = { @@ -211,11 +213,11 @@ in { expand_all = { max_folder_discovery = ${toString cfg.actions.expandAll.maxFolderDiscovery}, - exclude = ${nvim.lua.listToLuaTable cfg.actions.expandAll.exclude}, + exclude = ${listToLuaTable cfg.actions.expandAll.exclude}, }, file_popup = { - open_win_config = ${nvim.lua.expToLua cfg.actions.filePopup.openWinConfig}, + open_win_config = ${expToLua cfg.actions.filePopup.openWinConfig}, }, open_file = { @@ -227,8 +229,8 @@ in { picker = "${cfg.actions.openFile.windowPicker.picker}", chars = "${cfg.actions.openFile.windowPicker.chars}", exclude = { - filetype = ${nvim.lua.listToLuaTable cfg.actions.openFile.windowPicker.exclude.filetype}, - buftype = ${nvim.lua.listToLuaTable cfg.actions.openFile.windowPicker.exclude.buftype}, + filetype = ${listToLuaTable cfg.actions.openFile.windowPicker.exclude.filetype}, + buftype = ${listToLuaTable cfg.actions.openFile.windowPicker.exclude.buftype}, }, }, }, @@ -247,7 +249,7 @@ in { sync = { open = ${boolToString cfg.tab.sync.open}, close = ${boolToString cfg.tab.sync.close}, - ignore = ${nvim.lua.listToLuaTable cfg.tab.sync.ignore}, + ignore = ${listToLuaTable cfg.tab.sync.ignore}, }, }, @@ -264,9 +266,9 @@ in { }, }) - -- autostart behaviour ${ - lib.optionalString (cfg.openOnSetup) '' + optionalString cfg.openOnSetup '' + -- autostart behaviour -- Open on startup has been deprecated -- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup diff --git a/modules/git/config.nix b/modules/git/config.nix index e0d4a039..c02dc9e5 100644 --- a/modules/git/config.nix +++ b/modules/git/config.nix @@ -4,11 +4,13 @@ ... }: let inherit (builtins) toJSON; - inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetExprBinding mkSetLuaBinding nvim; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.binds) addDescriptionsToMappings mkSetExprBinding mkSetLuaBinding; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.git; - self = import ./git.nix {inherit lib;}; + self = import ./git.nix {inherit lib config;}; gsMappingDefinitions = self.options.vim.git.gitsigns.mappings; gsMappings = addDescriptionsToMappings cfg.gitsigns.mappings gsMappingDefinitions; @@ -61,7 +63,7 @@ in { (mkSetLuaBinding gsMappings.resetHunk "function() package.loaded.gitsigns.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end") ]; - vim.luaConfigRC.gitsigns = nvim.dag.entryAnywhere '' + vim.luaConfigRC.gitsigns = entryAnywhere '' require('gitsigns').setup{} ''; } diff --git a/modules/git/default.nix b/modules/git/default.nix index 6336b410..d3348bc3 100644 --- a/modules/git/default.nix +++ b/modules/git/default.nix @@ -1,4 +1,4 @@ -{...}: { +{ imports = [ ./config.nix ./git.nix diff --git a/modules/git/git.nix b/modules/git/git.nix index 0447fc45..12019823 100644 --- a/modules/git/git.nix +++ b/modules/git/git.nix @@ -1,11 +1,16 @@ -{lib, ...}: let - inherit (lib) mkEnableOption mkMappingOption; +{ + config, + lib, + ... +}: let + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.binds) mkMappingOption; in { options.vim.git = { - enable = mkEnableOption "git tools via gitsigns"; + enable = mkEnableOption "git integration"; gitsigns = { - enable = mkEnableOption "gitsigns"; + enable = mkEnableOption "gitsigns" // {default = config.vim.git.enable;}; mappings = { nextHunk = mkMappingOption "Next hunk [Gitsigns]" "]c"; diff --git a/modules/languages/bash/bash.nix b/modules/languages/bash/bash.nix index 243f30cc..03cce941 100644 --- a/modules/languages/bash/bash.nix +++ b/modules/languages/bash/bash.nix @@ -5,7 +5,10 @@ ... }: let inherit (builtins) attrNames; - inherit (lib) mkOption mkEnableOption types isList nvim; + inherit (lib.options) mkOption mkEnableOption literalExpression; + inherit (lib.lists) isList; + inherit (lib.types) enum either package listOf str bool; + inherit (lib.nvim.lua) expToLua; cfg = config.vim.languages.bash; @@ -19,7 +22,7 @@ on_attach = default_on_attach; cmd = ${ if isList cfg.lsp.package - then nvim.lua.expToLua cfg.lsp.package + then expToLua cfg.lsp.package else ''{"${cfg.lsp.package}/bin/bash-language-server", "start"}'' }; } @@ -70,14 +73,14 @@ in { server = mkOption { description = "Bash LSP server to use"; - type = with types; enum (attrNames servers); + type = enum (attrNames servers); default = defaultServer; }; package = mkOption { description = "bash-language-server package, or the command to run as a list of strings"; - example = lib.literalExpression ''[lib.getExe pkgs.nodePackages.bash-language-server "start"]''; - type = with types; either package (listOf str); + example = literalExpression ''[lib.getExe pkgs.nodePackages.bash-language-server "start"]''; + type = either package (listOf str); default = pkgs.nodePackages.bash-language-server; }; }; @@ -85,25 +88,24 @@ in { format = { enable = mkOption { description = "Enable Bash formatting"; - type = types.bool; + type = bool; default = config.vim.languages.enableFormat; }; type = mkOption { description = "Bash formatter to use"; - type = with types; enum (attrNames formats); + type = enum (attrNames formats); default = defaultFormat; }; package = mkOption { description = "Bash formatter package"; - type = types.package; + type = package; default = formats.${cfg.format.type}.package; }; }; extraDiagnostics = { enable = mkEnableOption "extra Bash diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;}; - types = lib.nvim.types.diagnostics { langDesc = "Bash"; inherit diagnostics; diff --git a/modules/languages/bash/config.nix b/modules/languages/bash/config.nix index 241032d8..e55600b5 100644 --- a/modules/languages/bash/config.nix +++ b/modules/languages/bash/config.nix @@ -4,7 +4,9 @@ lib, ... }: let - inherit (lib) isList nvim mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.lua) expToLua; cfg = config.vim.languages.bash; diagnostics = { @@ -44,7 +46,7 @@ on_attach = default_on_attach; cmd = ${ if isList cfg.lsp.package - then nvim.lua.expToLua cfg.lsp.package + then expToLua cfg.lsp.package else ''{"${cfg.lsp.package}/bin/bash-language-server", "start"}'' }; } diff --git a/modules/languages/bash/default.nix b/modules/languages/bash/default.nix index 7dd72f7f..7bb1ea2d 100644 --- a/modules/languages/bash/default.nix +++ b/modules/languages/bash/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./bash.nix ./config.nix diff --git a/modules/languages/dart/config.nix b/modules/languages/dart/config.nix index 510a4136..be7c111b 100644 --- a/modules/languages/dart/config.nix +++ b/modules/languages/dart/config.nix @@ -4,7 +4,12 @@ pkgs, ... }: let - inherit (lib) isList nvim mkIf mkMerge optionalString boolToString; + inherit (lib.lists) isList; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.strings) optionalString; + inherit (lib.trivial) boolToString; + inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.languages.dart; ftcfg = cfg.flutter-tools; @@ -17,7 +22,7 @@ on_attach=default_on_attach; cmd = ${ if isList cfg.lsp.package - then nvim.lua.expToLua cfg.lsp.package + then expToLua cfg.lsp.package else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}'' }; ${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"} @@ -38,13 +43,13 @@ in { vim.lsp.lspconfig.sources.dart-lsp = servers.${cfg.lsp.server}.lspConfig; }) - (mkIf (ftcfg.enable) { + (mkIf ftcfg.enable { vim.startPlugins = if ftcfg.enableNoResolvePatch then ["flutter-tools-patched"] else ["flutter-tools"]; - vim.luaConfigRC.flutter-tools = nvim.dag.entryAnywhere '' + vim.luaConfigRC.flutter-tools = entryAnywhere '' require('flutter-tools').setup { lsp = { color = { -- show the derived colours for dart variables diff --git a/modules/languages/dart/dart.nix b/modules/languages/dart/dart.nix index c30f1f38..13ce3d95 100644 --- a/modules/languages/dart/dart.nix +++ b/modules/languages/dart/dart.nix @@ -5,7 +5,12 @@ ... }: let inherit (builtins) attrNames; - inherit (lib) isList nvim mkEnableOption mkOption types optionalString; + inherit (lib.lists) isList; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) enum either listOf package nullOr str bool; + inherit (lib.strings) optionalString; + inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.types) mkGrammarOption; cfg = config.vim.languages.dart; defaultServer = "dart"; @@ -18,7 +23,7 @@ on_attach=default_on_attach; cmd = ${ if isList cfg.lsp.package - then nvim.lua.expToLua cfg.lsp.package + then expToLua cfg.lsp.package else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}'' }; ${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"} @@ -32,25 +37,25 @@ in { treesitter = { enable = mkEnableOption "Dart treesitter" // {default = config.vim.languages.enableTreesitter;}; - package = nvim.types.mkGrammarOption pkgs "dart"; + package = mkGrammarOption pkgs "dart"; }; lsp = { enable = mkEnableOption "Dart LSP support"; server = mkOption { description = "The Dart LSP server to use"; - type = with types; enum (attrNames servers); + type = enum (attrNames servers); default = defaultServer; }; package = mkOption { description = "Dart LSP server package, or the command to run as a list of strings"; example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]''; - type = with types; either package (listOf str); + type = either package (listOf str); default = servers.${cfg.lsp.server}.package; }; opts = mkOption { description = "Options to pass to Dart LSP server"; - type = with types; nullOr str; + type = nullOr str; default = null; }; }; @@ -58,7 +63,7 @@ in { dap = { enable = mkOption { description = "Enable Dart DAP support via flutter-tools"; - type = types.bool; + type = bool; default = config.vim.languages.enableDAP; }; }; @@ -66,7 +71,7 @@ in { flutter-tools = { enable = mkOption { description = "Enable flutter-tools for flutter support"; - type = types.bool; + type = bool; default = config.vim.languages.enableLSP; }; @@ -76,7 +81,7 @@ in { This is required if you want to use a flutter package built with nix. If you are using a flutter SDK installed from a different source and encounter the error "`dart` missing from PATH", disable this option. ''; - type = types.bool; + type = bool; default = true; }; @@ -84,13 +89,13 @@ in { enable = mkEnableOption "Whether or mot to highlight color variables at all"; highlightBackground = mkOption { - type = types.bool; + type = bool; default = false; description = "Highlight the background"; }; highlightForeground = mkOption { - type = types.bool; + type = bool; default = false; description = "Highlight the foreground"; }; @@ -99,7 +104,7 @@ in { enable = mkEnableOption "Show the highlight using virtual text"; character = mkOption { - type = types.str; + type = str; default = "■"; description = "Virtual text character to highlight"; }; diff --git a/modules/languages/dart/default.nix b/modules/languages/dart/default.nix index da454ec0..2ad34f34 100644 --- a/modules/languages/dart/default.nix +++ b/modules/languages/dart/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./dart.nix ./config.nix diff --git a/modules/languages/elixir/config.nix b/modules/languages/elixir/config.nix index dc05a48c..eaf26ea6 100644 --- a/modules/languages/elixir/config.nix +++ b/modules/languages/elixir/config.nix @@ -4,7 +4,9 @@ pkgs, ... }: let - inherit (lib) nvim mkIf getExe; + inherit (lib.modules) mkIf; + inherit (lib.meta) getExe; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.languages.elixir; in { @@ -13,14 +15,12 @@ in { "elixir-tools" ]; - vim.luaConfigRC.elixir-tools = nvim.dag.entryAnywhere '' + vim.luaConfigRC.elixir-tools = entryAnywhere '' local elixir = require("elixir") local elixirls = require("elixir.elixirls") elixir.setup { elixirls = { - - -- alternatively, point to an existing elixir-ls installation (optional) -- not currently supported by elixirls, but can be a table if you wish to pass other args `{"path/to/elixirls", "--foo"}` cmd = "${getExe pkgs.elixir-ls}", @@ -51,6 +51,7 @@ in { vim.keymap.set("n", "K", "lua vim.lsp.buf.hover()", map_opts) vim.keymap.set("n", "gD","lua vim.lsp.buf.implementation()", map_opts) vim.keymap.set("n", "1gD","lua vim.lsp.buf.type_definition()", map_opts) + -- keybinds for fzf-lsp.nvim: https://github.com/gfanto/fzf-lsp.nvim -- you could also use telescope.nvim: https://github.com/nvim-telescope/telescope.nvim -- there are also core vim.lsp functions that put the same data in the loclist diff --git a/modules/languages/elixir/default.nix b/modules/languages/elixir/default.nix index b8ea9be6..c84acf0c 100644 --- a/modules/languages/elixir/default.nix +++ b/modules/languages/elixir/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./elixir-tools.nix diff --git a/modules/languages/elixir/elixir-tools.nix b/modules/languages/elixir/elixir-tools.nix index 42e69a39..05273593 100644 --- a/modules/languages/elixir/elixir-tools.nix +++ b/modules/languages/elixir/elixir-tools.nix @@ -1,9 +1,5 @@ -{ - config, - lib, - ... -}: let - inherit (lib) mkEnableOption; +{lib, ...}: let + inherit (lib.options) mkEnableOption; in { options.vim.languages.elixir = { enable = mkEnableOption "Elixir language support"; diff --git a/modules/languages/lua.nix b/modules/languages/lua.nix index e902aa97..5cfe2032 100644 --- a/modules/languages/lua.nix +++ b/modules/languages/lua.nix @@ -27,33 +27,35 @@ in { }; }; - config = mkIf cfg.enable (mkMerge [ + config = mkMerge [ (mkIf cfg.treesitter.enable { vim.treesitter.enable = true; vim.treesitter.grammars = [cfg.treesitter.package]; }) - (mkIf cfg.lsp.enable { - vim.lsp.lspconfig.enable = true; - vim.lsp.lspconfig.sources.lua-lsp = '' - lspconfig.lua_ls.setup { - capabilities = capabilities; - on_attach = default_on_attach; - ${optionalString cfg.lsp.neodev.enable "before_init = require('neodev.lsp').before_init;"} - cmd = ${ - if isList cfg.lsp.package - then nvim.lua.expToLua cfg.lsp.package - else ''{"${getExe cfg.lsp.package}"}'' - }; - } - ''; - }) + (mkIf cfg.enable (mkMerge [ + (mkIf cfg.lsp.enable { + vim.lsp.lspconfig.enable = true; + vim.lsp.lspconfig.sources.lua-lsp = '' + lspconfig.lua_ls.setup { + capabilities = capabilities; + on_attach = default_on_attach; + ${optionalString cfg.lsp.neodev.enable "before_init = require('neodev.lsp').before_init;"} + cmd = ${ + if isList cfg.lsp.package + then nvim.lua.expToLua cfg.lsp.package + else ''{"${getExe cfg.lsp.package}"}'' + }; + } + ''; + }) - (mkIf cfg.lsp.neodev.enable { - vim.startPlugins = ["neodev-nvim"]; - vim.luaConfigRC.neodev = nvim.dag.entryBefore ["lua-lsp"] '' - require("neodev").setup({}) - ''; - }) - ]); + (mkIf cfg.lsp.neodev.enable { + vim.startPlugins = ["neodev-nvim"]; + vim.luaConfigRC.neodev = nvim.dag.entryBefore ["lua-lsp"] '' + require("neodev").setup({}) + ''; + }) + ])) + ]; } diff --git a/modules/utility/default.nix b/modules/utility/default.nix index 1fbd60a8..a5a88920 100644 --- a/modules/utility/default.nix +++ b/modules/utility/default.nix @@ -1,11 +1,12 @@ -_: { +{ imports = [ ./binds + ./ccc ./gestures ./motion ./telescope - ./ccc ./icon-picker + ./images ./telescope ./diffview ./wakatime diff --git a/modules/utility/images/default.nix b/modules/utility/images/default.nix new file mode 100644 index 00000000..5b876e0a --- /dev/null +++ b/modules/utility/images/default.nix @@ -0,0 +1,5 @@ +{ + imports = [ + ./image-nvim + ]; +} diff --git a/modules/utility/images/image-nvim/config.nix b/modules/utility/images/image-nvim/config.nix new file mode 100644 index 00000000..49ca3e53 --- /dev/null +++ b/modules/utility/images/image-nvim/config.nix @@ -0,0 +1,37 @@ +{ + config, + lib, + pkgs, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; + + cfg = config.vim.utility.images.image-nvim; +in { + config = mkIf cfg.enable { + assertions = [ + { + assertion = pkgs.stdenv.isDarwin && cfg.setupOpts.backend != "ueberzug"; + message = "image-nvim: ueberzug backend is broken on ${pkgs.stdenv.hostPlatform.system}. if you are using kitty, please set `vim.utility.images.image-nvim.setupOpts.backend` option to `kitty` in your configuration, otherwise disable this module."; + } + ]; + + vim = { + startPlugins = [ + "image-nvim" + ]; + + luaPackages = [ + "magick" + ]; + + luaConfigRC.image-nvim = entryAnywhere '' + require("image").setup( + ${toLuaObject cfg.setupOpts} + ) + ''; + }; + }; +} diff --git a/modules/assistant/tabnine/default.nix b/modules/utility/images/image-nvim/default.nix similarity index 62% rename from modules/assistant/tabnine/default.nix rename to modules/utility/images/image-nvim/default.nix index 84f3cf2f..f3cc02e7 100644 --- a/modules/assistant/tabnine/default.nix +++ b/modules/utility/images/image-nvim/default.nix @@ -1,6 +1,6 @@ -_: { +{ imports = [ ./config.nix - ./tabnine.nix + ./image-nvim.nix ]; } diff --git a/modules/utility/images/image-nvim/image-nvim.nix b/modules/utility/images/image-nvim/image-nvim.nix new file mode 100644 index 00000000..6433e50e --- /dev/null +++ b/modules/utility/images/image-nvim/image-nvim.nix @@ -0,0 +1,118 @@ +{ + config, + lib, + ... +}: let + inherit (lib.options) mkEnableOption mkOption; + + inherit (lib.types) enum listOf str nullOr int; + inherit (lib.nvim.types) mkPluginSetupOption; +in { + options.vim.utility.images.image-nvim = { + enable = mkEnableOption "image support in Neovim [image.nvim]"; + + setupOpts = mkPluginSetupOption "image.nvim" { + backend = mkOption { + type = enum ["kitty" "ueberzug"]; + default = "ueberzug"; + description = '' + The backend to use for rendering images. + + - kitty - best in class, works great and is very snappy + - ueberzug - backed by ueberzugpp, supports any terminal, + but has lower performance + ''; + }; + + integrations = { + markdown = { + enable = mkEnableOption " image.nvim in markdown files" // {default = true;}; + clearInInsertMode = mkEnableOption "clearing of images when entering insert mode"; + downloadRemoteImages = mkEnableOption "downloading remote images"; + onlyRenderAtCursor = mkEnableOption "only rendering images at cursor"; + filetypes = mkOption { + type = listOf str; + default = ["markdown" "vimwiki"]; + description = '' + Filetypes to enable image.nvim in. Markdown extensions + (i.e. quarto) can go here + ''; + }; + }; + + neorg = { + enable = mkEnableOption "image.nvim in Neorg files" // {default = true;}; + clearInInsertMode = mkEnableOption "clearing of images when entering insert mode"; + downloadRemoteImages = mkEnableOption "downloading remote images"; + onlyRenderAtCursor = mkEnableOption "only rendering images at cursor"; + filetypes = mkOption { + type = listOf str; + default = ["neorg"]; + description = '' + Filetypes to enable image.nvim in. + ''; + }; + }; + + maxWidth = mkOption { + type = nullOr int; + default = null; + description = '' + The maximum width of images to render. Images larger than + this will be scaled down to fit within this width. + ''; + }; + }; + + maxHeight = mkOption { + type = nullOr int; + default = null; + description = '' + The maximum height of images to render. Images larger than + this will be scaled down to fit within this height. + ''; + }; + + maxWidthWindowPercentage = mkOption { + type = nullOr int; + default = null; + description = '' + The maximum width of images to render as a percentage of the + window width. Images larger than this will be scaled down to + fit within this width. + ''; + }; + + maxHeightWindowPercentage = mkOption { + type = nullOr int; + default = 50; + description = '' + The maximum height of images to render as a percentage of the + window height. Images larger than this will be scaled down to + fit within this height. + ''; + }; + + windowOverlapClear = { + enable = mkEnableOption "clearing of images when they overlap with the window"; + ftIgnore = mkOption { + type = listOf str; + default = ["cmp_menu" "cmp_docs" ""]; + description = '' + Filetypes to ignore window overlap clearing in. + ''; + }; + }; + + editorOnlyRenderWhenFocused = mkEnableOption "only rendering images when the editor is focused"; + hijackFilePatterns = mkOption { + type = listOf str; + default = ["*.png" "*.jpg" "*.jpeg" "*.gif" "*.webp"]; + description = '' + File patterns to hijack for image.nvim. This is useful for + filetypes that don't have a dedicated integration. + ''; + }; + }; + }; +} diff --git a/modules/visuals/config.nix b/modules/visuals/config.nix index 7e4a83ba..8cd4ecfc 100644 --- a/modules/visuals/config.nix +++ b/modules/visuals/config.nix @@ -113,24 +113,9 @@ in { ''; }) - (mkIf cfg.fidget-nvim.enable { - vim.startPlugins = ["fidget-nvim"]; - vim.luaConfigRC.fidget-nvim = nvim.dag.entryAnywhere '' - require"fidget".setup{ - align = { - bottom = ${boolToString cfg.fidget-nvim.align.bottom}, - right = ${boolToString cfg.fidget-nvim.align.right}, - }, - window = { - blend = 0, - }, - } - ''; - }) - (mkIf cfg.highlight-undo.enable { vim.startPlugins = ["highlight-undo"]; - vim.luaConfigRC.fidget-nvim = nvim.dag.entryAnywhere '' + vim.luaConfigRC.highlight-undo = nvim.dag.entryAnywhere '' require('highlight-undo').setup({ duration = ${toString cfg.highlight-undo.duration}, highlight_for_count = ${boolToString cfg.highlight-undo.highlightForCount}, diff --git a/modules/visuals/default.nix b/modules/visuals/default.nix index 9efdde73..3c977cba 100644 --- a/modules/visuals/default.nix +++ b/modules/visuals/default.nix @@ -2,5 +2,6 @@ imports = [ ./config.nix ./visuals.nix + ./fidget ]; } diff --git a/modules/visuals/fidget/config.nix b/modules/visuals/fidget/config.nix new file mode 100644 index 00000000..cb212db2 --- /dev/null +++ b/modules/visuals/fidget/config.nix @@ -0,0 +1,16 @@ +{ + config, + lib, + ... +}: let + inherit (lib) mkIf nvim; + cfg = config.vim.visuals.fidget-nvim; +in { + config = mkIf cfg.enable { + vim.startPlugins = ["fidget-nvim"]; + + vim.luaConfigRC.fidget-nvim = nvim.dag.entryAnywhere '' + require'fidget'.setup(${nvim.lua.toLuaObject cfg.setupOpts}) + ''; + }; +} diff --git a/modules/visuals/fidget/default.nix b/modules/visuals/fidget/default.nix new file mode 100644 index 00000000..70dbc7c1 --- /dev/null +++ b/modules/visuals/fidget/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.nix + ./fidget.nix + ]; +} diff --git a/modules/visuals/fidget/fidget.nix b/modules/visuals/fidget/fidget.nix new file mode 100644 index 00000000..173cfd8d --- /dev/null +++ b/modules/visuals/fidget/fidget.nix @@ -0,0 +1,393 @@ +{ + config, + lib, + ... +}: let + inherit (lib) mkRemovedOptionModule mkEnableOption mkOption mapAttrs toUpper nvim types mkRenamedOptionModule; + rawLua = lua: {__raw = lua;}; +in { + imports = [ + (mkRenamedOptionModule ["vim" "visuals" "fidget-nvim" "align" "bottom"] ["vim" "visuals" "fidget-nvim" "setupOpts" "notification" "window" "align"]) + (mkRemovedOptionModule ["vim" "visuals" "fidget-nvim" "align" "right"] + "Option `vim.fidget-nvim.align.right` has been removed and does not have an equivalent replacement in rewritten fidget.nvim configuration.") + ]; + + options.vim.visuals.fidget-nvim = { + enable = mkEnableOption "nvim LSP UI element [fidget-nvim]"; + + setupOpts = nvim.types.mkPluginSetupOption "Fidget" { + progress = { + poll_rate = mkOption { + description = "How frequently to poll for LSP progress messages"; + type = types.int; + default = 0; + }; + suppress_on_insert = mkOption { + description = "Suppress new messages when in insert mode"; + type = types.bool; + default = false; + }; + ignore_done_already = mkOption { + description = "Ignore new tasks that are already done"; + type = types.bool; + default = false; + }; + ignore_empty_message = mkOption { + description = "Ignore new tasks with empty messages"; + type = types.bool; + default = false; + }; + clear_on_detach = mkOption { + description = "Clear notification group when LSP server detaches"; + type = types.bool; + default = true; + apply = clear: + if clear + then + rawLua '' + function(client_id) + local client = vim.lsp.get_client_by_id(client_id) + return client and client.name or nil + end + '' + else null; + }; + notification_group = mkOption { + description = "How to get a progress message's notification group key"; + type = types.str; + default = '' + function(msg) + return msg.lsp_client.name + end + ''; + apply = rawLua; + }; + ignore = mkOption { + description = "Ignore LSP servers by name"; + type = types.listOf types.str; + default = []; + }; + + display = { + render_limit = mkOption { + description = "Maximum number of messages to render"; + type = types.int; + default = 16; + }; + done_ttl = mkOption { + description = "How long a message should persist when complete"; + type = types.int; + default = 3; + }; + done_icon = mkOption { + description = "Icon shown when LSP progress tasks are completed"; + type = types.str; + default = "✓"; + }; + done_style = mkOption { + description = "Highlight group for completed LSP tasks"; + type = types.str; + default = "Constant"; + }; + progress_ttl = mkOption { + description = "How long a message should persist when in progress"; + type = types.int; + default = 99999; + }; + progress_icon = { + pattern = mkOption { + description = "Pattern shown when LSP progress tasks are in progress"; + type = types.enum [ + "dots" + "dots_negative" + "dots_snake" + "dots_footsteps" + "dots_hop" + "line" + "pipe" + "dots_ellipsis" + "dots_scrolling" + "star" + "flip" + "hamburger" + "grow_vertical" + "grow_horizontal" + "noise" + "dots_bounce" + "triangle" + "arc" + "circle" + "square_corners" + "circle_quarters" + "circle_halves" + "dots_toggle" + "box_toggle" + "arrow" + "zip" + "bouncing_bar" + "bouncing_ball" + "clock" + "earth" + "moon" + "dots_pulse" + "meter" + ]; + default = "dots"; + }; + period = mkOption { + description = "Period of the pattern"; + type = types.int; + default = 1; + }; + }; + progress_style = mkOption { + description = "Highlight group for in-progress LSP tasks"; + type = types.str; + default = "WarningMsg"; + }; + group_style = mkOption { + description = "Highlight group for group name (LSP server name)"; + type = types.str; + default = "Title"; + }; + icon_style = mkOption { + description = "Highlight group for group icons"; + type = types.str; + default = "Question"; + }; + priority = mkOption { + description = "Priority of the progress notification"; + type = types.int; + default = 30; + }; + skip_history = mkOption { + description = "Skip adding messages to history"; + type = types.bool; + default = true; + }; + format_message = mkOption { + description = "How to format a progress message"; + type = types.str; + default = '' + require("fidget.progress.display").default_format_message + ''; + apply = rawLua; + }; + format_annote = mkOption { + description = "How to format a progress annotation"; + type = types.str; + default = '' + function(msg) return msg.title end + ''; + apply = rawLua; + }; + format_group_name = mkOption { + description = "How to format a progress notification group's name"; + type = types.str; + default = '' + function(group) return tostring(group) end + ''; + apply = rawLua; + }; + overrides = mkOption { + description = "Override options from the default notification config"; + type = types.attrsOf types.str; + default = {rust_analyzer = "{ name = 'rust-analyzer' }";}; + apply = mapAttrs (key: lua: rawLua lua); + }; + }; + + lsp = { + progress_ringbuf_size = mkOption { + description = "Nvim's LSP client ring buffer size"; + type = types.int; + default = 100; + }; + log_handler = mkOption { + description = "Log `$/progress` handler invocations"; + type = types.bool; + default = false; + }; + }; + }; + + notification = { + poll_rate = mkOption { + description = "How frequently to update and render notifications"; + type = types.int; + default = 10; + }; + filter = mkOption { + description = "Minimum notifications level"; + type = types.enum ["debug" "info" "warn" "error"]; + default = "info"; + apply = filter: rawLua "vim.log.levels.${toUpper filter}"; + }; + history_size = mkOption { + description = "Number of removed messages to retain in history"; + type = types.int; + default = 128; + }; + override_vim_notify = mkOption { + description = "Automatically override vim.notify() with Fidget"; + type = types.bool; + default = false; + }; + configs = mkOption { + description = "How to configure notification groups when instantiated"; + type = types.attrsOf types.str; + default = {default = "require('fidget.notification').default_config";}; + apply = mapAttrs (key: lua: rawLua lua); + }; + redirect = mkOption { + description = "Conditionally redirect notifications to another backend"; + type = types.str; + default = '' + function(msg, level, opts) + if opts and opts.on_open then + return require("fidget.integration.nvim-notify").delegate(msg, level, opts) + end + end + ''; + apply = rawLua; + }; + + view = { + stack_upwards = mkOption { + description = "Display notification items from bottom to top"; + type = types.bool; + default = true; + }; + icon_separator = mkOption { + description = "Separator between group name and icon"; + type = types.str; + default = " "; + }; + group_separator = mkOption { + description = "Separator between notification groups"; + type = types.str; + default = "---"; + }; + group_separator_hl = mkOption { + description = "Highlight group used for group separator"; + type = types.str; + default = "Comment"; + }; + render_message = mkOption { + description = "How to render notification messages"; + type = types.str; + default = '' + function(msg, cnt) + return cnt == 1 and msg or string.format("(%dx) %s", cnt, msg) + end + ''; + apply = rawLua; + }; + }; + + window = { + normal_hl = mkOption { + description = "Base highlight group in the notification window"; + type = types.str; + default = "Comment"; + }; + winblend = mkOption { + description = "Background color opacity in the notification window"; + type = types.int; + default = 100; + }; + border = mkOption { + description = "Border style of the notification window"; + type = types.enum ["none" "single" "double" "rounded" "solid" "shadow"]; + default = + if config.vim.ui.borders.enable + then config.vim.ui.borders.globalStyle + else "none"; + }; + zindex = mkOption { + description = "Stacking priority of the notification window"; + type = types.int; + default = 45; + }; + max_width = mkOption { + description = "Maximum width of the notification window"; + type = types.int; + default = 0; + }; + max_height = mkOption { + description = "Maximum height of the notification window"; + type = types.int; + default = 0; + }; + x_padding = mkOption { + description = "Padding from right edge of window boundary"; + type = types.int; + default = 1; + }; + y_padding = mkOption { + description = "Padding from bottom edge of window boundary"; + type = types.int; + default = 0; + }; + align = mkOption { + description = "How to align the notification window"; + type = types.enum ["top" "bottom"]; + default = "bottom"; + }; + relative = mkOption { + description = "What the notification window position is relative to"; + type = types.enum ["editor" "win"]; + default = "editor"; + }; + }; + }; + + integration = { + nvim-tree = { + enable = mkOption { + description = "Integrate with nvim-tree/nvim-tree.lua (if enabled)"; + type = types.bool; + default = + if config.vim.filetree.nvimTree.enable + then true + else false; + }; + }; + xcodebuild-nvim = { + enable = mkOption { + description = "Integrate with wojciech-kulik/xcodebuild.nvim (if enabled)"; + type = types.bool; + default = true; + }; + }; + }; + + logger = { + level = mkOption { + description = "Minimum logging level"; + type = types.enum ["debug" "error" "info" "trace" "warn" "off"]; + default = "warn"; + apply = logLevel: rawLua "vim.log.levels.${toUpper logLevel}"; + }; + max_size = mkOption { + description = "Maximum log file size, in KB"; + type = types.int; + default = 10000; + }; + float_precision = mkOption { + description = "Limit the number of decimals displayed for floats"; + type = types.float; + default = 0.01; + }; + path = mkOption { + description = "Where Fidget writes its logs to"; + type = types.str; + default = '' + string.format("%s/fidget.nvim.log", vim.fn.stdpath("cache")) + ''; + apply = rawLua; + }; + }; + }; + }; +} diff --git a/modules/visuals/visuals.nix b/modules/visuals/visuals.nix index 08dc1c31..4fde5885 100644 --- a/modules/visuals/visuals.nix +++ b/modules/visuals/visuals.nix @@ -30,24 +30,6 @@ in { }; }; - fidget-nvim = { - enable = mkEnableOption "nvim LSP UI element [fidget-nvim]"; - - align = { - bottom = mkOption { - type = types.bool; - description = "Align to bottom"; - default = true; - }; - - right = mkOption { - type = types.bool; - description = "Align to right"; - default = true; - }; - }; - }; - cursorline = { enable = mkEnableOption "line hightlighting on the cursor [nvim-cursorline]";