From 868f8087099400e92451085b33dff0ccf771469b Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Sat, 10 Feb 2024 20:52:02 -0500 Subject: [PATCH 001/193] visuals/fidget: switch input branch to main --- flake.lock | 7 +++---- flake.nix | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index 44d96fa..d7af1a2 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" } diff --git a/flake.nix b/flake.nix index 67b6577..609f8fc 100644 --- a/flake.nix +++ b/flake.nix @@ -398,7 +398,7 @@ }; fidget-nvim = { - url = "github:j-hui/fidget.nvim?ref=legacy"; + url = "github:j-hui/fidget.nvim"; flake = false; }; From 042af029552d3ec48046e50099cd79b9e4477dd4 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Sat, 10 Feb 2024 20:49:27 -0500 Subject: [PATCH 002/193] visuals/fidget: migrate to newer configuration with custom setup options --- modules/visuals/config.nix | 17 +- modules/visuals/default.nix | 1 + modules/visuals/fidget/config.nix | 16 ++ modules/visuals/fidget/default.nix | 6 + modules/visuals/fidget/fidget.nix | 387 +++++++++++++++++++++++++++++ modules/visuals/visuals.nix | 18 -- 6 files changed, 411 insertions(+), 34 deletions(-) create mode 100644 modules/visuals/fidget/config.nix create mode 100644 modules/visuals/fidget/default.nix create mode 100644 modules/visuals/fidget/fidget.nix diff --git a/modules/visuals/config.nix b/modules/visuals/config.nix index 7e4a83b..8cd4ecf 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 9efdde7..3c977cb 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 0000000..cb212db --- /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 0000000..70dbc7c --- /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 0000000..efa8932 --- /dev/null +++ b/modules/visuals/fidget/fidget.nix @@ -0,0 +1,387 @@ +{ + config, + lib, + ... +}: let + inherit (lib) mkEnableOption mkOption mapAttrs toUpper nvim types; + rawLua = lua: {__raw = lua;}; +in { + options.vim.visuals.fidget-nvim = { + enable = mkEnableOption "nvim LSP UI element [fidget-nvim]"; + + setupOpts = nvim.types.mkPluginSetupOption "Nvim Tree" { + 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 08dc1c3..4fde588 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]"; From adde1f08e66688de996ddb8fa3403544dfe33f21 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Mon, 19 Feb 2024 01:58:41 -0500 Subject: [PATCH 003/193] docs: add entry for rewritten `fidget.nvim` module --- docs/release-notes/rl-0.6.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/rl-0.6.md b/docs/release-notes/rl-0.6.md index 01fbe62..c162ac0 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. From fc511966f0b97596c315a173c1fa6070493be5a2 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Mon, 19 Feb 2024 03:17:01 -0500 Subject: [PATCH 004/193] visuals/fidget: add `mkRemovedOptionModule` for the old configuration options --- modules/visuals/fidget/fidget.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/visuals/fidget/fidget.nix b/modules/visuals/fidget/fidget.nix index efa8932..5968d10 100644 --- a/modules/visuals/fidget/fidget.nix +++ b/modules/visuals/fidget/fidget.nix @@ -3,9 +3,16 @@ lib, ... }: let - inherit (lib) mkEnableOption mkOption mapAttrs toUpper nvim types; + inherit (lib) mkRemovedOptionModule mkEnableOption mkOption mapAttrs toUpper nvim types; rawLua = lua: {__raw = lua;}; in { + imports = [ + (mkRemovedOptionModule ["vim" "visuals" "fidget-nvim" "align" "bottom"] + "Option `vim.fidget-nvim.align.bottom` has been removed in favor of `vim.fidget-nvim.notification.window.align`, which supports the `bottom` value for the same purpose.") + (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]"; From 0b9e5e8f37ce5cb046818457587b36d4325d142c Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Mon, 19 Feb 2024 11:10:44 +0100 Subject: [PATCH 005/193] docs: use mkRenamedOptionModule instead of RemovedOption --- modules/visuals/fidget/fidget.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/visuals/fidget/fidget.nix b/modules/visuals/fidget/fidget.nix index 5968d10..6b88a4b 100644 --- a/modules/visuals/fidget/fidget.nix +++ b/modules/visuals/fidget/fidget.nix @@ -3,12 +3,11 @@ lib, ... }: let - inherit (lib) mkRemovedOptionModule mkEnableOption mkOption mapAttrs toUpper nvim types; + inherit (lib) mkRemovedOptionModule mkEnableOption mkOption mapAttrs toUpper nvim types mkRenamedOptionModule; rawLua = lua: {__raw = lua;}; in { imports = [ - (mkRemovedOptionModule ["vim" "visuals" "fidget-nvim" "align" "bottom"] - "Option `vim.fidget-nvim.align.bottom` has been removed in favor of `vim.fidget-nvim.notification.window.align`, which supports the `bottom` value for the same purpose.") + (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.") ]; From 055fcb4f571bfbe2efc726bf1eaaa996ee550338 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Mon, 19 Feb 2024 16:15:18 -0500 Subject: [PATCH 006/193] visuals/fidget: fix plugin setupOpts name --- modules/visuals/fidget/fidget.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/visuals/fidget/fidget.nix b/modules/visuals/fidget/fidget.nix index 6b88a4b..173cfd8 100644 --- a/modules/visuals/fidget/fidget.nix +++ b/modules/visuals/fidget/fidget.nix @@ -15,7 +15,7 @@ in { options.vim.visuals.fidget-nvim = { enable = mkEnableOption "nvim LSP UI element [fidget-nvim]"; - setupOpts = nvim.types.mkPluginSetupOption "Nvim Tree" { + setupOpts = nvim.types.mkPluginSetupOption "Fidget" { progress = { poll_rate = mkOption { description = "How frequently to poll for LSP progress messages"; From 48c8f38a1435d347f7fb81e74a5e2c690af2d450 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Tue, 20 Feb 2024 00:37:45 -0500 Subject: [PATCH 007/193] languages/lua: always include lua parser with treesitter --- modules/languages/lua.nix | 48 ++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/modules/languages/lua.nix b/modules/languages/lua.nix index e902aa9..5cfe203 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({}) + ''; + }) + ])) + ]; } From 29b9bd4db0c67a3b9d2bd4aa5ec6763d96997788 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Tue, 20 Feb 2024 22:15:18 -0500 Subject: [PATCH 008/193] utility/binds/which-key: allow configurable category labels --- modules/utility/binds/which-key/config.nix | 105 ++---------------- modules/utility/binds/which-key/which-key.nix | 15 ++- 2 files changed, 20 insertions(+), 100 deletions(-) diff --git a/modules/utility/binds/which-key/config.nix b/modules/utility/binds/which-key/config.nix index 6e2a83c..238d888 100644 --- a/modules/utility/binds/which-key/config.nix +++ b/modules/utility/binds/which-key/config.nix @@ -3,14 +3,17 @@ lib, ... }: let - inherit (lib) mkIf nvim; + inherit (lib.modules) mkIf; + inherit (lib.strings) optionalString; + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.binds.whichKey; in { config = mkIf (cfg.enable) { vim.startPlugins = ["which-key"]; - vim.luaConfigRC.whichkey = nvim.dag.entryAnywhere '' + vim.luaConfigRC.whichkey = entryAnywhere '' local wk = require("which-key") wk.setup ({ key_labels = { @@ -20,108 +23,14 @@ in { [""] = "TAB", }, - ${lib.optionalString (config.vim.ui.borders.plugins.which-key.enable) '' + ${optionalString (config.vim.ui.borders.plugins.which-key.enable) '' window = { border = "${config.vim.ui.borders.plugins.which-key.style}", }, ''} }) - wk.register({ - ${ - if config.vim.tabline.nvimBufferline.enable - then '' - -- Buffer - ["b"] = { name = "+Buffer" }, - ["bm"] = { name = "BufferLineMove" }, - ["bs"] = { name = "BufferLineSort" }, - ["bsi"] = { name = "BufferLineSortById" }, - '' - else "" - } - - ${ - if config.vim.telescope.enable - then '' - ["f"] = { name = "+Telescope" }, - -- Telescope - ["fl"] = { name = "Telescope LSP" }, - ["fm"] = { name = "Cellular Automaton" }, -- TODO: mvoe this to its own parent group - ["fv"] = { name = "Telescope Git" }, - ["fvc"] = { name = "Commits" }, - '' - else "" - } - - ${ - if config.vim.lsp.trouble.enable - then '' - -- Trouble - ["lw"] = { name = "Workspace" }, - ["x"] = { name = "+Trouble" }, -- TODO: move all trouble binds to the same parent group - ["l"] = { name = "+Trouble" }, - '' - else "" - } - - ${ - if config.vim.lsp.nvimCodeActionMenu.enable - then '' - -- Parent Groups - ["c"] = { name = "+CodeAction" }, - '' - else "" - } - - ${ - if config.vim.minimap.codewindow.enable || config.vim.minimap.minimap-vim.enable - then '' - -- Minimap - ["m"] = { name = "+Minimap" }, -- TODO: remap both minimap plugins' keys to be the same - '' - else "" - } - - ${ - if config.vim.notes.mind-nvim.enable || config.vim.notes.obsidian.enable || config.vim.notes.orgmode.enable - then '' - -- Notes - ["o"] = { name = "+Notes" }, - -- TODO: options for other note taking plugins and their individual binds - -- TODO: move all note-taker binds under leader + o - '' - else "" - } - - ${ - # TODO: This probably will need to be reworked for custom-keybinds - if config.vim.filetree.nvimTree.enable - then '' - -- NvimTree - ["t"] = { name = "+NvimTree" }, - '' - else "" - } - - ${ - if config.vim.git.gitsigns.enable - then '' - -- Git - ["g"] = { name = "+Gitsigns" }, - '' - else "" - } - - ${ - if config.vim.utility.preview.glow.enable - then '' - -- Markdown - ["pm"] = { name = "+Preview Markdown" }, - '' - else "" - } - - }) + wk.register(${toLuaObject cfg.register}) ''; }; } diff --git a/modules/utility/binds/which-key/which-key.nix b/modules/utility/binds/which-key/which-key.nix index ceba7de..796dc8e 100644 --- a/modules/utility/binds/which-key/which-key.nix +++ b/modules/utility/binds/which-key/which-key.nix @@ -1,7 +1,18 @@ -{lib, ...}: let - inherit (lib) mkEnableOption; +{ + config, + lib, + ... +}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) attrsOf str; in { options.vim.binds.whichKey = { enable = mkEnableOption "which-key keybind helper menu"; + + register = mkOption { + description = "Register label for which-key keybind helper menu"; + type = attrsOf str; + default = {}; + }; }; } From f19a5dd3ed5b288dc857c29b1de2028231e2f7f0 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Sun, 25 Feb 2024 11:40:43 -0500 Subject: [PATCH 009/193] lib: add function defaultAttributes --- lib/stdlib-extended.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/stdlib-extended.nix b/lib/stdlib-extended.nix index 9833248..943525b 100644 --- a/lib/stdlib-extended.nix +++ b/lib/stdlib-extended.nix @@ -68,6 +68,8 @@ in mkSetLuaBinding = binding: action: mkLuaBinding binding.value action binding.description; + defaultAttributes = attr: self.mapAttrs (name: value: self.mkDefault value) attr; + # For forward compatibility. literalExpression = super.literalExpression or super.literalExample; }) From b9aa7088b88a48bb9960ecb9803d46dca0386f2f Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Sun, 25 Feb 2024 11:39:05 -0500 Subject: [PATCH 010/193] treewide: register whichKey labels --- modules/filetree/nvimtree/config.nix | 6 +++++- modules/git/config.nix | 6 +++++- modules/lsp/nvim-code-action-menu/config.nix | 6 +++++- modules/lsp/trouble/config.nix | 8 +++++++- modules/minimap/codewindow/config.nix | 6 +++++- modules/minimap/minimap-vim/config.nix | 6 +++++- modules/notes/mind-nvim/config.nix | 6 +++++- modules/notes/obsidian/config.nix | 6 +++++- modules/notes/orgmode/config.nix | 6 +++++- modules/tabline/nvim-bufferline/config.nix | 9 ++++++++- modules/utility/preview/glow/config.nix | 6 +++++- modules/utility/telescope/config.nix | 10 +++++++++- 12 files changed, 69 insertions(+), 12 deletions(-) diff --git a/modules/filetree/nvimtree/config.nix b/modules/filetree/nvimtree/config.nix index 5f11c5a..2c37c27 100644 --- a/modules/filetree/nvimtree/config.nix +++ b/modules/filetree/nvimtree/config.nix @@ -4,7 +4,7 @@ pkgs, ... }: let - inherit (lib) mkIf mkMerge mkBinding nvim boolToString; + inherit (lib) mkIf mkMerge mkBinding nvim boolToString defaultAttributes; cfg = config.vim.filetree.nvimTree; self = import ./nvimtree.nix { @@ -23,6 +23,10 @@ in { (mkBinding cfg.mappings.focus ":NvimTreeFocus" mappings.focus.description) ]; + vim.binds.whichKey.register = defaultAttributes { + "t" = "+NvimTree"; + }; + vim.luaConfigRC.nvimtreelua = nvim.dag.entryAnywhere '' ${ lib.optionalString (cfg.disableNetrw) '' diff --git a/modules/git/config.nix b/modules/git/config.nix index e0d4a03..6d76db3 100644 --- a/modules/git/config.nix +++ b/modules/git/config.nix @@ -4,7 +4,7 @@ ... }: let inherit (builtins) toJSON; - inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetExprBinding mkSetLuaBinding nvim; + inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetExprBinding mkSetLuaBinding nvim defaultAttributes; cfg = config.vim.git; @@ -61,6 +61,10 @@ in { (mkSetLuaBinding gsMappings.resetHunk "function() package.loaded.gitsigns.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end") ]; + vim.binds.whichKey.register = defaultAttributes { + "g" = "+Gitsigns"; + }; + vim.luaConfigRC.gitsigns = nvim.dag.entryAnywhere '' require('gitsigns').setup{} ''; diff --git a/modules/lsp/nvim-code-action-menu/config.nix b/modules/lsp/nvim-code-action-menu/config.nix index c64f027..b667814 100644 --- a/modules/lsp/nvim-code-action-menu/config.nix +++ b/modules/lsp/nvim-code-action-menu/config.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib) addDescriptionsToMappings mkIf mkSetBinding nvim; + inherit (lib) addDescriptionsToMappings mkIf mkSetBinding nvim defaultAttributes; cfg = config.vim.lsp; @@ -17,6 +17,10 @@ in { vim.maps.normal = mkSetBinding mappings.open ":CodeActionMenu"; + vim.binds.whichKey.register = defaultAttributes { + "c" = "+CodeAction"; + }; + vim.luaConfigRC.code-action-menu = nvim.dag.entryAnywhere '' -- border configuration vim.g.code_action_menu_window_border = '${config.vim.ui.borders.plugins.code-action-menu.style}' diff --git a/modules/lsp/trouble/config.nix b/modules/lsp/trouble/config.nix index ee136a5..5dd566c 100644 --- a/modules/lsp/trouble/config.nix +++ b/modules/lsp/trouble/config.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim; + inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim defaultAttributes; cfg = config.vim.lsp; @@ -24,6 +24,12 @@ in { (mkSetBinding mappings.locList "TroubleToggle loclist") ]; + vim.binds.whichKey.register = defaultAttributes { + "l" = "Trouble"; + "x" = "+Trouble"; + "lw" = "Workspace"; + }; + vim.luaConfigRC.trouble = nvim.dag.entryAnywhere '' -- Enable trouble diagnostics viewer require("trouble").setup {} diff --git a/modules/minimap/codewindow/config.nix b/modules/minimap/codewindow/config.nix index 86b0137..fafd454 100644 --- a/modules/minimap/codewindow/config.nix +++ b/modules/minimap/codewindow/config.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetLuaBinding nvim; + inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetLuaBinding nvim defaultAttributes; cfg = config.vim.minimap.codewindow; @@ -24,6 +24,10 @@ in { (mkSetLuaBinding mappings.toggleFocus "require('codewindow').toggle_focus") ]; + vim.binds.whichKey.register = defaultAttributes { + "m" = "+Minimap"; + }; + vim.luaConfigRC.codewindow = nvim.dag.entryAnywhere '' local codewindow = require('codewindow') codewindow.setup({ diff --git a/modules/minimap/minimap-vim/config.nix b/modules/minimap/minimap-vim/config.nix index ef318f7..c9d738f 100644 --- a/modules/minimap/minimap-vim/config.nix +++ b/modules/minimap/minimap-vim/config.nix @@ -4,7 +4,7 @@ lib, ... }: let - inherit (lib) mkIf; + inherit (lib) mkIf defaultAttributes; cfg = config.vim.minimap.minimap-vim; in { @@ -13,5 +13,9 @@ in { pkgs.code-minimap "minimap-vim" ]; + + vim.binds.whichKey.register = defaultAttributes { + "m" = "+Minimap"; + }; }; } diff --git a/modules/notes/mind-nvim/config.nix b/modules/notes/mind-nvim/config.nix index 98f7751..c704d4b 100644 --- a/modules/notes/mind-nvim/config.nix +++ b/modules/notes/mind-nvim/config.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib) mkIf nvim; + inherit (lib) mkIf nvim defaultAttributes; cfg = config.vim.notes.mind-nvim; in { @@ -18,6 +18,10 @@ in { "oc" = {action = ":MindClose";}; }; + vim.binds.whichKey.register = defaultAttributes { + "o" = "+Notes"; + }; + vim.luaConfigRC.mind-nvim = nvim.dag.entryAnywhere '' require'mind'.setup() ''; diff --git a/modules/notes/obsidian/config.nix b/modules/notes/obsidian/config.nix index 192244b..6cb0ef3 100644 --- a/modules/notes/obsidian/config.nix +++ b/modules/notes/obsidian/config.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib) mkIf nvim; + inherit (lib) mkIf nvim defaultAttributes; cfg = config.vim.notes.obsidian; auto = config.vim.autocomplete; @@ -15,6 +15,10 @@ in { "tabular" ]; + vim.binds.whichKey.register = defaultAttributes { + "o" = "+Notes"; + }; + vim.luaConfigRC.obsidian = nvim.dag.entryAnywhere '' require("obsidian").setup({ dir = "${cfg.dir}", diff --git a/modules/notes/orgmode/config.nix b/modules/notes/orgmode/config.nix index 967a937..46201ef 100644 --- a/modules/notes/orgmode/config.nix +++ b/modules/notes/orgmode/config.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib) mkIf mkMerge nvim; + inherit (lib) mkIf mkMerge nvim defaultAttributes; cfg = config.vim.notes.orgmode; in { @@ -13,6 +13,10 @@ in { "orgmode-nvim" ]; + vim.binds.whichKey.register = defaultAttributes { + "o" = "+Notes"; + }; + vim.luaConfigRC.orgmode = nvim.dag.entryAnywhere '' -- Load custom treesitter grammar for org filetype require('orgmode').setup_ts_grammar() diff --git a/modules/tabline/nvim-bufferline/config.nix b/modules/tabline/nvim-bufferline/config.nix index 9004c89..256875b 100644 --- a/modules/tabline/nvim-bufferline/config.nix +++ b/modules/tabline/nvim-bufferline/config.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib) mkIf mkMerge mkLuaBinding mkBinding nvim; + inherit (lib) mkIf mkMerge mkLuaBinding mkBinding nvim defaultAttributes; cfg = config.vim.tabline.nvimBufferline; self = import ./nvim-bufferline.nix { @@ -40,6 +40,13 @@ in { (mkBinding cfg.mappings.movePrevious ":BufferLineMovePrev" mappings.movePrevious.description) ]; + vim.binds.whichKey.register = defaultAttributes { + "b" = "+Buffer"; + "bm" = "BufferLineMove"; + "bs" = "BufferLineSort"; + "bsi" = "BufferLineSortById"; + }; + vim.luaConfigRC.nvimBufferline = nvim.dag.entryAnywhere '' require("bufferline").setup{ options = { diff --git a/modules/utility/preview/glow/config.nix b/modules/utility/preview/glow/config.nix index 5b9e14f..130a1a5 100644 --- a/modules/utility/preview/glow/config.nix +++ b/modules/utility/preview/glow/config.nix @@ -4,7 +4,7 @@ lib, ... }: let - inherit (lib) nvim mkIf mkMerge mkBinding; + inherit (lib) nvim mkIf mkMerge mkBinding defaultAttributes; cfg = config.vim.utility.preview.glow; self = import ./glow.nix { @@ -19,6 +19,10 @@ in { (mkBinding cfg.mappings.openPreview ":Glow" mappings.openPreview.description) ]; + vim.binds.whichKey.register = defaultAttributes { + "pm" = "+Preview Markdown"; + }; + vim.luaConfigRC.glow = nvim.dag.entryAnywhere '' require('glow').setup({ glow_path = "${pkgs.glow}/bin/glow" diff --git a/modules/utility/telescope/config.nix b/modules/utility/telescope/config.nix index 53cde96..fa790bf 100644 --- a/modules/utility/telescope/config.nix +++ b/modules/utility/telescope/config.nix @@ -4,7 +4,7 @@ lib, ... }: let - inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim; + inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim defaultAttributes; cfg = config.vim.telescope; self = import ./telescope.nix {inherit lib;}; @@ -52,6 +52,14 @@ in { ) ]; + vim.binds.whichKey.register = defaultAttributes { + "f" = "+Telescope"; + "fl" = "Telescope LSP"; + "fm" = "Cellular Automaton"; + "fv" = "Telescope Git"; + "fvc" = "Commits"; + }; + vim.luaConfigRC.telescope = nvim.dag.entryAnywhere '' local telescope = require('telescope') telescope.setup { From 9a7087e53cee73829d83dfc3e81eeea021b164f6 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Sun, 25 Feb 2024 11:49:43 -0500 Subject: [PATCH 011/193] docs: add entry for option `vim.binds.whichKey.register` --- docs/release-notes/rl-0.6.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/release-notes/rl-0.6.md b/docs/release-notes/rl-0.6.md index c162ac0..532f5d9 100644 --- a/docs/release-notes/rl-0.6.md +++ b/docs/release-notes/rl-0.6.md @@ -56,3 +56,5 @@ Release notes for release 0.6 - 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. + +- `which-key.nvim` categories can now be customized through [vim.binds.whichKey.register](vim.binds.whichKey.register). From 4716fd731f67054c32e2a15f0b6a5ed8eb540056 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Sun, 25 Feb 2024 22:52:21 -0500 Subject: [PATCH 012/193] treewide: rename function `defaultAttributes` to `pushDownDefault` --- lib/stdlib-extended.nix | 2 +- modules/filetree/nvimtree/config.nix | 4 ++-- modules/git/config.nix | 4 ++-- modules/lsp/nvim-code-action-menu/config.nix | 4 ++-- modules/lsp/trouble/config.nix | 4 ++-- modules/minimap/codewindow/config.nix | 4 ++-- modules/minimap/minimap-vim/config.nix | 4 ++-- modules/notes/mind-nvim/config.nix | 4 ++-- modules/notes/obsidian/config.nix | 4 ++-- modules/notes/orgmode/config.nix | 4 ++-- modules/tabline/nvim-bufferline/config.nix | 4 ++-- modules/utility/preview/glow/config.nix | 4 ++-- modules/utility/telescope/config.nix | 4 ++-- 13 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/stdlib-extended.nix b/lib/stdlib-extended.nix index 943525b..ff7b7f6 100644 --- a/lib/stdlib-extended.nix +++ b/lib/stdlib-extended.nix @@ -68,7 +68,7 @@ in mkSetLuaBinding = binding: action: mkLuaBinding binding.value action binding.description; - defaultAttributes = attr: self.mapAttrs (name: value: self.mkDefault value) attr; + pushDownDefault = attr: self.mapAttrs (name: value: self.mkDefault value) attr; # For forward compatibility. literalExpression = super.literalExpression or super.literalExample; diff --git a/modules/filetree/nvimtree/config.nix b/modules/filetree/nvimtree/config.nix index 2c37c27..9da8afd 100644 --- a/modules/filetree/nvimtree/config.nix +++ b/modules/filetree/nvimtree/config.nix @@ -4,7 +4,7 @@ pkgs, ... }: let - inherit (lib) mkIf mkMerge mkBinding nvim boolToString defaultAttributes; + inherit (lib) mkIf mkMerge mkBinding nvim boolToString pushDownDefault; cfg = config.vim.filetree.nvimTree; self = import ./nvimtree.nix { @@ -23,7 +23,7 @@ in { (mkBinding cfg.mappings.focus ":NvimTreeFocus" mappings.focus.description) ]; - vim.binds.whichKey.register = defaultAttributes { + vim.binds.whichKey.register = pushDownDefault { "t" = "+NvimTree"; }; diff --git a/modules/git/config.nix b/modules/git/config.nix index 6d76db3..39366d9 100644 --- a/modules/git/config.nix +++ b/modules/git/config.nix @@ -4,7 +4,7 @@ ... }: let inherit (builtins) toJSON; - inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetExprBinding mkSetLuaBinding nvim defaultAttributes; + inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetExprBinding mkSetLuaBinding nvim pushDownDefault; cfg = config.vim.git; @@ -61,7 +61,7 @@ in { (mkSetLuaBinding gsMappings.resetHunk "function() package.loaded.gitsigns.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end") ]; - vim.binds.whichKey.register = defaultAttributes { + vim.binds.whichKey.register = pushDownDefault { "g" = "+Gitsigns"; }; diff --git a/modules/lsp/nvim-code-action-menu/config.nix b/modules/lsp/nvim-code-action-menu/config.nix index b667814..9f8f604 100644 --- a/modules/lsp/nvim-code-action-menu/config.nix +++ b/modules/lsp/nvim-code-action-menu/config.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib) addDescriptionsToMappings mkIf mkSetBinding nvim defaultAttributes; + inherit (lib) addDescriptionsToMappings mkIf mkSetBinding nvim pushDownDefault; cfg = config.vim.lsp; @@ -17,7 +17,7 @@ in { vim.maps.normal = mkSetBinding mappings.open ":CodeActionMenu"; - vim.binds.whichKey.register = defaultAttributes { + vim.binds.whichKey.register = pushDownDefault { "c" = "+CodeAction"; }; diff --git a/modules/lsp/trouble/config.nix b/modules/lsp/trouble/config.nix index 5dd566c..bb751c7 100644 --- a/modules/lsp/trouble/config.nix +++ b/modules/lsp/trouble/config.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim defaultAttributes; + inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim pushDownDefault; cfg = config.vim.lsp; @@ -24,7 +24,7 @@ in { (mkSetBinding mappings.locList "TroubleToggle loclist") ]; - vim.binds.whichKey.register = defaultAttributes { + vim.binds.whichKey.register = pushDownDefault { "l" = "Trouble"; "x" = "+Trouble"; "lw" = "Workspace"; diff --git a/modules/minimap/codewindow/config.nix b/modules/minimap/codewindow/config.nix index fafd454..b95aca8 100644 --- a/modules/minimap/codewindow/config.nix +++ b/modules/minimap/codewindow/config.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetLuaBinding nvim defaultAttributes; + inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetLuaBinding nvim pushDownDefault; cfg = config.vim.minimap.codewindow; @@ -24,7 +24,7 @@ in { (mkSetLuaBinding mappings.toggleFocus "require('codewindow').toggle_focus") ]; - vim.binds.whichKey.register = defaultAttributes { + vim.binds.whichKey.register = pushDownDefault { "m" = "+Minimap"; }; diff --git a/modules/minimap/minimap-vim/config.nix b/modules/minimap/minimap-vim/config.nix index c9d738f..6577e8c 100644 --- a/modules/minimap/minimap-vim/config.nix +++ b/modules/minimap/minimap-vim/config.nix @@ -4,7 +4,7 @@ lib, ... }: let - inherit (lib) mkIf defaultAttributes; + inherit (lib) mkIf pushDownDefault; cfg = config.vim.minimap.minimap-vim; in { @@ -14,7 +14,7 @@ in { "minimap-vim" ]; - vim.binds.whichKey.register = defaultAttributes { + vim.binds.whichKey.register = pushDownDefault { "m" = "+Minimap"; }; }; diff --git a/modules/notes/mind-nvim/config.nix b/modules/notes/mind-nvim/config.nix index c704d4b..8a609b0 100644 --- a/modules/notes/mind-nvim/config.nix +++ b/modules/notes/mind-nvim/config.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib) mkIf nvim defaultAttributes; + inherit (lib) mkIf nvim pushDownDefault; cfg = config.vim.notes.mind-nvim; in { @@ -18,7 +18,7 @@ in { "oc" = {action = ":MindClose";}; }; - vim.binds.whichKey.register = defaultAttributes { + vim.binds.whichKey.register = pushDownDefault { "o" = "+Notes"; }; diff --git a/modules/notes/obsidian/config.nix b/modules/notes/obsidian/config.nix index 6cb0ef3..f521c62 100644 --- a/modules/notes/obsidian/config.nix +++ b/modules/notes/obsidian/config.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib) mkIf nvim defaultAttributes; + inherit (lib) mkIf nvim pushDownDefault; cfg = config.vim.notes.obsidian; auto = config.vim.autocomplete; @@ -15,7 +15,7 @@ in { "tabular" ]; - vim.binds.whichKey.register = defaultAttributes { + vim.binds.whichKey.register = pushDownDefault { "o" = "+Notes"; }; diff --git a/modules/notes/orgmode/config.nix b/modules/notes/orgmode/config.nix index 46201ef..08df2de 100644 --- a/modules/notes/orgmode/config.nix +++ b/modules/notes/orgmode/config.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib) mkIf mkMerge nvim defaultAttributes; + inherit (lib) mkIf mkMerge nvim pushDownDefault; cfg = config.vim.notes.orgmode; in { @@ -13,7 +13,7 @@ in { "orgmode-nvim" ]; - vim.binds.whichKey.register = defaultAttributes { + vim.binds.whichKey.register = pushDownDefault { "o" = "+Notes"; }; diff --git a/modules/tabline/nvim-bufferline/config.nix b/modules/tabline/nvim-bufferline/config.nix index 256875b..befafcd 100644 --- a/modules/tabline/nvim-bufferline/config.nix +++ b/modules/tabline/nvim-bufferline/config.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib) mkIf mkMerge mkLuaBinding mkBinding nvim defaultAttributes; + inherit (lib) mkIf mkMerge mkLuaBinding mkBinding nvim pushDownDefault; cfg = config.vim.tabline.nvimBufferline; self = import ./nvim-bufferline.nix { @@ -40,7 +40,7 @@ in { (mkBinding cfg.mappings.movePrevious ":BufferLineMovePrev" mappings.movePrevious.description) ]; - vim.binds.whichKey.register = defaultAttributes { + vim.binds.whichKey.register = pushDownDefault { "b" = "+Buffer"; "bm" = "BufferLineMove"; "bs" = "BufferLineSort"; diff --git a/modules/utility/preview/glow/config.nix b/modules/utility/preview/glow/config.nix index 130a1a5..aca57f0 100644 --- a/modules/utility/preview/glow/config.nix +++ b/modules/utility/preview/glow/config.nix @@ -4,7 +4,7 @@ lib, ... }: let - inherit (lib) nvim mkIf mkMerge mkBinding defaultAttributes; + inherit (lib) nvim mkIf mkMerge mkBinding pushDownDefault; cfg = config.vim.utility.preview.glow; self = import ./glow.nix { @@ -19,7 +19,7 @@ in { (mkBinding cfg.mappings.openPreview ":Glow" mappings.openPreview.description) ]; - vim.binds.whichKey.register = defaultAttributes { + vim.binds.whichKey.register = pushDownDefault { "pm" = "+Preview Markdown"; }; diff --git a/modules/utility/telescope/config.nix b/modules/utility/telescope/config.nix index fa790bf..eb7a14e 100644 --- a/modules/utility/telescope/config.nix +++ b/modules/utility/telescope/config.nix @@ -4,7 +4,7 @@ lib, ... }: let - inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim defaultAttributes; + inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim pushDownDefault; cfg = config.vim.telescope; self = import ./telescope.nix {inherit lib;}; @@ -52,7 +52,7 @@ in { ) ]; - vim.binds.whichKey.register = defaultAttributes { + vim.binds.whichKey.register = pushDownDefault { "f" = "+Telescope"; "fl" = "Telescope LSP"; "fm" = "Cellular Automaton"; From bc0586b68240d22de00ef0bc1c9d9121c851241e Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 26 Feb 2024 07:17:51 +0300 Subject: [PATCH 013/193] flake: bump nixpkgs input --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index d7af1a2..01f880d 100644 --- a/flake.lock +++ b/flake.lock @@ -851,11 +851,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": { From 54a6e28e18c18e709f3ef216e9876d332e5e1b60 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 26 Feb 2024 07:18:12 +0300 Subject: [PATCH 014/193] flake: move home-manager module to flake-parts root --- flake.nix | 4 +--- lib/module/default.nix => flake/modules/home-manager.nix | 0 2 files changed, 1 insertion(+), 3 deletions(-) rename lib/module/default.nix => flake/modules/home-manager.nix (100%) diff --git a/flake.nix b/flake.nix index 609f8fc..a1f1797 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; 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 From 4bc51c5128213126f04bc4f1ee1843a3747a8a6b Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 26 Feb 2024 07:19:19 +0300 Subject: [PATCH 015/193] modules/assistant: completely drop tabnine --- modules/assistant/default.nix | 3 +- modules/assistant/tabnine/config.nix | 54 --------------------------- modules/assistant/tabnine/default.nix | 6 --- modules/assistant/tabnine/tabnine.nix | 30 --------------- 4 files changed, 1 insertion(+), 92 deletions(-) delete mode 100644 modules/assistant/tabnine/config.nix delete mode 100644 modules/assistant/tabnine/default.nix delete mode 100644 modules/assistant/tabnine/tabnine.nix diff --git a/modules/assistant/default.nix b/modules/assistant/default.nix index a8096c8..3521c52 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 e9cc209..0000000 --- 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/default.nix b/modules/assistant/tabnine/default.nix deleted file mode 100644 index 84f3cf2..0000000 --- a/modules/assistant/tabnine/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -_: { - imports = [ - ./config.nix - ./tabnine.nix - ]; -} diff --git a/modules/assistant/tabnine/tabnine.nix b/modules/assistant/tabnine/tabnine.nix deleted file mode 100644 index 949a6b1..0000000 --- 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"; - }; - }; -} From 460ba8c7b61512a84e751e8c157d7a08d65e31dc Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 26 Feb 2024 07:27:44 +0300 Subject: [PATCH 016/193] lib: deprecate unused nmd lib extension --- lib/nmd.nix | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 lib/nmd.nix diff --git a/lib/nmd.nix b/lib/nmd.nix deleted file mode 100644 index fd945f1..0000000 --- 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; - }; -} From bf1118eb2871f7b0a2131c5a3f5011d49df99357 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 26 Feb 2024 07:28:07 +0300 Subject: [PATCH 017/193] lib: start moving top-level binds to `binds` --- lib/binds.nix | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/default.nix | 4 ++- lib/vim.nix | 2 +- 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 lib/binds.nix diff --git a/lib/binds.nix b/lib/binds.nix new file mode 100644 index 0000000..c52e255 --- /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 d82ea5f..0e0b73f 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,6 +1,8 @@ {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;}; diff --git a/lib/vim.nix b/lib/vim.nix index b00d7ca..c81dcc3 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. From 024e1a6845a8c483c41b9dc6d95be0e8a6eab2ac Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 26 Feb 2024 08:05:23 +0300 Subject: [PATCH 018/193] modules: make lib calls explicit where possible --- modules/assistant/copilot/config.nix | 15 +++-- modules/assistant/copilot/copilot.nix | 47 ++++++++++------ modules/assistant/copilot/default.nix | 2 +- modules/autopairs/default.nix | 2 +- modules/autopairs/nvim-autopairs/config.nix | 36 ++++++------ modules/autopairs/nvim-autopairs/default.nix | 2 +- .../nvim-autopairs/nvim-autopairs.nix | 11 ++-- .../comments/comment-nvim/comment-nvim.nix | 3 +- modules/comments/comment-nvim/config.nix | 12 ++-- modules/comments/comment-nvim/default.nix | 2 +- modules/comments/default.nix | 2 +- modules/completion/default.nix | 2 +- modules/completion/nvim-cmp/config.nix | 13 +++-- modules/completion/nvim-cmp/nvim-cmp.nix | 10 ++-- modules/dashboard/alpha/alpha.nix | 10 +--- modules/dashboard/alpha/config.nix | 5 +- modules/dashboard/alpha/default.nix | 2 +- modules/dashboard/dashboard-nvim/config.nix | 5 +- .../dashboard-nvim/dashboard-nvim.nix | 8 +-- modules/dashboard/dashboard-nvim/default.nix | 2 +- modules/dashboard/default.nix | 2 +- modules/dashboard/startify/config.nix | 4 +- modules/dashboard/startify/startify.nix | 55 ++++++++++--------- modules/debugger/default.nix | 2 +- modules/debugger/nvim-dap/config.nix | 16 +++--- modules/debugger/nvim-dap/default.nix | 2 +- modules/debugger/nvim-dap/nvim-dap.nix | 8 ++- modules/filetree/default.nix | 2 +- modules/filetree/nvimtree/config.nix | 52 +++++++++--------- modules/git/config.nix | 8 ++- modules/git/default.nix | 2 +- modules/git/git.nix | 13 +++-- modules/languages/bash/bash.nix | 20 ++++--- modules/languages/bash/config.nix | 6 +- modules/languages/bash/default.nix | 2 +- modules/languages/dart/config.nix | 13 +++-- modules/languages/dart/dart.nix | 29 ++++++---- modules/languages/dart/default.nix | 2 +- modules/languages/elixir/config.nix | 9 +-- modules/languages/elixir/default.nix | 2 +- modules/languages/elixir/elixir-tools.nix | 8 +-- 41 files changed, 245 insertions(+), 203 deletions(-) diff --git a/modules/assistant/copilot/config.nix b/modules/assistant/copilot/config.nix index 18f540d..5cfe955 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 8583869..283a0b6 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 fb291bd..2b89045 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/autopairs/default.nix b/modules/autopairs/default.nix index 742665c..cc2f69c 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 0aceca5..1502db8 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 f228331..7098049 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 330d118..940a60c 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 13ca475..61a9171 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 ea2f1e1..40ccb0a 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 db4eb42..6a6dbcb 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 cb6ac19..afc1a87 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 77d51b4..0cae45f 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 b20f71b..142a118 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 38c8619..59c32db 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 3c43e15..d5329cc 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 a2ee14b..12072e3 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 16496c6..913b32b 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 13c08e6..9d827a4 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 78264ca..6233391 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 5bc4473..1483749 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 c63ad3e..365ea8d 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 447f385..7e9a0f4 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 36118f4..fa70a4d 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 f882196..a34e059 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 db9558d..cc04c26 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 083220b..a921e26 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 ade007a..3fab33a 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 fdceb6a..1441b4f 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 5f11c5a..684be7a 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 e0d4a03..c02dc9e 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 6336b41..d3348bc 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 0447fc4..1201982 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 243f30c..03cce94 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 241032d..e55600b 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 7dd72f7..7bb1ea2 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 510a413..be7c111 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 c30f1f3..13ce3d9 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 da454ec..2ad34f3 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 dc05a48..eaf26ea 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 b8ea9be..c84acf0 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 42e69a3..0527359 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"; From 7cb428520bff36f66f22fc18a83783d4ca141fe7 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 17 Feb 2024 03:19:38 +0300 Subject: [PATCH 019/193] utility/images: add image.nvim --- configuration.nix | 6 +- flake.lock | 17 +++ flake.nix | 5 + lib/types/plugins.nix | 3 + modules/utility/default.nix | 5 +- modules/utility/images/default.nix | 6 + modules/utility/images/hologram/default.nix | 6 + modules/utility/images/image-nvim/config.nix | 27 ++++ modules/utility/images/image-nvim/default.nix | 6 + .../utility/images/image-nvim/image-nvim.nix | 116 ++++++++++++++++++ 10 files changed, 194 insertions(+), 3 deletions(-) create mode 100644 modules/utility/images/default.nix create mode 100644 modules/utility/images/hologram/default.nix create mode 100644 modules/utility/images/image-nvim/config.nix create mode 100644 modules/utility/images/image-nvim/default.nix create mode 100644 modules/utility/images/image-nvim/image-nvim.nix diff --git a/configuration.nix b/configuration.nix index 1875eaa..0be5b58 100644 --- a/configuration.nix +++ b/configuration.nix @@ -178,10 +178,14 @@ inputs: let hop.enable = true; leap.enable = true; }; + + images = { + image-nvim.enable = true; + }; }; 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/flake.lock b/flake.lock index 01f880d..7ad4c53 100644 --- a/flake.lock +++ b/flake.lock @@ -596,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": { @@ -1516,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 a1f1797..25bf39e 100644 --- a/flake.nix +++ b/flake.nix @@ -162,6 +162,11 @@ flake = false; }; + image-nvim = { + url = "github:3rd/image.nvim"; + flake = false; + }; + # Tidal cycles tidalcycles = { url = "github:mitchmindtree/tidalcycles.nix"; diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index f20a914..4db7542 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/modules/utility/default.nix b/modules/utility/default.nix index 1fbd60a..a5a8892 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 0000000..3def81d --- /dev/null +++ b/modules/utility/images/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + #./hologram + ./image-nvim + ]; +} diff --git a/modules/utility/images/hologram/default.nix b/modules/utility/images/hologram/default.nix new file mode 100644 index 0000000..42211c7 --- /dev/null +++ b/modules/utility/images/hologram/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.nix + ./hologram.nix + ]; +} diff --git a/modules/utility/images/image-nvim/config.nix b/modules/utility/images/image-nvim/config.nix new file mode 100644 index 0000000..f0d1746 --- /dev/null +++ b/modules/utility/images/image-nvim/config.nix @@ -0,0 +1,27 @@ +{ + config, + pkgs, + lib, + ... +}: let + inherit (lib) nvim mkIf attrValues; + + cfg = config.vim.utility.images.image-nvim; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = + [ + "image-nvim" + # TODO: needs luarockss here somehow + ] + ++ (attrValues {inherit (pkgs) luarocks imagemagick;}); + + luaConfigRC.image-nvim = nvim.dag.entryAnywhere '' + require("image").setup( + ${nvim.lua.toLuaObject cfg.setupOpts} + ) + ''; + }; + }; +} diff --git a/modules/utility/images/image-nvim/default.nix b/modules/utility/images/image-nvim/default.nix new file mode 100644 index 0000000..f3cc02e --- /dev/null +++ b/modules/utility/images/image-nvim/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.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 0000000..b8b74b4 --- /dev/null +++ b/modules/utility/images/image-nvim/image-nvim.nix @@ -0,0 +1,116 @@ +{ + config, + lib, + ... +}: let + inherit (lib) mkEnableOption mkOption nvim types; +in { + options.vim.utility.images.image-nvim = { + enable = mkEnableOption "image support in Neovim [image.nvim]"; + + setupOpts = nvim.types.mkPluginSetupOption "image.nvim" { + backend = mkOption { + type = types.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 = with types; 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 = with types; listOf str; + default = ["neorg"]; + description = '' + Filetypes to enable image.nvim in. + ''; + }; + }; + + maxWidth = mkOption { + type = with types; 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 = with types; 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 = with types; 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 = with types; 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 = with types; 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 = with types; 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. + ''; + }; + }; + }; + }; +} + From d7878b525c52b9faa5b2cc33638e7078aa4f4729 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Sat, 17 Feb 2024 17:06:05 -0500 Subject: [PATCH 020/193] utility/images: add magick to lua packages --- modules/utility/images/image-nvim/config.nix | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/utility/images/image-nvim/config.nix b/modules/utility/images/image-nvim/config.nix index f0d1746..eca14a8 100644 --- a/modules/utility/images/image-nvim/config.nix +++ b/modules/utility/images/image-nvim/config.nix @@ -10,12 +10,13 @@ in { config = mkIf cfg.enable { vim = { - startPlugins = - [ - "image-nvim" - # TODO: needs luarockss here somehow - ] - ++ (attrValues {inherit (pkgs) luarocks imagemagick;}); + startPlugins = [ + "image-nvim" + ]; + + luaPackages = [ + "magick" + ]; luaConfigRC.image-nvim = nvim.dag.entryAnywhere '' require("image").setup( From a6b133124d2ea4e14e8267c4978d66d8f1d88eae Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Sat, 17 Feb 2024 17:11:58 -0500 Subject: [PATCH 021/193] utility/images: fix unrelated options being part of 'integrations' --- .../utility/images/image-nvim/image-nvim.nix | 85 +++++++++---------- 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/modules/utility/images/image-nvim/image-nvim.nix b/modules/utility/images/image-nvim/image-nvim.nix index b8b74b4..5e89b8d 100644 --- a/modules/utility/images/image-nvim/image-nvim.nix +++ b/modules/utility/images/image-nvim/image-nvim.nix @@ -59,58 +59,57 @@ in { this will be scaled down to fit within this width. ''; }; + }; - maxHeight = mkOption { - type = with types; 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. - ''; - }; + maxHeight = mkOption { + type = with types; 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 = with types; 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. - ''; - }; + maxWidthWindowPercentage = mkOption { + type = with types; 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 = with types; 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. - ''; - }; + maxHeightWindowPercentage = mkOption { + type = with types; 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 = with types; 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 { + windowOverlapClear = { + enable = mkEnableOption "clearing of images when they overlap with the window"; + ftIgnore = mkOption { type = with types; listOf str; - default = ["*.png" "*.jpg" "*.jpeg" "*.gif" "*.webp"]; + default = ["cmp_menu" "cmp_docs" ""]; description = '' - File patterns to hijack for image.nvim. This is useful for - filetypes that don't have a dedicated integration. + Filetypes to ignore window overlap clearing in. ''; }; }; + + editorOnlyRenderWhenFocused = mkEnableOption "only rendering images when the editor is focused"; + hijackFilePatterns = mkOption { + type = with types; 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. + ''; + }; }; }; } - From d2af30545d8dec4fc47631fddb145d5f06a45869 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 26 Feb 2024 11:54:07 +0300 Subject: [PATCH 022/193] =?UTF-8?q?utility/images:=20remote=20hologram.nvi?= =?UTF-8?q?=C3=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit image.nvim has better coverage --- modules/utility/images/default.nix | 2 +- modules/utility/images/hologram/default.nix | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 modules/utility/images/hologram/default.nix diff --git a/modules/utility/images/default.nix b/modules/utility/images/default.nix index 3def81d..de0a1f7 100644 --- a/modules/utility/images/default.nix +++ b/modules/utility/images/default.nix @@ -1,6 +1,6 @@ { imports = [ - #./hologram + ./hologram ./image-nvim ]; } diff --git a/modules/utility/images/hologram/default.nix b/modules/utility/images/hologram/default.nix deleted file mode 100644 index 42211c7..0000000 --- a/modules/utility/images/hologram/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - imports = [ - ./config.nix - ./hologram.nix - ]; -} From 30fb2e4f28b7be56165251d6f9a061d3143ba108 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 26 Feb 2024 11:54:20 +0300 Subject: [PATCH 023/193] images/image-nvim: make lib calls more explicit --- modules/utility/images/image-nvim/config.nix | 9 ++++--- .../utility/images/image-nvim/image-nvim.nix | 25 +++++++++++-------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/modules/utility/images/image-nvim/config.nix b/modules/utility/images/image-nvim/config.nix index eca14a8..52666d3 100644 --- a/modules/utility/images/image-nvim/config.nix +++ b/modules/utility/images/image-nvim/config.nix @@ -1,10 +1,11 @@ { config, - pkgs, lib, ... }: let - inherit (lib) nvim mkIf attrValues; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.utility.images.image-nvim; in { @@ -18,9 +19,9 @@ in { "magick" ]; - luaConfigRC.image-nvim = nvim.dag.entryAnywhere '' + luaConfigRC.image-nvim = entryAnywhere '' require("image").setup( - ${nvim.lua.toLuaObject cfg.setupOpts} + ${toLuaObject cfg.setupOpts} ) ''; }; diff --git a/modules/utility/images/image-nvim/image-nvim.nix b/modules/utility/images/image-nvim/image-nvim.nix index 5e89b8d..e208968 100644 --- a/modules/utility/images/image-nvim/image-nvim.nix +++ b/modules/utility/images/image-nvim/image-nvim.nix @@ -3,14 +3,17 @@ lib, ... }: let - inherit (lib) mkEnableOption mkOption nvim types; + inherit (lib.options) mkEnableOption mkOption; + + inherit (lib.types) enum listOf str nullOr int; + inherit (lib.nvim.lua) mkPluginSetupOption; in { options.vim.utility.images.image-nvim = { enable = mkEnableOption "image support in Neovim [image.nvim]"; - setupOpts = nvim.types.mkPluginSetupOption "image.nvim" { + setupOpts = mkPluginSetupOption "image.nvim" { backend = mkOption { - type = types.enum ["kitty" "ueberzug"]; + type = enum ["kitty" "ueberzug"]; default = "ueberzug"; description = '' The backend to use for rendering images. @@ -28,7 +31,7 @@ in { downloadRemoteImages = mkEnableOption "downloading remote images"; onlyRenderAtCursor = mkEnableOption "only rendering images at cursor"; filetypes = mkOption { - type = with types; listOf str; + type = listOf str; default = ["markdown" "vimwiki"]; description = '' Filetypes to enable image.nvim in. Markdown extensions @@ -43,7 +46,7 @@ in { downloadRemoteImages = mkEnableOption "downloading remote images"; onlyRenderAtCursor = mkEnableOption "only rendering images at cursor"; filetypes = mkOption { - type = with types; listOf str; + type = listOf str; default = ["neorg"]; description = '' Filetypes to enable image.nvim in. @@ -52,7 +55,7 @@ in { }; maxWidth = mkOption { - type = with types; nullOr int; + type = nullOr int; default = null; description = '' The maximum width of images to render. Images larger than @@ -62,7 +65,7 @@ in { }; maxHeight = mkOption { - type = with types; nullOr int; + type = nullOr int; default = null; description = '' The maximum height of images to render. Images larger than @@ -71,7 +74,7 @@ in { }; maxWidthWindowPercentage = mkOption { - type = with types; nullOr int; + type = nullOr int; default = null; description = '' The maximum width of images to render as a percentage of the @@ -81,7 +84,7 @@ in { }; maxHeightWindowPercentage = mkOption { - type = with types; nullOr int; + type = nullOr int; default = 50; description = '' The maximum height of images to render as a percentage of the @@ -93,7 +96,7 @@ in { windowOverlapClear = { enable = mkEnableOption "clearing of images when they overlap with the window"; ftIgnore = mkOption { - type = with types; listOf str; + type = listOf str; default = ["cmp_menu" "cmp_docs" ""]; description = '' Filetypes to ignore window overlap clearing in. @@ -103,7 +106,7 @@ in { editorOnlyRenderWhenFocused = mkEnableOption "only rendering images when the editor is focused"; hijackFilePatterns = mkOption { - type = with types; listOf str; + type = listOf str; default = ["*.png" "*.jpg" "*.jpeg" "*.gif" "*.webp"]; description = '' File patterns to hijack for image.nvim. This is useful for From b6166f298d237092d975fa806515a2de6e0f0d77 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Mon, 26 Feb 2024 06:42:04 -0500 Subject: [PATCH 024/193] utility/images: remove import for non existing hologram module --- modules/utility/images/default.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/utility/images/default.nix b/modules/utility/images/default.nix index de0a1f7..5b876e0 100644 --- a/modules/utility/images/default.nix +++ b/modules/utility/images/default.nix @@ -1,6 +1,5 @@ { imports = [ - ./hologram ./image-nvim ]; } From 2d16435392991951986065b407dd634e66eef764 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Mon, 26 Feb 2024 06:43:20 -0500 Subject: [PATCH 025/193] utility/images/image-nvim: fix inherit for `mkPluginSetupOption` --- modules/utility/images/image-nvim/image-nvim.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/utility/images/image-nvim/image-nvim.nix b/modules/utility/images/image-nvim/image-nvim.nix index e208968..6433e50 100644 --- a/modules/utility/images/image-nvim/image-nvim.nix +++ b/modules/utility/images/image-nvim/image-nvim.nix @@ -6,7 +6,7 @@ inherit (lib.options) mkEnableOption mkOption; inherit (lib.types) enum listOf str nullOr int; - inherit (lib.nvim.lua) mkPluginSetupOption; + inherit (lib.nvim.types) mkPluginSetupOption; in { options.vim.utility.images.image-nvim = { enable = mkEnableOption "image support in Neovim [image.nvim]"; From a32f13b63677b01b5e3d6180f1afd8adda6f312b Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Mon, 26 Feb 2024 06:51:55 -0500 Subject: [PATCH 026/193] lib: fix trying to call an attrset --- lib/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/default.nix b/lib/default.nix index 0e0b73f..94db90b 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -5,5 +5,5 @@ 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; } From 38ca1f98a22cfb3067e347ebbf875ba87913635b Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Mon, 26 Feb 2024 07:31:30 -0500 Subject: [PATCH 027/193] utility/images/image-nvim: add assertion for `ueberzug` backend on darwin --- configuration.nix | 2 +- modules/utility/images/image-nvim/config.nix | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/configuration.nix b/configuration.nix index 0be5b58..8420bbf 100644 --- a/configuration.nix +++ b/configuration.nix @@ -180,7 +180,7 @@ inputs: let }; images = { - image-nvim.enable = true; + image-nvim.enable = false; }; }; diff --git a/modules/utility/images/image-nvim/config.nix b/modules/utility/images/image-nvim/config.nix index 52666d3..49ca3e5 100644 --- a/modules/utility/images/image-nvim/config.nix +++ b/modules/utility/images/image-nvim/config.nix @@ -1,6 +1,7 @@ { config, lib, + pkgs, ... }: let inherit (lib.modules) mkIf; @@ -10,6 +11,13 @@ 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" From 83da7acf65bd120008d4f6ec6ea33aa9319c92ca Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Wed, 28 Feb 2024 10:09:08 -0500 Subject: [PATCH 028/193] images/image-nvim: remove assert for `ueberzug` backend on darwin --- modules/utility/images/image-nvim/config.nix | 7 ------- 1 file changed, 7 deletions(-) diff --git a/modules/utility/images/image-nvim/config.nix b/modules/utility/images/image-nvim/config.nix index 49ca3e5..cd188ac 100644 --- a/modules/utility/images/image-nvim/config.nix +++ b/modules/utility/images/image-nvim/config.nix @@ -11,13 +11,6 @@ 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" From d29934b85909e5df96bd95dd2b3139bd4232bf8e Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Thu, 29 Feb 2024 15:15:47 -0500 Subject: [PATCH 029/193] wrapper: migrate to `makeNeovimUnstable` wrapper --- modules/default.nix | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/modules/default.nix b/modules/default.nix index c9703b9..8ecdaef 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -6,8 +6,9 @@ inputs: { extraSpecialArgs ? {}, }: let inherit (builtins) map filter isString toString getAttr; - inherit (pkgs) wrapNeovim vimPlugins; + inherit (pkgs) wrapNeovimUnstable vimPlugins; inherit (pkgs.vimUtils) buildVimPlugin; + inherit (pkgs.neovimUtils) makeNeovimConfig; extendedLib = import ../lib/stdlib-extended.nix lib; @@ -57,21 +58,22 @@ inputs: { (f: f != null) plugins); - neovim = wrapNeovim vimOptions.package { + plugins = + (buildConfigPlugins vimOptions.startPlugins) + ++ (map (package: { + plugin = package; + optional = false; + }) + (buildConfigPlugins + vimOptions.optPlugins)); + + neovim = wrapNeovimUnstable vimOptions.package (makeNeovimConfig { inherit (vimOptions) viAlias; inherit (vimOptions) vimAlias; - inherit extraLuaPackages; - - configure = { - customRC = vimOptions.builtConfigRC; - - packages.myVimPackage = { - start = buildConfigPlugins vimOptions.startPlugins; - opt = buildConfigPlugins vimOptions.optPlugins; - }; - }; - }; + inherit plugins; + customRC = vimOptions.builtConfigRC; + }); in { inherit (module) options config; inherit (module._module.args) pkgs; From 6d3f28283fc1b36ae39772c221976fde1dfbb90e Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 8 Mar 2024 20:34:19 +0300 Subject: [PATCH 030/193] modules/languages: switch to explicit lib calls --- modules/languages/clang.nix | 30 +++++++++++++++---------- modules/languages/markdown/config.nix | 8 +++---- modules/languages/markdown/markdown.nix | 20 ++++++++++------- 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/modules/languages/clang.nix b/modules/languages/clang.nix index ee40edf..16cf337 100644 --- a/modules/languages/clang.nix +++ b/modules/languages/clang.nix @@ -1,19 +1,25 @@ { - pkgs, config, + pkgs, lib, ... }: let inherit (builtins) attrNames; - inherit (lib) isList nvim optionalString mkEnableOption mkOption types mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib) nvim; + inherit (lib.strings) optionalString; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) bool enum package either listOf str nullOr; + inherit (lib.modules) mkIf mkMerge; - cfg = config.vim.languages.clang; - - defaultServer = "ccls"; packageToCmd = package: defaultCmd: if isList cfg.lsp.package then nvim.lua.expToLua cfg.lsp.package else ''{ "${cfg.lsp.package}/bin/${defaultCmd}" }''; + + cfg = config.vim.languages.clang; + + defaultServer = "ccls"; servers = { ccls = { package = pkgs.ccls; @@ -79,7 +85,7 @@ in { C syntax for headers. Can fix treesitter errors, see: https://www.reddit.com/r/neovim/comments/orfpcd/question_does_the_c_parser_from_nvimtreesitter/ ''; - type = types.bool; + type = bool; default = false; }; @@ -94,20 +100,20 @@ in { server = mkOption { description = "The clang LSP server to use"; - type = with types; enum (attrNames servers); + type = enum (attrNames servers); default = defaultServer; }; package = mkOption { description = "clang 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 clang LSP server"; - type = with types; nullOr str; + type = nullOr str; default = null; }; }; @@ -115,17 +121,17 @@ in { dap = { enable = mkOption { description = "Enable clang Debug Adapter"; - type = types.bool; + type = bool; default = config.vim.languages.enableDAP; }; debugger = mkOption { description = "clang debugger to use"; - type = with types; enum (attrNames debuggers); + type = enum (attrNames debuggers); default = defaultDebugger; }; package = mkOption { description = "clang debugger package."; - type = types.package; + type = package; default = debuggers.${cfg.dap.debugger}.package; }; }; diff --git a/modules/languages/markdown/config.nix b/modules/languages/markdown/config.nix index 964bb69..ccc8836 100644 --- a/modules/languages/markdown/config.nix +++ b/modules/languages/markdown/config.nix @@ -4,7 +4,9 @@ lib, ... }: let - inherit (lib) nvim mkIf mkMerge isList; + inherit (lib.nvim.lua) expToLua; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) isList; cfg = config.vim.languages.markdown; servers = { @@ -16,7 +18,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/marksman", "server"}'' }, } @@ -27,13 +29,11 @@ in { config = mkIf cfg.enable (mkMerge [ (mkIf cfg.treesitter.enable { vim.treesitter.enable = true; - vim.treesitter.grammars = [cfg.treesitter.mdPackage cfg.treesitter.mdInlinePackage]; }) (mkIf cfg.lsp.enable { vim.lsp.lspconfig.enable = true; - vim.lsp.lspconfig.sources.markdown-lsp = servers.${cfg.lsp.server}.lspConfig; }) ]); diff --git a/modules/languages/markdown/markdown.nix b/modules/languages/markdown/markdown.nix index fe272c1..a58be2a 100644 --- a/modules/languages/markdown/markdown.nix +++ b/modules/languages/markdown/markdown.nix @@ -1,11 +1,15 @@ { - pkgs, config, + pkgs, lib, ... }: let inherit (builtins) attrNames; - inherit (lib) mkEnableOption mkOption types nvim isList; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.lists) isList; + inherit (lib.types) bool enum either package listOf str; + inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.types) mkGrammarOption; cfg = config.vim.languages.markdown; defaultServer = "marksman"; @@ -18,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/marksman", "server"}'' }, } @@ -32,11 +36,11 @@ in { treesitter = { enable = mkOption { description = "Enable Markdown treesitter"; - type = types.bool; + type = bool; default = config.vim.languages.enableTreesitter; }; - mdPackage = nvim.types.mkGrammarOption pkgs "markdown"; - mdInlinePackage = nvim.types.mkGrammarOption pkgs "markdown-inline"; + mdPackage = mkGrammarOption pkgs "markdown"; + mdInlinePackage = mkGrammarOption pkgs "markdown-inline"; }; lsp = { @@ -44,14 +48,14 @@ in { server = mkOption { description = "Markdown LSP server to use"; - type = with types; enum (attrNames servers); + type = enum (attrNames servers); default = defaultServer; }; package = mkOption { description = "Markdown 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; }; }; From b96737b3a77c5163ad8128d3b9686c9afbf548ac Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 9 Mar 2024 05:32:01 +0300 Subject: [PATCH 031/193] flake: bump inputs --- flake.lock | 325 +++++++++++++++++++++++++++-------------------------- flake.nix | 3 +- 2 files changed, 165 insertions(+), 163 deletions(-) diff --git a/flake.lock b/flake.lock index 7ad4c53..ae4bd62 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "alpha-nvim": { "flake": false, "locked": { - "lastModified": 1705520464, - "narHash": "sha256-Yz5ZqxjaargJjnbmH1L43EwYp5J5w5RPREG7/smdRQc=", + "lastModified": 1708891191, + "narHash": "sha256-kTVPKZ/e1us/uHfSwFwR38lFYN8EotJq2jKz6xm/eqg=", "owner": "goolord", "repo": "alpha-nvim", - "rev": "4b36c1ca9ea475bdc006896657cf1ccc486aeffa", + "rev": "41283fb402713fc8b327e60907f74e46166f4cfd", "type": "github" }, "original": { @@ -19,11 +19,11 @@ "bufdelete-nvim": { "flake": false, "locked": { - "lastModified": 1703393686, - "narHash": "sha256-O0JRhx6UJzeZTG+XwGi/6DLaoX8hfqxwSt0W9yQXhBw=", + "lastModified": 1708814161, + "narHash": "sha256-ljUNfmpImtxFCS19HC9kFlaLlqaPDltKtnx1+/6Y33U=", "owner": "famiu", "repo": "bufdelete.nvim", - "rev": "0b9c0f182b09c51170bb9f252f15de7695e4d507", + "rev": "f6bcea78afb3060b198125256f897040538bcb81", "type": "github" }, "original": { @@ -35,11 +35,11 @@ "catppuccin": { "flake": false, "locked": { - "lastModified": 1706227543, - "narHash": "sha256-br32TBzK++QK6RqlMjyN4vmNi1cgNgDca8byZqV3oUQ=", + "lastModified": 1709646581, + "narHash": "sha256-arOnsTg+q14qMI24QrcA/ca3tU7qxhoenRksRk1xBtE=", "owner": "catppuccin", "repo": "nvim", - "rev": "afab7ec2a79c7127627dede79c0018b6e45663d0", + "rev": "045e3499d9ec8d84635fb08877ae44fd33f6a38d", "type": "github" }, "original": { @@ -51,11 +51,11 @@ "ccc": { "flake": false, "locked": { - "lastModified": 1702716924, - "narHash": "sha256-nWe7uYWPZ1LjQRVynYnPomb4EFfyh919Jsh07UPSdvg=", + "lastModified": 1709880055, + "narHash": "sha256-8+QB1yxBoqd6m/UaLWQk+gYuk7XJhgbvfHwpGi57JEE=", "owner": "uga-rosa", "repo": "ccc.nvim", - "rev": "ec6e23fd2c0bf4ffcf71c1271acdcee6e2c6f49c", + "rev": "f3d9d31aab7990d50ae6922fd7c1e3a9eb7da183", "type": "github" }, "original": { @@ -243,11 +243,11 @@ "copilot-lua": { "flake": false, "locked": { - "lastModified": 1704638182, - "narHash": "sha256-8/EPnigWaY2P4ZlVyu42DOQVOjRPgSCtmdOVbl2ACN8=", + "lastModified": 1709095198, + "narHash": "sha256-JX3sdsnOnjkY7r9fCtC2oauo0PXF3SQ+SHUo8ifBvAc=", "owner": "zbirenbaum", "repo": "copilot.lua", - "rev": "b03617a6dc4bc88b65ab5deac1631da9a9c2dcaf", + "rev": "f7612f5af4a7d7615babf43ab1e67a2d790c13a6", "type": "github" }, "original": { @@ -259,11 +259,11 @@ "crates-nvim": { "flake": false, "locked": { - "lastModified": 1706141227, - "narHash": "sha256-vkq1N6XvJOSsIbCCcAk1+9ReRMF4it/mofq55JhwQRY=", + "lastModified": 1709849980, + "narHash": "sha256-D92Ot13H2ILs6wp5UWKui0+ZJtBOlA7gd5l51EBn95g=", "owner": "Saecki", "repo": "crates.nvim", - "rev": "f2a169840e97a8ed2048abb507d2742c3895c85b", + "rev": "535773ed3b321d68ddd6ef8cd5a1e07b345026a6", "type": "github" }, "original": { @@ -275,11 +275,11 @@ "dashboard-nvim": { "flake": false, "locked": { - "lastModified": 1699578883, - "narHash": "sha256-LNjYIRL5xZyLgFkoTu3K5USOfk1mtaXe5RhKBAbzYRw=", + "lastModified": 1707803848, + "narHash": "sha256-vi82Q+ytumRmpLIRT2QhOCR547xJ4ynSPWokQAY7uF0=", "owner": "glepnir", "repo": "dashboard-nvim", - "rev": "63df28409d940f9cac0a925df09d3dc369db9841", + "rev": "413442b12d85315fc626c44a0ce4929b213ef604", "type": "github" }, "original": { @@ -324,11 +324,11 @@ "dracula": { "flake": false, "locked": { - "lastModified": 1705994462, - "narHash": "sha256-yGV/bA7+Xi+LBi4Iz/SZDVl0KWoo+IO9kgfSIgTk0Ow=", + "lastModified": 1708834650, + "narHash": "sha256-I3rtbJYv1D+kniOLL9hmTF3ucp/qSNewnO2GmYAERko=", "owner": "Mofiqul", "repo": "dracula.nvim", - "rev": "a6cb758d4b182d9f2b7e742910078d94877c1059", + "rev": "8d8bddb8814c3e7e62d80dda65a9876f97eb699c", "type": "github" }, "original": { @@ -340,11 +340,11 @@ "dressing-nvim": { "flake": false, "locked": { - "lastModified": 1706209758, - "narHash": "sha256-P8XlaiNNbOtkOS2un+pfCOOayOzJ/8uLQFrcFlSW7tQ=", + "lastModified": 1706493651, + "narHash": "sha256-Y+ABLhb3GIaPKOuQzkxsZsTo1WfgURAYVioP/eCSp/Y=", "owner": "stevearc", "repo": "dressing.nvim", - "rev": "0e88293ce3459f4bb310125f3366304af6dc7990", + "rev": "6f212262061a2120e42da0d1e87326e8a41c0478", "type": "github" }, "original": { @@ -356,11 +356,11 @@ "elixir-ls": { "flake": false, "locked": { - "lastModified": 1705860624, - "narHash": "sha256-pd/ZkDpzlheEJfX7X6fFWY4Y5B5Y2EnJMBtuNHPuUJw=", + "lastModified": 1709063485, + "narHash": "sha256-7Kc4LClN4jCpTnKJsMnYtc8jaatefXdvysOnndA4TK8=", "owner": "elixir-lsp", "repo": "elixir-ls", - "rev": "d10ce2cfe3acf475949e9a21984d18be579d7ec4", + "rev": "cb5315afca9e624ce1ba1040607d6a154727d8c1", "type": "github" }, "original": { @@ -372,11 +372,11 @@ "elixir-tools": { "flake": false, "locked": { - "lastModified": 1703976612, - "narHash": "sha256-6QdjqugY2kouDVzQa4bxFb9dp9vVantueO+6nnbnOwo=", + "lastModified": 1709873623, + "narHash": "sha256-1QuEz45AjaO/sF7PtRISCP57tLFlLFvIgw2upnGHnZk=", "owner": "elixir-tools", "repo": "elixir-tools.nvim", - "rev": "163522196c962fa87cac0df2a0d1ad332e1e0755", + "rev": "3048ae88235eb4c1a7ae789185aa23edb479a995", "type": "github" }, "original": { @@ -388,11 +388,11 @@ "fidget-nvim": { "flake": false, "locked": { - "lastModified": 1707329128, - "narHash": "sha256-mMLAhAbIs33RoU9c8COchbWRr2NM231zJn6TtwJmI+4=", + "lastModified": 1708381371, + "narHash": "sha256-cfoz2nGX7yzDLjTitposErJpC8EVX0DBy69kFKY0jps=", "owner": "j-hui", "repo": "fidget.nvim", - "rev": "ad8873c16faa123fe3f9fd6539c41dfb0f97a9e9", + "rev": "60404ba67044c6ab01894dd5bf77bd64ea5e09aa", "type": "github" }, "original": { @@ -422,11 +422,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1704982712, - "narHash": "sha256-2Ptt+9h8dczgle2Oo6z5ni5rt/uLMG47UFTR1ry/wgg=", + "lastModified": 1709336216, + "narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "07f6395285469419cf9d078f59b5b49993198c00", + "rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2", "type": "github" }, "original": { @@ -440,11 +440,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1705309234, - "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "lastModified": 1709126324, + "narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=", "owner": "numtide", "repo": "flake-utils", - "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "rev": "d465f4819400de7c8d874d50b982301f28a84605", "type": "github" }, "original": { @@ -471,11 +471,11 @@ "flutter-tools": { "flake": false, "locked": { - "lastModified": 1705943990, - "narHash": "sha256-g/cgFJ8kwBk1gNVaio+s1sa5KqpC/LMf06/6+MOPZk4=", + "lastModified": 1708365315, + "narHash": "sha256-8zdaw+Ns/IqCt0MCGyJC2fGHmkMEn9kbvdE0leA+vI8=", "owner": "akinsho", "repo": "flutter-tools.nvim", - "rev": "271eec9edb0f1a2bf30ad449ec3b4eeb2c88af05", + "rev": "01d72d9c1bdf2d454a60c5ba450f83e5ea783f6a", "type": "github" }, "original": { @@ -503,11 +503,11 @@ "gitsigns-nvim": { "flake": false, "locked": { - "lastModified": 1706282483, - "narHash": "sha256-jVzZPD9RdM0Ie3nWuZgv+XVhwWzLJ2QODrIGRCENWjo=", + "lastModified": 1706372432, + "narHash": "sha256-SLDaqzbvBTTuJEP9H2WOADuxsguMntR+upsGPW8aOEk=", "owner": "lewis6991", "repo": "gitsigns.nvim", - "rev": "fb9fd5312476b51a42a98122616e1c448d823d5c", + "rev": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae", "type": "github" }, "original": { @@ -535,11 +535,11 @@ "gruvbox": { "flake": false, "locked": { - "lastModified": 1704132908, - "narHash": "sha256-p/y65ub1qL+5g0ZiWzaTyQeiP7LtVfsdcdJ0eb0A7Og=", + "lastModified": 1706538659, + "narHash": "sha256-jWnrRy/PT7D0UcPGL+XTbKHWvS0ixvbyqPtTzG9HY84=", "owner": "ellisonleao", "repo": "gruvbox.nvim", - "rev": "4176b0b720db0c90ab4030e5c1b4893faf41fd51", + "rev": "6e4027ae957cddf7b193adfaec4a8f9e03b4555f", "type": "github" }, "original": { @@ -599,11 +599,11 @@ "image-nvim": { "flake": false, "locked": { - "lastModified": 1707861531, - "narHash": "sha256-mh3J3lW2Co2uA7YJzSGum0ZmpJBP0ZzBWUvJLAI9bHw=", + "lastModified": 1708996376, + "narHash": "sha256-XaC14kVGgK0fOjZHbPEixQU7dty7Di4faGl+h63Wlj0=", "owner": "3rd", "repo": "image.nvim", - "rev": "4c6cb5ad93ee93d8d7b7c84e1eb291cee99f0a0e", + "rev": "0dd8bdbb8855bc98c534a902c91dc9eddb8155b1", "type": "github" }, "original": { @@ -615,11 +615,11 @@ "indent-blankline": { "flake": false, "locked": { - "lastModified": 1705027513, - "narHash": "sha256-T0tbTyD9+J7OWcvfrPolrXbjGiXzEXhTtgC9Xj3ANFc=", + "lastModified": 1707806353, + "narHash": "sha256-ZzsQVLP7EmHeVEkSvbENce/hk1HANN+qL8Vv7FaOiV0=", "owner": "lukas-reineke", "repo": "indent-blankline.nvim", - "rev": "12e92044d313c54c438bd786d11684c88f6f78cd", + "rev": "821a7acd88587d966f7e464b0b3031dfe7f5680c", "type": "github" }, "original": { @@ -647,11 +647,11 @@ "leap-nvim": { "flake": false, "locked": { - "lastModified": 1706284537, - "narHash": "sha256-kA6Lkfx7RHPUZjhxx4tc0gsAdhrfFvp6yY5qO+ZXUtM=", + "lastModified": 1709760573, + "narHash": "sha256-LauAJuXLHXtviSlt9MtdcvfT1CL600QISP+WEdma5RY=", "owner": "ggandor", "repo": "leap.nvim", - "rev": "14eda5bb233354933baa99b6d40bef3a40dbeaae", + "rev": "89d878f8399d00fb348ad65b6077b996808234d8", "type": "github" }, "original": { @@ -679,11 +679,11 @@ "lsp-signature": { "flake": false, "locked": { - "lastModified": 1701211782, - "narHash": "sha256-4GcTfu7MRpZUi5dqewaddSvaOezRl9ROKrR7wnnLnKE=", + "lastModified": 1709592196, + "narHash": "sha256-WAQ8DWjNWKYBbELC/M8ClGxU0cAqB4X1TlkWIEBqp24=", "owner": "ray-x", "repo": "lsp_signature.nvim", - "rev": "fed2c8389c148ff1dfdcdca63c2b48d08a50dea0", + "rev": "e92b4e7073345b2a30a56b20db3d541a9aa2771e", "type": "github" }, "original": { @@ -727,11 +727,11 @@ "lualine": { "flake": false, "locked": { - "lastModified": 1706181415, - "narHash": "sha256-LMMcRY4qnGywdK6Bl4YeAEKLhnRuOZ2txn4oYoso2gI=", + "lastModified": 1709556301, + "narHash": "sha256-G4npmdS7vue68h5QN8vWx3Oh5FHdvmzFHGxqMIRC+Mk=", "owner": "hoob3rt", "repo": "lualine.nvim", - "rev": "7d131a8d3ba5016229e8a1d08bf8782acea98852", + "rev": "8b56462bfb746760465264de41b4907310f113ec", "type": "github" }, "original": { @@ -759,11 +759,11 @@ "minimap-vim": { "flake": false, "locked": { - "lastModified": 1696276849, - "narHash": "sha256-bPW/wDCvItpl0VIQCgz5AEYfx1aAnIMhB1S/tJN5/80=", + "lastModified": 1709503043, + "narHash": "sha256-W4EUEVjHNlemkMn+lCaraIV5/d5Kw4/LusHA17qQBjI=", "owner": "wfxr", "repo": "minimap.vim", - "rev": "701f4cf4b60a3e1685d2da484282f3a3d8bf9db6", + "rev": "6dc0c36fd92eab38064f22c016e43639f42293d3", "type": "github" }, "original": { @@ -812,11 +812,11 @@ "neocord": { "flake": false, "locked": { - "lastModified": 1704948184, - "narHash": "sha256-HnaMKTNjMuDwHDvxHH5kd4ysa5WU+MlbdD9jH/iJcU8=", + "lastModified": 1709140653, + "narHash": "sha256-TdmXKh/qAKorpRFgAhCMAyXY6zUrqdEuNaLgerY46qc=", "owner": "IogaMaster", "repo": "neocord", - "rev": "9b624d5189f699ab454e9515262c13965395b8dd", + "rev": "fe83e48ad6f5fa7f70c93b47694c36d0d7deff04", "type": "github" }, "original": { @@ -828,11 +828,11 @@ "neodev-nvim": { "flake": false, "locked": { - "lastModified": 1706249139, - "narHash": "sha256-BRsZdc1TO88pCoehDv7ervBjaeOpcmSGm/RZAInhI9Q=", + "lastModified": 1709144748, + "narHash": "sha256-VyJTGbWBzGmuEkotKwTxAVpznfrrQ26aaBc31n6ZjlE=", "owner": "folke", "repo": "neodev.nvim", - "rev": "64b2a51b02c6f2ae177c745e4d8bc801a339fe09", + "rev": "84e0290f5600e8b89c0dfcafc864f45496a53400", "type": "github" }, "original": { @@ -867,11 +867,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1708807242, - "narHash": "sha256-sRTRkhMD4delO/hPxxi+XwLqPn8BuUq6nnj4JqLwOu0=", + "lastModified": 1709703039, + "narHash": "sha256-6hqgQ8OK6gsMu1VtcGKBxKQInRLHtzulDo9Z5jxHEFY=", "owner": "nixos", "repo": "nixpkgs", - "rev": "73de017ef2d18a04ac4bfd0c02650007ccb31c2a", + "rev": "9df3e30ce24fd28c7b3e2de0d986769db5d6225d", "type": "github" }, "original": { @@ -884,11 +884,11 @@ "nixpkgs-lib": { "locked": { "dir": "lib", - "lastModified": 1703961334, - "narHash": "sha256-M1mV/Cq+pgjk0rt6VxoyyD+O8cOUiai8t9Q6Yyq4noY=", + "lastModified": 1709237383, + "narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b0d36bd0a420ecee3bc916c91886caca87c894e9", + "rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8", "type": "github" }, "original": { @@ -982,27 +982,28 @@ "none-ls": { "flake": false, "locked": { - "lastModified": 1706069423, - "narHash": "sha256-s+Hp0Yzge7FKKDez4DO8uytsNORIqeNWYOLSO7kSZbo=", + "lastModified": 1708525772, + "narHash": "sha256-VCDUKiy9C3Bu9suf2bI6XSis1+j01oFC3GFPyQxi74c=", "owner": "nvimtools", "repo": "none-ls.nvim", - "rev": "a311c7cc8f17543143a7482cdbe3a384c371d56a", + "rev": "bb680d752cec37949faca7a1f509e2fe67ab418a", "type": "github" }, "original": { "owner": "nvimtools", "repo": "none-ls.nvim", + "rev": "bb680d752cec37949faca7a1f509e2fe67ab418a", "type": "github" } }, "nui-nvim": { "flake": false, "locked": { - "lastModified": 1704411133, - "narHash": "sha256-SWG0IQDNXrgWK1ApQSpc2oPKNYgTPend877DQ6FuqUc=", + "lastModified": 1709703853, + "narHash": "sha256-pzGzQXctHKbI1SZnzX4bApE+pyEADw1pjWvNy9j61U0=", "owner": "MunifTanjim", "repo": "nui.nvim", - "rev": "35da9ca1de0fc4dda96c2e214d93d363c145f418", + "rev": "756c59f46057cd2d43619cd3a6d4e01b2aa60295", "type": "github" }, "original": { @@ -1014,11 +1015,11 @@ "nvim-autopairs": { "flake": false, "locked": { - "lastModified": 1705959312, - "narHash": "sha256-4sZoZfg6ORbEwbvjIRnaDrKtVnoHpx7cAOcxn1Er6pg=", + "lastModified": 1708848946, + "narHash": "sha256-w95F9wK3M3S4P43kKPT/uM+PFT/Z6NcTDLj60H2r/tQ=", "owner": "windwp", "repo": "nvim-autopairs", - "rev": "096d0baecc34f6c5d8a6dd25851e9d5ad338209b", + "rev": "c6139ca0d5ad7af129ea6c89cb4c56093f2c034a", "type": "github" }, "original": { @@ -1030,11 +1031,11 @@ "nvim-bufferline-lua": { "flake": false, "locked": { - "lastModified": 1706180994, - "narHash": "sha256-/iGzUDJaodkUyWpwim8UtwaRuarfu/Nk6wxVApk+QxY=", + "lastModified": 1709805539, + "narHash": "sha256-drvgwupiyRAoShL2enXEYUumkYJnG+QtIkBIVqVZK+U=", "owner": "akinsho", "repo": "nvim-bufferline.lua", - "rev": "d6cb9b7cac52887bcac65f8698e67479553c0748", + "rev": "64e2c5def50dfd6b6f14d96a45fa3d815a4a1eef", "type": "github" }, "original": { @@ -1046,11 +1047,11 @@ "nvim-cmp": { "flake": false, "locked": { - "lastModified": 1702541213, - "narHash": "sha256-BtAYRYn6m788zAq/mNnbAzAxp1TGf9QkRE0hSOp9sdc=", + "lastModified": 1706857187, + "narHash": "sha256-FF7OHYUC4VFwFvqWKI/R5BSAC0JL6qFKUS6/XRSd9H8=", "owner": "hrsh7th", "repo": "nvim-cmp", - "rev": "538e37ba87284942c1d76ed38dd497e54e65b891", + "rev": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782", "type": "github" }, "original": { @@ -1126,11 +1127,11 @@ "nvim-dap": { "flake": false, "locked": { - "lastModified": 1705151920, - "narHash": "sha256-9Rc4dxbgN1LxoXPXHTi+V92MA0fEn5PveqCSMHbgn98=", + "lastModified": 1708166498, + "narHash": "sha256-mOn/1qnUFRuKXLnthrc0/h8q3rDlKxfCmIrr3gbU5LU=", "owner": "mfussenegger", "repo": "nvim-dap", - "rev": "9adbfdca13afbe646d09a8d7a86d5d031fb9c5a5", + "rev": "fc880e82059eb21c0fa896be60146e5f17680648", "type": "github" }, "original": { @@ -1142,11 +1143,11 @@ "nvim-dap-ui": { "flake": false, "locked": { - "lastModified": 1705942789, - "narHash": "sha256-4tYSdxPj+/hxd8KNzCU6Lvf+ACxpKgYyGOlF+Jwzxa8=", + "lastModified": 1708172616, + "narHash": "sha256-OMQS1m33scR0O+KiAHyjfrjsKEj1wFq0XWbjBIULDCo=", "owner": "rcarriga", "repo": "nvim-dap-ui", - "rev": "d845ebd798ad1cf30aa4abd4c4eff795cdcfdd4f", + "rev": "9720eb5fa2f41988e8770f973cd11b76dd568a5d", "type": "github" }, "original": { @@ -1190,11 +1191,11 @@ "nvim-lspconfig": { "flake": false, "locked": { - "lastModified": 1705757419, - "narHash": "sha256-StYsN9C2rV471JkncUR1PFeXs0S15ZGTF1DigSbwOHI=", + "lastModified": 1709879366, + "narHash": "sha256-sRu8LtKcxqjKpCdYUeHAvL48i6eaC9SKzxF+XlqIJsY=", "owner": "neovim", "repo": "nvim-lspconfig", - "rev": "8917d2c830e04bf944a699b8c41f097621283828", + "rev": "94cf4adb81158817520e18d2174963d8e1424df9", "type": "github" }, "original": { @@ -1254,11 +1255,11 @@ "nvim-notify": { "flake": false, "locked": { - "lastModified": 1705342184, - "narHash": "sha256-WhC80NnWXEAYHLORpUPIXb2s1ERJxyK3l2L9oke68mo=", + "lastModified": 1708161547, + "narHash": "sha256-xJYPOX4YLcWojMCdP1RO22/7FMrbcBQxqxrcVCE2TrU=", "owner": "rcarriga", "repo": "nvim-notify", - "rev": "80b67b265530632505193553d05127ae7fe09ddd", + "rev": "5371f4bfc1f6d3adf4fe9d62cd3a9d44356bfd15", "type": "github" }, "original": { @@ -1270,11 +1271,11 @@ "nvim-session-manager": { "flake": false, "locked": { - "lastModified": 1705767424, - "narHash": "sha256-BTVhCevq40A7yOYp2fLg6N9A+yarIWJM83Z2bfvlQuU=", + "lastModified": 1708284146, + "narHash": "sha256-+TDWY8mprJfUp9ZFKbz83to7XW8iiovja22jHms+N1A=", "owner": "Shatur", "repo": "neovim-session-manager", - "rev": "b8a22f2c88429a11272117a901db66055abf3e7f", + "rev": "d8e1ba3bbcf3fdc6a887bcfbd94c48ae4707b457", "type": "github" }, "original": { @@ -1286,11 +1287,11 @@ "nvim-surround": { "flake": false, "locked": { - "lastModified": 1705526094, - "narHash": "sha256-CGAQtBxhiP6AUQzwdra5AOpsNu+oeLO2hCJnmL61jgE=", + "lastModified": 1709063002, + "narHash": "sha256-uInXJq+TrfKM9WfOlUAYxbDad9mwf7DK5lETyTu+ShM=", "owner": "kylechui", "repo": "nvim-surround", - "rev": "0c02c52182a9c2a7fa7e122b4037f6408e98434a", + "rev": "84a26afce16cffa7e3322cfa80a42cddf60616eb", "type": "github" }, "original": { @@ -1302,11 +1303,11 @@ "nvim-tree-lua": { "flake": false, "locked": { - "lastModified": 1705818283, - "narHash": "sha256-EKAzWIT2Qs65Il1pwgpkFsCogFViapUiSHcZgVy+QsY=", + "lastModified": 1709951243, + "narHash": "sha256-1lWdTSZt/J4geoQKLkZLQ5Yh992XpZ4cFHw4AGEJFPY=", "owner": "nvim-tree", "repo": "nvim-tree.lua", - "rev": "7bdb220d0fe604a77361e92cdbc7af1b8a412126", + "rev": "041dbd18f440207ad161503a384e7c82d575db66", "type": "github" }, "original": { @@ -1318,11 +1319,11 @@ "nvim-treesitter-context": { "flake": false, "locked": { - "lastModified": 1706217055, - "narHash": "sha256-QhmTXikUIye+xxLw52ttRJz9T0bfhn/ks5VSQd8tDo0=", + "lastModified": 1709675035, + "narHash": "sha256-wvr1ydulJlUuYQDCSXZjauDQi9Q0GugoLJ4TYZPonPE=", "owner": "nvim-treesitter", "repo": "nvim-treesitter-context", - "rev": "9c06b115abc57c99cf0aa81dc29490f5001f57a1", + "rev": "b8b7e52c1517d401d7c519787d5dc4528c41291a", "type": "github" }, "original": { @@ -1334,11 +1335,11 @@ "nvim-ts-autotag": { "flake": false, "locked": { - "lastModified": 1706174398, - "narHash": "sha256-C3FOh11eF5Blzh6vsFSA6AB7opXl5Gocdti1QhFZ2vM=", + "lastModified": 1707265789, + "narHash": "sha256-cPIEIjcYxX3ZkOyou2mYlHMdhBxCoVTpJVXZtiWe9Ks=", "owner": "windwp", "repo": "nvim-ts-autotag", - "rev": "a65b202cfd08e0e69e531eab737205ff5bc082a4", + "rev": "531f48334c422222aebc888fd36e7d109cb354cd", "type": "github" }, "original": { @@ -1350,11 +1351,11 @@ "nvim-web-devicons": { "flake": false, "locked": { - "lastModified": 1706072160, - "narHash": "sha256-w038PU9i1onEBo3x4bo1kDz9Fo46Whd8ZJhyIqxz3I8=", + "lastModified": 1709950025, + "narHash": "sha256-ZnO0qe6zQiSKaBzMezzaZOQw++oZFaVFSdTD26ezR2I=", "owner": "nvim-tree", "repo": "nvim-web-devicons", - "rev": "b427ac5f9dff494f839e81441fb3f04a58cbcfbc", + "rev": "0db6a106d0fba1b54ff2b7f9db108e7505a4c26f", "type": "github" }, "original": { @@ -1366,11 +1367,11 @@ "obsidian-nvim": { "flake": false, "locked": { - "lastModified": 1706230460, - "narHash": "sha256-jl03+C9/L081eza6XwK05GiGZI0U82wqQBMwTjtedv8=", + "lastModified": 1709943920, + "narHash": "sha256-iMH1WoldkWhr+u//G/LhI42SfPtCWFjqTS2sfineFKQ=", "owner": "epwalsh", "repo": "obsidian.nvim", - "rev": "194f9fc798ac0f73dbac2e83fc3d5c99b8f70e78", + "rev": "6888c7620109684371ed9304df2ba68abc78d558", "type": "github" }, "original": { @@ -1382,11 +1383,11 @@ "onedark": { "flake": false, "locked": { - "lastModified": 1705931596, - "narHash": "sha256-jjvZ2z93xd1Yng8g6+cdsXhLkm2lC7DSUHiFYC+Gg5k=", + "lastModified": 1706527208, + "narHash": "sha256-1+aO8vrUGEe/NIVI1C1xJyuQVPQZ1s510lopkEVP7No=", "owner": "navarasu", "repo": "onedark.nvim", - "rev": "14e5de43cf1ff761c280d1ff5b9980897f5b46c7", + "rev": "1230aaf2a427b2c5b73aba6e4a9a5881d3e69429", "type": "github" }, "original": { @@ -1398,11 +1399,11 @@ "orgmode-nvim": { "flake": false, "locked": { - "lastModified": 1706216082, - "narHash": "sha256-M9AI3LlJvs6ZqQPeYr+rqRFu4gYVZbLFV3PUuZ77ReE=", + "lastModified": 1709672029, + "narHash": "sha256-2zYAtyiZQErkGbeVZ3Kww0/p44lLQT5u0EGOzvNN4Ag=", "owner": "nvim-orgmode", "repo": "orgmode", - "rev": "ab045e3084d5987e8939d25d69b09baaf762278c", + "rev": "18734589e5807074f57a5228ce06b52ea898b802", "type": "github" }, "original": { @@ -1431,11 +1432,11 @@ "plenary-nvim": { "flake": false, "locked": { - "lastModified": 1705841956, - "narHash": "sha256-awRAI1ov9OBt6VuNxk/qjPTSPBYsMJzURKVV+IA7kok=", + "lastModified": 1709720625, + "narHash": "sha256-/ltkFqa5MTAI9z8oLv7+5SJ/Qq9l1kkuKGD955NbLi8=", "owner": "nvim-lua", "repo": "plenary.nvim", - "rev": "663246936325062427597964d81d30eaa42ab1e4", + "rev": "f7adfc4b3f4f91aab6caebf42b3682945fbc35be", "type": "github" }, "original": { @@ -1608,11 +1609,11 @@ "rose-pine": { "flake": false, "locked": { - "lastModified": 1707703907, - "narHash": "sha256-jmDGDlCurGAG85SglAwmQr943kVr8KUr11zpPejQliQ=", + "lastModified": 1709650037, + "narHash": "sha256-uRRuJYGNhJEz+2y5GG47GutolSSisSYUHvB7eKDfAZ8=", "owner": "rose-pine", "repo": "neovim", - "rev": "f01ce3a71748a92997d266cfe2c985decd18c601", + "rev": "a29b09d15a9ef5cd575fbe5ae2a3cfb854876caf", "type": "github" }, "original": { @@ -1791,11 +1792,11 @@ "telescope": { "flake": false, "locked": { - "lastModified": 1706154992, - "narHash": "sha256-uagWtwd/L07RRUpSu+kVv0qD+neySSmSrIeFBJ0gZiM=", + "lastModified": 1709849420, + "narHash": "sha256-i+pGEMw8MQnFse5WGZdX9MMjEoR4H4rzHswCaT/zoso=", "owner": "nvim-telescope", "repo": "telescope.nvim", - "rev": "1bfbb1fb5c56d2dbe33216fcb2ebe82e499aa06c", + "rev": "7472420f8734c710bd7009081cef9b97f08a3821", "type": "github" }, "original": { @@ -1864,11 +1865,11 @@ "toggleterm-nvim": { "flake": false, "locked": { - "lastModified": 1705944058, - "narHash": "sha256-y+83w0D2jD68QJpBCYXLqUUxVu9MTBZ+nJutYD7jAoQ=", + "lastModified": 1707733615, + "narHash": "sha256-FJyDxQm2vs9R4WkqAbh6ryCvEABfrLSKRrAGo/qI5jM=", "owner": "akinsho", "repo": "toggleterm.nvim", - "rev": "b49df5cdce67a8964d1b027dae94bde212092b51", + "rev": "193786e0371e3286d3bc9aa0079da1cd41beaa62", "type": "github" }, "original": { @@ -1880,11 +1881,11 @@ "tokyonight": { "flake": false, "locked": { - "lastModified": 1706078362, - "narHash": "sha256-qHuX21iC8edV5K0RgHin4PowMtKBXWXQgvHjx2SPTKE=", + "lastModified": 1706697570, + "narHash": "sha256-mzCdcf7FINhhVLUIPv/eLohm4qMG9ndRJ5H4sFU2vO0=", "owner": "folke", "repo": "tokyonight.nvim", - "rev": "e3301873c1e96903daebb98cc9b5926810bf73dd", + "rev": "610179f7f12db3d08540b6cc61434db2eaecbcff", "type": "github" }, "original": { @@ -1945,11 +1946,11 @@ "vim-dirtytalk": { "flake": false, "locked": { - "lastModified": 1697142601, - "narHash": "sha256-ezbcgCvOXhPSpsOZpCI2QIaFFaRGZAFbuAluMvB7Jjk=", + "lastModified": 1709557124, + "narHash": "sha256-5+efbDDHmFB16T3j8v/7O1BXcplEj/9XvPErTHOuIw4=", "owner": "psliwka", "repo": "vim-dirtytalk", - "rev": "f5b0d51a7d822177814e7edc116ca484f852665f", + "rev": "64c532cded23059ae422730f89ab1300fcf3da02", "type": "github" }, "original": { @@ -1961,11 +1962,11 @@ "vim-illuminate": { "flake": false, "locked": { - "lastModified": 1706241276, - "narHash": "sha256-8stuFv+PzjmFKib1Y7kwK4C1db5dlDyptuaz9iU+ptM=", + "lastModified": 1707016059, + "narHash": "sha256-KNIu4cNyZddZSRS8KZ0U0T8uSSLJu8iqNLQN8e+Bv94=", "owner": "RRethy", "repo": "vim-illuminate", - "rev": "97c1265ff0b67064b6cfdc15bafc50202a537ae2", + "rev": "305bf07b919ac526deb5193280379e2f8b599926", "type": "github" }, "original": { @@ -1977,11 +1978,11 @@ "vim-markdown": { "flake": false, "locked": { - "lastModified": 1698870120, - "narHash": "sha256-d3GDuMlnhweAajSc284wWN/h0teu5uFG6NQTWa+dcxo=", + "lastModified": 1709279705, + "narHash": "sha256-eKwWdyvMZ7FV3FvOtqWVD7pulXNnhbEEjHq7MYg1woU=", "owner": "preservim", "repo": "vim-markdown", - "rev": "46add6c3017d3e4035dc10ffa9cb54221d8dfe1a", + "rev": "a657e697376909c41475a686eeef7fc7a4972d94", "type": "github" }, "original": { @@ -2094,11 +2095,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1706288111, - "narHash": "sha256-CvSS/BMm86Uzjeb8pEkWa3qnuzMiPPmT8hf5lDOP6TE=", + "lastModified": 1709943697, + "narHash": "sha256-IATQNonwPhNboTKUpPbj54/A/UVr8ys07CHofD+Tkp8=", "owner": "mitchellh", "repo": "zig-overlay", - "rev": "7f5d4cbecf3aa75ac8afaef8a20723b3a57f7d20", + "rev": "7e0a85db5007bf378dca37cee03c1edfff692ef4", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 25bf39e..2ad148f 100644 --- a/flake.nix +++ b/flake.nix @@ -117,7 +117,8 @@ }; none-ls = { - url = "github:nvimtools/none-ls.nvim"; + # https://github.com/nvimtools/none-ls.nvim/issues/58 + url = "github:nvimtools/none-ls.nvim/bb680d752cec37949faca7a1f509e2fe67ab418a"; flake = false; }; From f2c90a861d2e62a65c94708a67a663326ca41fa0 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 9 Mar 2024 05:41:50 +0300 Subject: [PATCH 032/193] docs: update assets path in the README --- .github/README.md | 128 +++++++++++------- .../assets}/neovim-flake-logo-work.svg | 0 2 files changed, 82 insertions(+), 46 deletions(-) rename {assets => .github/assets}/neovim-flake-logo-work.svg (100%) diff --git a/.github/README.md b/.github/README.md index 780e34b..cd34e6e 100644 --- a/.github/README.md +++ b/.github/README.md @@ -1,5 +1,5 @@
- neovim-flake Logo + neovim-flake Logo

❄️ neovim-flake

@@ -30,7 +30,10 @@ @@ -62,106 +65,137 @@ ### Using `nix` CLI -If you would like to try out the configuration before even thinking about installing it, you can run the following command +If you would like to try out the configuration before even thinking about +installing it, you can run the following command ```console nix run github:notashelf/neovim-flake ``` -This will get you a feel for the base configuration and UI design. The flake exposes `#nix` as the default package, providing minimal language support and various -utilities.You may also use `#nix`, `#tidal` or `#maximal` to get try out different configurations. +This will get you a feel for the base configuration and UI design. +The flake exposes `#nix` as the default package, providing minimal +language support and various utilities.You may also use `#nix`, +`#tidal` or `#maximal` to get try out different configurations. -It is as simple as changing the target output to get a different configuration. For example, to get a configuration with `tidal` support, run: +It is as simple as changing the target output to get a different +configuration. For example, to get a configuration with `tidal` support, run: ```console nix run github:notashelf/neovim-flake#tidal ``` -Similar instructions will apply for `nix profile install`. However, you are recommended to instead use the module system as described in the manual. +Similar instructions will apply for `nix profile install`. However, you are +recommended to instead use the module system as described in the manual. > [!NOTE] -> The `maximal` configuration is _massive_ and will take a while to build. To get a feel for the configuration, use the default `nix` or `tidal` configurations. -> Should you choose to try out the `maximal` configuration, using the binary cache as described in the manual is _strongly_ recommended. +> The `maximal` configuration is _massive_ and will take a while to build. +> To get a feel for the configuration, use the default `nix` or `tidal` +> configurations. Should you choose to try out the `maximal` configuration, +> using the binary cache as described in the manual is _strongly_ recommended. ### Docker -As of version 0.5, an image for the `nix` output is published to Dockerhub and GitHub packages with each tagged release. If you do not have Nix installed +As of version 0.5, an image for the `nix` output is published to Dockerhub +and GitHub packages with each tagged release. If you do not have Nix installed on your system, you may run neovim within a container using your favorite tool. -The following command will open the current directory in neovim with necessary tools bootstrapped. +The following command will open the current directory in neovim with necessary +tools bootstrapped. ```console docker run -v `pwd`:/home/neovim/demo --rm -it notashelf/neovim-flake:latest ``` -The available registeres are `ghcr.io` and `dockerhub` for the time being. Adjust to your liking. +The available registeres are `ghcr.io` and `dockerhub` for the time being. +Adjust to your liking. ## Documentation -See the [neovim-flake Manual](https://notashelf.github.io/neovim-flake/) for detailed installation guides, configurations, available options, release notes -and more. +See the [neovim-flake Manual](https://notashelf.github.io/neovim-flake/) for +detailed installation guides, configurations, available options, release notes +and more. Tips for installing userspace plugins is also contained in the +documentation. -If you want to dive right into trying **neovim-flake** you can get a fully featured configuration with `nix` -language support by running: +If you want to dive right into trying **neovim-flake** you can get a fully +featured configuration with `nix` language support by running: ```console nix run github:notashelf/neovim-flake ``` -Please create an issue on the [issue tracker](../../../issues) if you find the documentation lacking or confusing. -I also appreciate any contributions to the documentation. +Please create an issue on the [issue tracker](../../../issues) if you find +the documentation lacking or confusing. I also appreciate any contributions +to the documentation. ## Help -You can create an issue on the [issue tracker](../../../issues) to ask questions or report bugs. -I am not yet on spaces like matrix or IRC, so please use the issue tracker for now. +You can create an issue on the [issue tracker](../../../issues) to ask questions +or report bugs. I am not yet on spaces like matrix or IRC, so please use the issue +tracker for now. ## Contributing -I am always looking for new ways to help improve this flake. If you would like to contribute, please read -the [contributing guide](CONTRIBUTING.md) before submitting a pull request. You can also create an -issue on the [issue tracker](../../../issues) before submitting a pull request if you would like to discuss -a feature or bug fix. +I am always looking for new ways to help improve this flake. If you would like +to contribute, please read the [contributing guide](CONTRIBUTING.md) before +submitting a pull request. You can also create an issue on the +[issue tracker](../../../issues) before submitting a pull request if you would +like to discuss a feature or bug fix. ## Philosophy -The philosophy behind this flake configuration is to create an easily configurable and reproducible Neovim environment. -While it does sacrifice in size (which I know some users will find _disagreeable_), it offers a lot of flexibility and customizability in -exchange for the large size of the flake inputs. The "KISS" (Keep it simple, stupid) principle has mostly been abandoned here, however, you _can_ -ultimately leverage the flexibility of this flake to declare a configuration that follows KISS principles, as it is very easy to bring your -own plugins and configurations from non-nix. What this flake is meant to be does eventually fall into your hands. Whether you are a -developer, writer, or live coder, you can quickly craft a config that suits every project's need. Think of it like a distribution of Neovim that you have -full control over. A distribution that takes advantage of pinning vim plugins and third party dependencies (such as tree-sitter grammars, language servers, and more). +The philosophy behind this flake configuration is to create an easily +configurable and reproducible Neovim environment. While it does sacrifice in +size (which I know some users will find _disagreeable_), it offers a lot of +flexibility and customizability in exchange for the large size of the flake +inputs. The "KISS" (Keep it simple, stupid) principle has mostly been abandoned +here, however, you _can_ ultimately leverage the flexibility of this flake to +declare a configuration that follows KISS principles, as it is very easy to +bring your own plugins and configurations from non-nix. What this flake is +meant to be does eventually fall into your hands. Whether you are a developer, +writer, or live coder, you can quickly craft a config that suits every project's +needs. Think of it like a distribution of Neovim that you have full control over. -One should never get a broken config when setting options. If setting multiple options results in a broken Neovim, file an issue! -Each plugin knows when another plugin which allows for smart configuration of keybindings and automatic setup of things -like completion sources and languages. +A distribution that takes advantage of pinning vim plugins and third party +dependencies (such as tree-sitter grammars, language servers, and more). + +One should never get a broken config when setting options. If setting multiple +options results in a broken Neovim, file an issue! Each plugin knows when another +plugin which allows for smart configuration of keybindings and automatic setup +of things like completion sources and languages. ## FAQ **Q**: Why is this flake so big?
-**A**: I have sacrificed in size in order to provide a highly configurable and reproducible Neovim environment. A binary cache is provided to -eleminate the need to build the flake from source, but it is still a large flake. If you do not need all the features, you can use the default `nix` output -instead of the `maximal` output. This will reduce size by a lot, but you will lose some language specific features. +**A**: I have sacrificed in size in order to provide a highly configurable and +reproducible Neovim environment. A binary cache is provided to eleminate the +need to build the flake from source, but it is still a large flake. If you do +not need all the features, you can use the default `nix` output instead of the +`maximal` output. This will reduce size by a lot, but you will lose some +language specific features.

**Q**: Will you try to make this flake smaller?
-**A**: Yes. As a matter of fact, I am actively working on making this flake smaller. Unfortunately the process of providing everything -possible by itself makes the flake large. Best I can do is to optimize the flake as much as possible by selecting plugins that -are small and fast. And the binary cache, so at least you don't have to build it from source. +**A**: Yes. As a matter of fact, I am actively working on making this flake +smaller. Unfortunately the process of providing everything possible by itself +makes the flake large. Best I can do is to optimize the flake as much as +possible by selecting plugins that are small and fast. And the binary cache, so +at least you don't have to build it from source.

**Q**: Will you use a plugin manager/language server installer?
-**A**: No. If you feel the need to ask that question, then you have missed the whole point of using nix and ultimately this flake. -The whole reason we use nix is to be able to handle EVERYTHING declaratively, well including the LSP and plugin installations. +**A**: No. If you feel the need to ask that question, then you have missed the +whole point of using nix and ultimately this flake. The whole reason we use nix +is to be able to handle EVERYTHING declaratively, well including the LSP and +plugin installations.

**Q**: Can you add _X_?
-**A**: Maybe. Open an issue using the appropriate template and I will consider it. I do not intend to -add _every plugin that is in existence_, but I will consider it, should it offer something useful to the flake. +**A**: Maybe. Open an issue using the appropriate template and I will consider +it. I do not intend to add _every plugin that is in existence_, but I will +consider it, should it offer something useful to the flake. ## Credits @@ -180,14 +214,16 @@ and everyone who has submitted issues or pull requests! ### Inspiration -This configuration borrows from and is based on a few other configurations, including: +This configuration borrows from and is based on a few other configurations, +including: - [@jordanisaacs's](https://github.com/jordanisaacs) [neovim-flake](https://github.com/jordanisaacs/neovim-flake) that this flake is originally based on. - [@sioodmy's](https://github.com/sioodmy) [dotfiles](https://github.com/sioodmy/dotfiles) that inspired the design choices. - [@wiltaylor's](https://github.com/wiltaylor) [neovim-flake](https://github.com/wiltaylor/neovim-flake) for plugin and design ideas. - [@gvolpe's](https://github.com/gvolpe) [neovim-flake](https://github.com/gvolpe/neovim-flake) for plugin, design and nix concepts. -I am grateful for their previous work and inspiration, and I wholeheartedly recommend checking their work out. +I am grateful for their previous work and inspiration, and I wholeheartedly +recommend checking their work out.
--- diff --git a/assets/neovim-flake-logo-work.svg b/.github/assets/neovim-flake-logo-work.svg similarity index 100% rename from assets/neovim-flake-logo-work.svg rename to .github/assets/neovim-flake-logo-work.svg From dfc7c6737f13e5d98ab178dee8b743b4264056a0 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 9 Mar 2024 08:49:22 +0300 Subject: [PATCH 033/193] modules/languages: finish making lib calls explicit --- modules/languages/css.nix | 15 ++- modules/languages/go.nix | 25 +++-- modules/languages/html.nix | 37 ++++---- modules/languages/java.nix | 17 ++-- modules/languages/lua.nix | 21 +++-- modules/languages/nim.nix | 32 ++++--- modules/languages/nix.nix | 39 ++++---- modules/languages/php.nix | 20 ++-- modules/languages/python.nix | 36 +++++--- modules/languages/rust.nix | 158 +++++++++++++++++--------------- modules/languages/sql.nix | 32 ++++--- modules/languages/svelte.nix | 21 +++-- modules/languages/tailwind.nix | 12 ++- modules/languages/terraform.nix | 11 ++- modules/languages/ts.nix | 25 +++-- modules/languages/zig.nix | 17 ++-- 16 files changed, 301 insertions(+), 217 deletions(-) diff --git a/modules/languages/css.nix b/modules/languages/css.nix index c39ff40..9646e02 100644 --- a/modules/languages/css.nix +++ b/modules/languages/css.nix @@ -5,7 +5,12 @@ ... }: let inherit (builtins) attrNames; - inherit (lib) mkEnableOption mkOption mkIf mkMerge isList types nvim; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib.types) enum either listOf package str; + inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.lua) expToLua; cfg = config.vim.languages.css; @@ -25,7 +30,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/vscode-css-language-server", "--stdio"}'' } } @@ -39,7 +44,7 @@ in { treesitter = { enable = mkEnableOption "CSS treesitter" // {default = config.vim.languages.enableTreesitter;}; - package = nvim.types.mkGrammarOption pkgs "css"; + package = mkGrammarOption pkgs "css"; }; lsp = { @@ -47,14 +52,14 @@ in { server = mkOption { description = "CSS LSP server to use"; - type = with types; enum (attrNames servers); + type = enum (attrNames servers); default = defaultServer; }; package = mkOption { description = "CSS 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; }; }; diff --git a/modules/languages/go.nix b/modules/languages/go.nix index 8e3694c..055e8ed 100644 --- a/modules/languages/go.nix +++ b/modules/languages/go.nix @@ -1,11 +1,17 @@ { - pkgs, config, + pkgs, lib, ... }: let inherit (builtins) attrNames; - inherit (lib) isList nvim getExe mkEnableOption mkOption types mkMerge mkIf; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.meta) getExe; + inherit (lib.lists) isList; + inherit (lib.types) bool enum either listOf package str; + inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.lua) expToLua; cfg = config.vim.languages.go; @@ -19,13 +25,14 @@ 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/gopls", "serve"}'' }, } ''; }; }; + defaultDebugger = "delve"; debuggers = { delve = { @@ -73,7 +80,7 @@ in { treesitter = { enable = mkEnableOption "Go treesitter" // {default = config.vim.languages.enableTreesitter;}; - package = nvim.types.mkGrammarOption pkgs "go"; + package = mkGrammarOption pkgs "go"; }; lsp = { @@ -81,14 +88,14 @@ in { server = mkOption { description = "Go LSP server to use"; - type = with types; enum (attrNames servers); + type = enum (attrNames servers); default = defaultServer; }; package = mkOption { description = "Go 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; }; }; @@ -96,17 +103,17 @@ in { dap = { enable = mkOption { description = "Enable Go Debug Adapter"; - type = types.bool; + type = bool; default = config.vim.languages.enableDAP; }; debugger = mkOption { description = "Go debugger to use"; - type = with types; enum (attrNames debuggers); + type = enum (attrNames debuggers); default = defaultDebugger; }; package = mkOption { description = "Go debugger package."; - type = types.package; + type = package; default = debuggers.${cfg.dap.debugger}.package; }; }; diff --git a/modules/languages/html.nix b/modules/languages/html.nix index e2eadac..a4cf238 100644 --- a/modules/languages/html.nix +++ b/modules/languages/html.nix @@ -1,27 +1,26 @@ { - pkgs, config, + pkgs, lib, ... }: let - inherit (lib) mkEnableOption mkOption types nvim mkIf mkMerge optional; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.types) bool; + inherit (lib.lists) optional; + inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.languages.html; in { options.vim.languages.html = { enable = mkEnableOption "HTML language support"; - treesitter = { - enable = mkOption { - description = "Enable HTML treesitter"; - type = types.bool; - default = config.vim.languages.enableTreesitter; - }; - package = nvim.types.mkGrammarOption pkgs "html"; - + enable = mkEnableOption "HTML treesitter support" // {default = config.vim.languages.enableTreesitter;}; + package = mkGrammarOption pkgs "html"; autotagHtml = mkOption { description = "Enable autoclose/autorename of html tags (nvim-ts-autotag)"; - type = types.bool; + type = bool; default = true; }; }; @@ -29,14 +28,18 @@ in { config = mkIf cfg.enable (mkMerge [ (mkIf cfg.treesitter.enable { - vim.treesitter.enable = true; - vim.treesitter.grammars = [cfg.treesitter.package]; + vim = { + startPlugins = optional cfg.treesitter.autotagHtml "nvim-ts-autotag"; - vim.startPlugins = optional cfg.treesitter.autotagHtml "nvim-ts-autotag"; + treesitter = { + enable = true; + grammars = [cfg.treesitter.package]; + }; - vim.luaConfigRC.html-autotag = mkIf cfg.treesitter.autotagHtml (nvim.dag.entryAnywhere '' - require('nvim-ts-autotag').setup() - ''); + luaConfigRC.html-autotag = mkIf cfg.treesitter.autotagHtml (entryAnywhere '' + require('nvim-ts-autotag').setup() + ''); + }; }) ]); } diff --git a/modules/languages/java.nix b/modules/languages/java.nix index fc138cc..dc46fcf 100644 --- a/modules/languages/java.nix +++ b/modules/languages/java.nix @@ -1,10 +1,16 @@ { - pkgs, config, + pkgs, lib, ... }: let - inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge getExe; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.meta) getExe; + inherit (lib.lists) isList; + inherit (lib.types) either listOf package str; + inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.lua) expToLua; cfg = config.vim.languages.java; in { @@ -13,16 +19,15 @@ in { treesitter = { enable = mkEnableOption "Java treesitter" // {default = config.vim.languages.enableTreesitter;}; - package = nvim.types.mkGrammarOption pkgs "java"; + package = mkGrammarOption pkgs "java"; }; lsp = { enable = mkEnableOption "Java LSP support (java-language-server)" // {default = config.vim.languages.enableLSP;}; - package = mkOption { description = "java language 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 = pkgs.jdt-language-server; }; }; @@ -37,7 +42,7 @@ in { on_attach = default_on_attach, cmd = ${ if isList cfg.lsp.package - then nvim.lua.expToLua cfg.lsp.package + then expToLua cfg.lsp.package else ''{"${getExe cfg.lsp.package}", "-data", vim.fn.stdpath("cache").."/jdtls/workspace"}'' }, } diff --git a/modules/languages/lua.nix b/modules/languages/lua.nix index 5cfe203..7cbacb6 100644 --- a/modules/languages/lua.nix +++ b/modules/languages/lua.nix @@ -1,10 +1,18 @@ { - pkgs, config, + pkgs, lib, ... }: let - inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge optionalString getExe; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.meta) getExe; + inherit (lib.lists) isList; + inherit (lib.strings) optionalString; + inherit (lib.types) either listOf package str; + inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.dag) entryBefore; cfg = config.vim.languages.lua; in { @@ -12,14 +20,15 @@ in { enable = mkEnableOption "Lua language support"; treesitter = { enable = mkEnableOption "Lua Treesitter support" // {default = config.vim.languages.enableTreesitter;}; - package = nvim.types.mkGrammarOption pkgs "lua"; + package = mkGrammarOption pkgs "lua"; }; + lsp = { enable = mkEnableOption "Lua LSP support via LuaLS" // {default = config.vim.languages.enableLSP;}; package = mkOption { description = "LuaLS package, or the command to run as a list of strings"; - type = with types; either package (listOf str); + type = either package (listOf str); default = pkgs.lua-language-server; }; @@ -43,7 +52,7 @@ in { ${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 + then expToLua cfg.lsp.package else ''{"${getExe cfg.lsp.package}"}'' }; } @@ -52,7 +61,7 @@ in { (mkIf cfg.lsp.neodev.enable { vim.startPlugins = ["neodev-nvim"]; - vim.luaConfigRC.neodev = nvim.dag.entryBefore ["lua-lsp"] '' + vim.luaConfigRC.neodev = entryBefore ["lua-lsp"] '' require("neodev").setup({}) ''; }) diff --git a/modules/languages/nim.nix b/modules/languages/nim.nix index 7297ada..f218038 100644 --- a/modules/languages/nim.nix +++ b/modules/languages/nim.nix @@ -1,11 +1,17 @@ { - pkgs, config, + pkgs, lib, ... }: let inherit (builtins) attrNames; - inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib.types) enum either listOf package str; + inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.lua) expToLua; + cfg = config.vim.languages.nim; defaultServer = "nimlsp"; @@ -18,7 +24,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/nimlsp"} '' @@ -47,41 +53,37 @@ in { enable = mkEnableOption "Nim language support"; treesitter = { - enable = mkOption { - description = "Enable Nim treesitter"; - type = types.bool; - default = config.vim.languages.enableTreesitter; - }; - package = nvim.types.mkGrammarOption pkgs "nim"; + enable = mkEnableOption "Nim treesitter" // {default = config.vim.languages.enableTreesitter;}; + package = mkGrammarOption pkgs "nim"; }; lsp = { enable = mkEnableOption "Nim LSP support" // {default = config.vim.languages.enableLSP;}; - server = mkOption { description = "Nim LSP server to use"; - type = types.str; + type = str; default = defaultServer; }; + package = mkOption { description = "Nim LSP server package, or the command to run as a list of strings"; example = ''[lib.getExe pkgs.nimlsp]''; - type = with types; either package (listOf str); + type = either package (listOf str); default = servers.${cfg.lsp.server}.package; }; }; format = { enable = mkEnableOption "Nim formatting" // {default = config.vim.languages.enableFormat;}; - type = mkOption { description = "Nim formatter to use"; - type = with types; enum (attrNames formats); + type = enum (attrNames formats); default = defaultFormat; }; + package = mkOption { description = "Nim formatter package"; - type = types.package; + type = package; default = formats.${cfg.format.type}.package; }; }; diff --git a/modules/languages/nix.nix b/modules/languages/nix.nix index e8b5578..6061018 100644 --- a/modules/languages/nix.nix +++ b/modules/languages/nix.nix @@ -1,11 +1,17 @@ { - pkgs, config, + pkgs, lib, ... }: let inherit (builtins) attrNames; - inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge optionalString; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib.strings) optionalString; + inherit (lib.types) enum either listOf package str; + inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.languages.nix; @@ -82,6 +88,7 @@ ) ''; }; + nixpkgs-fmt = { package = pkgs.nixpkgs-fmt; # Never need to use null-ls for nixpkgs-fmt @@ -101,6 +108,7 @@ ) ''; }; + deadnix = { package = pkgs.deadnix; nullConfig = pkg: '' @@ -118,26 +126,22 @@ in { enable = mkEnableOption "Nix language support"; treesitter = { - enable = mkOption { - description = "Enable Nix treesitter"; - type = types.bool; - default = config.vim.languages.enableTreesitter; - }; - package = nvim.types.mkGrammarOption pkgs "nix"; + enable = mkEnableOption "Nix treesitter" // {default = config.vim.languages.enableTreesitter;}; + package = mkGrammarOption pkgs "nix"; }; lsp = { enable = mkEnableOption "Nix LSP support" // {default = config.vim.languages.enableLSP;}; - server = mkOption { description = "Nix LSP server to use"; - type = types.str; + type = str; default = defaultServer; }; + package = mkOption { description = "Nix 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; }; }; @@ -147,22 +151,19 @@ in { type = mkOption { description = "Nix formatter to use"; - type = with types; enum (attrNames formats); + type = enum (attrNames formats); default = defaultFormat; }; package = mkOption { description = "Nix formatter package"; - type = types.package; + type = package; default = formats.${cfg.format.type}.package; }; }; extraDiagnostics = { - enable = mkOption { - description = "Enable extra Nix diagnostics"; - type = types.bool; - default = config.vim.languages.enableExtraDiagnostics; - }; + enable = mkEnableOption "extra Nix diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;}; + types = lib.nvim.types.diagnostics { langDesc = "Nix"; inherit diagnostics; @@ -173,7 +174,7 @@ in { config = mkIf cfg.enable (mkMerge [ { - vim.configRC.nix = nvim.dag.entryAnywhere '' + vim.configRC.nix = entryAnywhere '' autocmd filetype nix setlocal tabstop=2 shiftwidth=2 softtabstop=2 ''; } diff --git a/modules/languages/php.nix b/modules/languages/php.nix index 6a0071a..d921b11 100644 --- a/modules/languages/php.nix +++ b/modules/languages/php.nix @@ -1,11 +1,17 @@ { - pkgs, config, + pkgs, lib, ... }: let inherit (builtins) attrNames; - inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge getExe; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.meta) getExe; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib.types) enum either listOf package str; + inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.lua) expToLua; cfg = config.vim.languages.php; @@ -19,7 +25,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 '' { "${getExe cfg.lsp.package}", @@ -39,7 +45,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 '' { "${getExe cfg.lsp.package}", @@ -65,7 +71,7 @@ in { treesitter = { enable = mkEnableOption "PHP treesitter" // {default = config.vim.languages.enableTreesitter;}; - package = nvim.types.mkGrammarOption pkgs "php"; + package = mkGrammarOption pkgs "php"; }; lsp = { @@ -73,14 +79,14 @@ in { server = mkOption { description = "PHP LSP server to use"; - type = with types; enum (attrNames servers); + type = enum (attrNames servers); default = defaultServer; }; package = mkOption { description = "PHP 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; }; }; diff --git a/modules/languages/python.nix b/modules/languages/python.nix index 970906f..d9df6bf 100644 --- a/modules/languages/python.nix +++ b/modules/languages/python.nix @@ -1,11 +1,16 @@ { - pkgs, config, + pkgs, lib, ... }: let inherit (builtins) attrNames; - inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge getExe literalExpression; + inherit (lib.options) mkEnableOption mkOption literalExpression; + inherit (lib.meta) getExe; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib.types) enum either listOf package str bool; + inherit (lib.nvim.lua) expToLua; cfg = config.vim.languages.python; @@ -19,7 +24,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/pyright-langserver", "--stdio"}'' } } @@ -40,6 +45,7 @@ ) ''; }; + isort = { package = pkgs.isort; nullConfig = '' @@ -51,6 +57,7 @@ ) ''; }; + black-and-isort = { package = pkgs.writeShellApplication { name = "black"; @@ -140,7 +147,7 @@ in { enable = mkEnableOption "Python treesitter" // {default = config.vim.languages.enableTreesitter;}; package = mkOption { description = "Python treesitter grammar to use"; - type = types.package; + type = package; default = pkgs.vimPlugins.nvim-treesitter.builtGrammars.python; }; }; @@ -150,14 +157,14 @@ in { server = mkOption { description = "Python LSP server to use"; - type = with types; enum (attrNames servers); + type = enum (attrNames servers); default = defaultServer; }; package = mkOption { description = "python 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; }; }; @@ -167,13 +174,13 @@ in { type = mkOption { description = "Python formatter to use"; - type = with types; enum (attrNames formats); + type = enum (attrNames formats); default = defaultFormat; }; package = mkOption { description = "Python formatter package"; - type = types.package; + type = package; default = formats.${cfg.format.type}.package; }; }; @@ -182,25 +189,28 @@ in { dap = { enable = mkOption { description = "Enable Python Debug Adapter"; - type = types.bool; + type = bool; default = config.vim.languages.enableDAP; }; + debugger = mkOption { description = "Python debugger to use"; - type = with types; enum (attrNames debuggers); + type = enum (attrNames debuggers); default = defaultDebugger; }; + package = mkOption { + type = package; + default = debuggers.${cfg.dap.debugger}.package; + example = literalExpression "with pkgs; python39.withPackages (ps: with ps; [debugpy])"; description = '' Python debugger package. This is a python package with debugpy installed, see https://nixos.wiki/wiki/Python#Install_Python_Packages. ''; - example = literalExpression "with pkgs; python39.withPackages (ps: with ps; [debugpy])"; - type = types.package; - default = debuggers.${cfg.dap.debugger}.package; }; }; }; + config = mkIf cfg.enable (mkMerge [ (mkIf cfg.treesitter.enable { vim.treesitter.enable = true; diff --git a/modules/languages/rust.nix b/modules/languages/rust.nix index 1112f7b..8e4fc36 100644 --- a/modules/languages/rust.nix +++ b/modules/languages/rust.nix @@ -1,6 +1,6 @@ { - pkgs, config, + pkgs, lib, ... }: let @@ -27,7 +27,6 @@ in { lsp = { enable = mkEnableOption "Rust LSP support (rust-analyzer with extra tools)" // {default = config.vim.languages.enableLSP;}; - package = mkOption { description = "rust-analyzer package, or the command to run as a list of strings"; example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]''; @@ -48,6 +47,7 @@ in { type = types.bool; default = config.vim.languages.enableDAP; }; + package = mkOption { description = "lldb pacakge"; type = types.package; @@ -58,89 +58,95 @@ in { config = mkIf cfg.enable (mkMerge [ (mkIf cfg.crates.enable { - vim.lsp.null-ls.enable = mkIf cfg.crates.codeActions true; - - vim.startPlugins = ["crates-nvim"]; - - vim.autocomplete.sources = {"crates" = "[Crates]";}; - vim.luaConfigRC.rust-crates = nvim.dag.entryAnywhere '' - require('crates').setup { - null_ls = { - enabled = ${boolToString cfg.crates.codeActions}, - name = "crates.nvim", + vim = { + startPlugins = ["crates-nvim"]; + lsp.null-ls.enable = mkIf cfg.crates.codeActions true; + autocomplete.sources = {"crates" = "[Crates]";}; + luaConfigRC.rust-crates = nvim.dag.entryAnywhere '' + require('crates').setup { + null_ls = { + enabled = ${boolToString cfg.crates.codeActions}, + name = "crates.nvim", + } } - } - ''; + ''; + }; }) + (mkIf cfg.treesitter.enable { vim.treesitter.enable = true; vim.treesitter.grammars = [cfg.treesitter.package]; }) + (mkIf (cfg.lsp.enable || cfg.dap.enable) { - vim.startPlugins = ["rust-tools"] ++ optionals cfg.dap.enable [cfg.dap.package]; + vim = { + startPlugins = ["rust-tools"] ++ optionals cfg.dap.enable [cfg.dap.package]; - vim.lsp.lspconfig.enable = true; - vim.lsp.lspconfig.sources.rust-lsp = '' - local rt = require('rust-tools') - rust_on_attach = function(client, bufnr) - default_on_attach(client, bufnr) - local opts = { noremap=true, silent=true, buffer = bufnr } - vim.keymap.set("n", "ris", rt.inlay_hints.set, opts) - vim.keymap.set("n", "riu", rt.inlay_hints.unset, opts) - vim.keymap.set("n", "rr", rt.runnables.runnables, opts) - vim.keymap.set("n", "rp", rt.parent_module.parent_module, opts) - vim.keymap.set("n", "rm", rt.expand_macro.expand_macro, opts) - vim.keymap.set("n", "rc", rt.open_cargo_toml.open_cargo_toml, opts) - vim.keymap.set("n", "rg", function() rt.crate_graph.view_crate_graph("x11", nil) end, opts) - ${optionalString cfg.dap.enable '' - vim.keymap.set("n", "rd", ":RustDebuggables", opts) - vim.keymap.set( - "n", "${config.vim.debugger.nvim-dap.mappings.continue}", - function() - local dap = require("dap") - if dap.status() == "" then - vim.cmd "RustDebuggables" - else - dap.continue() - end - end, - opts - ) - ''} - end - local rustopts = { - tools = { - autoSetHints = true, - hover_with_actions = false, - inlay_hints = { - only_current_line = false, - } - }, - server = { - capabilities = capabilities, - on_attach = rust_on_attach, - cmd = ${ - if isList cfg.lsp.package - then nvim.lua.expToLua cfg.lsp.package - else ''{"${cfg.lsp.package}/bin/rust-analyzer"}'' - }, - settings = { - ${cfg.lsp.opts} - } - }, - - ${optionalString cfg.dap.enable '' - dap = { - adapter = { - type = "executable", - command = "${cfg.dap.package}/bin/lldb-vscode", - name = "rt_lldb", + lsp.lspconfig = { + enable = true; + sources.rust-lsp = '' + local rt = require('rust-tools') + rust_on_attach = function(client, bufnr) + default_on_attach(client, bufnr) + local opts = { noremap=true, silent=true, buffer = bufnr } + vim.keymap.set("n", "ris", rt.inlay_hints.set, opts) + vim.keymap.set("n", "riu", rt.inlay_hints.unset, opts) + vim.keymap.set("n", "rr", rt.runnables.runnables, opts) + vim.keymap.set("n", "rp", rt.parent_module.parent_module, opts) + vim.keymap.set("n", "rm", rt.expand_macro.expand_macro, opts) + vim.keymap.set("n", "rc", rt.open_cargo_toml.open_cargo_toml, opts) + vim.keymap.set("n", "rg", function() rt.crate_graph.view_crate_graph("x11", nil) end, opts) + ${optionalString cfg.dap.enable '' + vim.keymap.set("n", "rd", ":RustDebuggables", opts) + vim.keymap.set( + "n", "${config.vim.debugger.nvim-dap.mappings.continue}", + function() + local dap = require("dap") + if dap.status() == "" then + vim.cmd "RustDebuggables" + else + dap.continue() + end + end, + opts + ) + ''} + end + local rustopts = { + tools = { + autoSetHints = true, + hover_with_actions = false, + inlay_hints = { + only_current_line = false, + } + }, + server = { + capabilities = capabilities, + on_attach = rust_on_attach, + cmd = ${ + if isList cfg.lsp.package + then nvim.lua.expToLua cfg.lsp.package + else ''{"${cfg.lsp.package}/bin/rust-analyzer"}'' }, - }, - ''} - } - rt.setup(rustopts) - ''; + settings = { + ${cfg.lsp.opts} + } + }, + + ${optionalString cfg.dap.enable '' + dap = { + adapter = { + type = "executable", + command = "${cfg.dap.package}/bin/lldb-vscode", + name = "rt_lldb", + }, + }, + ''} + } + rt.setup(rustopts) + ''; + }; + }; }) ]); } diff --git a/modules/languages/sql.nix b/modules/languages/sql.nix index 83415ba..790bf13 100644 --- a/modules/languages/sql.nix +++ b/modules/languages/sql.nix @@ -1,11 +1,15 @@ { - pkgs, config, + pkgs, lib, ... }: let inherit (builtins) attrNames; - inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib.types) enum either listOf package str; + inherit (lib.nvim.lua) expToLua; cfg = config.vim.languages.sql; sqlfluffDefault = pkgs.sqlfluff; @@ -23,7 +27,7 @@ end, cmd = ${ if isList cfg.lsp.package - then nvim.lua.expToLua cfg.lsp.package + then expToLua cfg.lsp.package else ''{ "${cfg.lsp.package}/bin/sqls", "-config", string.format("%s/config.yml", vim.fn.getcwd()) }'' } } @@ -68,7 +72,7 @@ in { dialect = mkOption { description = "SQL dialect for sqlfluff (if used)"; - type = types.str; + type = str; default = "ansi"; }; @@ -77,7 +81,7 @@ in { package = mkOption { description = "SQL treesitter grammar to use"; - type = types.package; + type = package; default = pkgs.vimPlugins.nvim-treesitter.builtGrammars.sql; }; }; @@ -87,14 +91,14 @@ in { server = mkOption { description = "SQL LSP server to use"; - type = with types; enum (attrNames servers); + type = enum (attrNames servers); default = defaultServer; }; package = mkOption { description = "SQL 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; }; }; @@ -104,13 +108,13 @@ in { type = mkOption { description = "SQL formatter to use"; - type = with types; enum (attrNames formats); + type = enum (attrNames formats); default = defaultFormat; }; package = mkOption { description = "SQL formatter package"; - type = types.package; + type = package; default = formats.${cfg.format.type}.package; }; }; @@ -133,10 +137,14 @@ in { }) (mkIf cfg.lsp.enable { - vim.startPlugins = ["sqls-nvim"]; + vim = { + startPlugins = ["sqls-nvim"]; - vim.lsp.lspconfig.enable = true; - vim.lsp.lspconfig.sources.sql-lsp = servers.${cfg.lsp.server}.lspConfig; + lsp.lspconfig = { + enable = true; + sources.sql-lsp = servers.${cfg.lsp.server}.lspConfig; + }; + }; }) (mkIf cfg.format.enable { diff --git a/modules/languages/svelte.nix b/modules/languages/svelte.nix index 2c0d40e..b99ea0c 100644 --- a/modules/languages/svelte.nix +++ b/modules/languages/svelte.nix @@ -1,11 +1,16 @@ { - pkgs, config, + pkgs, lib, ... }: let inherit (builtins) attrNames; - inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib.types) enum either listOf package str; + inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.types) mkGrammarOption; cfg = config.vim.languages.svelte; @@ -19,7 +24,7 @@ on_attach = attach_keymaps, cmd = ${ if isList cfg.lsp.package - then nvim.lua.expToLua cfg.lsp.package + then expToLua cfg.lsp.package else ''{"${cfg.lsp.package}/bin/svelteserver", "--stdio"}'' } } @@ -65,7 +70,7 @@ in { treesitter = { enable = mkEnableOption "Svelte treesitter" // {default = config.vim.languages.enableTreesitter;}; - sveltePackage = nvim.types.mkGrammarOption pkgs "svelte"; + sveltePackage = mkGrammarOption pkgs "svelte"; }; lsp = { @@ -73,14 +78,14 @@ in { server = mkOption { description = "Svelte LSP server to use"; - type = with types; enum (attrNames servers); + type = enum (attrNames servers); default = defaultServer; }; package = mkOption { description = "Svelte 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; }; }; @@ -90,13 +95,13 @@ in { type = mkOption { description = "Svelte formatter to use"; - type = with types; enum (attrNames formats); + type = enum (attrNames formats); default = defaultFormat; }; package = mkOption { description = "Svelte formatter package"; - type = types.package; + type = package; default = formats.${cfg.format.type}.package; }; }; diff --git a/modules/languages/tailwind.nix b/modules/languages/tailwind.nix index 543eac8..d641b7e 100644 --- a/modules/languages/tailwind.nix +++ b/modules/languages/tailwind.nix @@ -5,7 +5,11 @@ ... }: let inherit (builtins) attrNames; - inherit (lib) mkEnableOption mkOption mkIf mkMerge isList types nvim; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib.types) enum either listOf package str; + inherit (lib.nvim.lua) expToLua; cfg = config.vim.languages.tailwind; @@ -19,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/tailwindcss-language-server", "--stdio"}'' } } @@ -35,14 +39,14 @@ in { server = mkOption { description = "Tailwindcss LSP server to use"; - type = with types; enum (attrNames servers); + type = enum (attrNames servers); default = defaultServer; }; package = mkOption { description = "Tailwindcss 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; }; }; diff --git a/modules/languages/terraform.nix b/modules/languages/terraform.nix index db2e525..33bb935 100644 --- a/modules/languages/terraform.nix +++ b/modules/languages/terraform.nix @@ -1,10 +1,13 @@ { - pkgs, config, + pkgs, lib, ... }: let - inherit (lib) nvim mkEnableOption mkOption types mkIf mkMerge; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.types) package; + inherit (lib.nvim.types) mkGrammarOption; cfg = config.vim.languages.terraform; in { @@ -13,7 +16,7 @@ in { treesitter = { enable = mkEnableOption "Terraform treesitter" // {default = config.vim.languages.enableTreesitter;}; - package = nvim.types.mkGrammarOption pkgs "terraform"; + package = mkGrammarOption pkgs "terraform"; }; lsp = { @@ -21,7 +24,7 @@ in { package = mkOption { description = "terraform-ls package"; - type = with types; package; + type = package; default = pkgs.terraform-ls; }; }; diff --git a/modules/languages/ts.nix b/modules/languages/ts.nix index 7fc1a24..a2a3711 100644 --- a/modules/languages/ts.nix +++ b/modules/languages/ts.nix @@ -1,11 +1,16 @@ { - pkgs, config, + pkgs, lib, ... }: let inherit (builtins) attrNames; - inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib.types) enum either listOf package str; + inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.types) mkGrammarOption; cfg = config.vim.languages.ts; @@ -19,7 +24,7 @@ on_attach = attach_keymaps, cmd = ${ if isList cfg.lsp.package - then nvim.lua.expToLua cfg.lsp.package + then expToLua cfg.lsp.package else ''{"${cfg.lsp.package}/bin/typescript-language-server", "--stdio"}'' } } @@ -34,7 +39,7 @@ on_attach = attach_keymaps, cmd = ${ if isList cfg.lsp.package - then nvim.lua.expToLua cfg.lsp.package + then expToLua cfg.lsp.package else ''{"${cfg.lsp.package}/bin/deno", "lsp"}'' } } @@ -90,8 +95,8 @@ in { treesitter = { enable = mkEnableOption "Typescript/Javascript treesitter" // {default = config.vim.languages.enableTreesitter;}; - tsPackage = nvim.types.mkGrammarOption pkgs "tsx"; - jsPackage = nvim.types.mkGrammarOption pkgs "javascript"; + tsPackage = mkGrammarOption pkgs "tsx"; + jsPackage = mkGrammarOption pkgs "javascript"; }; lsp = { @@ -99,14 +104,14 @@ in { server = mkOption { description = "Typescript/Javascript LSP server to use"; - type = with types; enum (attrNames servers); + type = enum (attrNames servers); default = defaultServer; }; package = mkOption { description = "Typescript/Javascript 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; }; }; @@ -116,13 +121,13 @@ in { type = mkOption { description = "Typescript/Javascript formatter to use"; - type = with types; enum (attrNames formats); + type = enum (attrNames formats); default = defaultFormat; }; package = mkOption { description = "Typescript/Javascript formatter package"; - type = types.package; + type = package; default = formats.${cfg.format.type}.package; }; }; diff --git a/modules/languages/zig.nix b/modules/languages/zig.nix index bb4f278..b0217b9 100644 --- a/modules/languages/zig.nix +++ b/modules/languages/zig.nix @@ -1,10 +1,15 @@ { - pkgs, config, + pkgs, lib, ... }: let - inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib.types) either listOf package str; + inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.types) mkGrammarOption; cfg = config.vim.languages.zig; in { @@ -13,7 +18,7 @@ in { treesitter = { enable = mkEnableOption "Zig treesitter" // {default = config.vim.languages.enableTreesitter;}; - package = nvim.types.mkGrammarOption pkgs "zig"; + package = mkGrammarOption pkgs "zig"; }; lsp = { @@ -22,13 +27,13 @@ in { package = mkOption { description = "ZLS 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 = pkgs.zls; }; zigPackage = mkOption { description = "Zig package used by ZLS"; - type = types.package; + type = package; default = pkgs.zig; }; }; @@ -47,7 +52,7 @@ in { 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/zls"}'' }, settings = { From c488f0490fd290d71c77ae6e4d501a5afb0ddd54 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 12 Mar 2024 03:46:29 +0300 Subject: [PATCH 034/193] modules/lsp: switch to explicit lib calls --- modules/lsp/config.nix | 163 +++++++++--------- modules/lsp/default.nix | 2 +- modules/lsp/lightbulb/config.nix | 19 +- modules/lsp/lightbulb/default.nix | 2 +- modules/lsp/lightbulb/lightbulb.nix | 8 +- modules/lsp/lsp-signature/config.nix | 34 ++-- modules/lsp/lsp-signature/default.nix | 2 +- modules/lsp/lsp-signature/lsp-signature.nix | 10 +- modules/lsp/lspconfig/config.nix | 31 ++-- modules/lsp/lspconfig/default.nix | 2 +- modules/lsp/lspconfig/lspconfig.nix | 12 +- modules/lsp/lspkind/config.nix | 6 +- modules/lsp/lspkind/default.nix | 2 +- modules/lsp/lspkind/lspkind.nix | 14 +- modules/lsp/lsplines/config.nix | 5 +- modules/lsp/lsplines/default.nix | 2 +- modules/lsp/lsplines/lsplines.nix | 6 +- modules/lsp/lspsaga/config.nix | 58 ++++--- modules/lsp/lspsaga/default.nix | 2 +- modules/lsp/lspsaga/lspsaga.nix | 3 +- modules/lsp/module.nix | 3 +- modules/lsp/null-ls/config.nix | 40 +++-- modules/lsp/null-ls/default.nix | 2 +- modules/lsp/null-ls/null-ls.nix | 14 +- modules/lsp/nvim-code-action-menu/config.nix | 35 ++-- modules/lsp/nvim-code-action-menu/default.nix | 2 +- .../nvim-code-action-menu.nix | 3 +- modules/lsp/nvim-docs-view/config.nix | 6 +- modules/lsp/nvim-docs-view/default.nix | 2 +- modules/lsp/nvim-docs-view/nvim-docs-view.nix | 20 ++- modules/lsp/trouble/config.nix | 43 ++--- modules/lsp/trouble/default.nix | 2 +- modules/lsp/trouble/trouble.nix | 3 +- 33 files changed, 285 insertions(+), 273 deletions(-) diff --git a/modules/lsp/config.nix b/modules/lsp/config.nix index 1d44ea7..cabe371 100644 --- a/modules/lsp/config.nix +++ b/modules/lsp/config.nix @@ -15,99 +15,102 @@ mkBinding = binding: action: "vim.api.nvim_buf_set_keymap(bufnr, 'n', '${binding.value}', 'lua ${action}', {noremap=true, silent=true, desc='${binding.description}'})"; in { config = mkIf cfg.enable { - vim.startPlugins = optional usingNvimCmp "cmp-nvim-lsp"; + vim = { + startPlugins = optional usingNvimCmp "cmp-nvim-lsp"; - vim.autocomplete.sources = {"nvim_lsp" = "[LSP]";}; - vim.luaConfigRC.lsp-setup = '' - vim.g.formatsave = ${boolToString cfg.formatOnSave}; + autocomplete.sources = {"nvim_lsp" = "[LSP]";}; - local attach_keymaps = function(client, bufnr) - ${mkBinding mappings.goToDeclaration "vim.lsp.buf.declaration()"} - ${mkBinding mappings.goToDefinition "vim.lsp.buf.definition()"} - ${mkBinding mappings.goToType "vim.lsp.buf.type_definition()"} - ${mkBinding mappings.listImplementations "vim.lsp.buf.implementation()"} - ${mkBinding mappings.listReferences "vim.lsp.buf.references()"} - ${mkBinding mappings.nextDiagnostic "vim.diagnostic.goto_next()"} - ${mkBinding mappings.previousDiagnostic "vim.diagnostic.goto_prev()"} - ${mkBinding mappings.openDiagnosticFloat "vim.diagnostic.open_float()"} - ${mkBinding mappings.documentHighlight "vim.lsp.buf.document_highlight()"} - ${mkBinding mappings.listDocumentSymbols "vim.lsp.buf.document_symbol()"} - ${mkBinding mappings.addWorkspaceFolder "vim.lsp.buf.add_workspace_folder()"} - ${mkBinding mappings.removeWorkspaceFolder "vim.lsp.buf.remove_workspace_folder()"} - ${mkBinding mappings.listWorkspaceFolders "print(vim.inspect(vim.lsp.buf.list_workspace_folders()))"} - ${mkBinding mappings.listWorkspaceSymbols "vim.lsp.buf.workspace_symbol()"} - ${mkBinding mappings.hover "vim.lsp.buf.hover()"} - ${mkBinding mappings.signatureHelp "vim.lsp.buf.signature_help()"} - ${mkBinding mappings.renameSymbol "vim.lsp.buf.rename()"} - ${mkBinding mappings.codeAction "vim.lsp.buf.code_action()"} - ${mkBinding mappings.format "vim.lsp.buf.format()"} - ${mkBinding mappings.toggleFormatOnSave "vim.b.disableFormatSave = not vim.b.disableFormatSave"} - end + luaConfigRC.lsp-setup = '' + vim.g.formatsave = ${boolToString cfg.formatOnSave}; - -- Enable formatting - local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) + local attach_keymaps = function(client, bufnr) + ${mkBinding mappings.goToDeclaration "vim.lsp.buf.declaration()"} + ${mkBinding mappings.goToDefinition "vim.lsp.buf.definition()"} + ${mkBinding mappings.goToType "vim.lsp.buf.type_definition()"} + ${mkBinding mappings.listImplementations "vim.lsp.buf.implementation()"} + ${mkBinding mappings.listReferences "vim.lsp.buf.references()"} + ${mkBinding mappings.nextDiagnostic "vim.diagnostic.goto_next()"} + ${mkBinding mappings.previousDiagnostic "vim.diagnostic.goto_prev()"} + ${mkBinding mappings.openDiagnosticFloat "vim.diagnostic.open_float()"} + ${mkBinding mappings.documentHighlight "vim.lsp.buf.document_highlight()"} + ${mkBinding mappings.listDocumentSymbols "vim.lsp.buf.document_symbol()"} + ${mkBinding mappings.addWorkspaceFolder "vim.lsp.buf.add_workspace_folder()"} + ${mkBinding mappings.removeWorkspaceFolder "vim.lsp.buf.remove_workspace_folder()"} + ${mkBinding mappings.listWorkspaceFolders "print(vim.inspect(vim.lsp.buf.list_workspace_folders()))"} + ${mkBinding mappings.listWorkspaceSymbols "vim.lsp.buf.workspace_symbol()"} + ${mkBinding mappings.hover "vim.lsp.buf.hover()"} + ${mkBinding mappings.signatureHelp "vim.lsp.buf.signature_help()"} + ${mkBinding mappings.renameSymbol "vim.lsp.buf.rename()"} + ${mkBinding mappings.codeAction "vim.lsp.buf.code_action()"} + ${mkBinding mappings.format "vim.lsp.buf.format()"} + ${mkBinding mappings.toggleFormatOnSave "vim.b.disableFormatSave = not vim.b.disableFormatSave"} + end - format_callback = function(client, bufnr) - if vim.g.formatsave then - vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) - vim.api.nvim_create_autocmd("BufWritePre", { - group = augroup, - buffer = bufnr, - callback = function() - ${ - if config.vim.lsp.null-ls.enable - then '' - if vim.b.disableFormatSave then - return - end + -- Enable formatting + local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) - local function is_null_ls_formatting_enabled(bufnr) - local file_type = vim.api.nvim_buf_get_option(bufnr, "filetype") - local generators = require("null-ls.generators").get_available( - file_type, - require("null-ls.methods").internal.FORMATTING - ) - return #generators > 0 - end + format_callback = function(client, bufnr) + if vim.g.formatsave then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + ${ + if config.vim.lsp.null-ls.enable + then '' + if vim.b.disableFormatSave then + return + end - if is_null_ls_formatting_enabled(bufnr) then - vim.lsp.buf.format({ - bufnr = bufnr, - filter = function(client) - return client.name == "null-ls" - end - }) - else - vim.lsp.buf.format({ - bufnr = bufnr, - }) - end - '' - else " + local function is_null_ls_formatting_enabled(bufnr) + local file_type = vim.api.nvim_buf_get_option(bufnr, "filetype") + local generators = require("null-ls.generators").get_available( + file_type, + require("null-ls.methods").internal.FORMATTING + ) + return #generators > 0 + end + + if is_null_ls_formatting_enabled(bufnr) then + vim.lsp.buf.format({ + bufnr = bufnr, + filter = function(client) + return client.name == "null-ls" + end + }) + else + vim.lsp.buf.format({ + bufnr = bufnr, + }) + end + '' + else " vim.lsp.buf.format({ bufnr = bufnr, }) " - } - end, - }) + } + end, + }) + end end - end - ${optionalString (config.vim.ui.breadcrumbs.enable) ''local navic = require("nvim-navic")''} - default_on_attach = function(client, bufnr) - attach_keymaps(client, bufnr) - format_callback(client, bufnr) - ${optionalString (config.vim.ui.breadcrumbs.enable) '' - -- let navic attach to buffers - if client.server_capabilities.documentSymbolProvider then - navic.attach(client, bufnr) + ${optionalString (config.vim.ui.breadcrumbs.enable) ''local navic = require("nvim-navic")''} + default_on_attach = function(client, bufnr) + attach_keymaps(client, bufnr) + format_callback(client, bufnr) + ${optionalString (config.vim.ui.breadcrumbs.enable) '' + -- let navic attach to buffers + if client.server_capabilities.documentSymbolProvider then + navic.attach(client, bufnr) + end + ''} end - ''} - end - local capabilities = vim.lsp.protocol.make_client_capabilities() - ${optionalString usingNvimCmp "capabilities = require('cmp_nvim_lsp').default_capabilities()"} - ''; + local capabilities = vim.lsp.protocol.make_client_capabilities() + ${optionalString usingNvimCmp "capabilities = require('cmp_nvim_lsp').default_capabilities()"} + ''; + }; }; } diff --git a/modules/lsp/default.nix b/modules/lsp/default.nix index 9a70efc..f8408aa 100644 --- a/modules/lsp/default.nix +++ b/modules/lsp/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ # nvim lsp support ./config.nix diff --git a/modules/lsp/lightbulb/config.nix b/modules/lsp/lightbulb/config.nix index 3a13f68..ef2239f 100644 --- a/modules/lsp/lightbulb/config.nix +++ b/modules/lsp/lightbulb/config.nix @@ -3,20 +3,21 @@ lib, ... }: let - inherit (lib) mkIf nvim; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.lsp; in { config = mkIf (cfg.enable && cfg.lightbulb.enable) { - vim.startPlugins = ["nvim-lightbulb"]; + vim = { + startPlugins = ["nvim-lightbulb"]; - vim.configRC.lightbulb = nvim.dag.entryAnywhere '' - autocmd CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_lightbulb() - ''; + luaConfigRC.lightbulb = entryAnywhere '' + vim.api.nvim_command('autocmd CursorHold,CursorHoldI * lua require\'nvim-lightbulb\'.update_lightbulb()') - vim.luaConfigRC.lightbulb = nvim.dag.entryAnywhere '' - -- Enable trouble diagnostics viewer - require'nvim-lightbulb'.setup() - ''; + -- Enable trouble diagnostics viewer + require'nvim-lightbulb'.setup() + ''; + }; }; } diff --git a/modules/lsp/lightbulb/default.nix b/modules/lsp/lightbulb/default.nix index 883944a..3e6e8a3 100644 --- a/modules/lsp/lightbulb/default.nix +++ b/modules/lsp/lightbulb/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./lightbulb.nix ./config.nix diff --git a/modules/lsp/lightbulb/lightbulb.nix b/modules/lsp/lightbulb/lightbulb.nix index 44d0ce0..ef101a0 100644 --- a/modules/lsp/lightbulb/lightbulb.nix +++ b/modules/lsp/lightbulb/lightbulb.nix @@ -1,9 +1,5 @@ -{ - config, - lib, - ... -}: let - inherit (lib) mkEnableOption; +{lib, ...}: let + inherit (lib.options) mkEnableOption; in { options.vim.lsp = { lightbulb = { diff --git a/modules/lsp/lsp-signature/config.nix b/modules/lsp/lsp-signature/config.nix index 18ac5d1..5b231bd 100644 --- a/modules/lsp/lsp-signature/config.nix +++ b/modules/lsp/lsp-signature/config.nix @@ -3,25 +3,29 @@ lib, ... }: let - inherit (lib) mkIf nvim optionalString; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.strings) optionalString; cfg = config.vim.lsp; in { config = mkIf (cfg.enable && cfg.lspSignature.enable) { - vim.startPlugins = [ - "lsp-signature" - ]; + vim = { + startPlugins = [ + "lsp-signature" + ]; - vim.luaConfigRC.lsp-signature = nvim.dag.entryAnywhere '' - -- Enable lsp signature viewer - require("lsp_signature").setup({ - ${optionalString (config.vim.ui.borders.plugins.lsp-signature.enable) '' - bind = true, -- This is mandatory, otherwise border config won't get registered. - handler_opts = { - border = "${config.vim.ui.borders.plugins.lsp-signature.style}" - } - ''} - }) - ''; + luaConfigRC.lsp-signature = entryAnywhere '' + -- Enable lsp signature viewer + require("lsp_signature").setup({ + ${optionalString config.vim.ui.borders.plugins.lsp-signature.enable '' + bind = true, -- This is mandatory, otherwise border config won't get registered. + handler_opts = { + border = "${config.vim.ui.borders.plugins.lsp-signature.style}" + } + ''} + }) + ''; + }; }; } diff --git a/modules/lsp/lsp-signature/default.nix b/modules/lsp/lsp-signature/default.nix index 0449a9e..d88ec99 100644 --- a/modules/lsp/lsp-signature/default.nix +++ b/modules/lsp/lsp-signature/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./lsp-signature.nix ./config.nix diff --git a/modules/lsp/lsp-signature/lsp-signature.nix b/modules/lsp/lsp-signature/lsp-signature.nix index d05161e..981526b 100644 --- a/modules/lsp/lsp-signature/lsp-signature.nix +++ b/modules/lsp/lsp-signature/lsp-signature.nix @@ -1,13 +1,9 @@ -{ - config, - lib, - ... -}: let - inherit (lib) mkEnableOption; +{lib, ...}: let + inherit (lib.options) mkEnableOption; in { options.vim.lsp = { lspSignature = { - enable = mkEnableOption "lsp signature viewer"; + enable = mkEnableOption "lsp signature viewer [lsp-signature]"; }; }; } diff --git a/modules/lsp/lspconfig/config.nix b/modules/lsp/lspconfig/config.nix index 527bbed..1736ce9 100644 --- a/modules/lsp/lspconfig/config.nix +++ b/modules/lsp/lspconfig/config.nix @@ -1,32 +1,35 @@ { - pkgs, config, lib, ... }: let - inherit (lib) mkIf mkMerge nvim optionalString mapAttrs; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.strings) optionalString; + inherit (lib.attrsets) mapAttrs; + inherit (lib.nvim.dag) entryAfter; cfg = config.vim.lsp; in { config = mkIf cfg.lspconfig.enable (mkMerge [ { - vim.lsp.enable = true; + vim = { + lsp.enable = true; - vim.startPlugins = ["nvim-lspconfig"]; + startPlugins = ["nvim-lspconfig"]; - vim.luaConfigRC.lspconfig = nvim.dag.entryAfter ["lsp-setup"] '' - local lspconfig = require('lspconfig') + luaConfigRC.lspconfig = entryAfter ["lsp-setup"] '' + local lspconfig = require('lspconfig') - ${ - # TODO: make border style configurable - optionalString (config.vim.ui.borders.enable) '' - require('lspconfig.ui.windows').default_options.border = '${config.vim.ui.borders.globalStyle}' - '' - } - ''; + ${ + optionalString config.vim.ui.borders.enable '' + require('lspconfig.ui.windows').default_options.border = '${config.vim.ui.borders.globalStyle}' + '' + } + ''; + }; } { - vim.luaConfigRC = mapAttrs (_: v: (nvim.dag.entryAfter ["lspconfig"] v)) cfg.lspconfig.sources; + vim.luaConfigRC = mapAttrs (_: v: (entryAfter ["lspconfig"] v)) cfg.lspconfig.sources; } ]); } diff --git a/modules/lsp/lspconfig/default.nix b/modules/lsp/lspconfig/default.nix index 117e4d4..e6e6c18 100644 --- a/modules/lsp/lspconfig/default.nix +++ b/modules/lsp/lspconfig/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./lspconfig.nix diff --git a/modules/lsp/lspconfig/lspconfig.nix b/modules/lsp/lspconfig/lspconfig.nix index 7dd8ff0..2f7c7ac 100644 --- a/modules/lsp/lspconfig/lspconfig.nix +++ b/modules/lsp/lspconfig/lspconfig.nix @@ -1,17 +1,13 @@ -{ - pkgs, - config, - lib, - ... -}: let - inherit (lib) mkEnableOption mkOption types; +{lib, ...}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) attrsOf str; in { options.vim.lsp.lspconfig = { enable = mkEnableOption "nvim-lspconfig, also enabled automatically"; sources = mkOption { description = "nvim-lspconfig sources"; - type = with types; attrsOf str; + type = attrsOf str; default = {}; }; }; diff --git a/modules/lsp/lspkind/config.nix b/modules/lsp/lspkind/config.nix index 2c21c26..a98aeab 100644 --- a/modules/lsp/lspkind/config.nix +++ b/modules/lsp/lspkind/config.nix @@ -1,16 +1,16 @@ { - pkgs, config, lib, ... }: let - inherit (lib) mkIf nvim; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.lsp; in { config = mkIf (cfg.enable && cfg.lspkind.enable) { vim.startPlugins = ["lspkind"]; - vim.luaConfigRC.lspkind = nvim.dag.entryAnywhere '' + vim.luaConfigRC.lspkind = entryAnywhere '' local lspkind = require'lspkind' local lspkind_opts = { mode = '${cfg.lspkind.mode}' diff --git a/modules/lsp/lspkind/default.nix b/modules/lsp/lspkind/default.nix index 81f7418..fbfa506 100644 --- a/modules/lsp/lspkind/default.nix +++ b/modules/lsp/lspkind/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./lspkind.nix diff --git a/modules/lsp/lspkind/lspkind.nix b/modules/lsp/lspkind/lspkind.nix index 4856688..8ae9f39 100644 --- a/modules/lsp/lspkind/lspkind.nix +++ b/modules/lsp/lspkind/lspkind.nix @@ -1,12 +1,6 @@ -{ - pkgs, - config, - lib, - ... -}: let - inherit (lib) mkEnableOption mkOption types; - - cfg = config.vim.lsp; +{lib, ...}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) enum; in { options.vim.lsp = { lspkind = { @@ -14,7 +8,7 @@ in { mode = mkOption { description = "Defines how annotations are shown"; - type = with types; enum ["text" "text_symbol" "symbol_text" "symbol"]; + type = enum ["text" "text_symbol" "symbol_text" "symbol"]; default = "symbol_text"; }; }; diff --git a/modules/lsp/lsplines/config.nix b/modules/lsp/lsplines/config.nix index 66eb5ff..3436f64 100644 --- a/modules/lsp/lsplines/config.nix +++ b/modules/lsp/lsplines/config.nix @@ -3,13 +3,14 @@ lib, ... }: let - inherit (lib) mkIf nvim; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAfter; cfg = config.vim.lsp; in { config = mkIf (cfg.enable && cfg.lsplines.enable) { vim.startPlugins = ["lsp-lines"]; - vim.luaConfigRC.lsplines = nvim.dag.entryAfter ["lspconfig"] '' + vim.luaConfigRC.lsplines = entryAfter ["lspconfig"] '' require("lsp_lines").setup() vim.diagnostic.config({ diff --git a/modules/lsp/lsplines/default.nix b/modules/lsp/lsplines/default.nix index fa50897..359cec4 100644 --- a/modules/lsp/lsplines/default.nix +++ b/modules/lsp/lsplines/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./lsplines.nix diff --git a/modules/lsp/lsplines/lsplines.nix b/modules/lsp/lsplines/lsplines.nix index 9b5f6a6..aac4cbb 100644 --- a/modules/lsp/lsplines/lsplines.nix +++ b/modules/lsp/lsplines/lsplines.nix @@ -1,9 +1,11 @@ {lib, ...}: let - inherit (lib) mkEnableOption; + inherit (lib.options) mkEnableOption; in { options.vim.lsp = { lsplines = { - enable = mkEnableOption "diagnostics using virtual lines on top of the real line of code. [lsp_lines]"; + enable = mkEnableOption '' + diagnostics using virtual lines on top of the real line of code. [lsp_lines] + ''; }; }; } diff --git a/modules/lsp/lspsaga/config.nix b/modules/lsp/lspsaga/config.nix index 722bdde..ffacf12 100644 --- a/modules/lsp/lspsaga/config.nix +++ b/modules/lsp/lspsaga/config.nix @@ -3,7 +3,10 @@ lib, ... }: let - inherit (lib) addDescriptionsToMappings mkIf mkSetLuaBinding mkMerge nvim optionalString; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.strings) optionalString; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding; cfg = config.vim.lsp; self = import ./lspsaga.nix {inherit lib;}; @@ -12,38 +15,39 @@ mappings = addDescriptionsToMappings cfg.lspsaga.mappings mappingDefinitions; in { config = mkIf (cfg.enable && cfg.lspsaga.enable) { - vim.startPlugins = ["lspsaga"]; + vim = { + startPlugins = ["lspsaga"]; - vim.maps.visual = mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').range_code_action"; + maps = { + visual = mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').range_code_action"; + normal = mkMerge [ + (mkSetLuaBinding mappings.lspFinder "require('lspsaga.provider').lsp_finder") + (mkSetLuaBinding mappings.renderHoveredDoc "require('lspsaga.hover').render_hover_doc") - vim.maps.normal = mkMerge [ - (mkSetLuaBinding mappings.lspFinder "require('lspsaga.provider').lsp_finder") - (mkSetLuaBinding mappings.renderHoveredDoc "require('lspsaga.hover').render_hover_doc") + (mkSetLuaBinding mappings.smartScrollUp "function() require('lspsaga.action').smart_scroll_with_saga(-1) end") + (mkSetLuaBinding mappings.smartScrollDown "function() require('lspsaga.action').smart_scroll_with_saga(1) end") - (mkSetLuaBinding mappings.smartScrollUp "function() require('lspsaga.action').smart_scroll_with_saga(-1) end") - (mkSetLuaBinding mappings.smartScrollDown "function() require('lspsaga.action').smart_scroll_with_saga(1) end") + (mkSetLuaBinding mappings.rename "require('lspsaga.rename').rename") + (mkSetLuaBinding mappings.previewDefinition "require('lspsaga.provider').preview_definition") - (mkSetLuaBinding mappings.rename "require('lspsaga.rename').rename") - (mkSetLuaBinding mappings.previewDefinition "require('lspsaga.provider').preview_definition") + (mkSetLuaBinding mappings.showLineDiagnostics "require('lspsaga.diagnostic').show_line_diagnostics") + (mkSetLuaBinding mappings.showCursorDiagnostics "require('lspsaga.diagnostic').show_cursor_diagnostics") - (mkSetLuaBinding mappings.showLineDiagnostics "require('lspsaga.diagnostic').show_line_diagnostics") - (mkSetLuaBinding mappings.showCursorDiagnostics "require('lspsaga.diagnostic').show_cursor_diagnostics") + (mkSetLuaBinding mappings.nextDiagnostic "require('lspsaga.diagnostic').navigate('next')") + (mkSetLuaBinding mappings.previousDiagnostic "require('lspsaga.diagnostic').navigate('prev')") - (mkSetLuaBinding mappings.nextDiagnostic "require('lspsaga.diagnostic').navigate('next')") - (mkSetLuaBinding mappings.previousDiagnostic "require('lspsaga.diagnostic').navigate('prev')") + (mkIf (!cfg.nvimCodeActionMenu.enable) (mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').code_action")) + (mkIf (!cfg.lspSignature.enable) (mkSetLuaBinding mappings.signatureHelp "require('lspsaga.signaturehelp').signature_help")) + ]; + }; - (mkIf (!cfg.nvimCodeActionMenu.enable) (mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').code_action")) - (mkIf (!cfg.lspSignature.enable) (mkSetLuaBinding mappings.signatureHelp "require('lspsaga.signaturehelp').signature_help")) - ]; - - vim.luaConfigRC.lspsage = nvim.dag.entryAnywhere '' - -- Enable lspsaga - local saga = require 'lspsaga' - saga.init_lsp_saga({ - ${optionalString (config.vim.ui.borders.plugins.lspsaga.enable) '' - border_style = '${config.vim.ui.borders.plugins.lspsaga.style}', - ''} - }) - ''; + luaConfigRC.lspsaga = entryAnywhere '' + require('lspsaga').init_lsp_saga({ + ${optionalString config.vim.ui.borders.plugins.lspsaga.enable '' + border_style = '${config.vim.ui.borders.plugins.lspsaga.style}', + ''} + }) + ''; + }; }; } diff --git a/modules/lsp/lspsaga/default.nix b/modules/lsp/lspsaga/default.nix index 29cf580..82c2ed7 100644 --- a/modules/lsp/lspsaga/default.nix +++ b/modules/lsp/lspsaga/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./lspsaga.nix ./config.nix diff --git a/modules/lsp/lspsaga/lspsaga.nix b/modules/lsp/lspsaga/lspsaga.nix index 35e1ecc..f308aaa 100644 --- a/modules/lsp/lspsaga/lspsaga.nix +++ b/modules/lsp/lspsaga/lspsaga.nix @@ -1,5 +1,6 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkMappingOption; + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.binds) mkMappingOption; in { options.vim.lsp.lspsaga = { enable = mkEnableOption "LSP Saga"; diff --git a/modules/lsp/module.nix b/modules/lsp/module.nix index 1a56240..b16f9c1 100644 --- a/modules/lsp/module.nix +++ b/modules/lsp/module.nix @@ -1,5 +1,6 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkMappingOption; + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.binds) mkMappingOption; in { options.vim.lsp = { enable = mkEnableOption "LSP, also enabled automatically through null-ls and lspconfig options"; diff --git a/modules/lsp/null-ls/config.nix b/modules/lsp/null-ls/config.nix index 23a6818..f161fb9 100644 --- a/modules/lsp/null-ls/config.nix +++ b/modules/lsp/null-ls/config.nix @@ -1,5 +1,4 @@ { - pkgs, config, lib, ... @@ -10,25 +9,28 @@ in { config = mkIf cfg.null-ls.enable (mkMerge [ { - vim.lsp.enable = true; - vim.startPlugins = ["none-ls"]; + vim = { + lsp.enable = true; + startPlugins = ["none-ls"]; - vim.luaConfigRC.null_ls-setup = nvim.dag.entryAnywhere '' - local null_ls = require("null-ls") - local null_helpers = require("null-ls.helpers") - local null_methods = require("null-ls.methods") - local ls_sources = {} - ''; - vim.luaConfigRC.null_ls = nvim.dag.entryAfter ["null_ls-setup" "lsp-setup"] '' - require('null-ls').setup({ - debug = false, - diagnostics_format = "[#{m}] #{s} (#{c})", - debounce = 250, - default_timeout = 5000, - sources = ls_sources, - on_attach=default_on_attach - }) - ''; + luaConfigRC.null_ls-setup = nvim.dag.entryAnywhere '' + local null_ls = require("null-ls") + local null_helpers = require("null-ls.helpers") + local null_methods = require("null-ls.methods") + local ls_sources = {} + ''; + + luaConfigRC.null_ls = nvim.dag.entryAfter ["null_ls-setup" "lsp-setup"] '' + require('null-ls').setup({ + debug = false, + diagnostics_format = "[#{m}] #{s} (#{c})", + debounce = 250, + default_timeout = 5000, + sources = ls_sources, + on_attach = default_on_attach + }) + ''; + }; } { vim.luaConfigRC = mapAttrs (_: v: (nvim.dag.entryBetween ["null_ls"] ["null_ls-setup"] v)) cfg.null-ls.sources; diff --git a/modules/lsp/null-ls/default.nix b/modules/lsp/null-ls/default.nix index 01e6e59..d104e68 100644 --- a/modules/lsp/null-ls/default.nix +++ b/modules/lsp/null-ls/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./null-ls.nix diff --git a/modules/lsp/null-ls/null-ls.nix b/modules/lsp/null-ls/null-ls.nix index 3ffb0ca..8c63df2 100644 --- a/modules/lsp/null-ls/null-ls.nix +++ b/modules/lsp/null-ls/null-ls.nix @@ -1,19 +1,13 @@ -{ - pkgs, - config, - lib, - ... -}: let - inherit (lib) mkEnableOption mkOption types; - - cfg = config.vim.lsp; +{lib, ...}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) attrsOf str; in { options.vim.lsp.null-ls = { enable = mkEnableOption "null-ls, also enabled automatically"; sources = mkOption { description = "null-ls sources"; - type = with types; attrsOf str; + type = attrsOf str; default = {}; }; }; diff --git a/modules/lsp/nvim-code-action-menu/config.nix b/modules/lsp/nvim-code-action-menu/config.nix index 9f8f604..e55fb4a 100644 --- a/modules/lsp/nvim-code-action-menu/config.nix +++ b/modules/lsp/nvim-code-action-menu/config.nix @@ -3,32 +3,35 @@ lib, ... }: let - inherit (lib) addDescriptionsToMappings mkIf mkSetBinding nvim pushDownDefault; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.binds) mkSetBinding addDescriptionsToMappings pushDownDefault; cfg = config.vim.lsp; self = import ./nvim-code-action-menu.nix {inherit lib;}; - mappingDefinitions = self.options.vim.lsp.nvimCodeActionMenu.mappings; mappings = addDescriptionsToMappings cfg.nvimCodeActionMenu.mappings mappingDefinitions; in { config = mkIf (cfg.enable && cfg.nvimCodeActionMenu.enable) { - vim.startPlugins = ["nvim-code-action-menu"]; + vim = { + startPlugins = ["nvim-code-action-menu"]; - vim.maps.normal = mkSetBinding mappings.open ":CodeActionMenu"; + maps.normal = mkSetBinding mappings.open ":CodeActionMenu"; - vim.binds.whichKey.register = pushDownDefault { - "c" = "+CodeAction"; + binds.whichKey.register = pushDownDefault { + "c" = "+CodeAction"; + }; + + luaConfigRC.code-action-menu = entryAnywhere '' + -- border configuration + vim.g.code_action_menu_window_border = '${config.vim.ui.borders.plugins.code-action-menu.style}' + + -- show individual sections of the code action menu + ${lib.optionalString cfg.nvimCodeActionMenu.show.details "vim.g.code_action_menu_show_details = true"} + ${lib.optionalString cfg.nvimCodeActionMenu.show.diff "vim.g.code_action_menu_show_diff = true"} + ${lib.optionalString cfg.nvimCodeActionMenu.show.actionKind "vim.g.code_action_menu_show_action_kind = true"} + ''; }; - - vim.luaConfigRC.code-action-menu = nvim.dag.entryAnywhere '' - -- border configuration - vim.g.code_action_menu_window_border = '${config.vim.ui.borders.plugins.code-action-menu.style}' - - -- show individual sections of the code action menu - ${lib.optionalString (cfg.nvimCodeActionMenu.show.details) "vim.g.code_action_menu_show_details = true"} - ${lib.optionalString (cfg.nvimCodeActionMenu.show.diff) "vim.g.code_action_menu_show_diff = true"} - ${lib.optionalString (cfg.nvimCodeActionMenu.show.actionKind) "vim.g.code_action_menu_show_action_kind = true"} - ''; }; } diff --git a/modules/lsp/nvim-code-action-menu/default.nix b/modules/lsp/nvim-code-action-menu/default.nix index 665cf92..f94dd22 100644 --- a/modules/lsp/nvim-code-action-menu/default.nix +++ b/modules/lsp/nvim-code-action-menu/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./nvim-code-action-menu.nix ./config.nix diff --git a/modules/lsp/nvim-code-action-menu/nvim-code-action-menu.nix b/modules/lsp/nvim-code-action-menu/nvim-code-action-menu.nix index c04beda..c303f7c 100644 --- a/modules/lsp/nvim-code-action-menu/nvim-code-action-menu.nix +++ b/modules/lsp/nvim-code-action-menu/nvim-code-action-menu.nix @@ -1,5 +1,6 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkMappingOption; + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.binds) mkMappingOption; in { options.vim.lsp = { nvimCodeActionMenu = { diff --git a/modules/lsp/nvim-docs-view/config.nix b/modules/lsp/nvim-docs-view/config.nix index d7dc837..008eee8 100644 --- a/modules/lsp/nvim-docs-view/config.nix +++ b/modules/lsp/nvim-docs-view/config.nix @@ -3,8 +3,10 @@ lib, ... }: let - inherit (lib) mkIf nvim addDescriptionsToMappings mkSetBinding mkMerge; inherit (builtins) toString; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding; cfg = config.vim.lsp.nvim-docs-view; self = import ./nvim-docs-view.nix {inherit lib;}; @@ -17,7 +19,7 @@ in { lsp.enable = true; startPlugins = ["nvim-docs-view"]; - luaConfigRC.nvim-docs-view = nvim.dag.entryAnywhere '' + luaConfigRC.nvim-docs-view = entryAnywhere '' require("docs-view").setup { position = "${cfg.position}", width = ${toString cfg.width}, diff --git a/modules/lsp/nvim-docs-view/default.nix b/modules/lsp/nvim-docs-view/default.nix index 499ec39..48716d0 100644 --- a/modules/lsp/nvim-docs-view/default.nix +++ b/modules/lsp/nvim-docs-view/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./nvim-docs-view.nix diff --git a/modules/lsp/nvim-docs-view/nvim-docs-view.nix b/modules/lsp/nvim-docs-view/nvim-docs-view.nix index 808613e..6b59a27 100644 --- a/modules/lsp/nvim-docs-view/nvim-docs-view.nix +++ b/modules/lsp/nvim-docs-view/nvim-docs-view.nix @@ -1,11 +1,13 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkOption types mkMappingOption; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) enum int; + inherit (lib.nvim.binds) mkMappingOption; in { options.vim.lsp.nvim-docs-view = { enable = mkEnableOption "nvim-docs-view, for displaying lsp hover documentation in a side panel."; position = mkOption { - type = types.enum ["left" "right" "top" "bottom"]; + type = enum ["left" "right" "top" "bottom"]; default = "right"; description = '' Where to open the docs view panel @@ -13,7 +15,7 @@ in { }; height = mkOption { - type = types.int; + type = int; default = 10; description = '' Height of the docs view panel if the position is set to either top or bottom @@ -21,7 +23,7 @@ in { }; width = mkOption { - type = types.int; + type = int; default = 60; description = '' Width of the docs view panel if the position is set to either left or right @@ -29,12 +31,14 @@ in { }; updateMode = mkOption { - type = types.enum ["auto" "manual"]; + type = enum ["auto" "manual"]; default = "auto"; description = '' - Determines the mechanism used to update the docs view panel content. - - If auto, the content will update upon cursor move. - - If manual, the content will only update once :DocsViewUpdate is called + Determines the mechanism used to update the docs view panel content + + Possible values: + - auto: the content will update upon cursor move. + - manual: the content will only update once :DocsViewUpdate is called ''; }; diff --git a/modules/lsp/trouble/config.nix b/modules/lsp/trouble/config.nix index bb751c7..72fc1ec 100644 --- a/modules/lsp/trouble/config.nix +++ b/modules/lsp/trouble/config.nix @@ -3,36 +3,39 @@ lib, ... }: let - inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim pushDownDefault; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding pushDownDefault; cfg = config.vim.lsp; self = import ./trouble.nix {inherit lib;}; - mappingDefinitions = self.options.vim.lsp.trouble.mappings; mappings = addDescriptionsToMappings cfg.trouble.mappings mappingDefinitions; in { config = mkIf (cfg.enable && cfg.trouble.enable) { - vim.startPlugins = ["trouble"]; + vim = { + startPlugins = ["trouble"]; - vim.maps.normal = mkMerge [ - (mkSetBinding mappings.toggle "TroubleToggle") - (mkSetBinding mappings.workspaceDiagnostics "TroubleToggle workspace_diagnostics") - (mkSetBinding mappings.documentDiagnostics "TroubleToggle document_diagnostics") - (mkSetBinding mappings.lspReferences "TroubleToggle lsp_references") - (mkSetBinding mappings.quickfix "TroubleToggle quickfix") - (mkSetBinding mappings.locList "TroubleToggle loclist") - ]; + maps.normal = mkMerge [ + (mkSetBinding mappings.toggle "TroubleToggle") + (mkSetBinding mappings.workspaceDiagnostics "TroubleToggle workspace_diagnostics") + (mkSetBinding mappings.documentDiagnostics "TroubleToggle document_diagnostics") + (mkSetBinding mappings.lspReferences "TroubleToggle lsp_references") + (mkSetBinding mappings.quickfix "TroubleToggle quickfix") + (mkSetBinding mappings.locList "TroubleToggle loclist") + ]; - vim.binds.whichKey.register = pushDownDefault { - "l" = "Trouble"; - "x" = "+Trouble"; - "lw" = "Workspace"; + binds.whichKey.register = pushDownDefault { + "l" = "Trouble"; + "x" = "+Trouble"; + "lw" = "Workspace"; + }; + + luaConfigRC.trouble = entryAnywhere '' + -- Enable trouble diagnostics viewer + require("trouble").setup {} + ''; }; - - vim.luaConfigRC.trouble = nvim.dag.entryAnywhere '' - -- Enable trouble diagnostics viewer - require("trouble").setup {} - ''; }; } diff --git a/modules/lsp/trouble/default.nix b/modules/lsp/trouble/default.nix index 3a5d2cb..77e9337 100644 --- a/modules/lsp/trouble/default.nix +++ b/modules/lsp/trouble/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./trouble.nix ./config.nix diff --git a/modules/lsp/trouble/trouble.nix b/modules/lsp/trouble/trouble.nix index b8aa0de..bd16c67 100644 --- a/modules/lsp/trouble/trouble.nix +++ b/modules/lsp/trouble/trouble.nix @@ -1,5 +1,6 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkMappingOption; + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.binds) mkMappingOption; in { options.vim.lsp = { trouble = { From f6db808bfc386ada043813f00049c10d5d3351d8 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 12 Mar 2024 03:46:46 +0300 Subject: [PATCH 035/193] modules/minimap: switch to explicit lib calls --- modules/minimap/codewindow/codewindow.nix | 3 +- modules/minimap/codewindow/config.nix | 42 +++++++++++---------- modules/minimap/codewindow/default.nix | 2 +- modules/minimap/default.nix | 2 +- modules/minimap/minimap-vim/config.nix | 5 ++- modules/minimap/minimap-vim/default.nix | 2 +- modules/minimap/minimap-vim/minimap-vim.nix | 10 ++--- 7 files changed, 34 insertions(+), 32 deletions(-) diff --git a/modules/minimap/codewindow/codewindow.nix b/modules/minimap/codewindow/codewindow.nix index 551dd8e..381e310 100644 --- a/modules/minimap/codewindow/codewindow.nix +++ b/modules/minimap/codewindow/codewindow.nix @@ -1,5 +1,6 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkMappingOption; + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.binds) mkMappingOption; in { options.vim.minimap.codewindow = { enable = mkEnableOption "codewindow plugin for minimap view"; diff --git a/modules/minimap/codewindow/config.nix b/modules/minimap/codewindow/config.nix index b95aca8..11c38c9 100644 --- a/modules/minimap/codewindow/config.nix +++ b/modules/minimap/codewindow/config.nix @@ -3,7 +3,9 @@ lib, ... }: let - inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetLuaBinding nvim pushDownDefault; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding pushDownDefault; cfg = config.vim.minimap.codewindow; @@ -13,26 +15,28 @@ mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; in { config = mkIf cfg.enable { - vim.startPlugins = [ - "codewindow-nvim" - ]; + vim = { + startPlugins = [ + "codewindow-nvim" + ]; - vim.maps.normal = mkMerge [ - (mkSetLuaBinding mappings.open "require('codewindow').open_minimap") - (mkSetLuaBinding mappings.close "require('codewindow').close_minimap") - (mkSetLuaBinding mappings.toggle "require('codewindow').toggle_minimap") - (mkSetLuaBinding mappings.toggleFocus "require('codewindow').toggle_focus") - ]; + maps.normal = mkMerge [ + (mkSetLuaBinding mappings.open "require('codewindow').open_minimap") + (mkSetLuaBinding mappings.close "require('codewindow').close_minimap") + (mkSetLuaBinding mappings.toggle "require('codewindow').toggle_minimap") + (mkSetLuaBinding mappings.toggleFocus "require('codewindow').toggle_focus") + ]; - vim.binds.whichKey.register = pushDownDefault { - "m" = "+Minimap"; + binds.whichKey.register = pushDownDefault { + "m" = "+Minimap"; + }; + + luaConfigRC.codewindow = entryAnywhere '' + local codewindow = require('codewindow') + codewindow.setup({ + exclude_filetypes = { 'NvimTree', 'orgagenda', 'Alpha'}, + }) + ''; }; - - vim.luaConfigRC.codewindow = nvim.dag.entryAnywhere '' - local codewindow = require('codewindow') - codewindow.setup({ - exclude_filetypes = { 'NvimTree', 'orgagenda', 'Alpha'}, - }) - ''; }; } diff --git a/modules/minimap/codewindow/default.nix b/modules/minimap/codewindow/default.nix index f3f8a9a..0ce3ad2 100644 --- a/modules/minimap/codewindow/default.nix +++ b/modules/minimap/codewindow/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./codewindow.nix ./config.nix diff --git a/modules/minimap/default.nix b/modules/minimap/default.nix index 6a03b01..7612ac1 100644 --- a/modules/minimap/default.nix +++ b/modules/minimap/default.nix @@ -1,4 +1,4 @@ -{...}: { +{ imports = [ ./minimap-vim ./codewindow diff --git a/modules/minimap/minimap-vim/config.nix b/modules/minimap/minimap-vim/config.nix index 6577e8c..5276a42 100644 --- a/modules/minimap/minimap-vim/config.nix +++ b/modules/minimap/minimap-vim/config.nix @@ -1,10 +1,11 @@ { - pkgs, config, + pkgs, lib, ... }: let - inherit (lib) mkIf pushDownDefault; + inherit (lib.modules) mkIf; + inherit (lib.nvim.binds) pushDownDefault; cfg = config.vim.minimap.minimap-vim; in { diff --git a/modules/minimap/minimap-vim/default.nix b/modules/minimap/minimap-vim/default.nix index 889184e..bf3aa55 100644 --- a/modules/minimap/minimap-vim/default.nix +++ b/modules/minimap/minimap-vim/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./minimap-vim.nix ./config.nix diff --git a/modules/minimap/minimap-vim/minimap-vim.nix b/modules/minimap/minimap-vim/minimap-vim.nix index 12f7f42..e8f9270 100644 --- a/modules/minimap/minimap-vim/minimap-vim.nix +++ b/modules/minimap/minimap-vim/minimap-vim.nix @@ -1,11 +1,7 @@ -{ - config, - lib, - ... -}: let - inherit (lib) mkEnableOption; +{lib, ...}: let + inherit (lib.options) mkEnableOption; in { options.vim.minimap.minimap-vim = { - enable = mkEnableOption "minimap-vim plugin for minimap view"; + enable = mkEnableOption "minimap view [minimap-vim]"; }; } From 2101ac906131c2be772c9e57f5a9b58c459061b0 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 12 Mar 2024 03:47:01 +0300 Subject: [PATCH 036/193] modules/notes: switch to explicit lib calls --- modules/notes/default.nix | 2 +- modules/notes/mind-nvim/config.nix | 38 +++++----- modules/notes/mind-nvim/default.nix | 2 +- modules/notes/mind-nvim/mind-nvim.nix | 10 +-- modules/notes/obsidian/config.nix | 70 +++++++++--------- modules/notes/obsidian/default.nix | 2 +- modules/notes/obsidian/obsidian.nix | 18 ++--- modules/notes/orgmode/config.nix | 62 ++++++++-------- modules/notes/orgmode/default.nix | 2 +- modules/notes/orgmode/orgmode.nix | 11 +-- modules/notes/todo-comments/config.nix | 71 ++++++++++--------- modules/notes/todo-comments/default.nix | 2 +- modules/notes/todo-comments/todo-comments.nix | 8 ++- 13 files changed, 154 insertions(+), 144 deletions(-) diff --git a/modules/notes/default.nix b/modules/notes/default.nix index eaf247f..88a7092 100644 --- a/modules/notes/default.nix +++ b/modules/notes/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./obsidian ./orgmode diff --git a/modules/notes/mind-nvim/config.nix b/modules/notes/mind-nvim/config.nix index 8a609b0..7f7ea9d 100644 --- a/modules/notes/mind-nvim/config.nix +++ b/modules/notes/mind-nvim/config.nix @@ -3,27 +3,31 @@ lib, ... }: let - inherit (lib) mkIf nvim pushDownDefault; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.binds) pushDownDefault; cfg = config.vim.notes.mind-nvim; in { - config = mkIf (cfg.enable) { - vim.startPlugins = [ - "mind-nvim" - ]; + config = mkIf cfg.enable { + vim = { + startPlugins = [ + "mind-nvim" + ]; - vim.maps.normal = { - "om" = {action = ":MindOpenMain";}; - "op" = {action = ":MindOpenProject";}; - "oc" = {action = ":MindClose";}; + maps.normal = { + "om" = {action = ":MindOpenMain";}; + "op" = {action = ":MindOpenProject";}; + "oc" = {action = ":MindClose";}; + }; + + binds.whichKey.register = pushDownDefault { + "o" = "+Notes"; + }; + + luaConfigRC.mind-nvim = entryAnywhere '' + require'mind'.setup() + ''; }; - - vim.binds.whichKey.register = pushDownDefault { - "o" = "+Notes"; - }; - - vim.luaConfigRC.mind-nvim = nvim.dag.entryAnywhere '' - require'mind'.setup() - ''; }; } diff --git a/modules/notes/mind-nvim/default.nix b/modules/notes/mind-nvim/default.nix index e136b9d..be25fff 100644 --- a/modules/notes/mind-nvim/default.nix +++ b/modules/notes/mind-nvim/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./mind-nvim.nix ./config.nix diff --git a/modules/notes/mind-nvim/mind-nvim.nix b/modules/notes/mind-nvim/mind-nvim.nix index f0d43ea..ad1a395 100644 --- a/modules/notes/mind-nvim/mind-nvim.nix +++ b/modules/notes/mind-nvim/mind-nvim.nix @@ -1,11 +1,7 @@ -{ - config, - lib, - ... -}: let - inherit (lib) mkEnableOption; +{lib, ...}: let + inherit (lib.options) mkEnableOption; in { options.vim.notes.mind-nvim = { - enable = mkEnableOption "organizer tool for Neovim."; + enable = mkEnableOption "note organizer tool for Neovim [mind-nvim]"; }; } diff --git a/modules/notes/obsidian/config.nix b/modules/notes/obsidian/config.nix index f521c62..818d447 100644 --- a/modules/notes/obsidian/config.nix +++ b/modules/notes/obsidian/config.nix @@ -3,45 +3,49 @@ lib, ... }: let - inherit (lib) mkIf nvim pushDownDefault; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.binds) pushDownDefault; cfg = config.vim.notes.obsidian; auto = config.vim.autocomplete; in { - config = mkIf (cfg.enable) { - vim.startPlugins = [ - "obsidian-nvim" - "vim-markdown" - "tabular" - ]; + config = mkIf cfg.enable { + vim = { + startPlugins = [ + "obsidian-nvim" + "vim-markdown" + "tabular" + ]; - vim.binds.whichKey.register = pushDownDefault { - "o" = "+Notes"; - }; + binds.whichKey.register = pushDownDefault { + "o" = "+Notes"; + }; - vim.luaConfigRC.obsidian = nvim.dag.entryAnywhere '' - require("obsidian").setup({ - dir = "${cfg.dir}", - completion = { - nvim_cmp = ${ - if (auto.type == "nvim-cmp") - then "true" - else "false" - } - }, - daily_notes = { - folder = ${ - if (cfg.daily-notes.folder == "") - then "nil," - else "'${cfg.daily-notes.folder}'," - } - date_format = ${ - if (cfg.daily-notes.date-format == "") - then "nil," - else "'${cfg.daily-notes.date-format}'," - } + luaConfigRC.obsidian = entryAnywhere '' + require("obsidian").setup({ + dir = "${cfg.dir}", + completion = { + nvim_cmp = ${ + if (auto.type == "nvim-cmp") + then "true" + else "false" } - }) - ''; + }, + daily_notes = { + folder = ${ + if (cfg.daily-notes.folder == "") + then "nil," + else "'${cfg.daily-notes.folder}'," + } + date_format = ${ + if (cfg.daily-notes.date-format == "") + then "nil," + else "'${cfg.daily-notes.date-format}'," + } + } + }) + ''; + }; }; } diff --git a/modules/notes/obsidian/default.nix b/modules/notes/obsidian/default.nix index d73bfc2..db8c675 100644 --- a/modules/notes/obsidian/default.nix +++ b/modules/notes/obsidian/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./obsidian.nix ./config.nix diff --git a/modules/notes/obsidian/obsidian.nix b/modules/notes/obsidian/obsidian.nix index cfc0eda..1b7bae6 100644 --- a/modules/notes/obsidian/obsidian.nix +++ b/modules/notes/obsidian/obsidian.nix @@ -1,27 +1,24 @@ -{ - config, - lib, - ... -}: let - inherit (lib) mkEnableOption mkOption types; +{lib, ...}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) str bool; in { options.vim.notes = { obsidian = { enable = mkEnableOption "complementary neovim plugins for Obsidian editor"; dir = mkOption { - type = types.str; + type = str; default = "~/my-vault"; description = "Obsidian vault directory"; }; daily-notes = { folder = mkOption { - type = types.str; + type = str; default = ""; description = "Directory in which daily notes should be created"; }; date-format = mkOption { - type = types.str; + type = str; default = ""; description = "Date format used for creating daily notes"; }; @@ -29,8 +26,7 @@ in { completion = { nvim_cmp = mkOption { - # if using nvim-cmp, otherwise set to false - type = types.bool; + type = bool; description = "If using nvim-cmp, otherwise set to false"; }; }; diff --git a/modules/notes/orgmode/config.nix b/modules/notes/orgmode/config.nix index 08df2de..635f0f1 100644 --- a/modules/notes/orgmode/config.nix +++ b/modules/notes/orgmode/config.nix @@ -3,42 +3,46 @@ lib, ... }: let - inherit (lib) mkIf mkMerge nvim pushDownDefault; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.binds) pushDownDefault; cfg = config.vim.notes.orgmode; in { config = mkIf cfg.enable (mkMerge [ { - vim.startPlugins = [ - "orgmode-nvim" - ]; + vim = { + startPlugins = [ + "orgmode-nvim" + ]; - vim.binds.whichKey.register = pushDownDefault { - "o" = "+Notes"; + binds.whichKey.register = pushDownDefault { + "o" = "+Notes"; + }; + + luaConfigRC.orgmode = entryAnywhere '' + -- Load custom treesitter grammar for org filetype + require('orgmode').setup_ts_grammar() + + -- Treesitter configuration + require('nvim-treesitter.configs').setup { + + -- If TS highlights are not enabled at all, or disabled via `disable` prop, + -- highlighting will fallback to default Vim syntax highlighting + highlight = { + enable = true, + -- Required for spellcheck, some LaTex highlights and + -- code block highlights that do not have ts grammar + additional_vim_regex_highlighting = {'org'}, + }, + } + + require('orgmode').setup({ + org_agenda_files = ${cfg.orgAgendaFiles}, + org_default_notes_file = '${cfg.orgDefaultNotesFile}', + }) + ''; }; - - vim.luaConfigRC.orgmode = nvim.dag.entryAnywhere '' - -- Load custom treesitter grammar for org filetype - require('orgmode').setup_ts_grammar() - - -- Treesitter configuration - require('nvim-treesitter.configs').setup { - - -- If TS highlights are not enabled at all, or disabled via `disable` prop, - -- highlighting will fallback to default Vim syntax highlighting - highlight = { - enable = true, - -- Required for spellcheck, some LaTex highlights and - -- code block highlights that do not have ts grammar - additional_vim_regex_highlighting = {'org'}, - }, - } - - require('orgmode').setup({ - org_agenda_files = ${cfg.orgAgendaFiles}, - org_default_notes_file = '${cfg.orgDefaultNotesFile}', - }) - ''; } (mkIf cfg.treesitter.enable { diff --git a/modules/notes/orgmode/default.nix b/modules/notes/orgmode/default.nix index 299c754..c4f5a1a 100644 --- a/modules/notes/orgmode/default.nix +++ b/modules/notes/orgmode/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./orgmode.nix ./config.nix diff --git a/modules/notes/orgmode/orgmode.nix b/modules/notes/orgmode/orgmode.nix index d7fce12..2a06605 100644 --- a/modules/notes/orgmode/orgmode.nix +++ b/modules/notes/orgmode/orgmode.nix @@ -4,27 +4,28 @@ pkgs, ... }: let - inherit (lib) mkEnableOption types mkOption nvim; + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) str; + inherit (lib.nvim.types) mkGrammarOption; in { options.vim.notes.orgmode = { enable = mkEnableOption "nvim-orgmode: Neovim plugin for Emac Orgmode. Get the best of both worlds"; orgAgendaFiles = mkOption { - type = types.str; + type = str; default = "{'~/Documents/org/*', '~/my-orgs/**/*'}"; description = "List of org files to be used as agenda files."; }; orgDefaultNotesFile = mkOption { - type = types.str; + type = str; default = "~/Documents/org/refile.org"; description = "Default org file to be used for notes."; }; treesitter = { enable = mkEnableOption "Orgmode treesitter" // {default = config.vim.languages.enableTreesitter;}; - - orgPackage = nvim.types.mkGrammarOption pkgs "org"; + orgPackage = mkGrammarOption pkgs "org"; }; }; } diff --git a/modules/notes/todo-comments/config.nix b/modules/notes/todo-comments/config.nix index f1ced60..8db653f 100644 --- a/modules/notes/todo-comments/config.nix +++ b/modules/notes/todo-comments/config.nix @@ -4,46 +4,49 @@ lib, ... }: let - inherit (lib) mkMerge mkBinding mkIf; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.binds) mkBinding; cfg = config.vim.notes.todo-comments; self = import ./todo-comments.nix {inherit lib;}; - mappings = self.options.vim.notes.todo-comments.mappings; + inherit (self.options.vim.notes.todo-comments) mappings; in { - config = mkIf (cfg.enable) { - vim.startPlugins = [ - "todo-comments" - ]; + config = mkIf cfg.enable { + vim = { + startPlugins = [ + "todo-comments" + ]; - vim.maps.normal = mkMerge [ - (mkBinding cfg.mappings.quickFix ":TodoQuickFix" mappings.quickFix.description) - (mkIf config.vim.telescope.enable (mkBinding cfg.mappings.telescope ":TodoTelescope" mappings.telescope.description)) - (mkIf config.vim.lsp.trouble.enable (mkBinding cfg.mappings.trouble ":TodoTrouble" mappings.trouble.description)) - ]; + maps.normal = mkMerge [ + (mkBinding cfg.mappings.quickFix ":TodoQuickFix" mappings.quickFix.description) + (mkIf config.vim.telescope.enable (mkBinding cfg.mappings.telescope ":TodoTelescope" mappings.telescope.description)) + (mkIf config.vim.lsp.trouble.enable (mkBinding cfg.mappings.trouble ":TodoTrouble" mappings.trouble.description)) + ]; - vim.luaConfigRC.todo-comments = '' - require('todo-comments').setup { - highlight = { - before = "", -- "fg" or "bg" or empty - keyword = "bg", -- "fg", "bg", "wide" or empty - after = "fg", -- "fg" or "bg" or empty - pattern = ${cfg.patterns.highlight}, - comments_only = true, -- uses treesitter to match keywords in comments only - max_line_len = 400, -- ignore lines longer than this - exclude = {}, -- list of file types to exclude highlighting - }, - search = { - command = "${pkgs.ripgrep}/bin/rg", - args = { - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", + luaConfigRC.todo-comments = '' + require('todo-comments').setup { + highlight = { + before = "", -- "fg" or "bg" or empty + keyword = "bg", -- "fg", "bg", "wide" or empty + after = "fg", -- "fg" or "bg" or empty + pattern = ${cfg.patterns.highlight}, + comments_only = true, -- uses treesitter to match keywords in comments only + max_line_len = 400, -- ignore lines longer than this + exclude = {}, -- list of file types to exclude highlighting }, - pattern = ${cfg.patterns.search}, - }, - } - ''; + search = { + command = "${pkgs.ripgrep}/bin/rg", + args = { + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + }, + pattern = ${cfg.patterns.search}, + }, + } + ''; + }; }; } diff --git a/modules/notes/todo-comments/default.nix b/modules/notes/todo-comments/default.nix index ac730fe..6030067 100644 --- a/modules/notes/todo-comments/default.nix +++ b/modules/notes/todo-comments/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./todo-comments.nix ./config.nix diff --git a/modules/notes/todo-comments/todo-comments.nix b/modules/notes/todo-comments/todo-comments.nix index 6fbc71b..ca4e4be 100644 --- a/modules/notes/todo-comments/todo-comments.nix +++ b/modules/notes/todo-comments/todo-comments.nix @@ -1,18 +1,20 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkOption types mkMappingOption; + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) str; + inherit (lib.nvim.binds) mkMappingOption; in { options.vim.notes.todo-comments = { enable = mkEnableOption "todo-comments: highlight and search for todo comments like TODO, HACK, BUG in your code base"; patterns = { highlight = mkOption { - type = types.str; + type = str; default = ''[[.*<(KEYWORDS)(\([^\)]*\))?:]]''; description = "vim regex pattern used for highlighting comments"; }; search = mkOption { - type = types.str; + type = str; default = ''[[\b(KEYWORDS)(\([^\)]*\))?:]]''; description = "ripgrep regex pattern used for searching comments"; }; From 2c483d90afe15dfdd9105ace3f233ff10801ece4 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 12 Mar 2024 03:47:12 +0300 Subject: [PATCH 037/193] modules/theme: switch to explicit lib calls --- modules/theme/config.nix | 8 ++------ modules/theme/default.nix | 2 +- modules/theme/theme.nix | 28 +++++++++++++++++----------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/modules/theme/config.nix b/modules/theme/config.nix index 01be14c..f6544b3 100644 --- a/modules/theme/config.nix +++ b/modules/theme/config.nix @@ -1,9 +1,5 @@ -{ - config, - lib, - ... -}: let - inherit (lib) mkDefault; +{lib, ...}: let + inherit (lib.modules) mkDefault; in { config = { vim.theme = { diff --git a/modules/theme/default.nix b/modules/theme/default.nix index 02f4f37..3b37928 100644 --- a/modules/theme/default.nix +++ b/modules/theme/default.nix @@ -1,4 +1,4 @@ -{...}: { +{ imports = [ ./theme.nix ./config.nix diff --git a/modules/theme/theme.nix b/modules/theme/theme.nix index 094a56c..2ae3e45 100644 --- a/modules/theme/theme.nix +++ b/modules/theme/theme.nix @@ -3,44 +3,50 @@ lib, ... }: let - inherit (lib) mkOption types attrNames mkIf nvim; + inherit (lib.options) mkOption; + inherit (lib.attrsets) attrNames; + inherit (lib.types) bool lines enum; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryBefore; cfg = config.vim.theme; supported_themes = import ./supported_themes.nix {inherit lib;}; in { options.vim.theme = { enable = mkOption { - type = types.bool; + type = bool; description = "Enable theming"; }; name = mkOption { - type = types.enum (attrNames supported_themes); + type = enum (attrNames supported_themes); description = "Supported themes can be found in `supported_themes.nix`"; }; style = mkOption { - type = with types; enum supported_themes.${cfg.name}.styles; + type = enum supported_themes.${cfg.name}.styles; description = "Specific style for theme if it supports it"; }; transparent = mkOption { - type = with types; bool; + type = bool; default = false; description = "Whether or not transparency should be enabled. Has no effect for themes that do not support transparency"; }; extraConfig = mkOption { - type = with types; lines; + type = lines; description = "Additional lua configuration to add before setup"; }; }; config = mkIf cfg.enable { - vim.startPlugins = [cfg.name]; - vim.luaConfigRC.themeSetup = nvim.dag.entryBefore ["theme"] cfg.extraConfig; - vim.luaConfigRC.theme = supported_themes.${cfg.name}.setup (with cfg; { - inherit style transparent; - }); + vim = { + startPlugins = [cfg.name]; + luaConfigRC = { + themeSetup = entryBefore ["theme"] cfg.extraConfig; + theme = supported_themes.${cfg.name}.setup (with cfg; {inherit style transparent;}); + }; + }; }; } From 32c2e7733a3267399e44ef6b9cab09c8c9010996 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 12 Mar 2024 03:47:27 +0300 Subject: [PATCH 038/193] modules/terminal: switch to explicit lib calls --- modules/terminal/default.nix | 2 +- modules/terminal/toggleterm/config.nix | 60 ++++++++++++---------- modules/terminal/toggleterm/default.nix | 2 +- modules/terminal/toggleterm/toggleterm.nix | 15 +++--- 4 files changed, 43 insertions(+), 36 deletions(-) diff --git a/modules/terminal/default.nix b/modules/terminal/default.nix index c8bbc22..a268e8b 100644 --- a/modules/terminal/default.nix +++ b/modules/terminal/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./toggleterm ]; diff --git a/modules/terminal/toggleterm/config.nix b/modules/terminal/toggleterm/config.nix index eca6e60..1ffec58 100644 --- a/modules/terminal/toggleterm/config.nix +++ b/modules/terminal/toggleterm/config.nix @@ -4,48 +4,54 @@ ... }: let inherit (builtins) toJSON; - inherit (lib) mkMerge mkIf mkBinding nvim getExe; + inherit (lib.lists) optionals; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.meta) getExe; + inherit (lib.nvim.binds) mkBinding; + inherit (lib.nvim.dag) entryAnywhere entryAfter; cfg = config.vim.terminal.toggleterm; in { config = mkMerge [ ( mkIf cfg.enable { - vim.startPlugins = [ - "toggleterm-nvim" - ]; + vim = { + startPlugins = [ + "toggleterm-nvim" + ]; - vim.maps.normal = mkBinding cfg.mappings.open "execute v:count . \"ToggleTerm\"" "Toggle terminal"; + maps.normal = mkBinding cfg.mappings.open "execute v:count . \"ToggleTerm\"" "Toggle terminal"; - vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere '' - require("toggleterm").setup({ - open_mapping = null, - direction = '${toString cfg.direction}', - -- TODO: this should probably be turned into a module that uses the lua function if and only if the user has not set it - size = function(term) - if term.direction == "horizontal" then - return 15 - elseif term.direction == "vertical" then - return vim.o.columns * 0.4 - end - end, - winbar = { - enabled = '${toString cfg.enable_winbar}', - name_formatter = function(term) -- term: Terminal - return term.name - end - }, - }) - ''; + luaConfigRC.toggleterm = entryAnywhere '' + require("toggleterm").setup({ + open_mapping = null, + direction = '${toString cfg.direction}', + -- TODO: this should probably be turned into a module that uses the lua function if and only if the user has not set it + size = function(term) + if term.direction == "horizontal" then + return 15 + elseif term.direction == "vertical" then + return vim.o.columns * 0.4 + end + end, + winbar = { + enabled = '${toString cfg.enable_winbar}', + name_formatter = function(term) -- term: Terminal + return term.name + end + }, + }) + ''; + }; } ) ( mkIf (cfg.enable && cfg.lazygit.enable) { - vim.startPlugins = lib.optionals (cfg.lazygit.package != null) [ + vim.startPlugins = optionals (cfg.lazygit.package != null) [ cfg.lazygit.package ]; - vim.luaConfigRC.toggleterm-lazygit = nvim.dag.entryAfter ["toggleterm"] '' + vim.luaConfigRC.toggleterm-lazygit = entryAfter ["toggleterm"] '' local terminal = require 'toggleterm.terminal' local lazygit = terminal.Terminal:new({ cmd = '${ diff --git a/modules/terminal/toggleterm/default.nix b/modules/terminal/toggleterm/default.nix index a540f3f..093dc0d 100644 --- a/modules/terminal/toggleterm/default.nix +++ b/modules/terminal/toggleterm/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./toggleterm.nix ./config.nix diff --git a/modules/terminal/toggleterm/toggleterm.nix b/modules/terminal/toggleterm/toggleterm.nix index 3579063..dbc8e54 100644 --- a/modules/terminal/toggleterm/toggleterm.nix +++ b/modules/terminal/toggleterm/toggleterm.nix @@ -1,29 +1,30 @@ { pkgs, - config, lib, ... }: let - inherit (lib) mkEnableOption mkOption types mkMappingOption; + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.nvim.binds) mkMappingOption; + inherit (lib.types) nullOr str enum bool package; in { options.vim.terminal.toggleterm = { enable = mkEnableOption "toggleterm as a replacement to built-in terminal command"; mappings = { open = mkOption { - type = types.nullOr types.str; + type = nullOr str; description = "The keymapping to open toggleterm"; default = ""; }; }; direction = mkOption { - type = types.enum ["horizontal" "vertical" "tab" "float"]; + type = enum ["horizontal" "vertical" "tab" "float"]; default = "horizontal"; description = "Direction of the terminal"; }; enable_winbar = mkOption { - type = types.bool; + type = bool; default = false; description = "Enable winbar"; }; @@ -31,13 +32,13 @@ in { lazygit = { enable = mkEnableOption "LazyGit integration"; direction = mkOption { - type = types.enum ["horizontal" "vertical" "tab" "float"]; + type = enum ["horizontal" "vertical" "tab" "float"]; default = "float"; description = "Direction of the lazygit window"; }; package = mkOption { - type = with types; nullOr package; + type = nullOr package; default = pkgs.lazygit; description = "The package that should be used for lazygit. Setting it to null will attempt to use lazygit from your PATH"; }; From e80f2c92803c53472479794b3e06eb0bfb41f180 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 12 Mar 2024 03:47:41 +0300 Subject: [PATCH 039/193] modules/tabline: switch to explicit lib calls --- modules/tabline/default.nix | 2 +- modules/tabline/nvim-bufferline/config.nix | 159 +++++++++--------- modules/tabline/nvim-bufferline/default.nix | 2 +- .../nvim-bufferline/nvim-bufferline.nix | 5 +- 4 files changed, 86 insertions(+), 82 deletions(-) diff --git a/modules/tabline/default.nix b/modules/tabline/default.nix index 539302e..5730dba 100644 --- a/modules/tabline/default.nix +++ b/modules/tabline/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./nvim-bufferline ]; diff --git a/modules/tabline/nvim-bufferline/config.nix b/modules/tabline/nvim-bufferline/config.nix index befafcd..93b0f58 100644 --- a/modules/tabline/nvim-bufferline/config.nix +++ b/modules/tabline/nvim-bufferline/config.nix @@ -3,13 +3,14 @@ lib, ... }: let - inherit (lib) mkIf mkMerge mkLuaBinding mkBinding nvim pushDownDefault; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.binds) mkLuaBinding mkBinding pushDownDefault; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.tabline.nvimBufferline; - self = import ./nvim-bufferline.nix { - inherit lib; - }; - mappings = self.options.vim.tabline.nvimBufferline.mappings; + + self = import ./nvim-bufferline.nix {inherit lib;}; + inherit (self.options.vim.tabline.nvimBufferline) mappings; in { config = mkIf cfg.enable ( let @@ -22,82 +23,84 @@ in { ''; }; in { - vim.startPlugins = [ - (assert config.vim.visuals.nvimWebDevicons.enable == true; "nvim-bufferline-lua") - "bufdelete-nvim" - ]; + vim = { + startPlugins = [ + (assert config.vim.visuals.nvimWebDevicons.enable; "nvim-bufferline-lua") + "bufdelete-nvim" + ]; - vim.maps.normal = mkMerge [ - (mkLuaBinding cfg.mappings.closeCurrent "require(\"bufdelete\").bufdelete" mappings.closeCurrent.description) - (mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext" mappings.cycleNext.description) - (mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext" mappings.cycleNext.description) - (mkBinding cfg.mappings.cyclePrevious ":BufferLineCyclePrev" mappings.cyclePrevious.description) - (mkBinding cfg.mappings.pick ":BufferLinePick" mappings.pick.description) - (mkBinding cfg.mappings.sortByExtension ":BufferLineSortByExtension" mappings.sortByExtension.description) - (mkBinding cfg.mappings.sortByDirectory ":BufferLineSortByDirectory" mappings.sortByDirectory.description) - (mkLuaBinding cfg.mappings.sortById "function() require(\"bufferline\").sort_buffers_by(function (buf_a, buf_b) return buf_a.id < buf_b.id end) end" mappings.sortById.description) - (mkBinding cfg.mappings.moveNext ":BufferLineMoveNext" mappings.moveNext.description) - (mkBinding cfg.mappings.movePrevious ":BufferLineMovePrev" mappings.movePrevious.description) - ]; + maps.normal = mkMerge [ + (mkLuaBinding cfg.mappings.closeCurrent "require(\"bufdelete\").bufdelete" mappings.closeCurrent.description) + (mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext" mappings.cycleNext.description) + (mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext" mappings.cycleNext.description) + (mkBinding cfg.mappings.cyclePrevious ":BufferLineCyclePrev" mappings.cyclePrevious.description) + (mkBinding cfg.mappings.pick ":BufferLinePick" mappings.pick.description) + (mkBinding cfg.mappings.sortByExtension ":BufferLineSortByExtension" mappings.sortByExtension.description) + (mkBinding cfg.mappings.sortByDirectory ":BufferLineSortByDirectory" mappings.sortByDirectory.description) + (mkLuaBinding cfg.mappings.sortById "function() require(\"bufferline\").sort_buffers_by(function (buf_a, buf_b) return buf_a.id < buf_b.id end) end" mappings.sortById.description) + (mkBinding cfg.mappings.moveNext ":BufferLineMoveNext" mappings.moveNext.description) + (mkBinding cfg.mappings.movePrevious ":BufferLineMovePrev" mappings.movePrevious.description) + ]; - vim.binds.whichKey.register = pushDownDefault { - "b" = "+Buffer"; - "bm" = "BufferLineMove"; - "bs" = "BufferLineSort"; - "bsi" = "BufferLineSortById"; + binds.whichKey.register = pushDownDefault { + "b" = "+Buffer"; + "bm" = "BufferLineMove"; + "bs" = "BufferLineSort"; + "bsi" = "BufferLineSortById"; + }; + + luaConfigRC.nvimBufferline = entryAnywhere '' + require("bufferline").setup{ + options = { + mode = "buffers", + numbers = "both", + close_command = ${mouse.close}, + right_mouse_command = ${mouse.right}, + indicator = { + style = 'icon', + indicator_icon = '▎', + }, + buffer_close_icon = '󰅖', + modified_icon = '●', + close_icon = '', + left_trunc_marker = '', + right_trunc_marker = '', + max_name_length = 18, + max_prefix_length = 15, + tab_size = 18, + show_buffer_icons = true, + show_buffer_close_icons = true, + show_close_icon = true, + show_tab_indicators = true, + persist_buffer_sort = true, + --separator_style = "thin", + separator_style = { " ", " " }, + enforce_regular_tabs = true, + always_show_bufferline = true, + offsets = { + {filetype = "NvimTree", text = "File Explorer", text_align = "center"} + }, + sort_by = 'extension', + diagnostics = "nvim_lsp", -- TODO: use coc if it's enabled + diagnostics_update_in_insert = true, + diagnostics_indicator = function(count, level, diagnostics_dict, context) + local s = "" + for e, n in pairs(diagnostics_dict) do + local sym = e == "error" and "" + or (e == "warning" and "" or "" ) + if(sym ~= "") then + s = s .. " " .. n .. sym + end + end + return s + end, + numbers = function(opts) + return string.format('%s·%s', opts.raise(opts.id), opts.lower(opts.ordinal)) + end, + } + } + ''; }; - - vim.luaConfigRC.nvimBufferline = nvim.dag.entryAnywhere '' - require("bufferline").setup{ - options = { - mode = "buffers", - numbers = "both", - close_command = ${mouse.close}, - right_mouse_command = ${mouse.right}, - indicator = { - style = 'icon', - indicator_icon = '▎', - }, - buffer_close_icon = '󰅖', - modified_icon = '●', - close_icon = '', - left_trunc_marker = '', - right_trunc_marker = '', - max_name_length = 18, - max_prefix_length = 15, - tab_size = 18, - show_buffer_icons = true, - show_buffer_close_icons = true, - show_close_icon = true, - show_tab_indicators = true, - persist_buffer_sort = true, - --separator_style = "thin", - separator_style = { " ", " " }, - enforce_regular_tabs = true, - always_show_bufferline = true, - offsets = { - {filetype = "NvimTree", text = "File Explorer", text_align = "center"} - }, - sort_by = 'extension', - diagnostics = "nvim_lsp", -- TODO: use coc if it's enabled - diagnostics_update_in_insert = true, - diagnostics_indicator = function(count, level, diagnostics_dict, context) - local s = "" - for e, n in pairs(diagnostics_dict) do - local sym = e == "error" and "" - or (e == "warning" and "" or "" ) - if(sym ~= "") then - s = s .. " " .. n .. sym - end - end - return s - end, - numbers = function(opts) - return string.format('%s·%s', opts.raise(opts.id), opts.lower(opts.ordinal)) - end, - } - } - ''; } ); } diff --git a/modules/tabline/nvim-bufferline/default.nix b/modules/tabline/nvim-bufferline/default.nix index 8fe4868..9f31874 100644 --- a/modules/tabline/nvim-bufferline/default.nix +++ b/modules/tabline/nvim-bufferline/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./nvim-bufferline.nix ./config.nix diff --git a/modules/tabline/nvim-bufferline/nvim-bufferline.nix b/modules/tabline/nvim-bufferline/nvim-bufferline.nix index 1ca3ff0..6e2b87e 100644 --- a/modules/tabline/nvim-bufferline/nvim-bufferline.nix +++ b/modules/tabline/nvim-bufferline/nvim-bufferline.nix @@ -1,8 +1,9 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkMappingOption; + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.binds) mkMappingOption; in { options.vim.tabline.nvimBufferline = { - enable = mkEnableOption "nvim-bufferline-lua as a bufferline"; + enable = mkEnableOption "neovim bufferline"; mappings = { closeCurrent = mkMappingOption "Close buffer" null; From 3a9f5db55f0766906c20a5fc4c81684eb9763f2f Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 12 Mar 2024 03:47:57 +0300 Subject: [PATCH 040/193] modules/statusline: switch to explicit lib calls --- modules/statusline/default.nix | 2 +- modules/statusline/lualine/config.nix | 37 +++++++------ modules/statusline/lualine/default.nix | 2 +- modules/statusline/lualine/lualine.nix | 77 +++++++++++++------------- 4 files changed, 63 insertions(+), 55 deletions(-) diff --git a/modules/statusline/default.nix b/modules/statusline/default.nix index 82e3dd2..4f43398 100644 --- a/modules/statusline/default.nix +++ b/modules/statusline/default.nix @@ -1,4 +1,4 @@ -{...}: { +{ imports = [ ./lualine ]; diff --git a/modules/statusline/lualine/config.nix b/modules/statusline/lualine/config.nix index d73e0f6..04f123d 100644 --- a/modules/statusline/lualine/config.nix +++ b/modules/statusline/lualine/config.nix @@ -3,16 +3,21 @@ lib, ... }: let + inherit (lib.modules) mkIf; + inherit (lib.trivial) boolToString; + inherit (lib.strings) optionalString; + inherit (lib.nvim.lua) luaTable listToLuaTable; + inherit (lib.nvim.dag) entryAnywhere; + cfg = config.vim.statusline.lualine; breadcrumbsCfg = config.vim.ui.breadcrumbs; - inherit (lib) mkIf nvim boolToString optionalString; in { config = (mkIf cfg.enable) { vim.startPlugins = [ "lualine" ]; - vim.luaConfigRC.lualine = nvim.dag.entryAnywhere '' + vim.luaConfigRC.lualine = entryAnywhere '' local lualine = require('lualine') lualine.setup { options = { @@ -20,10 +25,10 @@ in { theme = "${cfg.theme}", component_separators = {"${cfg.componentSeparator.left}","${cfg.componentSeparator.right}"}, section_separators = {"${cfg.sectionSeparator.left}","${cfg.sectionSeparator.right}"}, - disabled_filetypes = ${nvim.lua.listToLuaTable cfg.disabledFiletypes}, + disabled_filetypes = ${listToLuaTable cfg.disabledFiletypes}, always_divide_middle = ${boolToString cfg.alwaysDivideMiddle}, globalstatus = ${boolToString cfg.globalStatus}, - ignore_focus = ${nvim.lua.listToLuaTable cfg.ignoreFocus}, + ignore_focus = ${listToLuaTable cfg.ignoreFocus}, extensions = {${optionalString config.vim.filetree.nvimTree.enable "'nvim-tree'"}}, refresh = { statusline = ${toString cfg.refresh.statusline}, @@ -34,22 +39,22 @@ in { -- active sections sections = { - lualine_a = ${nvim.lua.luaTable (cfg.activeSection.a ++ cfg.extraActiveSection.a)}, - lualine_b = ${nvim.lua.luaTable (cfg.activeSection.b ++ cfg.extraActiveSection.b)}, - lualine_c = ${nvim.lua.luaTable (cfg.activeSection.c ++ cfg.extraActiveSection.c)}, - lualine_x = ${nvim.lua.luaTable (cfg.activeSection.x ++ cfg.extraActiveSection.x)}, - lualine_y = ${nvim.lua.luaTable (cfg.activeSection.y ++ cfg.extraActiveSection.y)}, - lualine_z = ${nvim.lua.luaTable (cfg.activeSection.z ++ cfg.extraActiveSection.z)}, + lualine_a = ${luaTable (cfg.activeSection.a ++ cfg.extraActiveSection.a)}, + lualine_b = ${luaTable (cfg.activeSection.b ++ cfg.extraActiveSection.b)}, + lualine_c = ${luaTable (cfg.activeSection.c ++ cfg.extraActiveSection.c)}, + lualine_x = ${luaTable (cfg.activeSection.x ++ cfg.extraActiveSection.x)}, + lualine_y = ${luaTable (cfg.activeSection.y ++ cfg.extraActiveSection.y)}, + lualine_z = ${luaTable (cfg.activeSection.z ++ cfg.extraActiveSection.z)}, }, -- inactive sections inactive_sections = { - lualine_a = ${nvim.lua.luaTable (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a)}, - lualine_b = ${nvim.lua.luaTable (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b)}, - lualine_c = ${nvim.lua.luaTable (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c)}, - lualine_x = ${nvim.lua.luaTable (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x)}, - lualine_y = ${nvim.lua.luaTable (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y)}, - lualine_z = ${nvim.lua.luaTable (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z)}, + lualine_a = ${luaTable (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a)}, + lualine_b = ${luaTable (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b)}, + lualine_c = ${luaTable (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c)}, + lualine_x = ${luaTable (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x)}, + lualine_y = ${luaTable (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y)}, + lualine_z = ${luaTable (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z)}, }, -- tabline (currently unsupported) diff --git a/modules/statusline/lualine/default.nix b/modules/statusline/lualine/default.nix index 879e72f..56d9207 100644 --- a/modules/statusline/lualine/default.nix +++ b/modules/statusline/lualine/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./lualine.nix ./config.nix diff --git a/modules/statusline/lualine/lualine.nix b/modules/statusline/lualine/lualine.nix index 8f9d726..9f5b583 100644 --- a/modules/statusline/lualine/lualine.nix +++ b/modules/statusline/lualine/lualine.nix @@ -3,7 +3,10 @@ lib, ... }: let - inherit (lib) mkEnableOption mkOption types elem optional; + inherit (builtins) elem; + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) int bool str listOf enum; + inherit (lib.lists) optional; supported_themes = import ./supported_themes.nix; colorPuccin = @@ -20,44 +23,44 @@ in { refresh = { statusline = mkOption { - type = types.int; + type = int; description = "Refresh rate for lualine"; default = 1000; }; tabline = mkOption { - type = types.int; + type = int; description = "Refresh rate for tabline"; default = 1000; }; winbar = mkOption { - type = types.int; + type = int; description = "Refresh rate for winbar"; default = 1000; }; }; globalStatus = mkOption { - type = types.bool; + type = bool; description = "Enable global status for lualine"; default = true; }; alwaysDivideMiddle = mkOption { - type = types.bool; + type = bool; description = "Always divide middle section"; default = true; }; disabledFiletypes = mkOption { - type = with types; listOf str; + type = listOf str; description = "Filetypes to disable lualine on"; default = ["alpha"]; }; ignoreFocus = mkOption { - type = with types; listOf str; + type = listOf str; default = ["NvimTree"]; description = '' If current filetype is in this list it'll always be drawn as inactive statusline @@ -70,7 +73,7 @@ in { in mkOption { description = "Theme for lualine"; - type = types.enum ([ + type = enum ([ "auto" "16color" "gruvbox" @@ -112,13 +115,13 @@ in { sectionSeparator = { left = mkOption { - type = types.str; + type = str; description = "Section separator for left side"; default = ""; }; right = mkOption { - type = types.str; + type = str; description = "Section separator for right side"; default = ""; }; @@ -126,13 +129,13 @@ in { componentSeparator = { left = mkOption { - type = types.str; + type = str; description = "Component separator for left side"; default = ""; }; right = mkOption { - type = types.str; + type = str; description = "Component separator for right side"; default = ""; }; @@ -140,7 +143,7 @@ in { activeSection = { a = mkOption { - type = with types; listOf str; + type = listOf str; description = "active config for: | (A) | B | C X | Y | Z |"; default = [ '' @@ -157,7 +160,7 @@ in { }; b = mkOption { - type = with types; listOf str; + type = listOf str; description = "active config for: | A | (B) | C X | Y | Z |"; default = [ '' @@ -180,7 +183,7 @@ in { }; c = mkOption { - type = with types; listOf str; + type = listOf str; description = "active config for: | A | B | (C) X | Y | Z |"; default = [ '' @@ -207,7 +210,7 @@ in { }; x = mkOption { - type = with types; listOf str; + type = listOf str; description = "active config for: | A | B | C (X) | Y | Z |"; default = [ '' @@ -268,7 +271,7 @@ in { }; y = mkOption { - type = with types; listOf str; + type = listOf str; description = "active config for: | A | B | C X | (Y) | Z |"; default = [ '' @@ -290,7 +293,7 @@ in { }; z = mkOption { - type = with types; listOf str; + type = listOf str; description = "active config for: | A | B | C X | Y | (Z) |"; default = [ '' @@ -322,32 +325,32 @@ in { }; extraActiveSection = { a = mkOption { - type = with types; listOf str; + type = listOf str; description = "Extra entries for activeSection.a"; default = []; }; b = mkOption { - type = with types; listOf str; + type = listOf str; description = "Extra entries for activeSection.b"; default = []; }; c = mkOption { - type = with types; listOf str; + type = listOf str; description = "Extra entries for activeSection.c"; default = []; }; x = mkOption { - type = with types; listOf str; + type = listOf str; description = "Extra entries for activeSection.x"; default = []; }; y = mkOption { - type = with types; listOf str; + type = listOf str; description = "Extra entries for activeSection.y"; default = []; }; z = mkOption { - type = with types; listOf str; + type = listOf str; description = "Extra entries for activeSection.z"; default = []; }; @@ -355,69 +358,69 @@ in { inactiveSection = { a = mkOption { - type = with types; listOf str; + type = listOf str; description = "inactive config for: | (A) | B | C X | Y | Z |"; default = []; }; b = mkOption { - type = with types; listOf str; + type = listOf str; description = "inactive config for: | A | (B) | C X | Y | Z |"; default = []; }; c = mkOption { - type = with types; listOf str; + type = listOf str; description = "inactive config for: | A | B | (C) X | Y | Z |"; default = ["'filename'"]; }; x = mkOption { - type = with types; listOf str; + type = listOf str; description = "inactive config for: | A | B | C (X) | Y | Z |"; default = ["'location'"]; }; y = mkOption { - type = with types; listOf str; + type = listOf str; description = "inactive config for: | A | B | C X | (Y) | Z |"; default = []; }; z = mkOption { - type = with types; listOf str; + type = listOf str; description = "inactive config for: | A | B | C X | Y | (Z) |"; default = []; }; }; extraInactiveSection = { a = mkOption { - type = with types; listOf str; + type = listOf str; description = "Extra entries for inactiveSection.a"; default = []; }; b = mkOption { - type = with types; listOf str; + type = listOf str; description = "Extra entries for inactiveSection.b"; default = []; }; c = mkOption { - type = with types; listOf str; + type = listOf str; description = "Extra entries for inactiveSection.c"; default = []; }; x = mkOption { - type = with types; listOf str; + type = listOf str; description = "Extra entries for inactiveSection.x"; default = []; }; y = mkOption { - type = with types; listOf str; + type = listOf str; description = "Extra entries for inactiveSection.y"; default = []; }; z = mkOption { - type = with types; listOf str; + type = listOf str; description = "Extra entries for inactiveSection.z"; default = []; }; From e5383a8123f31b814f6e218279357b6db5741d06 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 12 Mar 2024 03:48:10 +0300 Subject: [PATCH 041/193] modules/snippets: switch to explicit lib calls --- modules/snippets/default.nix | 2 +- modules/snippets/vsnip/config.nix | 2 +- modules/snippets/vsnip/default.nix | 2 +- modules/snippets/vsnip/vsnip.nix | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/snippets/default.nix b/modules/snippets/default.nix index cde3f7c..3f9758a 100644 --- a/modules/snippets/default.nix +++ b/modules/snippets/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./vsnip ]; diff --git a/modules/snippets/vsnip/config.nix b/modules/snippets/vsnip/config.nix index fd4bf50..5c6ba75 100644 --- a/modules/snippets/vsnip/config.nix +++ b/modules/snippets/vsnip/config.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib) mkIf; + inherit (lib.modules) mkIf; cfg = config.vim.snippets.vsnip; in { diff --git a/modules/snippets/vsnip/default.nix b/modules/snippets/vsnip/default.nix index fee36eb..87ef29e 100644 --- a/modules/snippets/vsnip/default.nix +++ b/modules/snippets/vsnip/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./vsnip.nix ]; diff --git a/modules/snippets/vsnip/vsnip.nix b/modules/snippets/vsnip/vsnip.nix index 2d423cb..5d3b6d9 100644 --- a/modules/snippets/vsnip/vsnip.nix +++ b/modules/snippets/vsnip/vsnip.nix @@ -1,5 +1,5 @@ {lib, ...}: let - inherit (lib) mkEnableOption; + inherit (lib.options) mkEnableOption; in { options.vim.snippets.vsnip = { enable = mkEnableOption "vim-vsnip: snippet LSP/VSCode's format"; From 03025f76e1eb8d0916d8819bcd0614c55ba19309 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 12 Mar 2024 03:48:24 +0300 Subject: [PATCH 042/193] modules/session: switch to explicit lib calls --- modules/session/default.nix | 2 +- .../session/nvim-session-manager/config.nix | 69 ++++++++++--------- .../session/nvim-session-manager/default.nix | 2 +- .../nvim-session-manager.nix | 42 +++++------ 4 files changed, 61 insertions(+), 54 deletions(-) diff --git a/modules/session/default.nix b/modules/session/default.nix index b984f72..54e7ef9 100644 --- a/modules/session/default.nix +++ b/modules/session/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./nvim-session-manager ]; diff --git a/modules/session/nvim-session-manager/config.nix b/modules/session/nvim-session-manager/config.nix index 70ed26b..91072f1 100644 --- a/modules/session/nvim-session-manager/config.nix +++ b/modules/session/nvim-session-manager/config.nix @@ -3,51 +3,58 @@ lib, ... }: let - inherit (lib) mkIf optionals mkMerge mkBinding nvim concatStringsSep boolToString; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) optionals; + inherit (lib.strings) concatStringsSep; + inherit (lib.trivial) boolToString; + inherit (lib.nvim.binds) mkBinding; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.session.nvim-session-manager; in { config = mkIf cfg.enable { - vim.startPlugins = - [ - "nvim-session-manager" - "plenary-nvim" - ] - ++ optionals (cfg.usePicker) ["dressing-nvim"]; + vim = { + startPlugins = + [ + "nvim-session-manager" + "plenary-nvim" + ] + ++ optionals (cfg.usePicker) ["dressing-nvim"]; - vim.maps.normal = mkMerge [ - (mkBinding cfg.mappings.loadSession ":SessionManager load_session" "Load session") - (mkBinding cfg.mappings.deleteSession ":SessionManager delete_session" "Delete session") - (mkBinding cfg.mappings.saveCurrentSession ":SessionManager save_current_session" "Save current session") - (mkBinding cfg.mappings.loadLastSession ":SessionManager load_last_session" "Load last session") - # TODO: load_current_dir_session - ]; + maps.normal = mkMerge [ + (mkBinding cfg.mappings.loadSession ":SessionManager load_session" "Load session") + (mkBinding cfg.mappings.deleteSession ":SessionManager delete_session" "Delete session") + (mkBinding cfg.mappings.saveCurrentSession ":SessionManager save_current_session" "Save current session") + (mkBinding cfg.mappings.loadLastSession ":SessionManager load_last_session" "Load last session") + # TODO: load_current_dir_session + ]; - vim.luaConfigRC.nvim-session-manager = nvim.dag.entryAnywhere '' - local Path = require('plenary.path') - local sm = require('session_manager.config') - require('session_manager').setup({ - sessions_dir = Path:new(vim.fn.stdpath('data'), 'sessions'), + luaConfigRC.nvim-session-manager = entryAnywhere '' + local Path = require('plenary.path') + local sm = require('session_manager.config') + require('session_manager').setup({ + sessions_dir = Path:new(vim.fn.stdpath('data'), 'sessions'), - path_replacer = '${toString cfg.pathReplacer}', + path_replacer = '${toString cfg.pathReplacer}', - colon_replacer = '${toString cfg.colonReplacer}', + colon_replacer = '${toString cfg.colonReplacer}', - autoload_mode = sm.AutoloadMode.${toString cfg.autoloadMode}, + autoload_mode = sm.AutoloadMode.${toString cfg.autoloadMode}, - autosave_last_session = ${boolToString cfg.autoSave.lastSession}, + autosave_last_session = ${boolToString cfg.autoSave.lastSession}, - autosave_ignore_not_normal = ${boolToString cfg.autoSave.ignoreNotNormal}, + autosave_ignore_not_normal = ${boolToString cfg.autoSave.ignoreNotNormal}, - autosave_ignore_dirs = {${concatStringsSep ", " (map (x: "\'" + x + "\'") cfg.autoSave.ignoreDirs)}}, + autosave_ignore_dirs = {${concatStringsSep ", " (map (x: "\'" + x + "\'") cfg.autoSave.ignoreDirs)}}, - autosave_ignore_filetypes = {${concatStringsSep ", " (map (x: "\'" + x + "\'") cfg.autoSave.ignoreFiletypes)}}, + autosave_ignore_filetypes = {${concatStringsSep ", " (map (x: "\'" + x + "\'") cfg.autoSave.ignoreFiletypes)}}, - autosave_ignore_buftypes = {${concatStringsSep ", " (map (x: "\'" + x + "\'") cfg.autoSave.ignoreBufTypes)}}, + autosave_ignore_buftypes = {${concatStringsSep ", " (map (x: "\'" + x + "\'") cfg.autoSave.ignoreBufTypes)}}, - autosave_only_in_session = ${boolToString cfg.autoSave.onlyInSession}, - max_path_length = ${toString cfg.maxPathLength}, - }) - ''; + autosave_only_in_session = ${boolToString cfg.autoSave.onlyInSession}, + max_path_length = ${toString cfg.maxPathLength}, + }) + ''; + }; }; } diff --git a/modules/session/nvim-session-manager/default.nix b/modules/session/nvim-session-manager/default.nix index 607c453..2a99059 100644 --- a/modules/session/nvim-session-manager/default.nix +++ b/modules/session/nvim-session-manager/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./nvim-session-manager.nix ./config.nix diff --git a/modules/session/nvim-session-manager/nvim-session-manager.nix b/modules/session/nvim-session-manager/nvim-session-manager.nix index a5395a0..2182db3 100644 --- a/modules/session/nvim-session-manager/nvim-session-manager.nix +++ b/modules/session/nvim-session-manager/nvim-session-manager.nix @@ -1,99 +1,99 @@ -{ - config, - lib, - ... -}: let - inherit (lib) mkEnableOption mkOption types; +{lib, ...}: let + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) nullOr str bool int listOf enum; in { options.vim.session.nvim-session-manager = { enable = mkEnableOption "nvim-session-manager: manage sessions like folders in VSCode"; mappings = { loadSession = mkOption { - type = types.nullOr types.str; + type = nullOr str; description = "Load session"; default = "sl"; }; + deleteSession = mkOption { - type = types.nullOr types.str; + type = nullOr str; description = "Delete session"; default = "sd"; }; + saveCurrentSession = mkOption { - type = types.nullOr types.str; + type = nullOr str; description = "Save current session"; default = "sc"; }; + loadLastSession = mkOption { - type = types.nullOr types.str; + type = nullOr str; description = "Load last session"; default = "slt"; }; }; usePicker = mkOption { - type = types.bool; + type = bool; default = true; description = "Whether or not we should use dressing.nvim to build a session picker UI"; }; pathReplacer = mkOption { - type = types.str; + type = str; default = "__"; description = "The character to which the path separator will be replaced for session files"; }; colonReplacer = mkOption { - type = types.str; + type = str; default = "++"; description = "The character to which the colon symbol will be replaced for session files"; }; autoloadMode = mkOption { - type = types.enum ["Disabled" "CurrentDir" "LastSession"]; + type = enum ["Disabled" "CurrentDir" "LastSession"]; default = "LastSession"; description = "Define what to do when Neovim is started without arguments. Possible values: Disabled, CurrentDir, LastSession"; }; maxPathLength = mkOption { - type = types.nullOr types.int; + type = nullOr int; default = 80; description = "Shorten the display path if length exceeds this threshold. Use 0 if don't want to shorten the path at all"; }; autoSave = { lastSession = mkOption { - type = types.bool; + type = bool; default = true; description = "Automatically save last session on exit and on session switch"; }; ignoreNotNormal = mkOption { - type = types.bool; + type = bool; default = true; description = "Plugin will not save a session when no buffers are opened, or all of them aren't writable or listed"; }; ignoreDirs = mkOption { - type = types.listOf types.str; + type = listOf str; default = []; description = "A list of directories where the session will not be autosaved"; }; ignoreFiletypes = mkOption { - type = types.listOf types.str; + type = listOf str; default = ["gitcommit"]; description = "All buffers of these file types will be closed before the session is saved"; }; ignoreBufTypes = mkOption { - type = types.listOf types.str; + type = listOf str; default = []; description = "All buffers of these bufer types will be closed before the session is saved"; }; onlyInSession = mkOption { - type = types.bool; + type = bool; default = false; description = "Always autosaves session. If true, only autosaves after a session is active"; }; From b54032f3f3268594094da79f28d688a3a2fe74a3 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 12 Mar 2024 03:48:38 +0300 Subject: [PATCH 043/193] modules/projects: switch to explicit lib calls --- modules/projects/default.nix | 2 +- modules/projects/project-nvim/config.nix | 7 ++++-- modules/projects/project-nvim/default.nix | 2 +- .../projects/project-nvim/project-nvim.nix | 25 ++++++++----------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/projects/default.nix b/modules/projects/default.nix index aa04d03..6b6c112 100644 --- a/modules/projects/default.nix +++ b/modules/projects/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./project-nvim ]; diff --git a/modules/projects/project-nvim/config.nix b/modules/projects/project-nvim/config.nix index 6fc78e4..5c036ef 100644 --- a/modules/projects/project-nvim/config.nix +++ b/modules/projects/project-nvim/config.nix @@ -3,7 +3,10 @@ lib, ... }: let - inherit (lib) mkIf nvim boolToString concatStringsSep; + inherit (lib.modules) mkIf; + inherit (lib.trivial) boolToString; + inherit (lib.strings) concatStringsSep; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.projects.project-nvim; in { @@ -12,7 +15,7 @@ in { "project-nvim" ]; - vim.luaConfigRC.project-nvim = nvim.dag.entryAnywhere '' + vim.luaConfigRC.project-nvim = entryAnywhere '' require('project_nvim').setup({ manual_mode = ${boolToString cfg.manualMode}, detection_methods = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.detectionMethods)} }, diff --git a/modules/projects/project-nvim/default.nix b/modules/projects/project-nvim/default.nix index db404ae..1e7b91a 100644 --- a/modules/projects/project-nvim/default.nix +++ b/modules/projects/project-nvim/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./project-nvim.nix diff --git a/modules/projects/project-nvim/project-nvim.nix b/modules/projects/project-nvim/project-nvim.nix index 5811f96..9331f37 100644 --- a/modules/projects/project-nvim/project-nvim.nix +++ b/modules/projects/project-nvim/project-nvim.nix @@ -1,60 +1,57 @@ -{ - config, - lib, - ... -}: let - inherit (lib) mkEnableOption mkOption types; +{lib, ...}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) enum bool listOf str; in { options.vim.projects.project-nvim = { enable = mkEnableOption "project-nvim for project management"; manualMode = mkOption { - type = types.bool; + type = bool; default = true; description = "don't automatically change the root directory so the user has the option to manually do so using `:ProjectRoot` command"; }; # detection methods should accept one or more strings from a list detectionMethods = mkOption { - type = types.listOf types.str; + type = listOf str; default = ["lsp" "pattern"]; description = "Detection methods to use"; }; # patterns patterns = mkOption { - type = types.listOf types.str; + type = listOf str; default = [".git" "_darcs" ".hg" ".bzr" ".svn" "Makefile" "package.json" "flake.nix" "cargo.toml"]; description = "Patterns to use for pattern detection method"; }; # table of lsp servers to ignore by name lspIgnored = mkOption { - type = types.listOf types.str; + type = listOf str; default = []; description = "LSP servers no ignore by name"; }; excludeDirs = mkOption { - type = types.listOf types.str; + type = listOf str; default = []; description = "Directories to exclude from project root search"; }; showHidden = mkOption { - type = types.bool; + type = bool; default = false; description = "Show hidden files in telescope picker"; }; silentChdir = mkOption { - type = types.bool; + type = bool; default = true; description = "Silently change directory when changing project"; }; scopeChdir = mkOption { - type = types.enum ["global" "tab" "win"]; + type = enum ["global" "tab" "win"]; default = "global"; description = "What scope to change the directory"; }; From d3f64465414ae983e9de9b2fbe21e122ed631f9f Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 12 Mar 2024 03:48:53 +0300 Subject: [PATCH 044/193] lib: add pushDownDefault to binds --- lib/binds.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/binds.nix b/lib/binds.nix index c52e255..34d7a7c 100644 --- a/lib/binds.nix +++ b/lib/binds.nix @@ -1,6 +1,6 @@ {lib}: let inherit (lib.options) mkOption; - inherit (lib.modules) mkIf; + inherit (lib.modules) mkIf mkDefault; inherit (lib.types) nullOr str; inherit (lib.attrsets) isAttrs mapAttrs; @@ -65,6 +65,8 @@ mkSetLuaBinding = binding: action: mkLuaBinding binding.value action binding.description; + + pushDownDefault = attr: mapAttrs (_name: value: mkDefault value) attr; }; in binds From 81b9a8a95c2dffde476525da8ea099c3ab2ff861 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 15 Mar 2024 14:19:11 +0300 Subject: [PATCH 045/193] modules/treesitter: switch to explicit lib calls --- modules/treesitter/config.nix | 84 ++++++++++++++++--------------- modules/treesitter/context.nix | 30 ++++++----- modules/treesitter/default.nix | 2 +- modules/treesitter/treesitter.nix | 25 ++++----- 4 files changed, 73 insertions(+), 68 deletions(-) diff --git a/modules/treesitter/config.nix b/modules/treesitter/config.nix index d197129..92802a8 100644 --- a/modules/treesitter/config.nix +++ b/modules/treesitter/config.nix @@ -3,60 +3,64 @@ lib, ... }: let - inherit (lib) addDescriptionsToMappings mkIf optional mkSetBinding mkMerge nvim; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) optional; + inherit (lib.nvim.binds) mkSetBinding addDescriptionsToMappings; + inherit (lib.nvim.dag) entryBefore entryAnywhere; cfg = config.vim.treesitter; usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp"; self = import ./treesitter.nix {inherit lib;}; - mappingDefinitions = self.options.vim.treesitter.mappings; mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; in { config = mkIf cfg.enable { - vim.startPlugins = - ["nvim-treesitter"] - ++ optional usingNvimCmp "cmp-treesitter"; + vim = { + startPlugins = ["nvim-treesitter"] ++ optional usingNvimCmp "cmp-treesitter"; - vim.autocomplete.sources = {"treesitter" = "[Treesitter]";}; + autocomplete.sources = {"treesitter" = "[Treesitter]";}; - # For some reason, using mkSetLuaBinding and putting the lua code does not work. It just selects the whole file. - # This works though, and if it ain't broke, don't fix it. - vim.maps.normal = mkSetBinding mappings.incrementalSelection.init ":lua require('nvim-treesitter.incremental_selection').init_selection()"; + maps = { + # HACK: Using mkSetLuaBinding and putting the lua code does not work for some reason: It just selects the whole file. + # This works though, and if it ain't broke, don't fix it. + normal = mkSetBinding mappings.incrementalSelection.init ":lua require('nvim-treesitter.incremental_selection').init_selection()"; - vim.maps.visualOnly = mkMerge [ - (mkSetBinding mappings.incrementalSelection.incrementByNode ":lua require('nvim-treesitter.incremental_selection').node_incremental()") - (mkSetBinding mappings.incrementalSelection.incrementByScope ":lua require('nvim-treesitter.incremental_selection').scope_incremental()") - (mkSetBinding mappings.incrementalSelection.decrementByNode ":lua require('nvim-treesitter.incremental_selection').node_decremental()") - ]; + visualOnly = mkMerge [ + (mkSetBinding mappings.incrementalSelection.incrementByNode ":lua require('nvim-treesitter.incremental_selection').node_incremental()") + (mkSetBinding mappings.incrementalSelection.incrementByScope ":lua require('nvim-treesitter.incremental_selection').scope_incremental()") + (mkSetBinding mappings.incrementalSelection.decrementByNode ":lua require('nvim-treesitter.incremental_selection').node_decremental()") + ]; + }; - # For some reason treesitter highlighting does not work on start if this is set before syntax on - vim.configRC.treesitter-fold = mkIf cfg.fold (nvim.dag.entryBefore ["basic"] '' - set foldmethod=expr - set foldexpr=nvim_treesitter#foldexpr() - set nofoldenable - ''); + # For some reason treesitter highlighting does not work on start if this is set before syntax on + configRC.treesitter-fold = mkIf cfg.fold (entryBefore ["basic"] '' + set foldmethod=expr + set foldexpr=nvim_treesitter#foldexpr() + set nofoldenable + ''); - vim.luaConfigRC.treesitter = nvim.dag.entryAnywhere '' - require'nvim-treesitter.configs'.setup { - highlight = { - enable = true, - disable = {}, - }, - - auto_install = false, - ensure_installed = {}, - - incremental_selection = { - enable = true, - keymaps = { - init_selection = false, - node_incremental = false, - scope_incremental = false, - node_decremental = false, + luaConfigRC.treesitter = entryAnywhere '' + require'nvim-treesitter.configs'.setup { + highlight = { + enable = true, + disable = {}, }, - }, - } - ''; + + auto_install = false, + ensure_installed = {}, + + incremental_selection = { + enable = true, + keymaps = { + init_selection = false, + node_incremental = false, + scope_incremental = false, + node_decremental = false, + }, + }, + } + ''; + }; }; } diff --git a/modules/treesitter/context.nix b/modules/treesitter/context.nix index d6859d4..8bb65b5 100644 --- a/modules/treesitter/context.nix +++ b/modules/treesitter/context.nix @@ -1,12 +1,16 @@ { - pkgs, config, lib, ... }: let - inherit (lib) mkEnableOption mkOption types mkIf nvim boolToString; + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) int bool str nullOr enum; + inherit (lib.modules) mkIf; + inherit (lib.trivial) boolToString; + inherit (lib.nvim.lua) nullString; + inherit (lib.nvim.dag) entryAnywhere; - treesitter = config.vim.treesitter; + inherit (config.vim) treesitter; cfg = treesitter.context; in { options.vim.treesitter.context = { @@ -14,37 +18,37 @@ in { maxLines = mkOption { description = "How many lines the window should span. Values <=0 mean no limit."; - type = types.int; + type = int; default = 0; }; minWindowHeight = mkOption { description = "Minimum editor window height to enable context. Values <= 0 mean no limit."; - type = types.int; + type = int; default = 0; }; lineNumbers = mkOption { description = ""; - type = types.bool; + type = bool; default = true; }; multilineThreshold = mkOption { description = "Maximum number of lines to collapse for a single context line."; - type = types.int; + type = int; default = 20; }; trimScope = mkOption { description = "Which context lines to discard if [](#opt-vim.treesitter.context.maxLines) is exceeded."; - type = types.enum ["inner" "outer"]; + type = enum ["inner" "outer"]; default = "outer"; }; mode = mkOption { description = "Line used to calculate context."; - type = types.enum ["cursor" "topline"]; + type = enum ["cursor" "topline"]; default = "cursor"; }; @@ -54,13 +58,13 @@ in { When separator is set, the context will only show up when there are at least 2 lines above cursorline. ''; - type = with types; nullOr str; + type = nullOr str; default = null; }; zindex = mkOption { description = "The Z-index of the context window."; - type = types.int; + type = int; default = 20; }; }; @@ -68,7 +72,7 @@ in { config = mkIf (treesitter.enable && cfg.enable) { vim.startPlugins = ["nvim-treesitter-context"]; - vim.luaConfigRC.treesitter-context = nvim.dag.entryAnywhere '' + vim.luaConfigRC.treesitter-context = entryAnywhere '' require'treesitter-context'.setup { enable = true, max_lines = ${toString cfg.maxLines}, @@ -77,7 +81,7 @@ in { multiline_threshold = ${toString cfg.multilineThreshold}, trim_scope = '${cfg.trimScope}', mode = '${cfg.mode}', - separator = ${nvim.lua.nullString cfg.separator}, + separator = ${nullString cfg.separator}, max_lines = ${toString cfg.zindex}, } ''; diff --git a/modules/treesitter/default.nix b/modules/treesitter/default.nix index 30d51d5..5520cfe 100644 --- a/modules/treesitter/default.nix +++ b/modules/treesitter/default.nix @@ -1,4 +1,4 @@ -{...}: { +{ imports = [ ./treesitter.nix ./context.nix diff --git a/modules/treesitter/treesitter.nix b/modules/treesitter/treesitter.nix index 413f303..feae8d7 100644 --- a/modules/treesitter/treesitter.nix +++ b/modules/treesitter/treesitter.nix @@ -1,29 +1,26 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkMappingOption mkOption types; + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.nvim.binds) mkMappingOption; + inherit (lib.types) listOf package; in { options.vim.treesitter = { enable = mkEnableOption "treesitter, also enabled automatically through language options"; - fold = mkEnableOption "fold with treesitter"; - autotagHtml = mkEnableOption "autoclose and rename html tag"; - - mappings = { - incrementalSelection = { - init = mkMappingOption "Init selection [treesitter]" "gnn"; - incrementByNode = mkMappingOption "Increment selection by node [treesitter]" "grn"; - incrementByScope = mkMappingOption "Increment selection by scope [treesitter]" "grc"; - decrementByNode = mkMappingOption "Decrement selection by node [treesitter]" "grm"; - }; - }; - grammars = mkOption { - type = with types; listOf package; + type = listOf package; default = []; description = '' List of treesitter grammars to install. For supported languages use the `vim.language..treesitter` option ''; }; + + mappings.incrementalSelection = { + init = mkMappingOption "Init selection [treesitter]" "gnn"; + incrementByNode = mkMappingOption "Increment selection by node [treesitter]" "grn"; + incrementByScope = mkMappingOption "Increment selection by scope [treesitter]" "grc"; + decrementByNode = mkMappingOption "Decrement selection by node [treesitter]" "grm"; + }; }; } From a7531186a87baac7a3807f5f725c27599b2ac48b Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 16 Mar 2024 16:25:30 +0300 Subject: [PATCH 046/193] modules/ui: switch to explicit lib calls --- modules/ui/borders/borders.nix | 13 +- modules/ui/borders/default.nix | 2 +- modules/ui/breadcrumbs/breadcrumbs.nix | 205 +++++++++--------- modules/ui/breadcrumbs/config.nix | 38 ++-- modules/ui/breadcrumbs/default.nix | 2 +- modules/ui/colorizer/colorizer.nix | 62 ++---- modules/ui/colorizer/config.nix | 12 +- modules/ui/colorizer/default.nix | 2 +- modules/ui/default.nix | 2 +- modules/ui/illuminate/config.nix | 5 +- modules/ui/illuminate/default.nix | 2 +- modules/ui/illuminate/illuminate.nix | 10 +- modules/ui/modes/config.nix | 6 +- modules/ui/modes/default.nix | 2 +- modules/ui/modes/modes.nix | 24 +- modules/ui/noice/config.nix | 6 +- modules/ui/noice/default.nix | 2 +- modules/ui/noice/noice.nix | 8 +- modules/ui/notifications/default.nix | 2 +- .../ui/notifications/nvim-notify/config.nix | 53 ++--- .../ui/notifications/nvim-notify/default.nix | 2 +- .../notifications/nvim-notify/nvim-notify.nix | 19 +- modules/ui/smartcolumn/config.nix | 31 +-- modules/ui/smartcolumn/default.nix | 2 +- modules/ui/smartcolumn/smartcolumn.nix | 11 +- 25 files changed, 251 insertions(+), 272 deletions(-) diff --git a/modules/ui/borders/borders.nix b/modules/ui/borders/borders.nix index 69d1ccd..fb767ce 100644 --- a/modules/ui/borders/borders.nix +++ b/modules/ui/borders/borders.nix @@ -3,7 +3,8 @@ lib, ... }: let - inherit (lib) mkOption mkEnableOption types; + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) enum; cfg = config.vim.ui.borders; @@ -13,10 +14,10 @@ in { enable = mkEnableOption "visible borders for most windows"; globalStyle = mkOption { - type = types.enum defaultStyles; + type = enum defaultStyles; default = "rounded"; description = '' - global border style to use + The global border style to use ''; }; @@ -26,14 +27,14 @@ in { enable = mkEnableOption "borders for the ${name} plugin" // {default = cfg.enable;}; style = mkOption { - type = types.enum (defaultStyles ++ lib.optionals (name != "which-key") ["shadow"]); + type = enum (defaultStyles ++ lib.optionals (name != "which-key") ["shadow"]); default = cfg.globalStyle; - description = "border style to use for the ${name} plugin"; + description = "The border style to use for the ${name} plugin"; }; }; in { # despite not having it listed in example configuration, which-key does support the rounded type - # additionall, it supports a "shadow" type that is similar to none but is of higher contrast + # additionally, it supports a "shadow" type that is similar to none but is of higher contrast which-key = mkPluginStyleOption "which-key"; lspsaga = mkPluginStyleOption "lspsaga"; nvim-cmp = mkPluginStyleOption "nvim-cmp"; diff --git a/modules/ui/borders/default.nix b/modules/ui/borders/default.nix index 526ac4e..38b02b8 100644 --- a/modules/ui/borders/default.nix +++ b/modules/ui/borders/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./borders.nix ]; diff --git a/modules/ui/breadcrumbs/breadcrumbs.nix b/modules/ui/breadcrumbs/breadcrumbs.nix index c979e39..68c2a9f 100644 --- a/modules/ui/breadcrumbs/breadcrumbs.nix +++ b/modules/ui/breadcrumbs/breadcrumbs.nix @@ -1,14 +1,15 @@ { - lib, config, + lib, ... }: let - inherit (lib) mkEnableOption mkOption types; + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) nullOr listOf enum bool str int; in { options.vim.ui.breadcrumbs = { - enable = lib.mkEnableOption "breadcrumbs"; + enable = mkEnableOption "breadcrumbs"; source = mkOption { - type = with types; nullOr (enum ["nvim-navic"]); # TODO: lspsaga and dropbar + type = nullOr (enum ["nvim-navic"]); # TODO: lspsaga and dropbar default = "nvim-navic"; description = '' The source to be used for breadcrumbs component. Null means no breadcrumbs. @@ -18,7 +19,7 @@ in { # maybe this should be an option to *disable* alwaysRender optionally but oh well # too late alwaysRender = mkOption { - type = types.bool; + type = bool; default = true; description = "Whether to always display the breadcrumbs component on winbar (always renders winbar)"; }; @@ -28,152 +29,152 @@ in { # this option is interpreted as null if mkEnableOption is used, and therefore cannot be converted to a string in config.nix useDefaultMappings = mkOption { - type = types.bool; + type = bool; default = true; description = "use default Navbuddy keybindings (disables user-specified keybinds)"; }; mappings = { close = mkOption { - type = types.str; + type = str; default = ""; description = "keybinding to close Navbuddy UI"; }; nextSibling = mkOption { - type = types.str; + type = str; default = "j"; description = "keybinding to navigate to the next sibling node"; }; previousSibling = mkOption { - type = types.str; + type = str; default = "k"; description = "keybinding to navigate to the previous sibling node"; }; parent = mkOption { - type = types.str; + type = str; default = "h"; description = "keybinding to navigate to the parent node"; }; children = mkOption { - type = types.str; + type = str; default = "h"; description = "keybinding to navigate to the child node"; }; root = mkOption { - type = types.str; + type = str; default = "0"; description = "keybinding to navigate to the root node"; }; visualName = mkOption { - type = types.str; + type = str; default = "v"; description = "visual selection of name"; }; visualScope = mkOption { - type = types.str; + type = str; default = "V"; description = "visual selection of scope"; }; yankName = mkOption { - type = types.str; + type = str; default = "y"; description = "yank the name to system clipboard"; }; yankScope = mkOption { - type = types.str; + type = str; default = "Y"; description = "yank the scope to system clipboard"; }; insertName = mkOption { - type = types.str; + type = str; default = "i"; description = "insert at start of name"; }; insertScope = mkOption { - type = types.str; + type = str; default = "I"; description = "insert at start of scope"; }; appendName = mkOption { - type = types.str; + type = str; default = "a"; description = "insert at end of name"; }; appendScope = mkOption { - type = types.str; + type = str; default = "A"; description = "insert at end of scope"; }; rename = mkOption { - type = types.str; + type = str; default = "r"; description = "rename the node"; }; delete = mkOption { - type = types.str; + type = str; default = "d"; description = "delete the node"; }; foldCreate = mkOption { - type = types.str; + type = str; default = "f"; description = "create a new fold"; }; foldDelete = mkOption { - type = types.str; + type = str; default = "F"; description = "delete the current fold"; }; comment = mkOption { - type = types.str; + type = str; default = "c"; description = "comment the node"; }; select = mkOption { - type = types.str; + type = str; default = ""; description = "goto selected symbol"; }; moveDown = mkOption { - type = types.str; + type = str; default = "J"; description = "move focused node down"; }; moveUp = mkOption { - type = types.str; + type = str; default = "K"; description = "move focused node up"; }; telescope = mkOption { - type = types.str; + type = str; default = "t"; description = "fuzzy finder at current level"; }; help = mkOption { - type = types.str; + type = str; default = "g?"; description = "open mapping help window"; }; @@ -185,13 +186,13 @@ in { border = mkOption { # TODO: let this type accept a custom string - type = types.enum ["single" "rounded" "double" "solid" "none"]; + type = enum ["single" "rounded" "double" "solid" "none"]; default = config.vim.ui.borders.globalStyle; description = "border style to use"; }; scrolloff = mkOption { - type = with types; nullOr int; + type = nullOr int; default = null; description = "Scrolloff value within navbuddy window"; }; @@ -209,7 +210,7 @@ in { border = mkOption { # TODO: let this type accept a custom string - type = with types; nullOr (enum ["single" "rounded" "double" "solid" "none"]); + type = nullOr (enum ["single" "rounded" "double" "solid" "none"]); default = config.vim.ui.borders.globalStyle; description = "border style to use for the left section of Navbuddy UI"; }; @@ -227,7 +228,7 @@ in { border = mkOption { # TODO: let this type accept a custom string - type = with types; nullOr (enum ["single" "rounded" "double" "solid" "none"]); + type = nullOr (enum ["single" "rounded" "double" "solid" "none"]); default = config.vim.ui.borders.globalStyle; description = "border style to use for the middle section of Navbuddy UI"; }; @@ -238,13 +239,13 @@ in { right = { border = mkOption { # TODO: let this type accept a custom string - type = with types; nullOr (enum ["single" "rounded" "double" "solid" "none"]); + type = nullOr (enum ["single" "rounded" "double" "solid" "none"]); default = config.vim.ui.borders.globalStyle; description = "border style to use for the right section of Navbuddy UI"; }; preview = mkOption { - type = types.enum ["leaf" "always" "never"]; + type = enum ["leaf" "always" "never"]; default = "leaf"; description = "display mode of the preview on the right section"; }; @@ -256,19 +257,19 @@ in { enable = mkEnableOption "node markers"; icons = { leaf = mkOption { - type = types.str; + type = str; default = " "; description = ""; }; leafSelected = mkOption { - type = types.str; + type = str; default = " → "; description = ""; }; branch = mkOption { - type = types.str; + type = str; default = " "; description = ""; }; @@ -277,13 +278,13 @@ in { lsp = { autoAttach = mkOption { - type = types.bool; + type = bool; default = true; description = "Whether to attach to LSP server manually"; }; preference = mkOption { - type = with types; nullOr (listOf str); + type = nullOr (listOf str); default = null; description = "list of lsp server names in order of preference"; }; @@ -291,25 +292,25 @@ in { sourceBuffer = { followNode = mkOption { - type = types.bool; + type = bool; default = true; description = "keep the current node in focus on the source buffer"; }; highlight = mkOption { - type = types.bool; + type = bool; default = true; description = "highlight the currently focused node"; }; reorient = mkOption { - type = types.enum ["smart" "top" "mid" "none"]; + type = enum ["smart" "top" "mid" "none"]; default = "smart"; description = "reorient buffer after changing nodes"; }; scrolloff = mkOption { - type = with types; nullOr int; + type = nullOr int; default = null; description = "scrolloff value when navbuddy is open"; }; @@ -319,159 +320,159 @@ in { # alas, I am not a nix wizard icons = { file = mkOption { - type = types.str; + type = str; default = "󰈙 "; - description = ""; + description = "File icon"; }; module = mkOption { - type = types.str; + type = str; default = " "; - description = ""; + description = "Module icon"; }; namespace = mkOption { - type = types.str; + type = str; default = "󰌗 "; - description = ""; + description = "Namespace icon"; }; package = mkOption { - type = types.str; - default = " "; - description = ""; + type = str; + default = " "; + description = "Package icon"; }; class = mkOption { - type = types.str; + type = str; default = "󰌗 "; - description = ""; + description = "Class icon"; }; property = mkOption { - type = types.str; - default = " "; - description = ""; + type = str; + default = " "; + description = "Property icon"; }; field = mkOption { - type = types.str; + type = str; default = " "; - description = ""; + description = "Field icon"; }; constructor = mkOption { - type = types.str; + type = str; default = " "; - description = ""; + description = "Constructor icon"; }; enum = mkOption { - type = types.str; + type = str; default = "󰕘"; - description = ""; + description = "Enum icon"; }; interface = mkOption { - type = types.str; + type = str; default = "󰕘"; - description = ""; + description = "Interface icon"; }; function = mkOption { - type = types.str; + type = str; default = "󰊕 "; - description = ""; + description = "Function icon"; }; variable = mkOption { - type = types.str; - default = "󰆧 "; - description = ""; + type = str; + default = "󰫧 "; + description = "Variable icon"; }; constant = mkOption { - type = types.str; + type = str; default = "󰏿 "; - description = ""; + description = "Constant icon"; }; string = mkOption { - type = types.str; - default = " "; - description = ""; + type = str; + default = " "; + description = "String icon"; }; number = mkOption { - type = types.str; + type = str; default = "󰎠 "; - description = ""; + description = "Number icon"; }; boolean = mkOption { - type = types.str; - default = "◩ "; - description = ""; + type = str; + default = " "; + description = "Boolean icon"; }; array = mkOption { - type = types.str; + type = str; default = "󰅪 "; - description = ""; + description = "Array icon"; }; object = mkOption { - type = types.str; + type = str; default = "󰅩 "; - description = ""; + description = "Object icon"; }; method = mkOption { - type = types.str; + type = str; default = "󰆧 "; - description = ""; + description = "Method icon"; }; key = mkOption { - type = types.str; + type = str; default = "󰌋 "; - description = ""; + description = "Key icon"; }; null = mkOption { - type = types.str; + type = str; default = "󰟢 "; - description = ""; + description = "Null icon"; }; enumMember = mkOption { - type = types.str; + type = str; default = "󰕘 "; - description = ""; + description = "Enum member icon"; }; struct = mkOption { - type = types.str; + type = str; default = "󰌗 "; - description = ""; + description = "Struct icon"; }; event = mkOption { - type = types.str; + type = str; default = " "; - description = ""; + description = "Event icon"; }; operator = mkOption { - type = types.str; + type = str; default = "󰆕 "; - description = ""; + description = "Operator icon"; }; typeParameter = mkOption { - type = types.str; + type = str; default = "󰊄 "; - description = ""; + description = "Type parameter icon"; }; }; }; diff --git a/modules/ui/breadcrumbs/config.nix b/modules/ui/breadcrumbs/config.nix index 22de56d..5afda30 100644 --- a/modules/ui/breadcrumbs/config.nix +++ b/modules/ui/breadcrumbs/config.nix @@ -3,11 +3,15 @@ lib, ... }: let - inherit (lib) optionalString boolToString mkIf optionals; + inherit (lib.modules) mkIf; + inherit (lib.strings) optionalString; + inherit (lib.trivial) boolToString; + inherit (lib.lists) optionals; inherit (lib.nvim.lua) nullString; + inherit (lib.nvim.dag) entryAfter; cfg = config.vim.ui.breadcrumbs; - nb = cfg.navbuddy; + nbcfg = cfg.navbuddy; in { config = mkIf cfg.enable { vim.startPlugins = @@ -26,7 +30,7 @@ in { "nvim-navic" ]; - vim.luaConfigRC.breadcrumbs = lib.nvim.dag.entryAfter ["lspconfig"] '' + vim.luaConfigRC.breadcrumbs = entryAfter ["lspconfig"] '' ${optionalString (cfg.source == "nvim-navic") '' local navic = require("nvim-navic") @@ -40,46 +44,46 @@ in { local actions = require("nvim-navbuddy.actions") navbuddy.setup { window = { - border = "${nb.window.border}", -- "rounded", "double", "solid", "none" + border = "${nbcfg.window.border}", -- "rounded", "double", "solid", "none" size = "60%", position = "50%", - scrolloff = ${(nullString nb.window.scrolloff)}, + scrolloff = ${(nullString nbcfg.window.scrolloff)}, sections = { left = { size = "20%", - border = ${(nullString nb.window.sections.left.border)}, + border = ${(nullString nbcfg.window.sections.left.border)}, }, mid = { size = "40%", - border = ${(nullString nb.window.sections.mid.border)}, + border = ${(nullString nbcfg.window.sections.mid.border)}, }, right = { - border = ${(nullString nb.window.sections.right.border)}, + border = ${(nullString nbcfg.window.sections.right.border)}, preview = "leaf", } }, }, node_markers = { - enabled = ${boolToString nb.nodeMarkers.enable}, + enabled = ${boolToString nbcfg.nodeMarkers.enable}, icons = { - leaf = "${nb.nodeMarkers.icons.leaf}", - leaf_selected = "${nb.nodeMarkers.icons.leafSelected}", - branch = "${nb.nodeMarkers.icons.branch}", + leaf = "${nbcfg.nodeMarkers.icons.leaf}", + leaf_selected = "${nbcfg.nodeMarkers.icons.leafSelected}", + branch = "${nbcfg.nodeMarkers.icons.branch}", }, }, lsp = { - auto_attach = ${boolToString nb.lsp.autoAttach}, + auto_attach = ${boolToString nbcfg.lsp.autoAttach}, -- preference = nil, -- TODO: convert list to lua table if not null }, source_buffer = { - follow_node = ${boolToString nb.sourceBuffer.followNode}, - highlight = ${boolToString nb.sourceBuffer.highlight}, - reorient = "${nb.sourceBuffer.reorient}", - scrolloff = ${nullString nb.sourceBuffer.scrolloff} + follow_node = ${boolToString nbcfg.sourceBuffer.followNode}, + highlight = ${boolToString nbcfg.sourceBuffer.highlight}, + reorient = "${nbcfg.sourceBuffer.reorient}", + scrolloff = ${nullString nbcfg.sourceBuffer.scrolloff} }, icons = { diff --git a/modules/ui/breadcrumbs/default.nix b/modules/ui/breadcrumbs/default.nix index 02c6351..50feefc 100644 --- a/modules/ui/breadcrumbs/default.nix +++ b/modules/ui/breadcrumbs/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./breadcrumbs.nix diff --git a/modules/ui/colorizer/colorizer.nix b/modules/ui/colorizer/colorizer.nix index 8497e04..de3281c 100644 --- a/modules/ui/colorizer/colorizer.nix +++ b/modules/ui/colorizer/colorizer.nix @@ -1,15 +1,12 @@ -{ - config, - lib, - ... -}: let - inherit (lib) mkEnableOption mkOption types; +{lib, ...}: let + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) attrsOf attrs bool enum; in { options.vim.ui.colorizer = { - enable = mkEnableOption "nvim-colorizer.lua for color highlighting"; + enable = mkEnableOption "color highlighting [nvim-colorizer.lua]"; filetypes = mkOption { - type = with types; attrsOf attrs; + type = attrsOf attrs; default = { css = {}; scss = {}; @@ -18,77 +15,54 @@ in { }; options = { + alwaysUpdate = mkEnableOption "updating color values even if buffer is not focused, like when using cmp_menu, cmp_docs"; + rgb = mkOption { - type = types.bool; + type = bool; default = true; description = "#RGB hex codes"; }; rrggbb = mkOption { - type = types.bool; + type = bool; default = true; description = "#RRGGBB hex codes"; }; names = mkOption { - type = types.bool; + type = bool; default = true; description = ''"Name" codes such as "Blue"''; }; rgb_fn = mkOption { - type = types.bool; + type = bool; default = false; description = "CSS rgb() and rgba() functions"; }; rrggbbaa = mkOption { - type = types.bool; + type = bool; default = false; description = "#RRGGBBAA hex codes"; }; hsl_fn = mkOption { - type = types.bool; + type = bool; default = false; description = "CSS hsl() and hsla() functions"; }; - css = mkOption { - type = types.bool; - default = false; - description = "Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB"; - }; - - css_fn = mkOption { - type = types.bool; - default = false; - description = "Enable all CSS *functions*: rgb_fn, hsl_fn"; - }; - mode = mkOption { - type = types.enum ["foreground" "background"]; + type = enum ["foreground" "background"]; default = "background"; description = "Set the display mode"; }; - tailwind = mkOption { - type = types.bool; - default = false; - description = "Enable tailwind colors"; - }; - - sass = mkOption { - type = types.bool; - default = false; - description = "Enable sass colors"; - }; - - alwaysUpdate = mkOption { - type = types.bool; - default = false; - description = "Update color values even if buffer is not focused, like when using cmp_menu, cmp_docs"; - }; + tailwind = mkEnableOption "tailwind colors"; + sass = mkEnableOption "sass colors"; + css = mkEnableOption "all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB"; + css_fn = mkEnableOption "all CSS *functions*: rgb_fn, hsl_fn"; }; }; } diff --git a/modules/ui/colorizer/config.nix b/modules/ui/colorizer/config.nix index 2706499..a21644f 100644 --- a/modules/ui/colorizer/config.nix +++ b/modules/ui/colorizer/config.nix @@ -1,10 +1,12 @@ { - pkgs, config, lib, ... }: let - inherit (lib) mkIf nvim boolToString; + inherit (lib.modules) mkIf; + inherit (lib.trivial) boolToString; + inherit (lib.nvim.lua) attrsetToLuaTable; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.ui.colorizer; in { @@ -13,14 +15,14 @@ in { "nvim-colorizer-lua" ]; - vim.luaConfigRC.colorizer = nvim.dag.entryAnywhere '' + vim.luaConfigRC.colorizer = entryAnywhere '' require('colorizer').setup({ - filetypes = ${nvim.lua.attrsetToLuaTable cfg.filetypes}, + filetypes = ${attrsetToLuaTable cfg.filetypes}, user_default_options = { RGB = ${boolToString cfg.options.rgb}; RRGGBB = ${boolToString cfg.options.rrggbb}; - names = ${boolToString cfg.options.names}; RRGGBBAA = ${boolToString cfg.options.rrggbbaa}; + names = ${boolToString cfg.options.names}; rgb_fn = ${boolToString cfg.options.rgb_fn}; hsl_fn = ${boolToString cfg.options.hsl_fn}; css = ${boolToString cfg.options.css}; diff --git a/modules/ui/colorizer/default.nix b/modules/ui/colorizer/default.nix index 3b5b491..ef88180 100644 --- a/modules/ui/colorizer/default.nix +++ b/modules/ui/colorizer/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./colorizer.nix ./config.nix diff --git a/modules/ui/default.nix b/modules/ui/default.nix index bbcb9d2..262cdbb 100644 --- a/modules/ui/default.nix +++ b/modules/ui/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./noice ./modes diff --git a/modules/ui/illuminate/config.nix b/modules/ui/illuminate/config.nix index 4377622..6d08c76 100644 --- a/modules/ui/illuminate/config.nix +++ b/modules/ui/illuminate/config.nix @@ -3,14 +3,15 @@ lib, ... }: let - inherit (lib) mkIf nvim; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.ui.illuminate; in { config = mkIf cfg.enable { vim.startPlugins = ["vim-illuminate"]; - vim.luaConfigRC.vim-illuminate = nvim.dag.entryAnywhere '' + vim.luaConfigRC.vim-illuminate = entryAnywhere '' require('illuminate').configure({ filetypes_denylist = { 'dirvish', diff --git a/modules/ui/illuminate/default.nix b/modules/ui/illuminate/default.nix index 366bb7b..03efe4c 100644 --- a/modules/ui/illuminate/default.nix +++ b/modules/ui/illuminate/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./illuminate.nix diff --git a/modules/ui/illuminate/illuminate.nix b/modules/ui/illuminate/illuminate.nix index 29426f9..c9c5d2f 100644 --- a/modules/ui/illuminate/illuminate.nix +++ b/modules/ui/illuminate/illuminate.nix @@ -1,11 +1,7 @@ -{ - config, - lib, - ... -}: let - inherit (lib) mkEnableOption; +{lib, ...}: let + inherit (lib.options) mkEnableOption; in { options.vim.ui.illuminate = { - enable = mkEnableOption "vim-illuminate: automatically highlight other uses of the word under the cursor"; + enable = mkEnableOption "automatically highlight other uses of the word under the cursor [vim-illuminate]"; }; } diff --git a/modules/ui/modes/config.nix b/modules/ui/modes/config.nix index d8483af..25ee337 100644 --- a/modules/ui/modes/config.nix +++ b/modules/ui/modes/config.nix @@ -3,7 +3,9 @@ lib, ... }: let - inherit (lib) mkIf nvim boolToString; + inherit (lib.modules) mkIf; + inherit (lib.trivial) boolToString; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.ui.modes-nvim; in { @@ -12,7 +14,7 @@ in { "modes-nvim" ]; - vim.luaConfigRC.modes-nvim = nvim.dag.entryAnywhere '' + vim.luaConfigRC.modes-nvim = entryAnywhere '' require('modes').setup({ set_cursorline = ${boolToString cfg.setCursorline}, line_opacity = { diff --git a/modules/ui/modes/default.nix b/modules/ui/modes/default.nix index 8c668de..4fb9652 100644 --- a/modules/ui/modes/default.nix +++ b/modules/ui/modes/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./modes.nix ./config.nix diff --git a/modules/ui/modes/modes.nix b/modules/ui/modes/modes.nix index bfa80b0..e49251a 100644 --- a/modules/ui/modes/modes.nix +++ b/modules/ui/modes/modes.nix @@ -1,33 +1,31 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkOption types; + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) str; in { options.vim.ui.modes-nvim = { - enable = mkEnableOption "modes.nvim's prismatic line decorations"; - - setCursorline = mkOption { - type = types.bool; - description = "Set a colored cursorline on current line"; - default = false; # looks ugly, disabled by default - }; - + enable = mkEnableOption "prismatic line decorations [modes.nvim]"; + setCursorline = mkEnableOption "colored cursorline on current line"; colors = { copy = mkOption { - type = types.str; + type = str; description = "The #RRGGBB color code for the visual mode highlights"; default = "#f5c359"; }; + delete = mkOption { - type = types.str; + type = str; description = "The #RRGGBB color code for the visual mode highlights"; default = "#c75c6a"; }; + insert = mkOption { - type = types.str; + type = str; description = "The #RRGGBB color code for the visual mode highlights"; default = "#78ccc5"; }; + visual = mkOption { - type = types.str; + type = str; description = "The #RRGGBB color code for the visual mode highlights"; default = "#9745be"; }; diff --git a/modules/ui/noice/config.nix b/modules/ui/noice/config.nix index 2355497..63c4f2b 100644 --- a/modules/ui/noice/config.nix +++ b/modules/ui/noice/config.nix @@ -3,7 +3,9 @@ lib, ... }: let - inherit (lib) mkIf nvim boolToString; + inherit (lib.modules) mkIf; + inherit (lib.trivial) boolToString; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.ui.noice; in { @@ -13,7 +15,7 @@ in { "nui-nvim" ]; - vim.luaConfigRC.noice-nvim = nvim.dag.entryAnywhere '' + vim.luaConfigRC.noice-nvim = entryAnywhere '' require("noice").setup({ lsp = { override = { diff --git a/modules/ui/noice/default.nix b/modules/ui/noice/default.nix index e808738..24f0ab6 100644 --- a/modules/ui/noice/default.nix +++ b/modules/ui/noice/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./noice.nix ./config.nix diff --git a/modules/ui/noice/noice.nix b/modules/ui/noice/noice.nix index 7afe82c..df4ce85 100644 --- a/modules/ui/noice/noice.nix +++ b/modules/ui/noice/noice.nix @@ -1,11 +1,7 @@ -{ - config, - lib, - ... -}: let +{lib, ...}: let inherit (lib) mkEnableOption; in { options.vim.ui.noice = { - enable = mkEnableOption "noice-nvim UI modification library"; + enable = mkEnableOption "UI modification library [noice.nvim]"; }; } diff --git a/modules/ui/notifications/default.nix b/modules/ui/notifications/default.nix index aa5a73b..d1bd989 100644 --- a/modules/ui/notifications/default.nix +++ b/modules/ui/notifications/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./nvim-notify ]; diff --git a/modules/ui/notifications/nvim-notify/config.nix b/modules/ui/notifications/nvim-notify/config.nix index d291366..c2c4991 100644 --- a/modules/ui/notifications/nvim-notify/config.nix +++ b/modules/ui/notifications/nvim-notify/config.nix @@ -3,37 +3,40 @@ lib, ... }: let - inherit (lib) mkIf nvim; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.notify.nvim-notify; in { config = mkIf cfg.enable { - vim.startPlugins = ["nvim-notify"]; + vim = { + startPlugins = ["nvim-notify"]; - vim.luaConfigRC.nvim-notify = nvim.dag.entryAnywhere '' - require('notify').setup { - stages = "${cfg.stages}", - timeout = ${toString cfg.timeout}, - background_colour = "${cfg.background_colour}", - position = "${cfg.position}", - icons = { - ERROR = "${cfg.icons.ERROR}", - WARN = "${cfg.icons.WARN}", - INFO = "${cfg.icons.INFO}", - DEBUG = "${cfg.icons.DEBUG}", - TRACE = "${cfg.icons.TRACE}", - }, - } + luaConfigRC.nvim-notify = entryAnywhere '' + require('notify').setup { + stages = "${cfg.stages}", + timeout = ${toString cfg.timeout}, + background_colour = "${cfg.background_colour}", + position = "${cfg.position}", + icons = { + ERROR = "${cfg.icons.ERROR}", + WARN = "${cfg.icons.WARN}", + INFO = "${cfg.icons.INFO}", + DEBUG = "${cfg.icons.DEBUG}", + TRACE = "${cfg.icons.TRACE}", + }, + } - -- required to fix offset_encoding errors - local notify = vim.notify - vim.notify = function(msg, ...) - if msg:match("warning: multiple different client offset_encodings") then - return + -- required to fix offset_encoding errors + local notify = vim.notify + vim.notify = function(msg, ...) + if msg:match("warning: multiple different client offset_encodings") then + return + end + + notify(msg, ...) end - - notify(msg, ...) - end - ''; + ''; + }; }; } diff --git a/modules/ui/notifications/nvim-notify/default.nix b/modules/ui/notifications/nvim-notify/default.nix index 0d4c39d..d14648b 100644 --- a/modules/ui/notifications/nvim-notify/default.nix +++ b/modules/ui/notifications/nvim-notify/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./nvim-notify.nix diff --git a/modules/ui/notifications/nvim-notify/nvim-notify.nix b/modules/ui/notifications/nvim-notify/nvim-notify.nix index 0374114..ab78d45 100644 --- a/modules/ui/notifications/nvim-notify/nvim-notify.nix +++ b/modules/ui/notifications/nvim-notify/nvim-notify.nix @@ -1,38 +1,35 @@ -{ - config, - lib, - ... -}: let - inherit (lib) mkEnableOption mkOption types; +{lib, ...}: let + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) enum int str attrsOf; in { options.vim.notify.nvim-notify = { enable = mkEnableOption "nvim-notify notifications"; stages = mkOption { - type = types.enum ["fade_in_slide_out" "fade_in" "slide_out" "none"]; + type = enum ["fade_in_slide_out" "fade_in" "slide_out" "none"]; default = "fade_in_slide_out"; description = "The stages of the notification"; }; timeout = mkOption { - type = types.int; + type = int; default = 1000; description = "The timeout of the notification"; }; background_colour = mkOption { - type = types.str; + type = str; default = "#000000"; description = "The background colour of the notification"; }; position = mkOption { - type = types.enum ["top_left" "top_right" "bottom_left" "bottom_right"]; + type = enum ["top_left" "top_right" "bottom_left" "bottom_right"]; default = "top_right"; description = "The position of the notification"; }; icons = mkOption { - type = types.attrsOf types.str; + type = attrsOf str; description = "The icons of the notification"; default = { ERROR = ""; diff --git a/modules/ui/smartcolumn/config.nix b/modules/ui/smartcolumn/config.nix index 5cf7b74..3f4ae05 100644 --- a/modules/ui/smartcolumn/config.nix +++ b/modules/ui/smartcolumn/config.nix @@ -1,26 +1,27 @@ { - pkgs, config, lib, ... }: let - inherit (lib) mkIf nvim concatStringsSep; - + inherit (lib.modules) mkIf; + inherit (lib.strings) concatStringsSep; + inherit (lib.nvim.lua) attrsetToLuaTable; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.ui.smartcolumn; in { config = mkIf cfg.enable { - vim.startPlugins = [ - "smartcolumn" - ]; + vim = { + startPlugins = ["smartcolumn"]; - vim.luaConfigRC.smartcolumn = nvim.dag.entryAnywhere '' - require("smartcolumn").setup({ - colorcolumn = "${toString cfg.showColumnAt}", - -- { "help", "text", "markdown", "NvimTree", "alpha"}, - disabled_filetypes = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.disabledFiletypes)} }, - custom_colorcolumn = ${nvim.lua.attrsetToLuaTable cfg.columnAt.languages}, - scope = "file", - }) - ''; + luaConfigRC.smartcolumn = entryAnywhere '' + require("smartcolumn").setup({ + colorcolumn = "${toString cfg.showColumnAt}", + -- { "help", "text", "markdown", "NvimTree", "alpha"}, + disabled_filetypes = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.disabledFiletypes)} }, + custom_colorcolumn = ${attrsetToLuaTable cfg.columnAt.languages}, + scope = "file", + }) + ''; + }; }; } diff --git a/modules/ui/smartcolumn/default.nix b/modules/ui/smartcolumn/default.nix index 2169b22..baa85ba 100644 --- a/modules/ui/smartcolumn/default.nix +++ b/modules/ui/smartcolumn/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./smartcolumn.nix ./config.nix diff --git a/modules/ui/smartcolumn/smartcolumn.nix b/modules/ui/smartcolumn/smartcolumn.nix index a105463..fe578be 100644 --- a/modules/ui/smartcolumn/smartcolumn.nix +++ b/modules/ui/smartcolumn/smartcolumn.nix @@ -1,17 +1,18 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkOption types literalExpression; + inherit (lib.options) mkOption mkEnableOption literalExpression; + inherit (lib.types) attrsOf either nullOr listOf int str submodule; in { options.vim.ui.smartcolumn = { enable = mkEnableOption "line length indicator"; showColumnAt = mkOption { - type = types.nullOr types.int; + type = nullOr int; default = 120; description = "The position at which the column will be displayed. Set to null to disable"; }; disabledFiletypes = mkOption { - type = types.listOf types.str; + type = listOf str; default = ["help" "text" "markdown" "NvimTree" "alpha"]; description = "The filetypes smartcolumn will be disabled for."; }; @@ -19,8 +20,8 @@ in { columnAt = { languages = mkOption { description = "The position at which smart column should be displayed for each individual buffer type"; - type = types.submodule { - freeformType = with types; attrsOf (either int (listOf int)); + type = submodule { + freeformType = attrsOf (either int (listOf int)); }; example = literalExpression '' From 974bfcc78e346ed8dc1c5e9e8a55d3131fc00b65 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Sat, 23 Mar 2024 20:14:39 -0400 Subject: [PATCH 047/193] treewide: make lib calls explicit --- lib/dag.nix | 21 +- lib/languages.nix | 25 +- lib/lua.nix | 46 +-- lib/types/languages.nix | 8 +- lib/vim.nix | 4 +- modules/basic/config.nix | 9 +- modules/basic/module.nix | 60 ++-- modules/completion/nvim-cmp/nvim-cmp.nix | 4 +- modules/core/default.nix | 74 ++--- .../dashboard-nvim/dashboard-nvim.nix | 2 +- modules/filetree/nvimtree/config.nix | 2 +- modules/filetree/nvimtree/nvimtree.nix | 275 +++++++++--------- modules/languages/bash/bash.nix | 13 +- modules/languages/bash/config.nix | 7 +- modules/languages/clang.nix | 12 +- modules/languages/nix.nix | 20 +- modules/languages/rust.nix | 26 +- modules/languages/sql.nix | 16 +- modules/languages/svelte.nix | 20 +- modules/languages/tidal/config.nix | 2 +- modules/languages/tidal/tidal.nix | 7 +- modules/languages/ts.nix | 20 +- modules/lsp/config.nix | 6 +- modules/lsp/null-ls/config.nix | 10 +- modules/rich-presence/neocord/config.nix | 10 +- modules/rich-presence/neocord/neocord.nix | 40 +-- modules/ui/borders/borders.nix | 3 +- modules/ui/noice/noice.nix | 2 +- .../utility/binds/cheatsheet/cheatsheet.nix | 2 +- modules/utility/binds/cheatsheet/config.nix | 5 +- modules/utility/ccc/ccc.nix | 3 +- modules/utility/ccc/config.nix | 9 +- modules/utility/diffview/config.nix | 6 +- modules/utility/diffview/diffview.nix | 2 +- .../utility/gestures/gesture-nvim/config.nix | 6 +- .../gestures/gesture-nvim/gesture-nvim.nix | 3 +- modules/utility/icon-picker/config.nix | 5 +- modules/utility/icon-picker/icon-picker.nix | 2 +- modules/utility/motion/hop/config.nix | 6 +- modules/utility/motion/hop/hop.nix | 3 +- modules/utility/motion/leap/config.nix | 6 +- modules/utility/motion/leap/leap.nix | 13 +- modules/utility/preview/glow/config.nix | 8 +- modules/utility/preview/glow/glow.nix | 4 +- .../preview/markdown-preview/config.nix | 8 +- .../markdown-preview/markdown-preview.nix | 19 +- modules/utility/surround/config.nix | 6 +- modules/utility/surround/surround.nix | 28 +- modules/utility/telescope/config.nix | 8 +- modules/utility/telescope/telescope.nix | 3 +- modules/utility/wakatime/config.nix | 5 +- modules/utility/wakatime/vim-wakatime.nix | 5 +- modules/visuals/config.nix | 18 +- modules/visuals/fidget/config.nix | 9 +- modules/visuals/fidget/fidget.nix | 114 ++++---- modules/visuals/visuals.nix | 35 ++- 56 files changed, 589 insertions(+), 496 deletions(-) diff --git a/lib/dag.nix b/lib/dag.nix index 0b2dfc4..ba4d81c 100644 --- a/lib/dag.nix +++ b/lib/dag.nix @@ -8,13 +8,16 @@ # - the addition of the function `entryBefore` indicating a "wanted # by" relationship. {lib}: let - inherit (lib) all filterAttrs nvim mapAttrs toposort; + inherit (builtins) isAttrs attrValues attrNames elem all; + inherit (lib.attrsets) filterAttrs mapAttrs; + inherit (lib.lists) toposort; + inherit (lib.nvim.dag) isEntry entryBetween; in { empty = {}; isEntry = e: e ? data && e ? after && e ? before; isDag = dag: - builtins.isAttrs dag && all nvim.dag.isEntry (builtins.attrValues dag); + isAttrs dag && all isEntry (attrValues dag); /* Takes an attribute set containing entries built by entryAnywhere, @@ -76,8 +79,8 @@ in { */ topoSort = dag: let dagBefore = dag: name: - builtins.attrNames - (filterAttrs (_n: v: builtins.elem name v.before) dag); + attrNames + (filterAttrs (_n: v: elem name v.before) dag); normalizedDag = mapAttrs (n: v: { name = n; @@ -85,8 +88,8 @@ in { after = v.after ++ dagBefore dag n; }) dag; - before = a: b: builtins.elem a.name b.after; - sorted = toposort before (builtins.attrValues normalizedDag); + before = a: b: elem a.name b.after; + sorted = toposort before (attrValues normalizedDag); in if sorted ? result then { @@ -100,8 +103,8 @@ in { entryBetween = before: after: data: {inherit data before after;}; # Create a DAG entry with no particular dependency information. - entryAnywhere = nvim.dag.entryBetween [] []; + entryAnywhere = entryBetween [] []; - entryAfter = nvim.dag.entryBetween []; - entryBefore = before: nvim.dag.entryBetween before []; + entryAfter = entryBetween []; + entryBefore = before: entryBetween before []; } diff --git a/lib/languages.nix b/lib/languages.nix index 18cfc37..e47202e 100644 --- a/lib/languages.nix +++ b/lib/languages.nix @@ -1,32 +1,37 @@ # From home-manager: https://github.com/nix-community/home-manager/blob/master/modules/lib/booleans.nix -{lib}: { +{lib}: let + inherit (builtins) isString getAttr; + inherit (lib.options) mkOption; + inherit (lib.attrsets) listToAttrs; + inherit (lib.types) bool; +in { # Converts a boolean to a yes/no string. This is used in lots of # configuration formats. diagnosticsToLua = { lang, config, - diagnostics, + diagnosticsProviders, }: - lib.listToAttrs + listToAttrs (map (v: let type = - if builtins.isString v + if isString v then v - else builtins.getAttr v.type; + else getAttr v.type; package = - if builtins.isString v - then diagnostics.${type}.package + if isString v + then diagnosticsProviders.${type}.package else v.package; in { name = "${lang}-diagnostics-${type}"; - value = diagnostics.${type}.nullConfig package; + value = diagnosticsProviders.${type}.nullConfig package; }) config); mkEnable = desc: - lib.mkOption { + mkOption { description = "Turn on ${desc} for enabled languages by default"; - type = lib.types.bool; + type = bool; default = false; }; } diff --git a/lib/lua.nix b/lib/lua.nix index 708b464..d7dd982 100644 --- a/lib/lua.nix +++ b/lib/lua.nix @@ -1,7 +1,9 @@ # Helpers for converting values to lua {lib}: let - inherit (lib) mapAttrsToList filterAttrs concatStringsSep concatMapStringsSep stringToCharacters boolToString; - inherit (builtins) hasAttr head throw typeOf; + inherit (builtins) hasAttr head throw typeOf isList isAttrs isBool isInt isString isPath isFloat toJSON; + inherit (lib.attrsets) mapAttrsToList filterAttrs; + inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters; + inherit (lib.trivial) boolToString; in rec { # Convert a null value to lua's nil nullString = value: @@ -11,29 +13,29 @@ in rec { # convert an expression to lua expToLua = exp: - if builtins.isList exp + if isList exp then listToLuaTable exp # if list, convert to lua table - else if builtins.isAttrs exp + else if isAttrs exp then attrsetToLuaTable exp # if attrs, convert to table - else if builtins.isBool exp - then lib.boolToString exp # if bool, convert to string - else if builtins.isInt exp - then builtins.toString exp # if int, convert to string + else if isBool exp + then boolToString exp # if bool, convert to string + else if isInt exp + then toString exp # if int, convert to string else if exp == null then "nil" - else (builtins.toJSON exp); # otherwise jsonify the value and print as is + else (toJSON exp); # otherwise jsonify the value and print as is # convert list to a lua table listToLuaTable = list: - "{ " + (builtins.concatStringsSep ", " (map expToLua list)) + " }"; + "{ " + (concatStringsSep ", " (map expToLua list)) + " }"; # convert attrset to a lua table attrsetToLuaTable = attrset: "{ " + ( - builtins.concatStringsSep ", " + concatStringsSep ", " ( - lib.mapAttrsToList ( + mapAttrsToList ( name: value: name + " = " @@ -44,10 +46,10 @@ in rec { ) + " }"; # Convert a list of lua expressions to a lua table. The difference to listToLuaTable is that the elements here are expected to be lua expressions already, whereas listToLuaTable converts from nix types to lua first - luaTable = items: ''{${builtins.concatStringsSep "," items}}''; + luaTable = items: ''{${concatStringsSep "," items}}''; toLuaObject = args: - if builtins.isAttrs args + if isAttrs args then if hasAttr "__raw" args then args.__raw @@ -68,19 +70,19 @@ in rec { ) args))) + "}" - else if builtins.isList args + else if isList args then "{" + concatMapStringsSep "," toLuaObject args + "}" - else if builtins.isString args + else if isString args then # This should be enough! - builtins.toJSON args - else if builtins.isPath args - then builtins.toJSON (toString args) - else if builtins.isBool args + toJSON args + else if isPath args + then toJSON (toString args) + else if isBool args then "${boolToString args}" - else if builtins.isFloat args + else if isFloat args then "${toString args}" - else if builtins.isInt args + else if isInt args then "${toString args}" else if (args == null) then "nil" diff --git a/lib/types/languages.nix b/lib/types/languages.nix index 6b06759..e47f964 100644 --- a/lib/types/languages.nix +++ b/lib/types/languages.nix @@ -15,13 +15,13 @@ with lib; let in { diagnostics = { langDesc, - diagnostics, - defaultDiagnostics, + diagnosticsProviders, + defaultDiagnosticsProvider, }: mkOption { description = "List of ${langDesc} diagnostics to enable"; - type = with types; listOf (either (enum (attrNames diagnostics)) (submodule diagnosticSubmodule)); - default = defaultDiagnostics; + type = with types; listOf (either (enum (attrNames diagnosticsProviders)) (submodule diagnosticSubmodule)); + default = defaultDiagnosticsProvider; }; mkGrammarOption = pkgs: grammar: diff --git a/lib/vim.nix b/lib/vim.nix index c81dcc3..da5bf55 100644 --- a/lib/vim.nix +++ b/lib/vim.nix @@ -1,5 +1,5 @@ let - inherit (builtins) isInt isBool toJSON; + inherit (builtins) isInt isBool toJSON toString; in rec { # yes? no. yesNo = value: @@ -16,7 +16,7 @@ in rec { # convert a literal value to a vim compliant value valToVim = val: if (isInt val) - then (builtins.toString val) + then (toString val) else ( if (isBool val) diff --git a/modules/basic/config.nix b/modules/basic/config.nix index 1a3e97b..a74a6a9 100644 --- a/modules/basic/config.nix +++ b/modules/basic/config.nix @@ -4,12 +4,15 @@ ... }: let inherit (builtins) concatStringsSep; - inherit (lib) optionalString mkIf nvim; + inherit (lib.modules) mkIf; + inherit (lib.lists) optionals; + inherit (lib.strings) optionalString; + inherit (lib.nvim.dag) entryAfter; cfg = config.vim; in { config = { - vim.startPlugins = ["plenary-nvim"] ++ lib.optionals (cfg.spellChecking.enableProgrammingWordList) ["vim-dirtytalk"]; + vim.startPlugins = ["plenary-nvim"] ++ optionals (cfg.spellChecking.enableProgrammingWordList) ["vim-dirtytalk"]; vim.maps.normal = mkIf cfg.disableArrows { @@ -57,7 +60,7 @@ in { }; }; - vim.configRC.basic = nvim.dag.entryAfter ["globalsScript"] '' + vim.configRC.basic = entryAfter ["globalsScript"] '' " Settings that are set for everything set encoding=utf-8 set mouse=${cfg.mouseSupport} diff --git a/modules/basic/module.nix b/modules/basic/module.nix index 4a2750f..263aae0 100644 --- a/modules/basic/module.nix +++ b/modules/basic/module.nix @@ -3,12 +3,12 @@ lib, ... }: let - inherit (lib) mkEnableOption mkOption; - inherit (lib.types) types; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) package path str bool int listOf enum nullOr; in { options.vim = { package = mkOption { - type = types.package; + type = package; default = pkgs.neovim-unwrapped; description = '' The neovim package to use. You will need to use an unwrapped package for this option to work as intended. @@ -18,13 +18,13 @@ in { debugMode = { enable = mkEnableOption "debug mode"; level = mkOption { - type = types.int; + type = int; default = 20; description = "Set the debug level"; }; logFile = mkOption { - type = types.path; + type = path; default = "/tmp/nvim.log"; description = "Set the log file"; }; @@ -33,7 +33,7 @@ in { enableLuaLoader = mkEnableOption "experimental Lua module loader to speed up the start up process"; leaderKey = mkOption { - type = with types; nullOr str; + type = nullOr str; default = null; description = "The leader key to be used internally"; }; @@ -42,7 +42,7 @@ in { enable = mkEnableOption "neovim's built-in spellchecking"; enableProgrammingWordList = mkEnableOption "vim-dirtytalk, a wordlist for programmers, that includes programming words"; languages = mkOption { - type = with types; listOf str; + type = listOf str; description = "The languages to be used for spellchecking"; default = ["en"]; example = ["en" "de"]; @@ -50,55 +50,55 @@ in { }; colourTerm = mkOption { - type = types.bool; + type = bool; default = true; description = "Set terminal up for 256 colours"; }; disableArrows = mkOption { - type = types.bool; + type = bool; default = false; description = "Set to prevent arrow keys from moving cursor"; }; hideSearchHighlight = mkOption { - type = types.bool; + type = bool; default = false; description = "Hide search highlight so it doesn't stay highlighted"; }; scrollOffset = mkOption { - type = types.int; + type = int; default = 8; description = "Start scrolling this number of lines from the top or bottom of the page."; }; wordWrap = mkOption { - type = types.bool; + type = bool; default = true; description = "Enable word wrapping."; }; syntaxHighlighting = mkOption { - type = types.bool; + type = bool; default = true; description = "Enable syntax highlighting"; }; mapLeaderSpace = mkOption { - type = types.bool; + type = bool; default = true; description = "Map the space key to leader key"; }; useSystemClipboard = mkOption { - type = types.bool; + type = bool; default = false; description = "Make use of the clipboard for default yank and paste operations. Don't use * and +"; }; mouseSupport = mkOption { - type = with types; enum ["a" "n" "v" "i" "c"]; + type = enum ["a" "n" "v" "i" "c"]; default = "a"; description = '' Set modes for mouse support. @@ -112,7 +112,7 @@ in { }; lineNumberMode = mkOption { - type = with types; enum ["relative" "number" "relNumber" "none"]; + type = enum ["relative" "number" "relNumber" "none"]; default = "relNumber"; description = '' How line numbers are displayed. Available options are @@ -121,78 +121,78 @@ in { }; preventJunkFiles = mkOption { - type = types.bool; + type = bool; default = false; description = "Prevent swapfile, backupfile from being created"; }; tabWidth = mkOption { - type = types.int; + type = int; default = 4; description = "Set the width of tabs"; }; autoIndent = mkOption { - type = types.bool; + type = bool; default = true; description = "Enable auto indent"; }; cmdHeight = mkOption { - type = types.int; + type = int; default = 1; description = "Height of the command pane"; }; updateTime = mkOption { - type = types.int; + type = int; default = 300; description = "The number of milliseconds till Cursor Hold event is fired"; }; showSignColumn = mkOption { - type = types.bool; + type = bool; default = true; description = "Show the sign column"; }; bell = mkOption { - type = types.enum ["none" "visual" "on"]; + type = enum ["none" "visual" "on"]; default = "none"; description = "Set how bells are handled. Options: on, visual or none"; }; mapTimeout = mkOption { - type = types.int; + type = int; default = 500; description = "Timeout in ms that neovim will wait for mapped action to complete"; }; splitBelow = mkOption { - type = types.bool; + type = bool; default = true; description = "New splits will open below instead of on top"; }; splitRight = mkOption { - type = types.bool; + type = bool; default = true; description = "New splits will open to the right"; }; enableEditorconfig = mkOption { - type = types.bool; + type = bool; default = true; description = "Follow editorconfig rules in current directory"; }; cursorlineOpt = mkOption { - type = types.enum ["line" "screenline" "number" "both"]; + type = enum ["line" "screenline" "number" "both"]; default = "line"; description = "Highlight the text line of the cursor with CursorLine hl-CursorLine"; }; searchCase = mkOption { - type = types.enum ["ignore" "smart" "sensitive"]; + type = enum ["ignore" "smart" "sensitive"]; default = "sensitive"; description = "Set the case sensitivity of search"; }; diff --git a/modules/completion/nvim-cmp/nvim-cmp.nix b/modules/completion/nvim-cmp/nvim-cmp.nix index 59c32db..ac89783 100644 --- a/modules/completion/nvim-cmp/nvim-cmp.nix +++ b/modules/completion/nvim-cmp/nvim-cmp.nix @@ -1,5 +1,5 @@ {lib, ...}: let - inherit (lib.options) mkEnableOption mkOption; + inherit (lib.options) mkEnableOption mkOption literalMD; inherit (lib.nvim.binds) mkMappingOption; inherit (lib.types) enum attrsOf nullOr str; in { @@ -52,7 +52,7 @@ in { ''; type = str; default = "nvim_cmp_menu_map"; - example = lib.literalMD '' + example = literalMD '' ```lua function(entry, vim_item) return vim_item diff --git a/modules/core/default.nix b/modules/core/default.nix index 13534a4..682566c 100644 --- a/modules/core/default.nix +++ b/modules/core/default.nix @@ -4,10 +4,16 @@ ... }: let inherit (builtins) attrValues attrNames map mapAttrs toJSON isString concatStringsSep filter; - inherit (lib) mkOption types mapAttrsFlatten filterAttrs optionalString getAttrs literalExpression; - inherit (lib) nvim; - inherit (nvim.lua) toLuaObject; - inherit (nvim.vim) valToVim; + inherit (lib.options) mkOption literalExpression mdDoc; + inherit (lib.attrsets) filterAttrs getAttrs; + inherit (lib.strings) optionalString; + inherit (lib.misc) mapAttrsFlatten; + inherit (lib.trivial) showWarnings; + inherit (lib.types) bool str listOf oneOf attrsOf nullOr attrs submodule unspecified lines; + inherit (lib.nvim.types) dagOf pluginsOpt extraPluginType; + inherit (lib.nvim.dag) entryAnywhere entryAfter topoSort; + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.nvim.vim) valToVim; cfg = config.vim; @@ -22,7 +28,7 @@ mkBool = value: description: mkOption { - type = types.bool; + type = bool; default = value; inherit description; }; @@ -54,7 +60,7 @@ "Whether to use the 'noremap' variant of the command, ignoring any custom mappings on the defined action. It is highly advised to keep this on, which is the default."; desc = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = null; description = "A description of this keybind, to be shown in which-key, if you have it enabled."; }; @@ -94,17 +100,17 @@ }) maps); - mapOption = types.submodule { + mapOption = submodule { options = mapConfigOptions // { action = mkOption { - type = types.str; + type = str; description = "The action to execute."; }; lua = mkOption { - type = types.bool; + type = bool; description = '' If true, `action` is considered to be lua code. Thus, it will not be wrapped in `""`. @@ -117,13 +123,13 @@ mapOptions = mode: mkOption { description = "Mappings for ${mode} mode"; - type = types.attrsOf mapOption; + type = attrsOf mapOption; default = {}; }; in { options = { - assertions = lib.mkOption { - type = with types; listOf unspecified; + assertions = mkOption { + type = listOf unspecified; internal = true; default = []; example = literalExpression '' @@ -139,9 +145,9 @@ in { warnings = mkOption { internal = true; default = []; - type = with types; listOf str; + type = listOf str; example = ["The `foo' service is deprecated and will go away soon!"]; - description = lib.mdDoc '' + description = mdDoc '' This option allows modules to show warnings to users during the evaluation of the system configuration. ''; @@ -150,46 +156,46 @@ in { vim = { viAlias = mkOption { description = "Enable vi alias"; - type = types.bool; + type = bool; default = true; }; vimAlias = mkOption { description = "Enable vim alias"; - type = types.bool; + type = bool; default = true; }; configRC = mkOption { description = "vimrc contents"; - type = types.oneOf [(nvim.types.dagOf types.lines) types.str]; + type = oneOf [(dagOf lines) str]; default = {}; }; luaConfigRC = mkOption { description = "vim lua config"; - type = types.oneOf [(nvim.types.dagOf types.lines) types.str]; + type = oneOf [(dagOf lines) str]; default = {}; }; builtConfigRC = mkOption { internal = true; - type = types.lines; + type = lines; description = "The built config for neovim after resolving the DAG"; }; - startPlugins = nvim.types.pluginsOpt { + startPlugins = pluginsOpt { default = []; description = "List of plugins to startup."; }; - optPlugins = nvim.types.pluginsOpt { + optPlugins = pluginsOpt { default = []; description = "List of plugins to optionally load"; }; extraPlugins = mkOption { - type = types.attrsOf nvim.types.extraPluginType; + type = attrsOf extraPluginType; default = {}; description = '' List of plugins and related config. @@ -210,7 +216,7 @@ in { }; luaPackages = mkOption { - type = types.listOf types.str; + type = listOf str; default = []; description = '' List of lua packages to install. @@ -220,11 +226,11 @@ in { globals = mkOption { default = {}; description = "Set containing global variable values"; - type = types.attrs; + type = attrs; }; maps = mkOption { - type = types.submodule { + type = submodule { options = { normal = mapOptions "normal"; insert = mapOptions "insert"; @@ -289,12 +295,12 @@ in { mapResult, }: let # When the value is a string, default it to dag.entryAnywhere - finalDag = lib.mapAttrs (_: value: + finalDag = mapAttrs (_: value: if isString value - then nvim.dag.entryAnywhere value + then entryAnywhere value else value) dag; - sortedDag = nvim.dag.topoSort finalDag; + sortedDag = topoSort finalDag; result = if sortedDag ? result then mapResult sortedDag.result @@ -305,7 +311,7 @@ in { vim = { startPlugins = map (x: x.package) (attrValues cfg.extraPlugins); configRC = { - globalsScript = nvim.dag.entryAnywhere (concatStringsSep "\n" globalsScript); + globalsScript = entryAnywhere (concatStringsSep "\n" globalsScript); luaScript = let mkSection = r: '' @@ -319,7 +325,7 @@ in { inherit mapResult; }; in - nvim.dag.entryAfter ["globalsScript"] luaConfig; + entryAfter ["globalsScript"] luaConfig; extraPluginConfigs = let mkSection = r: '' @@ -332,7 +338,7 @@ in { setup, ... }: - nvim.dag.entryAfter after setup) + entryAfter after setup) cfg.extraPlugins; pluginConfig = resolveDag { name = "extra plugins config"; @@ -340,7 +346,7 @@ in { inherit mapResult; }; in - nvim.dag.entryAfter ["luaScript"] pluginConfig; + entryAfter ["luaScript"] pluginConfig; # This is probably not the right way to set the config. I'm not sure how it should look like. mappings = let @@ -359,7 +365,7 @@ in { ]; mapConfig = wrapLuaConfig (concatStringsSep "\n" (map (v: concatStringsSep "\n" v) maps)); in - nvim.dag.entryAfter ["globalsScript"] mapConfig; + entryAfter ["globalsScript"] mapConfig; }; builtConfigRC = let @@ -368,7 +374,7 @@ in { baseSystemAssertWarn = if failedAssertions != [] then throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}" - else lib.showWarnings config.warnings; + else showWarnings config.warnings; mkSection = r: '' " SECTION: ${r.name} diff --git a/modules/dashboard/dashboard-nvim/dashboard-nvim.nix b/modules/dashboard/dashboard-nvim/dashboard-nvim.nix index 6233391..518082e 100644 --- a/modules/dashboard/dashboard-nvim/dashboard-nvim.nix +++ b/modules/dashboard/dashboard-nvim/dashboard-nvim.nix @@ -1,5 +1,5 @@ {lib, ...}: let - inherit (lib) mkEnableOption; + inherit (lib.options) mkEnableOption; in { options.vim.dashboard.dashboard-nvim = { enable = mkEnableOption "Fancy and Blazing Fast start screen plugin of neovim [dashboard.nvim]"; diff --git a/modules/filetree/nvimtree/config.nix b/modules/filetree/nvimtree/config.nix index f6ac65a..0286c1a 100644 --- a/modules/filetree/nvimtree/config.nix +++ b/modules/filetree/nvimtree/config.nix @@ -33,7 +33,7 @@ in { vim.luaConfigRC.nvimtreelua = entryAnywhere '' ${ - lib.optionalString cfg.disableNetrw '' + optionalString cfg.disableNetrw '' -- disable netrew completely vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 diff --git a/modules/filetree/nvimtree/nvimtree.nix b/modules/filetree/nvimtree/nvimtree.nix index 2112577..ecd74b5 100644 --- a/modules/filetree/nvimtree/nvimtree.nix +++ b/modules/filetree/nvimtree/nvimtree.nix @@ -3,29 +3,30 @@ lib, ... }: let - inherit (lib) mkEnableOption mkOption types literalExpression; + inherit (lib.options) mkEnableOption mkOption literalExpression; + inherit (lib.types) nullOr str bool int listOf enum attrs oneOf addCheck submodule; in { options.vim.filetree.nvimTree = { enable = mkEnableOption "filetree via nvim-tree.lua"; mappings = { toggle = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = "t"; description = "Toggle NvimTree"; }; refresh = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = "tr"; description = "Refresh NvimTree"; }; findFile = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = "tg"; description = "Find file in NvimTree"; }; focus = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = "tf"; description = "Focus NvimTree"; }; @@ -34,19 +35,19 @@ in { disableNetrw = mkOption { default = false; description = "Disables netrw and replaces it with tree"; - type = types.bool; + type = bool; }; hijackNetrw = mkOption { default = true; description = "Prevents netrw from automatically opening when opening directories"; - type = types.bool; + type = bool; }; autoreloadOnWrite = mkOption { default = true; description = "Auto reload tree on write"; - type = types.bool; + type = bool; }; updateFocusedFile = mkOption { @@ -55,16 +56,16 @@ in { until it finds the file. ''; default = {}; - type = types.submodule { + type = submodule { options = { enable = mkOption { - type = types.bool; + type = bool; default = false; description = "update focused file"; }; updateRoot = mkOption { - type = types.bool; + type = bool; default = false; description = '' Update the root directory of the tree if the file is not under current @@ -75,7 +76,7 @@ in { }; ignoreList = mkOption { - type = with types; listOf str; + type = listOf str; default = []; description = '' List of buffer names and filetypes that will not update the root dir @@ -93,26 +94,26 @@ in { sorter = mkOption { default = "name"; description = "How files within the same directory are sorted."; - type = types.enum ["name" "extension" "modification_time" "case_sensitive" "suffix" "filetype"]; + type = enum ["name" "extension" "modification_time" "case_sensitive" "suffix" "filetype"]; }; foldersFirst = mkOption { default = true; description = "Sort folders before files. Has no effect when `sort.sorter` is a function."; - type = types.bool; + type = bool; }; }; hijackCursor = mkOption { default = false; description = "Hijack the cursor in the tree to put it at the start of the filename"; - type = types.bool; + type = bool; }; hijackUnnamedBufferWhenOpening = mkOption { default = false; description = "Open nvimtree in place of the unnamed buffer if it's empty."; - type = types.bool; + type = bool; }; rootDirs = mkOption { @@ -120,7 +121,7 @@ in { description = '' Preferred root directories. Only relevant when `updateFocusedFile.updateRoot` is `true` ''; - type = with types; listOf str; + type = listOf str; }; preferStartupRoot = mkOption { @@ -129,11 +130,11 @@ in { Prefer startup root directory when updating root directory of the tree. Only relevant when `update_focused_file.update_root` is `true` ''; - type = types.bool; + type = bool; }; syncRootWithCwd = mkOption { - type = types.bool; + type = bool; default = false; description = '' Changes the tree root directory on `DirChanged` and refreshes the tree. @@ -145,13 +146,13 @@ in { reloadOnBufEnter = mkOption { default = false; - type = types.bool; + type = bool; description = "Automatically reloads the tree on `BufEnter` nvim-tree."; }; respectBufCwd = mkOption { default = false; - type = types.bool; + type = bool; description = "Will change cwd of nvim-tree to that of new buffer's when opening nvim-tree."; }; @@ -163,10 +164,10 @@ in { autoOpen = false; }; - type = types.submodule { + type = submodule { options = { enable = mkOption { - type = types.bool; + type = bool; description = '' Enable the `hijack_directories` feature. Disable this option if you use vim-dirvish or dirbuf.nvim. If `hijack_netrw` and `disable_netrw` are `false`, this feature will be disabled. @@ -174,7 +175,7 @@ in { }; autoOpen = mkOption { - type = types.bool; + type = bool; description = '' Opens the tree if the tree was previously closed. ''; @@ -187,7 +188,7 @@ in { args = mkOption { default = []; description = "Optional argument list."; - type = with types; listOf str; + type = listOf str; }; cmd = mkOption { @@ -198,7 +199,7 @@ in { then "${pkgs.xdg-utils}/bin/xdg-open" else throw "NvimTree: No default system open command for this platform, please set `vim.filetree.nvimTree.systemOpen.cmd`"; description = "The open command itself"; - type = types.str; + type = str; }; }; @@ -210,13 +211,13 @@ in { default = {}; - type = types.submodule { + type = submodule { options = { enable = mkEnableOption "diagnostics view in the signcolumn."; debounceDelay = mkOption { description = "Idle milliseconds between diagnostic event and update."; - type = types.int; + type = int; default = 50; }; @@ -226,7 +227,7 @@ in { }; showOnOpenDirs = mkOption { - type = types.bool; + type = bool; default = true; description = '' Show diagnostics icons on directories that are open. @@ -237,26 +238,26 @@ in { icons = mkOption { description = "Icons for diagnostic severity."; default = {}; - type = types.submodule { + type = submodule { options = { hint = mkOption { description = "Icon used for `hint` diagnostic."; - type = types.str; + type = str; default = ""; }; info = mkOption { description = "Icon used for `info` diagnostic."; - type = types.str; + type = str; default = ""; }; warning = mkOption { description = "Icon used for `warning` diagnostic."; - type = types.str; + type = str; default = ""; }; error = mkOption { description = "Icon used for `error` diagnostic."; - type = types.str; + type = str; default = ""; }; }; @@ -266,17 +267,17 @@ in { severity = mkOption { description = "Severity for which the diagnostics will be displayed. See `:help diagnostic-severity`"; default = {}; - type = types.submodule { + type = submodule { options = { min = mkOption { description = "Minimum severity."; - type = types.enum ["HINT" "INFO" "WARNING" "ERROR"]; + type = enum ["HINT" "INFO" "WARNING" "ERROR"]; default = "HINT"; }; max = mkOption { description = "Maximum severity."; - type = types.enum ["HINT" "INFO" "WARNING" "ERROR"]; + type = enum ["HINT" "INFO" "WARNING" "ERROR"]; default = "ERROR"; }; }; @@ -290,19 +291,19 @@ in { enable = mkEnableOption "Git integration with icons and colors."; showOnDirs = mkOption { - type = types.bool; + type = bool; default = true; description = "Show git icons on parent directories."; }; showOnOpenDirs = mkOption { - type = types.bool; + type = bool; default = true; description = "Show git icons on directories that are open."; }; disableForDirs = mkOption { - type = with types; listOf str; + type = listOf str; default = []; description = '' Disable git integration when git top-level matches these paths. @@ -311,7 +312,7 @@ in { }; timeout = mkOption { - type = types.int; + type = int; default = 400; description = '' Kills the git process after some time if it takes too long. @@ -323,18 +324,18 @@ in { modified = mkOption { description = "Indicate which file have unsaved modification."; default = {}; - type = types.submodule { + type = submodule { options = { enable = mkEnableOption "Modified files with icons and color highlight."; showOnDirs = mkOption { - type = types.bool; + type = bool; description = "Show modified icons on parent directories."; default = true; }; showOnOpenDirs = mkOption { - type = types.bool; + type = bool; description = "Show modified icons on directories that are open."; default = true; }; @@ -351,22 +352,22 @@ in { performance. ''; default = {}; - type = types.submodule { + type = submodule { options = { enable = mkOption { description = "Enable filesystem watchers."; - type = types.bool; + type = bool; default = true; }; debounceDelay = mkOption { description = "Idle milliseconds between filesystem change and action."; - type = types.int; + type = int; default = 50; }; ignoreDirs = mkOption { - type = with types; listOf str; + type = listOf str; default = []; description = '' List of vim regex for absolute directory paths that will not be watched. @@ -385,22 +386,22 @@ in { view = mkOption { description = "Window / buffer setup."; default = {}; - type = types.submodule { + type = submodule { options = { centralizeSelection = mkOption { description = "If true, reposition the view so that the current node is initially centralized when entering nvim-tree."; - type = types.bool; + type = bool; default = false; }; cursorline = mkOption { description = "Enable cursorline in nvim-tree window."; - type = types.bool; + type = bool; default = true; }; debounceDelay = mkOption { - type = types.int; + type = int; default = 15; description = '' Idle milliseconds before some reload / refresh operations. @@ -416,7 +417,7 @@ in { A table (an attribute set in our case, see example) indicates that the view should be dynamically sized based on the longest line. ''; - type = with types; oneOf [int attrs]; + type = oneOf [int attrs]; default = 30; example = literalExpression '' { @@ -429,7 +430,7 @@ in { side = mkOption { description = "Side of the tree."; - type = types.enum ["left" "right"]; + type = enum ["left" "right"]; default = "left"; }; @@ -438,13 +439,13 @@ in { Preserves window proportions when opening a file. If `false`, the height and width of windows other than nvim-tree will be equalized. ''; - type = types.bool; + type = bool; default = false; }; number = mkOption { description = "Print the line number in front of each line."; - type = types.bool; + type = bool; default = false; }; @@ -454,13 +455,13 @@ in { If the option `view.number` is also `true`, the number on the cursor line will be the line number instead of `0`. ''; - type = types.bool; + type = bool; default = false; }; signcolumn = mkOption { description = ''Show diagnostic sign column. Value can be `"yes"`, `"auto"` or`"no"`.''; - type = types.enum ["yes" "auto" "no"]; + type = enum ["yes" "auto" "no"]; default = "yes"; }; @@ -468,23 +469,23 @@ in { description = "Configuration options for floating window."; default = {}; - type = types.submodule { + type = submodule { options = { enable = mkOption { description = "If true, tree window will be floating."; - type = types.bool; + type = bool; default = false; }; quitOnFocusLoss = mkOption { description = "Close the floating tree window when it loses focus."; - type = types.bool; + type = bool; default = true; }; openWinConfig = mkOption { description = "Floating window config. See `:h nvim_open_win()` for more details."; - type = types.attrs; + type = attrs; default = { relative = "editor"; border = "rounded"; @@ -505,23 +506,23 @@ in { addTrailing = mkOption { default = false; description = "Appends a trailing slash to folder names."; - type = types.bool; + type = bool; }; groupEmpty = mkOption { default = false; description = "Compact folders that only contain a single folder into one node in the file tree."; - type = types.bool; + type = bool; }; fullName = mkOption { default = false; description = "Display node whose name length is wider than the width of nvim-tree window in floating window."; - type = types.bool; + type = bool; }; highlightGit = mkOption { - type = types.bool; + type = bool; default = false; description = '' Enable file highlight for git attributes using `NvimTreeGit` highlight groups. @@ -531,7 +532,7 @@ in { }; highlightOpenedFiles = mkOption { - type = types.enum ["none" "icon" "name" "all"]; + type = enum ["none" "icon" "name" "all"]; default = "none"; description = '' Highlight icons and/or names for bufloaded() files using the @@ -540,7 +541,7 @@ in { }; highlightModified = mkOption { - type = types.enum ["none" "icon" "name" "all"]; + type = enum ["none" "icon" "name" "all"]; default = "none"; description = '' Highlight modified files in the tree using `NvimTreeNormal` highlight group. @@ -549,7 +550,7 @@ in { }; rootFolderLabel = mkOption { - type = with types; oneOf [str bool]; + type = oneOf [str bool]; default = false; example = ''"":~:s?$?/..?"''; description = '' @@ -566,7 +567,7 @@ in { }; indentWidth = mkOption { - type = with types; addCheck int (x: x >= 1); + type = addCheck int (x: x >= 1); default = 2; description = "Number of spaces for an each tree nesting level. Minimum 1."; }; @@ -574,17 +575,17 @@ in { indentMarkers = mkOption { description = "Configuration options for tree indent markers."; default = {}; - type = types.submodule { + type = submodule { options = { enable = mkEnableOption "Display indent markers when folders are open."; inlineArrows = mkOption { - type = types.bool; + type = bool; default = true; description = "Display folder arrows in the same column as indent marker when using `renderer.icons.show.folder_arrow`"; }; icons = mkOption { - type = types.attrs; + type = attrs; description = "Individual elements of the indent markers"; default = { corner = "└"; @@ -599,13 +600,13 @@ in { }; specialFiles = mkOption { - type = with types; listOf str; + type = listOf str; default = ["Cargo.toml" "README.md" "readme.md" "Makefile" "MAKEFILE" "flake.nix"]; # ;) description = "A list of filenames that gets highlighted with `NvimTreeSpecialFile"; }; symlinkDestination = mkOption { - type = types.bool; + type = bool; default = true; description = "Whether to show the destination of the symlink."; }; @@ -613,53 +614,53 @@ in { icons = mkOption { description = "Configuration options for icons."; default = {}; - type = types.submodule { + type = submodule { options = { webdevColors = mkOption { - type = types.bool; + type = bool; description = " Use the webdev icon colors, otherwise `NvimTreeFileIcon`"; default = true; }; gitPlacement = mkOption { - type = types.enum ["before" "after" "signcolumn"]; + type = enum ["before" "after" "signcolumn"]; description = "Place where the git icons will be rendered. `signcolumn` requires `view.signcolumn` to be enabled."; default = "before"; }; modifiedPlacement = mkOption { - type = types.enum ["before" "after" "signcolumn"]; + type = enum ["before" "after" "signcolumn"]; description = "Place where the modified icons will be rendered. `signcolumn` requires `view.signcolumn` to be enabled."; default = "after"; }; padding = mkOption { - type = types.str; + type = str; description = "Inserted between icon and filename"; default = " "; }; symlinkArrow = mkOption { - type = types.str; + type = str; description = "Used as a separator between symlinks' source and target."; default = " ➛ "; }; show = { file = mkOption { - type = types.bool; + type = bool; description = "Show an icon before the file name. `nvim-web-devicons` will be used if available."; default = true; }; folder = mkOption { - type = types.bool; + type = bool; description = "Show an icon before the folder name."; default = true; }; folderArrow = mkOption { - type = types.bool; + type = bool; default = true; description = '' Show a small arrow before the folder node. Arrow will be a part of the @@ -668,7 +669,7 @@ in { }; git = mkOption { - type = types.bool; + type = bool; default = false; description = '' Show a git status icon, see `renderer.icons.gitPlacement` @@ -677,7 +678,7 @@ in { }; modified = mkOption { - type = types.bool; + type = bool; default = true; description = '' Show a modified icon, see `renderer.icons.modifiedPlacement` @@ -692,29 +693,29 @@ in { to appear in the signcolumn. ''; default = {}; - type = types.submodule { + type = submodule { options = { default = mkOption { - type = types.str; + type = str; description = "Glyph for files. Will be overridden by `nvim-web-devicons` if available."; default = ""; }; symlink = mkOption { - type = types.str; + type = str; description = "Glyph for symlinks."; default = ""; }; modified = mkOption { - type = types.str; + type = str; description = "Icon to display for modified files."; default = ""; }; # TODO: hardcode each attribute folder = mkOption { - type = types.attrs; + type = attrs; description = "Glyphs for directories. Recommended to use the defaults unless you know what you are doing."; default = { default = ""; @@ -729,7 +730,7 @@ in { }; git = mkOption { - type = types.attrs; + type = attrs; description = "Glyphs for git status."; default = { unstaged = "✗"; @@ -759,22 +760,22 @@ in { noBuffer = false; exclude = []; }; - type = types.submodule { + type = submodule { options = { gitIgnored = mkOption { - type = types.bool; + type = bool; description = "Ignore files based on `.gitignore`. Requires git.enable` to be `true`"; default = false; }; dotfiles = mkOption { - type = types.bool; + type = bool; description = "Do not show dotfiles: files starting with a `.`"; default = false; }; gitClean = mkOption { - type = types.bool; + type = bool; default = false; description = '' @@ -784,13 +785,13 @@ in { }; noBuffer = mkOption { - type = types.bool; + type = bool; default = false; description = "Do not show files that have no `buflisted()` buffer."; }; exclude = mkOption { - type = with types; listOf str; + type = listOf str; default = []; description = "List of directories or files to exclude from filtering: always show them."; }; @@ -804,10 +805,10 @@ in { cmd = "${pkgs.glib}/bin/gio trash"; }; - type = types.submodule { + type = submodule { options = { cmd = mkOption { - type = types.str; + type = str; description = "The command used to trash items"; }; }; @@ -817,10 +818,10 @@ in { actions = mkOption { description = "Configuration for various actions."; default = {}; - type = types.submodule { + type = submodule { options = { useSystemClipboard = mkOption { - type = types.bool; + type = bool; default = true; description = '' A boolean value that toggle the use of system clipboard when copy/paste @@ -833,16 +834,16 @@ in { changeDir = mkOption { description = "vim `change-directory` behaviour"; default = {}; - type = types.submodule { + type = submodule { options = { enable = mkOption { - type = types.bool; + type = bool; default = true; description = "Change the working directory when changing directories in the tree."; }; global = mkOption { - type = types.bool; + type = bool; default = false; description = '' Use `:cd` instead of `:lcd` when changing directories. @@ -851,7 +852,7 @@ in { }; restrictAboveCwd = mkOption { - type = types.bool; + type = bool; default = false; description = '' Restrict changing to a directory above the global current working directory. @@ -865,10 +866,10 @@ in { expandAll = mkOption { description = "Configuration for expand_all behaviour."; default = {}; - type = types.submodule { + type = submodule { options = { maxFolderDiscovery = mkOption { - type = types.int; + type = int; default = 300; description = '' Limit the number of folders being explored when expanding every folders. @@ -876,7 +877,7 @@ in { ''; }; exclude = mkOption { - type = with types; listOf str; + type = listOf str; description = "A list of directories that should not be expanded automatically."; default = [".git" "target" "build" "result"]; }; @@ -888,10 +889,10 @@ in { filePopup = mkOption { description = "Configuration for file_popup behaviour."; default = {}; - type = types.submodule { + type = submodule { options = { openWinConfig = mkOption { - type = types.attrs; + type = attrs; default = { col = 1; row = 1; @@ -909,22 +910,22 @@ in { openFile = mkOption { description = "Configuration options for opening a file from nvim-tree."; default = {}; - type = types.submodule { + type = submodule { options = { quitOnOpen = mkOption { - type = types.bool; + type = bool; description = "Closes the explorer when opening a file."; default = false; }; eject = mkOption { - type = types.bool; + type = bool; description = "Prevent new opened file from opening in the same window as the tree."; default = false; }; resizeWindow = mkOption { - type = types.bool; + type = bool; default = false; description = "Resizes the tree when opening a file. Previously `view.auto_resize`"; @@ -933,16 +934,16 @@ in { windowPicker = mkOption { description = "window_picker"; default = {}; - type = types.submodule { + type = submodule { options = { enable = mkOption { - type = types.bool; + type = bool; description = "Enable the window picker. If this feature is not enabled, files will open in window from which you last opened the tree."; default = false; }; picker = mkOption { - type = types.str; + type = str; default = "default"; description = '' Change the default window picker, can be a string `"default"` or a function. @@ -959,20 +960,20 @@ in { }; chars = mkOption { - type = types.str; + type = str; description = "A string of chars used as identifiers by the window picker."; default = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; }; exclude = { filetype = mkOption { - type = with types; listOf str; + type = listOf str; description = "A list of filetypes to exclude from the window picker."; default = ["notify" "packer" "qf" "diff" "fugitive" "fugitiveblame"]; }; buftype = mkOption { - type = with types; listOf str; + type = listOf str; description = "A list of buftypes to exclude from the window picker."; default = ["nofile" "terminal" "help"]; }; @@ -986,7 +987,7 @@ in { removeFile = { closeWindow = mkOption { - type = types.bool; + type = bool; default = true; description = "Close any window displaying a file when removing the file from the tree"; }; @@ -1004,16 +1005,16 @@ in { The filter can be cleared with the `F` key by default. ''; default = {}; - type = types.submodule { + type = submodule { options = { prefix = mkOption { - type = types.str; + type = str; description = "Prefix of the filter displayed in the buffer."; default = "[FILTER]: "; }; alwaysShowFolders = mkOption { - type = types.bool; + type = bool; description = "Whether to filter folders or not."; default = true; }; @@ -1024,15 +1025,15 @@ in { tab = mkOption { description = "Configuration for tab behaviour."; default = {}; - type = types.submodule { + type = submodule { options = { sync = mkOption { description = "Configuration for syncing nvim-tree across tabs."; default = {}; - type = types.submodule { + type = submodule { options = { open = mkOption { - type = types.bool; + type = bool; default = false; description = '' Opens the tree automatically when switching tabpage or opening a new @@ -1041,7 +1042,7 @@ in { }; close = mkOption { - type = types.bool; + type = bool; default = false; description = '' Closes the tree across all tabpages when the tree is closed. @@ -1049,7 +1050,7 @@ in { }; ignore = mkOption { - type = with types; listOf str; + type = listOf str; default = []; description = '' List of filetypes or buffer names on new tab that will prevent @@ -1066,16 +1067,16 @@ in { notify = mkOption { description = "Configuration for notifications."; default = {}; - type = types.submodule { + type = submodule { options = { threshold = mkOption { - type = types.enum ["ERROR" "WARNING" "INFO" "DEBUG"]; + type = enum ["ERROR" "WARNING" "INFO" "DEBUG"]; description = "Specify minimum notification level, uses the values from `vim.log.levels`"; default = "INFO"; }; absolutePath = mkOption { - type = types.bool; + type = bool; description = "Whether to use absolute paths or item names in fs action notifications."; default = true; }; @@ -1086,17 +1087,17 @@ in { ui = mkOption { description = "General UI configuration."; default = {}; - type = types.submodule { + type = submodule { options = { confirm = { remove = mkOption { - type = types.bool; + type = bool; description = "Prompt before removing."; default = true; }; trash = mkOption { - type = types.bool; + type = bool; description = "Prompt before trash."; default = true; }; @@ -1109,7 +1110,7 @@ in { openOnSetup = mkOption { default = true; description = "Open when vim is started on a directory"; - type = types.bool; + type = bool; }; }; } diff --git a/modules/languages/bash/bash.nix b/modules/languages/bash/bash.nix index 03cce94..7b5de0f 100644 --- a/modules/languages/bash/bash.nix +++ b/modules/languages/bash/bash.nix @@ -9,6 +9,7 @@ inherit (lib.lists) isList; inherit (lib.types) enum either package listOf str bool; inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.types) diagnostics mkGrammarOption; cfg = config.vim.languages.bash; @@ -45,8 +46,8 @@ }; }; - defaultDiagnostics = ["shellcheck"]; - diagnostics = { + defaultDiagnosticsProvider = ["shellcheck"]; + diagnosticsProviders = { shellcheck = { package = pkgs.shellcheck; nullConfig = pkg: '' @@ -65,7 +66,7 @@ in { treesitter = { enable = mkEnableOption "Bash treesitter" // {default = config.vim.languages.enableTreesitter;}; - package = lib.nvim.types.mkGrammarOption pkgs "bash"; + package = mkGrammarOption pkgs "bash"; }; lsp = { @@ -106,10 +107,10 @@ in { extraDiagnostics = { enable = mkEnableOption "extra Bash diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;}; - types = lib.nvim.types.diagnostics { + types = diagnostics { langDesc = "Bash"; - inherit diagnostics; - inherit defaultDiagnostics; + inherit diagnosticsProviders; + inherit defaultDiagnosticsProvider; }; }; }; diff --git a/modules/languages/bash/config.nix b/modules/languages/bash/config.nix index e55600b..7f2a70a 100644 --- a/modules/languages/bash/config.nix +++ b/modules/languages/bash/config.nix @@ -7,9 +7,10 @@ inherit (lib.lists) isList; inherit (lib.modules) mkIf mkMerge; inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.languages) diagnosticsToLua; cfg = config.vim.languages.bash; - diagnostics = { + diagnosticsProviders = { shellcheck = { package = pkgs.shellcheck; nullConfig = pkg: '' @@ -72,10 +73,10 @@ in { (mkIf cfg.extraDiagnostics.enable { vim.lsp.null-ls.enable = true; - vim.lsp.null-ls.sources = lib.nvim.languages.diagnosticsToLua { + vim.lsp.null-ls.sources = diagnosticsToLua { lang = "bash"; config = cfg.extraDiagnostics.types; - inherit diagnostics; + inherit diagnosticsProviders; }; }) ]); diff --git a/modules/languages/clang.nix b/modules/languages/clang.nix index 16cf337..682277d 100644 --- a/modules/languages/clang.nix +++ b/modules/languages/clang.nix @@ -6,15 +6,17 @@ }: let inherit (builtins) attrNames; inherit (lib.lists) isList; - inherit (lib) nvim; inherit (lib.strings) optionalString; inherit (lib.options) mkEnableOption mkOption; inherit (lib.types) bool enum package either listOf str nullOr; inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.dag) entryAnywhere; packageToCmd = package: defaultCmd: if isList cfg.lsp.package - then nvim.lua.expToLua cfg.lsp.package + then expToLua cfg.lsp.package else ''{ "${cfg.lsp.package}/bin/${defaultCmd}" }''; cfg = config.vim.languages.clang; @@ -91,8 +93,8 @@ in { treesitter = { enable = mkEnableOption "C/C++ treesitter" // {default = config.vim.languages.enableTreesitter;}; - cPackage = nvim.types.mkGrammarOption pkgs "c"; - cppPackage = nvim.types.mkGrammarOption pkgs "cpp"; + cPackage = mkGrammarOption pkgs "c"; + cppPackage = mkGrammarOption pkgs "cpp"; }; lsp = { @@ -139,7 +141,7 @@ in { config = mkIf cfg.enable (mkMerge [ (mkIf cfg.cHeader { - vim.configRC.c-header = nvim.dag.entryAnywhere "let g:c_syntax_for_h = 1"; + vim.configRC.c-header = entryAnywhere "let g:c_syntax_for_h = 1"; }) (mkIf cfg.treesitter.enable { diff --git a/modules/languages/nix.nix b/modules/languages/nix.nix index 6061018..2e243eb 100644 --- a/modules/languages/nix.nix +++ b/modules/languages/nix.nix @@ -10,8 +10,10 @@ inherit (lib.lists) isList; inherit (lib.strings) optionalString; inherit (lib.types) enum either listOf package str; - inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.types) mkGrammarOption diagnostics; inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.languages) diagnosticsToLua; cfg = config.vim.languages.nix; @@ -21,7 +23,7 @@ defaultServer = "nil"; packageToCmd = package: defaultCmd: if isList package - then lib.nvim.lua.expToLua package + then expToLua package else ''{"${package}/bin/${defaultCmd}"}''; servers = { rnix = { @@ -95,8 +97,8 @@ }; }; - defaultDiagnostics = ["statix" "deadnix"]; - diagnostics = { + defaultDiagnosticsProvider = ["statix" "deadnix"]; + diagnosticsProviders = { statix = { package = pkgs.statix; nullConfig = pkg: '' @@ -164,10 +166,10 @@ in { extraDiagnostics = { enable = mkEnableOption "extra Nix diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;}; - types = lib.nvim.types.diagnostics { + types = diagnostics { langDesc = "Nix"; - inherit diagnostics; - inherit defaultDiagnostics; + inherit diagnosticsProviders; + inherit defaultDiagnosticsProvider; }; }; }; @@ -196,10 +198,10 @@ in { (mkIf cfg.extraDiagnostics.enable { vim.lsp.null-ls.enable = true; - vim.lsp.null-ls.sources = lib.nvim.languages.diagnosticsToLua { + vim.lsp.null-ls.sources = diagnosticsToLua { lang = "nix"; config = cfg.extraDiagnostics.types; - inherit diagnostics; + inherit diagnosticsProviders; }; }) ]); diff --git a/modules/languages/rust.nix b/modules/languages/rust.nix index 8e4fc36..8b4f1b4 100644 --- a/modules/languages/rust.nix +++ b/modules/languages/rust.nix @@ -4,7 +4,15 @@ lib, ... }: let - inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge optionalString boolToString optionals; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.strings) optionalString; + inherit (lib.trivial) boolToString; + inherit (lib.lists) isList optionals; + inherit (lib.types) bool package str listOf either; + inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.languages.rust; in { @@ -13,14 +21,14 @@ in { treesitter = { enable = mkEnableOption "Rust treesitter" // {default = config.vim.languages.enableTreesitter;}; - package = nvim.types.mkGrammarOption pkgs "rust"; + package = mkGrammarOption pkgs "rust"; }; crates = { enable = mkEnableOption "crates-nvim, tools for managing dependencies"; codeActions = mkOption { description = "Enable code actions through null-ls"; - type = types.bool; + type = bool; default = true; }; }; @@ -30,13 +38,13 @@ in { package = mkOption { description = "rust-analyzer 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 = pkgs.rust-analyzer; }; opts = mkOption { description = "Options to pass to rust analyzer"; - type = types.str; + type = str; default = ""; }; }; @@ -44,13 +52,13 @@ in { dap = { enable = mkOption { description = "Rust Debug Adapter support"; - type = types.bool; + type = bool; default = config.vim.languages.enableDAP; }; package = mkOption { description = "lldb pacakge"; - type = types.package; + type = package; default = pkgs.lldb; }; }; @@ -62,7 +70,7 @@ in { startPlugins = ["crates-nvim"]; lsp.null-ls.enable = mkIf cfg.crates.codeActions true; autocomplete.sources = {"crates" = "[Crates]";}; - luaConfigRC.rust-crates = nvim.dag.entryAnywhere '' + luaConfigRC.rust-crates = entryAnywhere '' require('crates').setup { null_ls = { enabled = ${boolToString cfg.crates.codeActions}, @@ -125,7 +133,7 @@ in { on_attach = rust_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/rust-analyzer"}'' }, settings = { diff --git a/modules/languages/sql.nix b/modules/languages/sql.nix index 790bf13..ed08ee7 100644 --- a/modules/languages/sql.nix +++ b/modules/languages/sql.nix @@ -10,6 +10,8 @@ inherit (lib.lists) isList; inherit (lib.types) enum either listOf package str; inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.languages) diagnosticsToLua; + inherit (lib.nvim.types) diagnostics; cfg = config.vim.languages.sql; sqlfluffDefault = pkgs.sqlfluff; @@ -51,8 +53,8 @@ }; }; - defaultDiagnostics = ["sqlfluff"]; - diagnostics = { + defaultDiagnosticsProvider = ["sqlfluff"]; + diagnosticsProviders = { sqlfluff = { package = sqlfluffDefault; nullConfig = pkg: '' @@ -122,10 +124,10 @@ in { extraDiagnostics = { enable = mkEnableOption "extra SQL diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;}; - types = lib.nvim.types.diagnostics { + types = diagnostics { langDesc = "SQL"; - inherit diagnostics; - inherit defaultDiagnostics; + inherit diagnosticsProviders; + inherit defaultDiagnosticsProvider; }; }; }; @@ -154,10 +156,10 @@ in { (mkIf cfg.extraDiagnostics.enable { vim.lsp.null-ls.enable = true; - vim.lsp.null-ls.sources = lib.nvim.languages.diagnosticsToLua { + vim.lsp.null-ls.sources = diagnosticsToLua { lang = "sql"; config = cfg.extraDiagnostics.types; - inherit diagnostics; + inherit diagnosticsProviders; }; }) ]); diff --git a/modules/languages/svelte.nix b/modules/languages/svelte.nix index b99ea0c..599686e 100644 --- a/modules/languages/svelte.nix +++ b/modules/languages/svelte.nix @@ -8,9 +8,11 @@ inherit (lib.options) mkEnableOption mkOption; inherit (lib.modules) mkIf mkMerge; inherit (lib.lists) isList; + inherit (lib.meta) getExe; inherit (lib.types) enum either listOf package str; inherit (lib.nvim.lua) expToLua; - inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.languages) diagnosticsToLua; + inherit (lib.nvim.types) mkGrammarOption diagnostics; cfg = config.vim.languages.svelte; @@ -49,15 +51,15 @@ }; # TODO: specify packages - defaultDiagnostics = ["eslint_d"]; - diagnostics = { + defaultDiagnosticsProvider = ["eslint_d"]; + diagnosticsProviders = { eslint_d = { package = pkgs.nodePackages.eslint_d; nullConfig = pkg: '' table.insert( ls_sources, null_ls.builtins.diagnostics.eslint_d.with({ - command = "${lib.getExe pkg}", + command = "${getExe pkg}", }) ) ''; @@ -109,10 +111,10 @@ in { extraDiagnostics = { enable = mkEnableOption "extra Svelte diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;}; - types = lib.nvim.types.diagnostics { + types = diagnostics { langDesc = "Svelte"; - inherit diagnostics; - inherit defaultDiagnostics; + inherit diagnosticsProviders; + inherit defaultDiagnosticsProvider; }; }; }; @@ -135,10 +137,10 @@ in { (mkIf cfg.extraDiagnostics.enable { vim.lsp.null-ls.enable = true; - vim.lsp.null-ls.sources = lib.nvim.languages.diagnosticsToLua { + vim.lsp.null-ls.sources = diagnosticsToLua { lang = "svelte"; config = cfg.extraDiagnostics.types; - inherit diagnostics; + inherit diagnosticsProviders; }; }) ]); diff --git a/modules/languages/tidal/config.nix b/modules/languages/tidal/config.nix index c659d06..344c1a7 100644 --- a/modules/languages/tidal/config.nix +++ b/modules/languages/tidal/config.nix @@ -4,7 +4,7 @@ lib, ... }: let - inherit (lib) mkIf; + inherit (lib.modules) mkIf; cfg = config.vim.tidal; in { diff --git a/modules/languages/tidal/tidal.nix b/modules/languages/tidal/tidal.nix index e5ec413..ebfe4a0 100644 --- a/modules/languages/tidal/tidal.nix +++ b/modules/languages/tidal/tidal.nix @@ -3,20 +3,21 @@ lib, ... }: let - inherit (lib) mkEnableOption mkOption types; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) int bool; in { options.vim.tidal = { enable = mkEnableOption "tidalcycles tools and plugins"; flash = mkOption { description = ''When sending a paragraph or a single line, vim-tidal will "flash" the selection for some milliseconds''; - type = types.int; + type = int; default = 150; }; openSC = mkOption { description = "Automatically run the supercollider CLI, sclang, alongside the Tidal GHCI terminal."; - type = types.bool; + type = bool; default = true; }; }; diff --git a/modules/languages/ts.nix b/modules/languages/ts.nix index a2a3711..ac77f54 100644 --- a/modules/languages/ts.nix +++ b/modules/languages/ts.nix @@ -8,9 +8,11 @@ inherit (lib.options) mkEnableOption mkOption; inherit (lib.modules) mkIf mkMerge; inherit (lib.lists) isList; + inherit (lib.meta) getExe; inherit (lib.types) enum either listOf package str; inherit (lib.nvim.lua) expToLua; - inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.types) mkGrammarOption diagnostics; + inherit (lib.nvim.languages) diagnosticsToLua; cfg = config.vim.languages.ts; @@ -75,15 +77,15 @@ }; # TODO: specify packages - defaultDiagnostics = ["eslint_d"]; - diagnostics = { + defaultDiagnosticsProvider = ["eslint_d"]; + diagnosticsProviders = { eslint_d = { package = pkgs.nodePackages.eslint_d; nullConfig = pkg: '' table.insert( ls_sources, null_ls.builtins.diagnostics.eslint_d.with({ - command = "${lib.getExe pkg}", + command = "${getExe pkg}", }) ) ''; @@ -135,10 +137,10 @@ in { extraDiagnostics = { enable = mkEnableOption "extra Typescript/Javascript diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;}; - types = lib.nvim.types.diagnostics { + types = diagnostics { langDesc = "Typescript/Javascript"; - inherit diagnostics; - inherit defaultDiagnostics; + inherit diagnosticsProviders; + inherit defaultDiagnosticsProvider; }; }; }; @@ -161,10 +163,10 @@ in { (mkIf cfg.extraDiagnostics.enable { vim.lsp.null-ls.enable = true; - vim.lsp.null-ls.sources = lib.nvim.languages.diagnosticsToLua { + vim.lsp.null-ls.sources = diagnosticsToLua { lang = "ts"; config = cfg.extraDiagnostics.types; - inherit diagnostics; + inherit diagnosticsProviders; }; }) ]); diff --git a/modules/lsp/config.nix b/modules/lsp/config.nix index cabe371..ba93b28 100644 --- a/modules/lsp/config.nix +++ b/modules/lsp/config.nix @@ -4,7 +4,11 @@ pkgs, ... }: let - inherit (lib) addDescriptionsToMappings mkIf optional boolToString optionalString; + inherit (lib.modules) mkIf; + inherit (lib.lists) optional; + inherit (lib.strings) optionalString; + inherit (lib.trivial) boolToString; + inherit (lib.nvim.binds) addDescriptionsToMappings; cfg = config.vim.lsp; usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp"; diff --git a/modules/lsp/null-ls/config.nix b/modules/lsp/null-ls/config.nix index f161fb9..83dada5 100644 --- a/modules/lsp/null-ls/config.nix +++ b/modules/lsp/null-ls/config.nix @@ -3,7 +3,9 @@ lib, ... }: let - inherit (lib) mkIf mkMerge nvim mapAttrs; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.attrsets) mapAttrs; + inherit (lib.nvim.dag) entryAnywhere entryAfter entryBetween; cfg = config.vim.lsp; in { @@ -13,14 +15,14 @@ in { lsp.enable = true; startPlugins = ["none-ls"]; - luaConfigRC.null_ls-setup = nvim.dag.entryAnywhere '' + luaConfigRC.null_ls-setup = entryAnywhere '' local null_ls = require("null-ls") local null_helpers = require("null-ls.helpers") local null_methods = require("null-ls.methods") local ls_sources = {} ''; - luaConfigRC.null_ls = nvim.dag.entryAfter ["null_ls-setup" "lsp-setup"] '' + luaConfigRC.null_ls = entryAfter ["null_ls-setup" "lsp-setup"] '' require('null-ls').setup({ debug = false, diagnostics_format = "[#{m}] #{s} (#{c})", @@ -33,7 +35,7 @@ in { }; } { - vim.luaConfigRC = mapAttrs (_: v: (nvim.dag.entryBetween ["null_ls"] ["null_ls-setup"] v)) cfg.null-ls.sources; + vim.luaConfigRC = mapAttrs (_: v: (entryBetween ["null_ls"] ["null_ls-setup"] v)) cfg.null-ls.sources; } ]); } diff --git a/modules/rich-presence/neocord/config.nix b/modules/rich-presence/neocord/config.nix index 0ff3890..3856db1 100644 --- a/modules/rich-presence/neocord/config.nix +++ b/modules/rich-presence/neocord/config.nix @@ -3,17 +3,19 @@ lib, ... }: let - inherit (lib) mkIf nvim boolToString; - inherit (lib.nvim.lua) listToLuaTable; - inherit (lib.strings) escapeNixString; inherit (builtins) toString; + inherit (lib.modules) mkIf; + inherit (lib.trivial) boolToString; + inherit (lib.strings) escapeNixString; + inherit (lib.nvim.lua) listToLuaTable; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.presence.neocord; in { config = mkIf cfg.enable { vim.startPlugins = ["neocord"]; - vim.luaConfigRC.neocord = nvim.dag.entryAnywhere '' + vim.luaConfigRC.neocord = entryAnywhere '' -- Description of each option can be found in https://github.com/IogaMaster/neocord#lua require("neocord").setup({ -- General options diff --git a/modules/rich-presence/neocord/neocord.nix b/modules/rich-presence/neocord/neocord.nix index 514c7ff..c962d2d 100644 --- a/modules/rich-presence/neocord/neocord.nix +++ b/modules/rich-presence/neocord/neocord.nix @@ -1,5 +1,7 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkOption types literalExpression mkRemovedOptionModule; + inherit (lib.modules) mkRemovedOptionModule; + inherit (lib.options) mkEnableOption mkOption literalExpression; + inherit (lib.types) bool int str enum nullOr listOf; in { imports = [ (mkRemovedOptionModule ["vim" "presence" "presence-nvim"] '' @@ -14,7 +16,7 @@ in { enable = mkEnableOption "neocord plugin for discord rich presence"; logo = mkOption { - type = types.str; # TODO: can the default be documented better, maybe with an enum? + type = str; # TODO: can the default be documented better, maybe with an enum? default = "auto"; description = '' Logo to be displayed on the RPC item @@ -24,55 +26,55 @@ in { }; logo_tooltip = mkOption { - type = types.str; + type = str; default = "The One True Text Editor"; description = "Text displayed when hovering over the Neovim image"; }; main_image = mkOption { - type = types.enum ["language" "logo"]; + type = enum ["language" "logo"]; default = "language"; description = "Main image to be displayed"; }; client_id = mkOption { - type = types.str; + type = str; default = "1157438221865717891"; description = "Client ID of the application"; }; log_level = mkOption { - type = with types; nullOr (enum ["debug" "info" "warn" "error"]); + type = nullOr (enum ["debug" "info" "warn" "error"]); default = null; description = "Log level to be used by the plugin"; }; debounce_timeout = mkOption { - type = types.int; + type = int; default = 10; description = "Number of seconds to debounce events"; }; auto_update = mkOption { - type = types.bool; + type = bool; default = true; description = "Automatically update the presence"; }; enable_line_number = mkOption { - type = types.bool; + type = bool; default = false; description = "Show line number on the RPC item"; }; show_time = mkOption { - type = types.bool; + type = bool; default = true; description = "Show time on the RPC item"; }; blacklist = mkOption { - type = with types; listOf str; + type = listOf str; default = []; example = literalExpression ''["Alpha"]''; description = "List of filetypes to ignore"; @@ -80,49 +82,49 @@ in { rich_presence = { editing_text = mkOption { - type = types.str; + type = str; default = "Editing %s"; description = "Text displayed when editing a file"; }; file_explorer_text = mkOption { - type = types.str; + type = str; default = "Browsing %s"; description = "Text displayed when browsing files"; }; git_commit_text = mkOption { - type = types.str; + type = str; default = "Committing changes"; description = "Text displayed when committing changes"; }; plugin_manager_text = mkOption { - type = types.str; + type = str; default = "Managing plugins"; description = "Text displayed when managing plugins"; }; reading_text = mkOption { - type = types.str; + type = str; default = "Reading %s"; description = "Text displayed when reading a file"; }; workspace_text = mkOption { - type = types.str; + type = str; default = "Working on %s"; description = "Text displayed when working on a project"; }; line_number_text = mkOption { - type = types.str; + type = str; default = "Line %s out of %s"; description = "Text displayed when showing line number"; }; terminal_text = mkOption { - type = types.str; + type = str; default = "Working on the terminal"; description = "Text displayed when working on the terminal"; }; diff --git a/modules/ui/borders/borders.nix b/modules/ui/borders/borders.nix index fb767ce..4d4952b 100644 --- a/modules/ui/borders/borders.nix +++ b/modules/ui/borders/borders.nix @@ -4,6 +4,7 @@ ... }: let inherit (lib.options) mkOption mkEnableOption; + inherit (lib.lists) optionals; inherit (lib.types) enum; cfg = config.vim.ui.borders; @@ -27,7 +28,7 @@ in { enable = mkEnableOption "borders for the ${name} plugin" // {default = cfg.enable;}; style = mkOption { - type = enum (defaultStyles ++ lib.optionals (name != "which-key") ["shadow"]); + type = enum (defaultStyles ++ optionals (name != "which-key") ["shadow"]); default = cfg.globalStyle; description = "The border style to use for the ${name} plugin"; }; diff --git a/modules/ui/noice/noice.nix b/modules/ui/noice/noice.nix index df4ce85..3997987 100644 --- a/modules/ui/noice/noice.nix +++ b/modules/ui/noice/noice.nix @@ -1,5 +1,5 @@ {lib, ...}: let - inherit (lib) mkEnableOption; + inherit (lib.options) mkEnableOption; in { options.vim.ui.noice = { enable = mkEnableOption "UI modification library [noice.nvim]"; diff --git a/modules/utility/binds/cheatsheet/cheatsheet.nix b/modules/utility/binds/cheatsheet/cheatsheet.nix index 667fafa..cddc6a5 100644 --- a/modules/utility/binds/cheatsheet/cheatsheet.nix +++ b/modules/utility/binds/cheatsheet/cheatsheet.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib) mkEnableOption; + inherit (lib.options) mkEnableOption; in { options.vim.binds.cheatsheet = { enable = mkEnableOption "cheatsheet-nvim: searchable cheatsheet for nvim using telescope"; diff --git a/modules/utility/binds/cheatsheet/config.nix b/modules/utility/binds/cheatsheet/config.nix index b5439a9..d0edf10 100644 --- a/modules/utility/binds/cheatsheet/config.nix +++ b/modules/utility/binds/cheatsheet/config.nix @@ -3,14 +3,15 @@ lib, ... }: let - inherit (lib) mkIf nvim; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.binds.cheatsheet; in { config = mkIf (cfg.enable) { vim.startPlugins = ["cheatsheet-nvim"]; - vim.luaConfigRC.cheaetsheet-nvim = nvim.dag.entryAnywhere '' + vim.luaConfigRC.cheaetsheet-nvim = entryAnywhere '' require('cheatsheet').setup({}) ''; }; diff --git a/modules/utility/ccc/ccc.nix b/modules/utility/ccc/ccc.nix index dab4ec9..f900b53 100644 --- a/modules/utility/ccc/ccc.nix +++ b/modules/utility/ccc/ccc.nix @@ -1,5 +1,6 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkMappingOption; + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.binds) mkMappingOption; in { options.vim.utility.ccc = { enable = mkEnableOption "ccc color picker for neovim"; diff --git a/modules/utility/ccc/config.nix b/modules/utility/ccc/config.nix index 5318d02..a9589bb 100644 --- a/modules/utility/ccc/config.nix +++ b/modules/utility/ccc/config.nix @@ -3,20 +3,17 @@ lib, ... }: let - inherit (lib) addDescriptionsToMappings mkIf nvim; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.utility.ccc; - self = import ./ccc.nix {inherit lib;}; - - mappingDefinitions = self.options.vim.utility.ccc.mappings; - mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; in { config = mkIf (cfg.enable) { vim.startPlugins = [ "ccc" ]; - vim.luaConfigRC.ccc = nvim.dag.entryAnywhere '' + vim.luaConfigRC.ccc = entryAnywhere '' local ccc = require("ccc") ccc.setup { highlighter = { diff --git a/modules/utility/diffview/config.nix b/modules/utility/diffview/config.nix index a572805..ffe8a58 100644 --- a/modules/utility/diffview/config.nix +++ b/modules/utility/diffview/config.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib) mkIf nvim; + inherit (lib.modules) mkIf; cfg = config.vim.utility.diffview-nvim; in { @@ -12,9 +12,5 @@ in { "diffview-nvim" "plenary-nvim" ]; - - vim.luaConfigRC.diffview-nvim = - nvim.dag.entryAnywhere '' - ''; }; } diff --git a/modules/utility/diffview/diffview.nix b/modules/utility/diffview/diffview.nix index 4830aba..74ddd57 100644 --- a/modules/utility/diffview/diffview.nix +++ b/modules/utility/diffview/diffview.nix @@ -1,5 +1,5 @@ {lib, ...}: let - inherit (lib) mkEnableOption; + inherit (lib.options) mkEnableOption; in { options.vim.utility.diffview-nvim = { enable = mkEnableOption "diffview-nvim: cycle through diffs for all modified files for any git rev"; diff --git a/modules/utility/gestures/gesture-nvim/config.nix b/modules/utility/gestures/gesture-nvim/config.nix index a926051..62a89ce 100644 --- a/modules/utility/gestures/gesture-nvim/config.nix +++ b/modules/utility/gestures/gesture-nvim/config.nix @@ -3,7 +3,9 @@ lib, ... }: let - inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetLuaBinding nvim; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.gestures.gesture-nvim; @@ -23,7 +25,7 @@ in { }) ]; - vim.luaConfigRC.gesture-nvim = nvim.dag.entryAnywhere '' + vim.luaConfigRC.gesture-nvim = entryAnywhere '' vim.opt.mouse = "a" local gesture = require("gesture") diff --git a/modules/utility/gestures/gesture-nvim/gesture-nvim.nix b/modules/utility/gestures/gesture-nvim/gesture-nvim.nix index bd963b3..aad51dc 100644 --- a/modules/utility/gestures/gesture-nvim/gesture-nvim.nix +++ b/modules/utility/gestures/gesture-nvim/gesture-nvim.nix @@ -1,5 +1,6 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkMappingOption; + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.binds) mkMappingOption; in { options.vim.gestures.gesture-nvim = { enable = mkEnableOption "gesture-nvim: mouse gestures"; diff --git a/modules/utility/icon-picker/config.nix b/modules/utility/icon-picker/config.nix index 642c9a4..79cd376 100644 --- a/modules/utility/icon-picker/config.nix +++ b/modules/utility/icon-picker/config.nix @@ -3,7 +3,8 @@ lib, ... }: let - inherit (lib) mkIf nvim; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.utility.icon-picker; in { @@ -13,7 +14,7 @@ in { "dressing-nvim" ]; - vim.luaConfigRC.icon-picker = nvim.dag.entryAnywhere '' + vim.luaConfigRC.icon-picker = entryAnywhere '' require("icon-picker").setup({ disable_legacy_commands = true }) diff --git a/modules/utility/icon-picker/icon-picker.nix b/modules/utility/icon-picker/icon-picker.nix index 94e16be..e91a4a6 100644 --- a/modules/utility/icon-picker/icon-picker.nix +++ b/modules/utility/icon-picker/icon-picker.nix @@ -1,5 +1,5 @@ {lib, ...}: let - inherit (lib) mkEnableOption; + inherit (lib.options) mkEnableOption; in { options.vim.utility.icon-picker = { enable = mkEnableOption "nerdfonts icon picker for nvim"; diff --git a/modules/utility/motion/hop/config.nix b/modules/utility/motion/hop/config.nix index 34015dc..94c4a8c 100644 --- a/modules/utility/motion/hop/config.nix +++ b/modules/utility/motion/hop/config.nix @@ -3,7 +3,9 @@ lib, ... }: let - inherit (lib) addDescriptionsToMappings mkIf mkSetBinding nvim; + inherit (lib.modules) mkIf; + inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.utility.motion.hop; @@ -17,7 +19,7 @@ in { vim.maps.normal = mkSetBinding mappings.hop " HopPattern"; - vim.luaConfigRC.hop-nvim = nvim.dag.entryAnywhere '' + vim.luaConfigRC.hop-nvim = entryAnywhere '' require('hop').setup() ''; }; diff --git a/modules/utility/motion/hop/hop.nix b/modules/utility/motion/hop/hop.nix index ada8bc3..6947ffc 100644 --- a/modules/utility/motion/hop/hop.nix +++ b/modules/utility/motion/hop/hop.nix @@ -1,5 +1,6 @@ {lib, ...}: let - inherit (lib) mkMappingOption mkEnableOption; + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.binds) mkMappingOption; in { options.vim.utility.motion.hop = { mappings = { diff --git a/modules/utility/motion/leap/config.nix b/modules/utility/motion/leap/config.nix index 4bfa3e8..f9a9655 100644 --- a/modules/utility/motion/leap/config.nix +++ b/modules/utility/motion/leap/config.nix @@ -3,7 +3,9 @@ lib, ... }: let - inherit (lib) mkIf mkMerge mkBinding nvim; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.binds) mkBinding; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.utility.motion.leap; in { @@ -35,7 +37,7 @@ in { (mkBinding cfg.mappings.leapFromWindow "(leap-from-window)" "Leap from window") ]; - vim.luaConfigRC.leap-nvim = nvim.dag.entryAnywhere '' + vim.luaConfigRC.leap-nvim = entryAnywhere '' require('leap').opts = { max_phase_one_targets = nil, highlight_unlabeled_phase_one_targets = false, diff --git a/modules/utility/motion/leap/leap.nix b/modules/utility/motion/leap/leap.nix index 6f00822..a5d7243 100644 --- a/modules/utility/motion/leap/leap.nix +++ b/modules/utility/motion/leap/leap.nix @@ -1,32 +1,33 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkOption types; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) nullOr str; in { options.vim.utility.motion.leap = { enable = mkEnableOption "leap.nvim plugin (easy motion)"; mappings = { leapForwardTo = mkOption { - type = types.nullOr types.str; + type = nullOr str; description = "Leap forward to"; default = "s"; }; leapBackwardTo = mkOption { - type = types.nullOr types.str; + type = nullOr str; description = "Leap backward to"; default = "S"; }; leapForwardTill = mkOption { - type = types.nullOr types.str; + type = nullOr str; description = "Leap forward till"; default = "x"; }; leapBackwardTill = mkOption { - type = types.nullOr types.str; + type = nullOr str; description = "Leap backward till"; default = "X"; }; leapFromWindow = mkOption { - type = types.nullOr types.str; + type = nullOr str; description = "Leap from window"; default = "gs"; }; diff --git a/modules/utility/preview/glow/config.nix b/modules/utility/preview/glow/config.nix index aca57f0..cf1e460 100644 --- a/modules/utility/preview/glow/config.nix +++ b/modules/utility/preview/glow/config.nix @@ -4,7 +4,11 @@ lib, ... }: let - inherit (lib) nvim mkIf mkMerge mkBinding pushDownDefault; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.binds) mkBinding; + inherit (lib.nvim.dag) entryAnywhere; + # TODO: move this to its own module + inherit (lib) pushDownDefault; cfg = config.vim.utility.preview.glow; self = import ./glow.nix { @@ -23,7 +27,7 @@ in { "pm" = "+Preview Markdown"; }; - vim.luaConfigRC.glow = nvim.dag.entryAnywhere '' + vim.luaConfigRC.glow = entryAnywhere '' require('glow').setup({ glow_path = "${pkgs.glow}/bin/glow" }); diff --git a/modules/utility/preview/glow/glow.nix b/modules/utility/preview/glow/glow.nix index 4843421..69f9f93 100644 --- a/modules/utility/preview/glow/glow.nix +++ b/modules/utility/preview/glow/glow.nix @@ -1,5 +1,7 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkMappingOption mkRenamedOptionModule; + inherit (lib.modules) mkRenamedOptionModule; + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.binds) mkMappingOption; in { imports = [ (mkRenamedOptionModule ["vim" "languages" "markdown" "glow" "enable"] ["vim" "utility" "preview" "glow" "enable"]) diff --git a/modules/utility/preview/markdown-preview/config.nix b/modules/utility/preview/markdown-preview/config.nix index b60f612..750cf7e 100644 --- a/modules/utility/preview/markdown-preview/config.nix +++ b/modules/utility/preview/markdown-preview/config.nix @@ -4,15 +4,17 @@ lib, ... }: let - inherit (lib) nvim mkIf concatMapStringsSep optionalString stringLength; - inherit (nvim.vim) mkVimBool; + inherit (lib.strings) optionalString stringLength concatMapStringsSep; + inherit (lib.modules) mkIf; + inherit (lib.nvim.vim) mkVimBool; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.utility.preview.markdownPreview; in { config = mkIf cfg.enable { vim.startPlugins = [pkgs.vimPlugins.markdown-preview-nvim]; - vim.configRC.markdown-preview = nvim.dag.entryAnywhere '' + vim.configRC.markdown-preview = entryAnywhere '' let g:mkdp_auto_start = ${mkVimBool cfg.autoStart} let g:mkdp_auto_close = ${mkVimBool cfg.autoClose} let g:mkdp_refresh_slow = ${mkVimBool cfg.lazyRefresh} diff --git a/modules/utility/preview/markdown-preview/markdown-preview.nix b/modules/utility/preview/markdown-preview/markdown-preview.nix index c3244b0..1d3b393 100644 --- a/modules/utility/preview/markdown-preview/markdown-preview.nix +++ b/modules/utility/preview/markdown-preview/markdown-preview.nix @@ -1,54 +1,55 @@ {lib, ...}: let - inherit (lib) types mkEnableOption mkOption; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) bool str listOf; in { options.vim.utility.preview = { markdownPreview = { enable = mkEnableOption "Markdown preview in neovim with markdown-preview.nvim"; autoStart = mkOption { - type = types.bool; + type = bool; default = false; description = "Automatically open the preview window after entering a Markdown buffer"; }; autoClose = mkOption { - type = types.bool; + type = bool; default = true; description = "Automatically close the preview window after leaving a Markdown buffer"; }; lazyRefresh = mkOption { - type = types.bool; + type = bool; default = false; description = "Only update preview when saving or leaving insert mode"; }; filetypes = mkOption { - type = with types; listOf str; + type = listOf str; default = ["markdown"]; description = "Allowed filetypes"; }; alwaysAllowPreview = mkOption { - type = types.bool; + type = bool; default = false; description = "Allow preview on all filetypes"; }; broadcastServer = mkOption { - type = types.bool; + type = bool; default = false; description = "Allow for outside and network wide connections"; }; customIP = mkOption { - type = types.str; + type = str; default = ""; description = "IP-address to use"; }; customPort = mkOption { - type = types.str; + type = str; default = ""; description = "Port to use"; }; diff --git a/modules/utility/surround/config.nix b/modules/utility/surround/config.nix index 78ec0a8..e392d9a 100644 --- a/modules/utility/surround/config.nix +++ b/modules/utility/surround/config.nix @@ -3,7 +3,9 @@ lib, ... }: let - inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.utility.surround; self = import ./surround.nix {inherit lib config;}; @@ -16,7 +18,7 @@ in { "nvim-surround" ]; - luaConfigRC.surround = nvim.dag.entryAnywhere '' + luaConfigRC.surround = entryAnywhere '' require('nvim-surround').setup() ''; diff --git a/modules/utility/surround/surround.nix b/modules/utility/surround/surround.nix index 7b20fb4..8024c9b 100644 --- a/modules/utility/surround/surround.nix +++ b/modules/utility/surround/surround.nix @@ -3,67 +3,69 @@ config, ... }: let - inherit (lib) mkOption types mkIf mkDefault; + inherit (lib.modules) mkIf mkDefault; + inherit (lib.options) mkOption; + inherit (lib.types) bool nullOr str; in { options.vim.utility.surround = { enable = mkOption { - type = types.bool; + type = bool; default = false; description = "nvim-surround: add/change/delete surrounding delimiter pairs with ease. Note that the default mappings deviate from upstreeam to avoid conflicts with nvim-leap."; }; useVendoredKeybindings = mkOption { - type = types.bool; + type = bool; default = true; description = "Use alternative set of keybindings that avoids conflicts with other popular plugins, e.g. nvim-leap"; }; mappings = { insert = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = "z"; description = "Add surround character around the cursor"; }; insertLine = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = "Z"; description = "Add surround character around the cursor on new lines"; }; normal = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = "gz"; description = "Surround motion with character"; }; normalCur = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = "gZ"; description = "Surround motion with character on new lines"; }; normalLine = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = "gzz"; description = "Surround line with character"; }; normalCurLine = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = "gZZ"; description = "Surround line with character on new lines"; }; visual = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = "gz"; description = "Surround selection with character"; }; visualLine = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = "gZ"; description = "Surround selection with character on new lines"; }; delete = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = "gzd"; description = "Delete surrounding character"; }; change = mkOption { - type = types.nullOr types.str; + type = nullOr str; default = "gzr"; description = "Change surrounding character"; }; diff --git a/modules/utility/telescope/config.nix b/modules/utility/telescope/config.nix index eb7a14e..d9a156f 100644 --- a/modules/utility/telescope/config.nix +++ b/modules/utility/telescope/config.nix @@ -4,7 +4,11 @@ lib, ... }: let - inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim pushDownDefault; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding; + inherit (lib.nvim.dag) entryAnywhere; + # TODO: move this to its own module + inherit (lib) pushDownDefault; cfg = config.vim.telescope; self = import ./telescope.nix {inherit lib;}; @@ -60,7 +64,7 @@ in { "fvc" = "Commits"; }; - vim.luaConfigRC.telescope = nvim.dag.entryAnywhere '' + vim.luaConfigRC.telescope = entryAnywhere '' local telescope = require('telescope') telescope.setup { defaults = { diff --git a/modules/utility/telescope/telescope.nix b/modules/utility/telescope/telescope.nix index 12ea887..fd8d2f3 100644 --- a/modules/utility/telescope/telescope.nix +++ b/modules/utility/telescope/telescope.nix @@ -1,5 +1,6 @@ {lib, ...}: let - inherit (lib) mkMappingOption mkEnableOption; + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.binds) mkMappingOption; in { options.vim.telescope = { mappings = { diff --git a/modules/utility/wakatime/config.nix b/modules/utility/wakatime/config.nix index 69063e2..e6332d5 100644 --- a/modules/utility/wakatime/config.nix +++ b/modules/utility/wakatime/config.nix @@ -4,7 +4,8 @@ pkgs, ... }: let - inherit (lib) mkIf nvim; + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.utility.vim-wakatime; in { @@ -13,7 +14,7 @@ in { pkgs.vimPlugins.vim-wakatime ]; - vim.configRC.vim-wakatime = nvim.dag.entryAnywhere '' + vim.configRC.vim-wakatime = entryAnywhere '' ${ if cfg.cli-package == null then "" diff --git a/modules/utility/wakatime/vim-wakatime.nix b/modules/utility/wakatime/vim-wakatime.nix index f0f42b9..6b85382 100644 --- a/modules/utility/wakatime/vim-wakatime.nix +++ b/modules/utility/wakatime/vim-wakatime.nix @@ -3,13 +3,14 @@ pkgs, ... }: let - inherit (lib) mkEnableOption mkOption types; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) nullOr package; in { options.vim.utility.vim-wakatime = { enable = mkEnableOption "vim-wakatime: live code statistics"; cli-package = mkOption { - type = with types; nullOr package; + type = nullOr package; default = pkgs.wakatime; description = "The package that should be used for wakatime-cli. Set as null to use the default path in `$XDG_DATA_HOME`"; }; diff --git a/modules/visuals/config.nix b/modules/visuals/config.nix index 8cd4ecf..f920cd3 100644 --- a/modules/visuals/config.nix +++ b/modules/visuals/config.nix @@ -3,14 +3,18 @@ lib, ... }: let - inherit (lib) mkIf mkMerge nvim optionalString boolToString mkBinding; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.strings) optionalString; + inherit (lib.trivial) boolToString; + inherit (lib.nvim.binds) mkBinding; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.visuals; in { config = mkIf cfg.enable (mkMerge [ (mkIf cfg.indentBlankline.enable { vim.startPlugins = ["indent-blankline"]; - vim.luaConfigRC.indent-blankline = nvim.dag.entryAnywhere '' + vim.luaConfigRC.indent-blankline = entryAnywhere '' -- highlight error: https://github.com/lukas-reineke/indent-blankline.nvim/issues/59 -- vim.wo.colorcolumn = "99999" vim.opt.list = true @@ -42,7 +46,7 @@ in { (mkIf cfg.cursorline.enable { vim.startPlugins = ["nvim-cursorline"]; - vim.luaConfigRC.cursorline = nvim.dag.entryAnywhere '' + vim.luaConfigRC.cursorline = entryAnywhere '' require('nvim-cursorline').setup { cursorline = { timeout = ${toString cfg.cursorline.lineTimeout}, @@ -58,7 +62,7 @@ in { (mkIf cfg.scrollBar.enable { vim.startPlugins = ["scrollbar-nvim"]; - vim.luaConfigRC.scrollBar = nvim.dag.entryAnywhere '' + vim.luaConfigRC.scrollBar = entryAnywhere '' require('scrollbar').setup{ excluded_filetypes = { 'prompt', @@ -77,7 +81,7 @@ in { (mkIf cfg.smoothScroll.enable { vim.startPlugins = ["cinnamon-nvim"]; - vim.luaConfigRC.smoothScroll = nvim.dag.entryAnywhere '' + vim.luaConfigRC.smoothScroll = entryAnywhere '' require('cinnamon').setup() ''; }) @@ -87,7 +91,7 @@ in { vim.maps.normal = mkBinding cfg.cellularAutomaton.mappings.makeItRain "CellularAutomaton make_it_rain" "Make it rain"; - vim.luaConfigRC.cellularAUtomaton = nvim.dag.entryAnywhere '' + vim.luaConfigRC.cellularAUtomaton = entryAnywhere '' local config = { fps = 50, name = 'slide', @@ -115,7 +119,7 @@ in { (mkIf cfg.highlight-undo.enable { vim.startPlugins = ["highlight-undo"]; - vim.luaConfigRC.highlight-undo = nvim.dag.entryAnywhere '' + vim.luaConfigRC.highlight-undo = entryAnywhere '' require('highlight-undo').setup({ duration = ${toString cfg.highlight-undo.duration}, highlight_for_count = ${boolToString cfg.highlight-undo.highlightForCount}, diff --git a/modules/visuals/fidget/config.nix b/modules/visuals/fidget/config.nix index cb212db..cde2f63 100644 --- a/modules/visuals/fidget/config.nix +++ b/modules/visuals/fidget/config.nix @@ -3,14 +3,17 @@ lib, ... }: let - inherit (lib) mkIf nvim; + inherit (lib.modules) mkIf; + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.nvim.dag) entryAnywhere; + 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}) + vim.luaConfigRC.fidget-nvim = entryAnywhere '' + require'fidget'.setup(${toLuaObject cfg.setupOpts}) ''; }; } diff --git a/modules/visuals/fidget/fidget.nix b/modules/visuals/fidget/fidget.nix index 173cfd8..482391a 100644 --- a/modules/visuals/fidget/fidget.nix +++ b/modules/visuals/fidget/fidget.nix @@ -3,7 +3,13 @@ lib, ... }: let - inherit (lib) mkRemovedOptionModule mkEnableOption mkOption mapAttrs toUpper nvim types mkRenamedOptionModule; + inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.attrsets) mapAttrs; + inherit (lib.strings) toUpper; + inherit (lib.types) int float bool str enum listOf attrsOf; + inherit (lib.nvim.types) mkPluginSetupOption; + rawLua = lua: {__raw = lua;}; in { imports = [ @@ -15,31 +21,31 @@ in { options.vim.visuals.fidget-nvim = { enable = mkEnableOption "nvim LSP UI element [fidget-nvim]"; - setupOpts = nvim.types.mkPluginSetupOption "Fidget" { + setupOpts = mkPluginSetupOption "Fidget" { progress = { poll_rate = mkOption { description = "How frequently to poll for LSP progress messages"; - type = types.int; + type = int; default = 0; }; suppress_on_insert = mkOption { description = "Suppress new messages when in insert mode"; - type = types.bool; + type = bool; default = false; }; ignore_done_already = mkOption { description = "Ignore new tasks that are already done"; - type = types.bool; + type = bool; default = false; }; ignore_empty_message = mkOption { description = "Ignore new tasks with empty messages"; - type = types.bool; + type = bool; default = false; }; clear_on_detach = mkOption { description = "Clear notification group when LSP server detaches"; - type = types.bool; + type = bool; default = true; apply = clear: if clear @@ -54,7 +60,7 @@ in { }; notification_group = mkOption { description = "How to get a progress message's notification group key"; - type = types.str; + type = str; default = '' function(msg) return msg.lsp_client.name @@ -64,40 +70,40 @@ in { }; ignore = mkOption { description = "Ignore LSP servers by name"; - type = types.listOf types.str; + type = listOf str; default = []; }; display = { render_limit = mkOption { description = "Maximum number of messages to render"; - type = types.int; + type = int; default = 16; }; done_ttl = mkOption { description = "How long a message should persist when complete"; - type = types.int; + type = int; default = 3; }; done_icon = mkOption { description = "Icon shown when LSP progress tasks are completed"; - type = types.str; + type = str; default = "✓"; }; done_style = mkOption { description = "Highlight group for completed LSP tasks"; - type = types.str; + type = str; default = "Constant"; }; progress_ttl = mkOption { description = "How long a message should persist when in progress"; - type = types.int; + type = int; default = 99999; }; progress_icon = { pattern = mkOption { description = "Pattern shown when LSP progress tasks are in progress"; - type = types.enum [ + type = enum [ "dots" "dots_negative" "dots_snake" @@ -136,38 +142,38 @@ in { }; period = mkOption { description = "Period of the pattern"; - type = types.int; + type = int; default = 1; }; }; progress_style = mkOption { description = "Highlight group for in-progress LSP tasks"; - type = types.str; + type = str; default = "WarningMsg"; }; group_style = mkOption { description = "Highlight group for group name (LSP server name)"; - type = types.str; + type = str; default = "Title"; }; icon_style = mkOption { description = "Highlight group for group icons"; - type = types.str; + type = str; default = "Question"; }; priority = mkOption { description = "Priority of the progress notification"; - type = types.int; + type = int; default = 30; }; skip_history = mkOption { description = "Skip adding messages to history"; - type = types.bool; + type = bool; default = true; }; format_message = mkOption { description = "How to format a progress message"; - type = types.str; + type = str; default = '' require("fidget.progress.display").default_format_message ''; @@ -175,7 +181,7 @@ in { }; format_annote = mkOption { description = "How to format a progress annotation"; - type = types.str; + type = str; default = '' function(msg) return msg.title end ''; @@ -183,7 +189,7 @@ in { }; format_group_name = mkOption { description = "How to format a progress notification group's name"; - type = types.str; + type = str; default = '' function(group) return tostring(group) end ''; @@ -191,7 +197,7 @@ in { }; overrides = mkOption { description = "Override options from the default notification config"; - type = types.attrsOf types.str; + type = attrsOf str; default = {rust_analyzer = "{ name = 'rust-analyzer' }";}; apply = mapAttrs (key: lua: rawLua lua); }; @@ -200,12 +206,12 @@ in { lsp = { progress_ringbuf_size = mkOption { description = "Nvim's LSP client ring buffer size"; - type = types.int; + type = int; default = 100; }; log_handler = mkOption { description = "Log `$/progress` handler invocations"; - type = types.bool; + type = bool; default = false; }; }; @@ -214,34 +220,34 @@ in { notification = { poll_rate = mkOption { description = "How frequently to update and render notifications"; - type = types.int; + type = int; default = 10; }; filter = mkOption { description = "Minimum notifications level"; - type = types.enum ["debug" "info" "warn" "error"]; + type = 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; + type = int; default = 128; }; override_vim_notify = mkOption { description = "Automatically override vim.notify() with Fidget"; - type = types.bool; + type = bool; default = false; }; configs = mkOption { description = "How to configure notification groups when instantiated"; - type = types.attrsOf types.str; + type = attrsOf 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; + type = str; default = '' function(msg, level, opts) if opts and opts.on_open then @@ -255,27 +261,27 @@ in { view = { stack_upwards = mkOption { description = "Display notification items from bottom to top"; - type = types.bool; + type = bool; default = true; }; icon_separator = mkOption { description = "Separator between group name and icon"; - type = types.str; + type = str; default = " "; }; group_separator = mkOption { description = "Separator between notification groups"; - type = types.str; + type = str; default = "---"; }; group_separator_hl = mkOption { description = "Highlight group used for group separator"; - type = types.str; + type = str; default = "Comment"; }; render_message = mkOption { description = "How to render notification messages"; - type = types.str; + type = str; default = '' function(msg, cnt) return cnt == 1 and msg or string.format("(%dx) %s", cnt, msg) @@ -288,17 +294,17 @@ in { window = { normal_hl = mkOption { description = "Base highlight group in the notification window"; - type = types.str; + type = str; default = "Comment"; }; winblend = mkOption { description = "Background color opacity in the notification window"; - type = types.int; + type = int; default = 100; }; border = mkOption { description = "Border style of the notification window"; - type = types.enum ["none" "single" "double" "rounded" "solid" "shadow"]; + type = enum ["none" "single" "double" "rounded" "solid" "shadow"]; default = if config.vim.ui.borders.enable then config.vim.ui.borders.globalStyle @@ -306,37 +312,37 @@ in { }; zindex = mkOption { description = "Stacking priority of the notification window"; - type = types.int; + type = int; default = 45; }; max_width = mkOption { description = "Maximum width of the notification window"; - type = types.int; + type = int; default = 0; }; max_height = mkOption { description = "Maximum height of the notification window"; - type = types.int; + type = int; default = 0; }; x_padding = mkOption { description = "Padding from right edge of window boundary"; - type = types.int; + type = int; default = 1; }; y_padding = mkOption { description = "Padding from bottom edge of window boundary"; - type = types.int; + type = int; default = 0; }; align = mkOption { description = "How to align the notification window"; - type = types.enum ["top" "bottom"]; + type = enum ["top" "bottom"]; default = "bottom"; }; relative = mkOption { description = "What the notification window position is relative to"; - type = types.enum ["editor" "win"]; + type = enum ["editor" "win"]; default = "editor"; }; }; @@ -346,7 +352,7 @@ in { nvim-tree = { enable = mkOption { description = "Integrate with nvim-tree/nvim-tree.lua (if enabled)"; - type = types.bool; + type = bool; default = if config.vim.filetree.nvimTree.enable then true @@ -356,7 +362,7 @@ in { xcodebuild-nvim = { enable = mkOption { description = "Integrate with wojciech-kulik/xcodebuild.nvim (if enabled)"; - type = types.bool; + type = bool; default = true; }; }; @@ -365,23 +371,23 @@ in { logger = { level = mkOption { description = "Minimum logging level"; - type = types.enum ["debug" "error" "info" "trace" "warn" "off"]; + type = 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; + type = int; default = 10000; }; float_precision = mkOption { description = "Limit the number of decimals displayed for floats"; - type = types.float; + type = float; default = 0.01; }; path = mkOption { description = "Where Fidget writes its logs to"; - type = types.str; + type = str; default = '' string.format("%s/fidget.nvim.log", vim.fn.stdpath("cache")) ''; diff --git a/modules/visuals/visuals.nix b/modules/visuals/visuals.nix index 4fde588..60ab907 100644 --- a/modules/visuals/visuals.nix +++ b/modules/visuals/visuals.nix @@ -3,7 +3,10 @@ lib, ... }: let - inherit (lib) mkEnableOption mkMappingOption mkOption types literalExpression mkRenamedOptionModule mkRemovedOptionModule; + inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule; + inherit (lib.options) mkEnableOption mkOption literalExpression; + inherit (lib.types) int bool str nullOr; + inherit (lib.nvim.binds) mkMappingOption; cfg = config.vim.visuals; in { @@ -34,13 +37,13 @@ in { enable = mkEnableOption "line hightlighting on the cursor [nvim-cursorline]"; lineTimeout = mkOption { - type = types.int; + type = int; description = "Time in milliseconds for cursorline to appear"; default = 0; }; lineNumbersOnly = mkOption { - type = types.bool; + type = bool; description = "Hightlight only in the presence of line numbers"; default = true; }; @@ -49,21 +52,21 @@ in { indentBlankline = { enable = mkEnableOption "indentation guides [indent-blankline]"; debounce = mkOption { - type = types.int; + type = int; description = "Debounce time in milliseconds"; default = 200; }; viewportBuffer = { min = mkOption { - type = types.int; + type = int; description = "Number of lines above and below of what is currently visible in the window"; default = 30; }; max = mkOption { - type = types.int; + type = int; description = "Number of lines above and below of what is currently visible in the window"; default = 500; @@ -72,34 +75,34 @@ in { indent = { char = mkOption { - type = types.str; + type = str; description = "Character for indentation line"; default = "│"; }; }; listChar = mkOption { - type = types.str; + type = str; description = "Character for indentation line"; default = "│"; }; fillChar = mkOption { description = "Character to fill indents"; - type = with types; nullOr types.str; + type = nullOr str; default = "⋅"; }; eolChar = mkOption { description = "Character at end of line"; - type = with types; nullOr types.str; + type = nullOr str; default = "↴"; }; scope = { enabled = mkOption { description = "Highlight current scope from treesitter"; - type = types.bool; + type = bool; default = config.vim.treesitter.enable; defaultText = literalExpression "config.vim.treesitter.enable"; }; @@ -109,7 +112,7 @@ in { Displays the end of line character set by [](#opt-vim.visuals.indentBlankline.eolChar) instead of the indent guide on line returns. ''; - type = types.bool; + type = bool; default = cfg.indentBlankline.eolChar != null; defaultText = literalExpression "config.vim.visuals.indentBlankline.eolChar != null"; }; @@ -120,7 +123,7 @@ in { enable = mkEnableOption "highlight undo [highlight-undo]"; highlightForCount = mkOption { - type = types.bool; + type = bool; default = true; description = '' Enable support for highlighting when a is provided before the key @@ -129,14 +132,14 @@ in { }; duration = mkOption { - type = types.int; + type = int; description = "Duration of highlight"; default = 500; }; undo = { hlGroup = mkOption { - type = types.str; + type = str; description = "Highlight group for undo"; default = "HighlightUndo"; }; @@ -144,7 +147,7 @@ in { redo = { hlGroup = mkOption { - type = types.str; + type = str; description = "Highlight group for redo"; default = "HighlightUndo"; }; From 315f44c6d6c6251abe3536080162535af768235b Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Sun, 24 Mar 2024 09:31:50 -0400 Subject: [PATCH 048/193] flake: provide formatter in default shell --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 2ad148f..cb9c5b8 100644 --- a/flake.nix +++ b/flake.nix @@ -46,7 +46,7 @@ default = self'.devShells.lsp; nvim-nix = pkgs.mkShell {nativeBuildInputs = [config.packages.nix];}; lsp = pkgs.mkShell { - nativeBuildInputs = with pkgs; [nil statix deadnix]; + nativeBuildInputs = with pkgs; [nil statix deadnix alejandra]; }; }; }; From db0df5c211752284908d164ccc2130eb30a55fef Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 3 Apr 2024 21:13:19 +0300 Subject: [PATCH 049/193] flake: update plugin inputs --- flake.lock | 293 ++++++++++++++------------- flake.nix | 6 + lib/types/plugins.nix | 1 + modules/debugger/nvim-dap/config.nix | 2 +- 4 files changed, 163 insertions(+), 139 deletions(-) diff --git a/flake.lock b/flake.lock index ae4bd62..4316578 100644 --- a/flake.lock +++ b/flake.lock @@ -35,11 +35,11 @@ "catppuccin": { "flake": false, "locked": { - "lastModified": 1709646581, - "narHash": "sha256-arOnsTg+q14qMI24QrcA/ca3tU7qxhoenRksRk1xBtE=", + "lastModified": 1711706907, + "narHash": "sha256-GQjxE8lQj52pheJtHCS+9v2lsJY7wMj2IXVCoNRmQSQ=", "owner": "catppuccin", "repo": "nvim", - "rev": "045e3499d9ec8d84635fb08877ae44fd33f6a38d", + "rev": "aebe43db9cb26e1c70fc5b2fd4158169c405e720", "type": "github" }, "original": { @@ -51,11 +51,11 @@ "ccc": { "flake": false, "locked": { - "lastModified": 1709880055, - "narHash": "sha256-8+QB1yxBoqd6m/UaLWQk+gYuk7XJhgbvfHwpGi57JEE=", + "lastModified": 1711976559, + "narHash": "sha256-rSOjeklOdIPQvxNfUBG9Hm001cIlBgrPYcnm7afc9TE=", "owner": "uga-rosa", "repo": "ccc.nvim", - "rev": "f3d9d31aab7990d50ae6922fd7c1e3a9eb7da183", + "rev": "46b8a38a3bc287f27789800d3d26480d093d65b5", "type": "github" }, "original": { @@ -99,11 +99,11 @@ "cinnamon-nvim": { "flake": false, "locked": { - "lastModified": 1670143364, - "narHash": "sha256-JglXQhoPgN9sQ3yuv0+VQxmKMvoQTu5lbGLSRaQkytI=", + "lastModified": 1711005384, + "narHash": "sha256-LNikkGldBpUsfyH8ThtX7RS1p/z3JzSPonT9qUU84jw=", "owner": "declancm", "repo": "cinnamon.nvim", - "rev": "c406ffda3a0302f32c23b24ab756ea20467d6578", + "rev": "559fe02fae00ffd78377e9c242b2faa25a428592", "type": "github" }, "original": { @@ -259,11 +259,11 @@ "crates-nvim": { "flake": false, "locked": { - "lastModified": 1709849980, - "narHash": "sha256-D92Ot13H2ILs6wp5UWKui0+ZJtBOlA7gd5l51EBn95g=", + "lastModified": 1710361360, + "narHash": "sha256-wfwSHuP05PEqCbpEG7GStGElMLkrDEbPW7V6p1EANGU=", "owner": "Saecki", "repo": "crates.nvim", - "rev": "535773ed3b321d68ddd6ef8cd5a1e07b345026a6", + "rev": "b4f4987ccdb1cc3899ee541ef4375c73c48c4570", "type": "github" }, "original": { @@ -275,11 +275,11 @@ "dashboard-nvim": { "flake": false, "locked": { - "lastModified": 1707803848, - "narHash": "sha256-vi82Q+ytumRmpLIRT2QhOCR547xJ4ynSPWokQAY7uF0=", + "lastModified": 1712122933, + "narHash": "sha256-s2PDyOnE3jVk+RCp0aaV2vVJGkO394iDhQTEHRcb9kY=", "owner": "glepnir", "repo": "dashboard-nvim", - "rev": "413442b12d85315fc626c44a0ce4929b213ef604", + "rev": "7c0c09d55118a2afeb8874e885f87ae80d8ff452", "type": "github" }, "original": { @@ -340,11 +340,11 @@ "dressing-nvim": { "flake": false, "locked": { - "lastModified": 1706493651, - "narHash": "sha256-Y+ABLhb3GIaPKOuQzkxsZsTo1WfgURAYVioP/eCSp/Y=", + "lastModified": 1710299803, + "narHash": "sha256-9AwOFTRvhWFo7USgoFYfceiojZM62IXPpBs8CnSqc18=", "owner": "stevearc", "repo": "dressing.nvim", - "rev": "6f212262061a2120e42da0d1e87326e8a41c0478", + "rev": "18e5beb3845f085b6a33c24112b37988f3f93c06", "type": "github" }, "original": { @@ -356,11 +356,11 @@ "elixir-ls": { "flake": false, "locked": { - "lastModified": 1709063485, - "narHash": "sha256-7Kc4LClN4jCpTnKJsMnYtc8jaatefXdvysOnndA4TK8=", + "lastModified": 1711286188, + "narHash": "sha256-OIB5f+FBOPsTWKGWyoU+/NQDMsJXBdj1v7UclbTP5ZY=", "owner": "elixir-lsp", "repo": "elixir-ls", - "rev": "cb5315afca9e624ce1ba1040607d6a154727d8c1", + "rev": "3e71900e0d0891f9f95e35d9a52b16c6a773a259", "type": "github" }, "original": { @@ -372,11 +372,11 @@ "elixir-tools": { "flake": false, "locked": { - "lastModified": 1709873623, - "narHash": "sha256-1QuEz45AjaO/sF7PtRISCP57tLFlLFvIgw2upnGHnZk=", + "lastModified": 1710172806, + "narHash": "sha256-pVDeS9oCFzA9t9J/JfYG/RfdMoSmaaERd5nUgL9KHyM=", "owner": "elixir-tools", "repo": "elixir-tools.nvim", - "rev": "3048ae88235eb4c1a7ae789185aa23edb479a995", + "rev": "4d003f4b41ab9b4f8b569104fa7818f048ed4e25", "type": "github" }, "original": { @@ -388,11 +388,11 @@ "fidget-nvim": { "flake": false, "locked": { - "lastModified": 1708381371, - "narHash": "sha256-cfoz2nGX7yzDLjTitposErJpC8EVX0DBy69kFKY0jps=", + "lastModified": 1710942727, + "narHash": "sha256-8pBg8uQto5UzNBRhjFFMMmWLnmpYsG0L1mDa+FN8tpU=", "owner": "j-hui", "repo": "fidget.nvim", - "rev": "60404ba67044c6ab01894dd5bf77bd64ea5e09aa", + "rev": "933db4596e4bab1b09b6d48a10e21819e4cc458f", "type": "github" }, "original": { @@ -422,11 +422,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1709336216, - "narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=", + "lastModified": 1712014858, + "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2", + "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", "type": "github" }, "original": { @@ -440,11 +440,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1709126324, - "narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "d465f4819400de7c8d874d50b982301f28a84605", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -471,11 +471,11 @@ "flutter-tools": { "flake": false, "locked": { - "lastModified": 1708365315, - "narHash": "sha256-8zdaw+Ns/IqCt0MCGyJC2fGHmkMEn9kbvdE0leA+vI8=", + "lastModified": 1711622317, + "narHash": "sha256-TQRz2MHg6qnzZGUDVFUoaZJiTBwQ3Hjqvc8AAeVS93Y=", "owner": "akinsho", "repo": "flutter-tools.nvim", - "rev": "01d72d9c1bdf2d454a60c5ba450f83e5ea783f6a", + "rev": "4f18033c3b78aa5450e538d81dfbbb3e67aeadec", "type": "github" }, "original": { @@ -503,11 +503,11 @@ "gitsigns-nvim": { "flake": false, "locked": { - "lastModified": 1706372432, - "narHash": "sha256-SLDaqzbvBTTuJEP9H2WOADuxsguMntR+upsGPW8aOEk=", + "lastModified": 1712162672, + "narHash": "sha256-uEHuKccCAYpLGVJovz2PY2Q7THA47z8TA5CHWexBv3E=", "owner": "lewis6991", "repo": "gitsigns.nvim", - "rev": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae", + "rev": "b45ff86f5618d1421a88c12d4feb286b80a1e2d3", "type": "github" }, "original": { @@ -599,11 +599,11 @@ "image-nvim": { "flake": false, "locked": { - "lastModified": 1708996376, - "narHash": "sha256-XaC14kVGgK0fOjZHbPEixQU7dty7Di4faGl+h63Wlj0=", + "lastModified": 1711809713, + "narHash": "sha256-4xsyVDZOFidvLqwfWRB7BPMOejWk3/uhsnUsCNG/hpU=", "owner": "3rd", "repo": "image.nvim", - "rev": "0dd8bdbb8855bc98c534a902c91dc9eddb8155b1", + "rev": "a0b756d589c1623ebbfe344666e6d7c49bdc9d71", "type": "github" }, "original": { @@ -615,11 +615,11 @@ "indent-blankline": { "flake": false, "locked": { - "lastModified": 1707806353, - "narHash": "sha256-ZzsQVLP7EmHeVEkSvbENce/hk1HANN+qL8Vv7FaOiV0=", + "lastModified": 1710388427, + "narHash": "sha256-Xp8ZQBz0in2MX3l0bnLUsSbH0lDPE+QvdmFpBFry5yY=", "owner": "lukas-reineke", "repo": "indent-blankline.nvim", - "rev": "821a7acd88587d966f7e464b0b3031dfe7f5680c", + "rev": "3d08501caef2329aba5121b753e903904088f7e6", "type": "github" }, "original": { @@ -647,11 +647,11 @@ "leap-nvim": { "flake": false, "locked": { - "lastModified": 1709760573, - "narHash": "sha256-LauAJuXLHXtviSlt9MtdcvfT1CL600QISP+WEdma5RY=", + "lastModified": 1711935259, + "narHash": "sha256-HcuNaKyf+rmhg3t4BQXiRlyeavwyhy16pfPn1Y1l09k=", "owner": "ggandor", "repo": "leap.nvim", - "rev": "89d878f8399d00fb348ad65b6077b996808234d8", + "rev": "7a9407d17fab3a1c3cfe201965d680a408776152", "type": "github" }, "original": { @@ -663,11 +663,11 @@ "lsp-lines": { "flake": false, "locked": { - "lastModified": 1698584731, - "narHash": "sha256-3DWM2mTnm6b7J4cYUwCKBGHkXw/dQDO0ZTJXkTl06aE=", + "lastModified": 1709989705, + "narHash": "sha256-opViLzbwtyUgDoaVKz4z6SN06N8jCQ0YmoqPIht8e64=", "owner": "~whynothugo", "repo": "lsp_lines.nvim", - "rev": "cf2306dd332e34a3e91075b40bdd4f6db824b2ee", + "rev": "6f3defec73f7c87939e800e9afa5d0571b19b401", "type": "sourcehut" }, "original": { @@ -679,11 +679,11 @@ "lsp-signature": { "flake": false, "locked": { - "lastModified": 1709592196, - "narHash": "sha256-WAQ8DWjNWKYBbELC/M8ClGxU0cAqB4X1TlkWIEBqp24=", + "lastModified": 1710647656, + "narHash": "sha256-O7y7pcCvF0xUFamG+wMLe4mC6hUQ679rJV+ZUoWB0oY=", "owner": "ray-x", "repo": "lsp_signature.nvim", - "rev": "e92b4e7073345b2a30a56b20db3d541a9aa2771e", + "rev": "c6aeb2f1d2538bbdfdaab1664d9d4c3c75aa9db8", "type": "github" }, "original": { @@ -727,11 +727,11 @@ "lualine": { "flake": false, "locked": { - "lastModified": 1709556301, - "narHash": "sha256-G4npmdS7vue68h5QN8vWx3Oh5FHdvmzFHGxqMIRC+Mk=", + "lastModified": 1710998293, + "narHash": "sha256-+2fi58GolO3e0O7+kl+idNeFuTfJA1b5yCBdY2RnVjA=", "owner": "hoob3rt", "repo": "lualine.nvim", - "rev": "8b56462bfb746760465264de41b4907310f113ec", + "rev": "b5e8bb642138f787a2c1c5aedc2a78cb2cebbd67", "type": "github" }, "original": { @@ -759,11 +759,11 @@ "minimap-vim": { "flake": false, "locked": { - "lastModified": 1709503043, - "narHash": "sha256-W4EUEVjHNlemkMn+lCaraIV5/d5Kw4/LusHA17qQBjI=", + "lastModified": 1710689313, + "narHash": "sha256-GR8VAHla5HWry1TAZQv0Xp7iG256vIGeQcBGMxyt310=", "owner": "wfxr", "repo": "minimap.vim", - "rev": "6dc0c36fd92eab38064f22c016e43639f42293d3", + "rev": "395378137e6180762d5b963ca9ad5ac2db5d3283", "type": "github" }, "original": { @@ -812,11 +812,11 @@ "neocord": { "flake": false, "locked": { - "lastModified": 1709140653, - "narHash": "sha256-TdmXKh/qAKorpRFgAhCMAyXY6zUrqdEuNaLgerY46qc=", + "lastModified": 1711651358, + "narHash": "sha256-ZZF7ttn/6QIsaub1m0LV0ZirvNVXyFh+WDc39wi4UsM=", "owner": "IogaMaster", "repo": "neocord", - "rev": "fe83e48ad6f5fa7f70c93b47694c36d0d7deff04", + "rev": "6269823e78a2d2d8c3954068da196879cf2f0fe6", "type": "github" }, "original": { @@ -828,11 +828,11 @@ "neodev-nvim": { "flake": false, "locked": { - "lastModified": 1709144748, - "narHash": "sha256-VyJTGbWBzGmuEkotKwTxAVpznfrrQ26aaBc31n6ZjlE=", + "lastModified": 1711715247, + "narHash": "sha256-mAJOMVN7/xO7ykVNAeTeX+z2A/7yB8zdqlEKHL6Pb74=", "owner": "folke", "repo": "neodev.nvim", - "rev": "84e0290f5600e8b89c0dfcafc864f45496a53400", + "rev": "ce9a2e8eaba5649b553529c5498acb43a6c317cd", "type": "github" }, "original": { @@ -867,11 +867,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1709703039, - "narHash": "sha256-6hqgQ8OK6gsMu1VtcGKBxKQInRLHtzulDo9Z5jxHEFY=", + "lastModified": 1711703276, + "narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "9df3e30ce24fd28c7b3e2de0d986769db5d6225d", + "rev": "d8fe5e6c92d0d190646fb9f1056741a229980089", "type": "github" }, "original": { @@ -884,11 +884,11 @@ "nixpkgs-lib": { "locked": { "dir": "lib", - "lastModified": 1709237383, - "narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=", + "lastModified": 1711703276, + "narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8", + "rev": "d8fe5e6c92d0d190646fb9f1056741a229980089", "type": "github" }, "original": { @@ -966,11 +966,11 @@ "noice-nvim": { "flake": false, "locked": { - "lastModified": 1705952416, - "narHash": "sha256-lNCdwB0B5arbTEIHdDoQ19/vQ0UT89AQFwZM+RHqOTg=", + "lastModified": 1711471279, + "narHash": "sha256-y6gHNkWVsIuwBf7MblCTKTZSqjGDxqeFeQZWexzwk94=", "owner": "folke", "repo": "noice.nvim", - "rev": "bf67d70bd7265d075191e7812d8eb42b9791f737", + "rev": "0cbe3f88d038320bdbda3c4c5c95f43a13c3aa12", "type": "github" }, "original": { @@ -999,11 +999,11 @@ "nui-nvim": { "flake": false, "locked": { - "lastModified": 1709703853, - "narHash": "sha256-pzGzQXctHKbI1SZnzX4bApE+pyEADw1pjWvNy9j61U0=", + "lastModified": 1710740032, + "narHash": "sha256-Zr5CNx6BIM6naCXW8YBc/Oj1qOtWV/3tuMoaaZjoSZA=", "owner": "MunifTanjim", "repo": "nui.nvim", - "rev": "756c59f46057cd2d43619cd3a6d4e01b2aa60295", + "rev": "cbd2668414331c10039278f558630ed19b93e69b", "type": "github" }, "original": { @@ -1015,11 +1015,11 @@ "nvim-autopairs": { "flake": false, "locked": { - "lastModified": 1708848946, - "narHash": "sha256-w95F9wK3M3S4P43kKPT/uM+PFT/Z6NcTDLj60H2r/tQ=", + "lastModified": 1710930065, + "narHash": "sha256-H4mJ43Eyo36noIqYZ0lyqM7WPwgIKqi96OjW5F3pfvU=", "owner": "windwp", "repo": "nvim-autopairs", - "rev": "c6139ca0d5ad7af129ea6c89cb4c56093f2c034a", + "rev": "dbfc1c34bed415906395db8303c71039b3a3ffb4", "type": "github" }, "original": { @@ -1047,11 +1047,11 @@ "nvim-cmp": { "flake": false, "locked": { - "lastModified": 1706857187, - "narHash": "sha256-FF7OHYUC4VFwFvqWKI/R5BSAC0JL6qFKUS6/XRSd9H8=", + "lastModified": 1712041554, + "narHash": "sha256-DBxQTmwuEGj2g7LP7d1PJk/SyO0iJq2CIIHsFh0QJ4I=", "owner": "hrsh7th", "repo": "nvim-cmp", - "rev": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782", + "rev": "ce16de5665c766f39c271705b17fff06f7bcb84f", "type": "github" }, "original": { @@ -1127,11 +1127,11 @@ "nvim-dap": { "flake": false, "locked": { - "lastModified": 1708166498, - "narHash": "sha256-mOn/1qnUFRuKXLnthrc0/h8q3rDlKxfCmIrr3gbU5LU=", + "lastModified": 1711382674, + "narHash": "sha256-HoLnYeA18TpHM1SJ3NOY53ZAyBo2y2EoUbAIr7TqtQI=", "owner": "mfussenegger", "repo": "nvim-dap", - "rev": "fc880e82059eb21c0fa896be60146e5f17680648", + "rev": "405df1dcc2e395ab5173a9c3d00e03942c023074", "type": "github" }, "original": { @@ -1143,11 +1143,11 @@ "nvim-dap-ui": { "flake": false, "locked": { - "lastModified": 1708172616, - "narHash": "sha256-OMQS1m33scR0O+KiAHyjfrjsKEj1wFq0XWbjBIULDCo=", + "lastModified": 1710867604, + "narHash": "sha256-KAwCt8E3lC0fzXQ9GpPsdb9wdWC6G2P4C/YFQFY9AAM=", "owner": "rcarriga", "repo": "nvim-dap-ui", - "rev": "9720eb5fa2f41988e8770f973cd11b76dd568a5d", + "rev": "edfa93f60b189e5952c016eee262d0685d838450", "type": "github" }, "original": { @@ -1191,11 +1191,11 @@ "nvim-lspconfig": { "flake": false, "locked": { - "lastModified": 1709879366, - "narHash": "sha256-sRu8LtKcxqjKpCdYUeHAvL48i6eaC9SKzxF+XlqIJsY=", + "lastModified": 1712139869, + "narHash": "sha256-DMhB4L/0FjYbhNx7SwFnyFVa4PLVLlwB4uiNbiKUmEo=", "owner": "neovim", "repo": "nvim-lspconfig", - "rev": "94cf4adb81158817520e18d2174963d8e1424df9", + "rev": "96e5711040df23583591391ce49e556b8cd248d8", "type": "github" }, "original": { @@ -1207,11 +1207,11 @@ "nvim-navbuddy": { "flake": false, "locked": { - "lastModified": 1694669446, - "narHash": "sha256-zy1Tq8M5UITNAwtAlFYaUFlHnIZ5LWD9ZLaZcy7ulQ8=", + "lastModified": 1711239174, + "narHash": "sha256-EZXzFjGsZHkb2Ui5uvOottPHA8X15F6xyikab4dBlYk=", "owner": "SmiteshP", "repo": "nvim-navbuddy", - "rev": "f137a3466a6cd1965cdcc5398daff54e66eebbe5", + "rev": "f34237e8a41ebc6e2716af2ebf49854d8c5289c8", "type": "github" }, "original": { @@ -1252,6 +1252,22 @@ "type": "github" } }, + "nvim-nio": { + "flake": false, + "locked": { + "lastModified": 1712067294, + "narHash": "sha256-bjYtZygrL05qB2dM7Q8lJor81VYO+u8/JWQqfZ19Wzk=", + "owner": "nvim-neotest", + "repo": "nvim-nio", + "rev": "173f285eebb410199273fa178aa517fd2d7edd80", + "type": "github" + }, + "original": { + "owner": "nvim-neotest", + "repo": "nvim-nio", + "type": "github" + } + }, "nvim-notify": { "flake": false, "locked": { @@ -1303,11 +1319,11 @@ "nvim-tree-lua": { "flake": false, "locked": { - "lastModified": 1709951243, - "narHash": "sha256-1lWdTSZt/J4geoQKLkZLQ5Yh992XpZ4cFHw4AGEJFPY=", + "lastModified": 1711866287, + "narHash": "sha256-AMbUthY+49wREBr7EQSZ/tH8hT4gixPfcPT+ZzssUKw=", "owner": "nvim-tree", "repo": "nvim-tree.lua", - "rev": "041dbd18f440207ad161503a384e7c82d575db66", + "rev": "d8d3a1590a05b2d8b5eb26e2ed1c6052b1b47a77", "type": "github" }, "original": { @@ -1319,11 +1335,11 @@ "nvim-treesitter-context": { "flake": false, "locked": { - "lastModified": 1709675035, - "narHash": "sha256-wvr1ydulJlUuYQDCSXZjauDQi9Q0GugoLJ4TYZPonPE=", + "lastModified": 1711099836, + "narHash": "sha256-iDBFUMUjGJXzEioZ4cTydDYHRR30GF6z9W0M7IZUasc=", "owner": "nvim-treesitter", "repo": "nvim-treesitter-context", - "rev": "b8b7e52c1517d401d7c519787d5dc4528c41291a", + "rev": "f19766163c18515fb4d3c12d572bf9cba6cdb990", "type": "github" }, "original": { @@ -1351,11 +1367,11 @@ "nvim-web-devicons": { "flake": false, "locked": { - "lastModified": 1709950025, - "narHash": "sha256-ZnO0qe6zQiSKaBzMezzaZOQw++oZFaVFSdTD26ezR2I=", + "lastModified": 1711417099, + "narHash": "sha256-G8URFQdABLf3ptj+9kwSFGXly9D+4lkt3SXfbhVDH6g=", "owner": "nvim-tree", "repo": "nvim-web-devicons", - "rev": "0db6a106d0fba1b54ff2b7f9db108e7505a4c26f", + "rev": "3ee60deaa539360518eaab93a6c701fe9f4d82ef", "type": "github" }, "original": { @@ -1367,11 +1383,11 @@ "obsidian-nvim": { "flake": false, "locked": { - "lastModified": 1709943920, - "narHash": "sha256-iMH1WoldkWhr+u//G/LhI42SfPtCWFjqTS2sfineFKQ=", + "lastModified": 1711994732, + "narHash": "sha256-RD5EhYv2AZvCywxQYKkPjZPY/jEjl2rEofMVCHO6SJQ=", "owner": "epwalsh", "repo": "obsidian.nvim", - "rev": "6888c7620109684371ed9304df2ba68abc78d558", + "rev": "d70f3289399c25153b7f503b838afbf981124a37", "type": "github" }, "original": { @@ -1399,11 +1415,11 @@ "orgmode-nvim": { "flake": false, "locked": { - "lastModified": 1709672029, - "narHash": "sha256-2zYAtyiZQErkGbeVZ3Kww0/p44lLQT5u0EGOzvNN4Ag=", + "lastModified": 1712161945, + "narHash": "sha256-44dTemgSevEdiluUanGLySo7WbvKrXW+n2dUwUO4cqY=", "owner": "nvim-orgmode", "repo": "orgmode", - "rev": "18734589e5807074f57a5228ce06b52ea898b802", + "rev": "ddcfbb1e52b2ff5b90469eb13214676931a66e09", "type": "github" }, "original": { @@ -1432,11 +1448,11 @@ "plenary-nvim": { "flake": false, "locked": { - "lastModified": 1709720625, - "narHash": "sha256-/ltkFqa5MTAI9z8oLv7+5SJ/Qq9l1kkuKGD955NbLi8=", + "lastModified": 1711369325, + "narHash": "sha256-wM/FuK24NPEyaWntwT+mi2SuPExC/abXDK9c2WvgUBk=", "owner": "nvim-lua", "repo": "plenary.nvim", - "rev": "f7adfc4b3f4f91aab6caebf42b3682945fbc35be", + "rev": "8aad4396840be7fc42896e3011751b7609ca4119", "type": "github" }, "original": { @@ -1568,6 +1584,7 @@ "nvim-navbuddy": "nvim-navbuddy", "nvim-navic": "nvim-navic", "nvim-neoclip": "nvim-neoclip", + "nvim-nio": "nvim-nio", "nvim-notify": "nvim-notify", "nvim-session-manager": "nvim-session-manager", "nvim-surround": "nvim-surround", @@ -1609,11 +1626,11 @@ "rose-pine": { "flake": false, "locked": { - "lastModified": 1709650037, - "narHash": "sha256-uRRuJYGNhJEz+2y5GG47GutolSSisSYUHvB7eKDfAZ8=", + "lastModified": 1711769966, + "narHash": "sha256-GVYCkyFdVgye/8pEXPT8Y+4YyLmivgX/IHht/G1DdEA=", "owner": "rose-pine", "repo": "neovim", - "rev": "a29b09d15a9ef5cd575fbe5ae2a3cfb854876caf", + "rev": "19055dfe90bfa46a1e5b0a706d13980bdffa2dee", "type": "github" }, "original": { @@ -1682,11 +1699,11 @@ "smartcolumn": { "flake": false, "locked": { - "lastModified": 1703592909, - "narHash": "sha256-c5tENO4LJaSRELxuCOp/aI94ifhKjqd8J2chJbxfFdc=", + "lastModified": 1710067624, + "narHash": "sha256-DHIeDNUF9n9s14GVeojIwc5QUPwJMYYl3gRvhvO/rdE=", "owner": "m4xshen", "repo": "smartcolumn.nvim", - "rev": "a52915d6d9abf9972e249ebcffcc651cf9b062dd", + "rev": "cefb17be095ad5526030a21bb2a80553cae09127", "type": "github" }, "original": { @@ -1792,11 +1809,11 @@ "telescope": { "flake": false, "locked": { - "lastModified": 1709849420, - "narHash": "sha256-i+pGEMw8MQnFse5WGZdX9MMjEoR4H4rzHswCaT/zoso=", + "lastModified": 1712065014, + "narHash": "sha256-8Bp1E9JY1MByjRCcON1HJLYRswLx63lmz20rGrJW7Wc=", "owner": "nvim-telescope", "repo": "telescope.nvim", - "rev": "7472420f8734c710bd7009081cef9b97f08a3821", + "rev": "4626aaa2bcfdacf55fd6d44b430e2df81b2403ff", "type": "github" }, "original": { @@ -1849,11 +1866,11 @@ "todo-comments": { "flake": false, "locked": { - "lastModified": 1705847650, - "narHash": "sha256-DiyieXXx7iYGWkpeOvduJf0n7dnpaQ7rXmaWvZQaCyE=", + "lastModified": 1711553769, + "narHash": "sha256-BJNU01iTRDNrPv48fgiJRS+ouaHkoqw2AYXKDRgDzfw=", "owner": "folke", "repo": "todo-comments.nvim", - "rev": "833d8dd8b07eeda37a09e99460f72a02616935cb", + "rev": "a7e39ae9e74f2c8c6dc4eea6d40c3971ae84752d", "type": "github" }, "original": { @@ -1881,11 +1898,11 @@ "tokyonight": { "flake": false, "locked": { - "lastModified": 1706697570, - "narHash": "sha256-mzCdcf7FINhhVLUIPv/eLohm4qMG9ndRJ5H4sFU2vO0=", + "lastModified": 1711665767, + "narHash": "sha256-ItCmSUMMTe8iQeneIJLuWedVXsNgm+FXNtdrrdJ/1oE=", "owner": "folke", "repo": "tokyonight.nvim", - "rev": "610179f7f12db3d08540b6cc61434db2eaecbcff", + "rev": "9bf9ec53d5e87b025e2404069b71e7ebdc3a13e5", "type": "github" }, "original": { @@ -1897,11 +1914,11 @@ "trouble": { "flake": false, "locked": { - "lastModified": 1697626811, - "narHash": "sha256-8nLghiueYOtWY7OGVxow9A2G/5lgt+Kt5D8q1xeJvVg=", + "lastModified": 1711693365, + "narHash": "sha256-kIQ72fqAsiMF9jq0MzC6peaHJddYn5PRNXfYFHTQB5Q=", "owner": "folke", "repo": "trouble.nvim", - "rev": "f1168feada93c0154ede4d1fe9183bf69bac54ea", + "rev": "b9cf677f20bb2faa2dacfa870b084e568dca9572", "type": "github" }, "original": { @@ -1946,11 +1963,11 @@ "vim-dirtytalk": { "flake": false, "locked": { - "lastModified": 1709557124, - "narHash": "sha256-5+efbDDHmFB16T3j8v/7O1BXcplEj/9XvPErTHOuIw4=", + "lastModified": 1711553630, + "narHash": "sha256-1cLseaHfWgyAvzHcK93nl9sy66J/zvlnK7P4vnIthmY=", "owner": "psliwka", "repo": "vim-dirtytalk", - "rev": "64c532cded23059ae422730f89ab1300fcf3da02", + "rev": "d2929ffff8639b2b4b4bb7c2b6c04575c1322d2f", "type": "github" }, "original": { @@ -2095,11 +2112,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1709943697, - "narHash": "sha256-IATQNonwPhNboTKUpPbj54/A/UVr8ys07CHofD+Tkp8=", + "lastModified": 1712017348, + "narHash": "sha256-At+mk7gHMk2kbisQhkts8cYkz7XhIRei9+zT3wP8bT8=", "owner": "mitchellh", "repo": "zig-overlay", - "rev": "7e0a85db5007bf378dca37cee03c1edfff692ef4", + "rev": "63bdd97bf1c93a1da1c658ec9ab974fef52a7280", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index cb9c5b8..51c8861 100644 --- a/flake.nix +++ b/flake.nix @@ -590,5 +590,11 @@ url = "github:tpope/vim-repeat"; flake = false; }; + + nvim-nio = { + # (required nvim-dap-ui) + url = "github:nvim-neotest/nvim-nio"; + flake = false; + }; }; } diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index 4db7542..da1d6ba 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -99,6 +99,7 @@ with lib; let "highlight-undo" "nvim-docs-view" "image-nvim" + "nvim-nio" ]; # You can either use the name of the plugin or a package. pluginType = with types; diff --git a/modules/debugger/nvim-dap/config.nix b/modules/debugger/nvim-dap/config.nix index cc04c26..b26a5bd 100644 --- a/modules/debugger/nvim-dap/config.nix +++ b/modules/debugger/nvim-dap/config.nix @@ -49,7 +49,7 @@ in { ]; }) (mkIf (cfg.enable && cfg.ui.enable) { - vim.startPlugins = ["nvim-dap-ui"]; + vim.startPlugins = ["nvim-dap-ui" "nvim-nio"]; vim.luaConfigRC.nvim-dap-ui = entryAfter ["nvim-dap"] ('' local dapui = require("dapui") From 5955d530776380f39f46c5eeaf446ceeedde89e8 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 15 Mar 2024 15:01:46 +0300 Subject: [PATCH 050/193] modules/ui: switch to explicit lib calls --- modules/ui/borders/borders.nix | 2 +- modules/ui/breadcrumbs/breadcrumbs.nix | 20 +++++++++---------- modules/ui/breadcrumbs/config.nix | 2 +- modules/ui/modes/modes.nix | 18 +++++++++++------ modules/ui/noice/noice.nix | 2 +- .../ui/notifications/nvim-notify/config.nix | 1 - .../notifications/nvim-notify/nvim-notify.nix | 2 +- modules/ui/smartcolumn/config.nix | 20 +++++++++---------- modules/ui/smartcolumn/smartcolumn.nix | 2 +- 9 files changed, 37 insertions(+), 32 deletions(-) diff --git a/modules/ui/borders/borders.nix b/modules/ui/borders/borders.nix index 4d4952b..37589dc 100644 --- a/modules/ui/borders/borders.nix +++ b/modules/ui/borders/borders.nix @@ -18,7 +18,7 @@ in { type = enum defaultStyles; default = "rounded"; description = '' - The global border style to use + The global border style to use. ''; }; diff --git a/modules/ui/breadcrumbs/breadcrumbs.nix b/modules/ui/breadcrumbs/breadcrumbs.nix index 68c2a9f..f56223b 100644 --- a/modules/ui/breadcrumbs/breadcrumbs.nix +++ b/modules/ui/breadcrumbs/breadcrumbs.nix @@ -339,8 +339,8 @@ in { package = mkOption { type = str; - default = " "; - description = "Package icon"; + default = " "; + description = ""; }; class = mkOption { @@ -351,8 +351,8 @@ in { property = mkOption { type = str; - default = " "; - description = "Property icon"; + default = " "; + description = ""; }; field = mkOption { @@ -387,8 +387,8 @@ in { variable = mkOption { type = str; - default = "󰫧 "; - description = "Variable icon"; + default = "󰆧 "; + description = ""; }; constant = mkOption { @@ -399,8 +399,8 @@ in { string = mkOption { type = str; - default = " "; - description = "String icon"; + default = " "; + description = ""; }; number = mkOption { @@ -411,8 +411,8 @@ in { boolean = mkOption { type = str; - default = " "; - description = "Boolean icon"; + default = "◩ "; + description = ""; }; array = mkOption { diff --git a/modules/ui/breadcrumbs/config.nix b/modules/ui/breadcrumbs/config.nix index 5afda30..3dc3713 100644 --- a/modules/ui/breadcrumbs/config.nix +++ b/modules/ui/breadcrumbs/config.nix @@ -3,9 +3,9 @@ lib, ... }: let - inherit (lib.modules) mkIf; inherit (lib.strings) optionalString; inherit (lib.trivial) boolToString; + inherit (lib.modules) mkIf; inherit (lib.lists) optionals; inherit (lib.nvim.lua) nullString; inherit (lib.nvim.dag) entryAfter; diff --git a/modules/ui/modes/modes.nix b/modules/ui/modes/modes.nix index e49251a..af45d30 100644 --- a/modules/ui/modes/modes.nix +++ b/modules/ui/modes/modes.nix @@ -3,31 +3,37 @@ inherit (lib.types) str; in { options.vim.ui.modes-nvim = { - enable = mkEnableOption "prismatic line decorations [modes.nvim]"; - setCursorline = mkEnableOption "colored cursorline on current line"; + enable = mkEnableOption "modes.nvim's prismatic line decorations"; + + setCursorline = mkOption { + type = bool; + description = "Set a colored cursorline on current line"; + default = false; # looks ugly, disabled by default + }; + colors = { copy = mkOption { type = str; - description = "The #RRGGBB color code for the visual mode highlights"; default = "#f5c359"; + description = "The #RRGGBB color code for the visual mode highlights"; }; delete = mkOption { type = str; - description = "The #RRGGBB color code for the visual mode highlights"; default = "#c75c6a"; + description = "The #RRGGBB color code for the visual mode highlights"; }; insert = mkOption { type = str; - description = "The #RRGGBB color code for the visual mode highlights"; default = "#78ccc5"; + description = "The #RRGGBB color code for the visual mode highlights"; }; visual = mkOption { type = str; - description = "The #RRGGBB color code for the visual mode highlights"; default = "#9745be"; + description = "The #RRGGBB color code for the visual mode highlights"; }; }; }; diff --git a/modules/ui/noice/noice.nix b/modules/ui/noice/noice.nix index 3997987..b361d45 100644 --- a/modules/ui/noice/noice.nix +++ b/modules/ui/noice/noice.nix @@ -2,6 +2,6 @@ inherit (lib.options) mkEnableOption; in { options.vim.ui.noice = { - enable = mkEnableOption "UI modification library [noice.nvim]"; + enable = mkEnableOption "noice.nvim UI modification library"; }; } diff --git a/modules/ui/notifications/nvim-notify/config.nix b/modules/ui/notifications/nvim-notify/config.nix index c2c4991..852b94d 100644 --- a/modules/ui/notifications/nvim-notify/config.nix +++ b/modules/ui/notifications/nvim-notify/config.nix @@ -11,7 +11,6 @@ in { config = mkIf cfg.enable { vim = { startPlugins = ["nvim-notify"]; - luaConfigRC.nvim-notify = entryAnywhere '' require('notify').setup { stages = "${cfg.stages}", diff --git a/modules/ui/notifications/nvim-notify/nvim-notify.nix b/modules/ui/notifications/nvim-notify/nvim-notify.nix index ab78d45..57683a4 100644 --- a/modules/ui/notifications/nvim-notify/nvim-notify.nix +++ b/modules/ui/notifications/nvim-notify/nvim-notify.nix @@ -1,5 +1,5 @@ {lib, ...}: let - inherit (lib.options) mkOption mkEnableOption; + inherit (lib) mkOption mkEnableOption; inherit (lib.types) enum int str attrsOf; in { options.vim.notify.nvim-notify = { diff --git a/modules/ui/smartcolumn/config.nix b/modules/ui/smartcolumn/config.nix index 3f4ae05..48b47d2 100644 --- a/modules/ui/smartcolumn/config.nix +++ b/modules/ui/smartcolumn/config.nix @@ -7,21 +7,21 @@ inherit (lib.strings) concatStringsSep; inherit (lib.nvim.lua) attrsetToLuaTable; inherit (lib.nvim.dag) entryAnywhere; + cfg = config.vim.ui.smartcolumn; in { config = mkIf cfg.enable { vim = { startPlugins = ["smartcolumn"]; - luaConfigRC.smartcolumn = entryAnywhere '' - require("smartcolumn").setup({ - colorcolumn = "${toString cfg.showColumnAt}", - -- { "help", "text", "markdown", "NvimTree", "alpha"}, - disabled_filetypes = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.disabledFiletypes)} }, - custom_colorcolumn = ${attrsetToLuaTable cfg.columnAt.languages}, - scope = "file", - }) - ''; - }; + vim.luaConfigRC.smartcolumn = entryAnywhere '' + require("smartcolumn").setup({ + colorcolumn = "${toString cfg.showColumnAt}", + -- { "help", "text", "markdown", "NvimTree", "alpha"}, + disabled_filetypes = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.disabledFiletypes)} }, + custom_colorcolumn = ${attrsetToLuaTable cfg.columnAt.languages}, + scope = "file", + }) + ''; }; } diff --git a/modules/ui/smartcolumn/smartcolumn.nix b/modules/ui/smartcolumn/smartcolumn.nix index fe578be..bac4c7d 100644 --- a/modules/ui/smartcolumn/smartcolumn.nix +++ b/modules/ui/smartcolumn/smartcolumn.nix @@ -1,6 +1,6 @@ {lib, ...}: let inherit (lib.options) mkOption mkEnableOption literalExpression; - inherit (lib.types) attrsOf either nullOr listOf int str submodule; + inherit (lib.types) nullOr int str submodule attrsOf either listOf; in { options.vim.ui.smartcolumn = { enable = mkEnableOption "line length indicator"; From 4001943a7b1dd512032e2eaadbfdd622c91bff68 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Wed, 3 Jan 2024 00:55:03 +0100 Subject: [PATCH 051/193] feat(nvimtree): add custom setup options --- modules/filetree/nvimtree/config.nix | 235 +-- modules/filetree/nvimtree/nvimtree.nix | 1904 ++++++++++++------------ 2 files changed, 951 insertions(+), 1188 deletions(-) diff --git a/modules/filetree/nvimtree/config.nix b/modules/filetree/nvimtree/config.nix index 0286c1a..c560650 100644 --- a/modules/filetree/nvimtree/config.nix +++ b/modules/filetree/nvimtree/config.nix @@ -6,10 +6,9 @@ }: let 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; + inherit (lib.nvim.lua) toLuaObject; # TODO: move this to its own module inherit (lib) pushDownDefault; @@ -40,237 +39,7 @@ in { '' } - require'nvim-tree'.setup({ - disable_netrw = ${boolToString cfg.disableNetrw}, - hijack_netrw = ${boolToString cfg.hijackNetrw}, - auto_reload_on_write = ${boolToString cfg.autoreloadOnWrite}, - - sort = { - sorter = "${cfg.sort.sorter}", - folders_first = ${boolToString cfg.sort.foldersFirst}, - }, - - hijack_unnamed_buffer_when_opening = ${boolToString cfg.hijackUnnamedBufferWhenOpening}, - hijack_cursor = ${boolToString cfg.hijackCursor}, - root_dirs = ${listToLuaTable cfg.rootDirs}, - prefer_startup_root = ${boolToString cfg.preferStartupRoot}, - sync_root_with_cwd = ${boolToString cfg.syncRootWithCwd}, - reload_on_bufenter = ${boolToString cfg.reloadOnBufEnter}, - respect_buf_cwd = ${boolToString cfg.respectBufCwd}, - - hijack_directories = { - enable = ${boolToString cfg.hijackDirectories.enable}, - auto_open = ${boolToString cfg.hijackDirectories.autoOpen}, - }, - - update_focused_file = { - enable = ${boolToString cfg.updateFocusedFile.enable}, - update_root = ${boolToString cfg.updateFocusedFile.updateRoot}, - ignore_list = ${listToLuaTable cfg.updateFocusedFile.ignoreList}, - }, - - system_open = { - cmd = "${cfg.systemOpen.cmd}", - args = ${listToLuaTable cfg.systemOpen.args}, - }, - - diagnostics = { - enable = ${boolToString cfg.diagnostics.enable}, - icons = { - hint = "${cfg.diagnostics.icons.hint}", - info = "${cfg.diagnostics.icons.info}", - warning = "${cfg.diagnostics.icons.warning}", - error = "${cfg.diagnostics.icons.error}", - }, - - severity = { - min = vim.diagnostic.severity.${cfg.diagnostics.severity.min}, - max = vim.diagnostic.severity.${cfg.diagnostics.severity.max}, - }, - }, - - git = { - enable = ${boolToString cfg.git.enable}, - show_on_dirs = ${boolToString cfg.git.showOnDirs}, - show_on_open_dirs = ${boolToString cfg.git.showOnOpenDirs}, - disable_for_dirs = ${listToLuaTable cfg.git.disableForDirs}, - timeout = ${toString cfg.git.timeout}, - }, - - modified = { - enable = ${boolToString cfg.modified.enable}, - show_on_dirs = ${boolToString cfg.modified.showOnDirs}, - show_on_open_dirs = ${boolToString cfg.modified.showOnOpenDirs}, - }, - - filesystem_watchers = { - enable = ${boolToString cfg.filesystemWatchers.enable}, - debounce_delay = ${toString cfg.filesystemWatchers.debounceDelay}, - ignore_dirs = ${listToLuaTable cfg.filesystemWatchers.ignoreDirs}, - }, - - select_prompts = ${boolToString cfg.selectPrompts}, - - view = { - centralize_selection = ${boolToString cfg.view.centralizeSelection}, - cursorline = ${boolToString cfg.view.cursorline}, - debounce_delay = ${toString cfg.view.debounceDelay}, - width = ${expToLua cfg.view.width}, - side = "${cfg.view.side}", - preserve_window_proportions = ${boolToString cfg.view.preserveWindowProportions}, - number = ${boolToString cfg.view.number}, - relativenumber = ${boolToString cfg.view.relativenumber}, - signcolumn = "${cfg.view.signcolumn}", - float = { - enable = ${boolToString cfg.view.float.enable}, - quit_on_focus_loss = ${boolToString cfg.view.float.quitOnFocusLoss}, - open_win_config = { - relative = "${cfg.view.float.openWinConfig.relative}", - border = "${cfg.view.float.openWinConfig.border}", - width = ${toString cfg.view.float.openWinConfig.width}, - height = ${toString cfg.view.float.openWinConfig.height}, - row = ${toString cfg.view.float.openWinConfig.row}, - col = ${toString cfg.view.float.openWinConfig.col}, - }, - }, - }, - - renderer = { - add_trailing = ${boolToString cfg.renderer.addTrailing}, - group_empty = ${boolToString cfg.renderer.groupEmpty}, - full_name = ${boolToString cfg.renderer.fullName}, - highlight_git = ${boolToString cfg.renderer.highlightGit}, - highlight_opened_files = ${cfg.renderer.highlightOpenedFiles}, - highlight_modified = ${cfg.renderer.highlightModified}, - 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 = ${expToLua cfg.renderer.indentMarkers.icons}, - }, - - special_files = ${listToLuaTable cfg.renderer.specialFiles}, - symlink_destination = ${boolToString cfg.renderer.symlinkDestination}, - - icons = { - webdev_colors = ${boolToString cfg.renderer.icons.webdevColors}, - git_placement = "${cfg.renderer.icons.gitPlacement}", - modified_placement = "${cfg.renderer.icons.modifiedPlacement}", - padding = "${cfg.renderer.icons.padding}", - symlink_arrow = "${cfg.renderer.icons.symlinkArrow}", - - show = { - git = ${boolToString cfg.renderer.icons.show.git}, - folder = ${boolToString cfg.renderer.icons.show.folder}, - folder_arrow = ${boolToString cfg.renderer.icons.show.folderArrow}, - file = ${boolToString cfg.renderer.icons.show.file}, - modified = ${boolToString cfg.renderer.icons.show.modified}, - }, - - glyphs = { - default = "${cfg.renderer.icons.glyphs.default}", - symlink = "${cfg.renderer.icons.glyphs.symlink}", - modified = "${cfg.renderer.icons.glyphs.modified}", - - folder = { - default = "${cfg.renderer.icons.glyphs.folder.default}", - open = "${cfg.renderer.icons.glyphs.folder.open}", - arrow_open = "${cfg.renderer.icons.glyphs.folder.arrowOpen}", - arrow_closed = "${cfg.renderer.icons.glyphs.folder.arrowClosed}", - empty = "${cfg.renderer.icons.glyphs.folder.empty}", - empty_open = "${cfg.renderer.icons.glyphs.folder.emptyOpen}", - symlink = "${cfg.renderer.icons.glyphs.folder.symlink}", - symlink_open = "${cfg.renderer.icons.glyphs.folder.symlinkOpen}", - }, - - git = { - unstaged = "${cfg.renderer.icons.glyphs.git.unstaged}", - staged = "${cfg.renderer.icons.glyphs.git.staged}", - unmerged = "${cfg.renderer.icons.glyphs.git.unmerged}", - renamed = "${cfg.renderer.icons.glyphs.git.renamed}", - untracked = "${cfg.renderer.icons.glyphs.git.untracked}", - deleted = "${cfg.renderer.icons.glyphs.git.deleted}", - ignored = "${cfg.renderer.icons.glyphs.git.ignored}", - }, - }, - }, - }, - - filters = { - git_ignored = ${boolToString cfg.filters.gitIgnored}, - dotfiles = ${boolToString cfg.filters.dotfiles}, - git_clean = ${boolToString cfg.filters.gitClean}, - no_buffer = ${boolToString cfg.filters.noBuffer}, - exclude = ${listToLuaTable cfg.filters.exclude}, - }, - - trash = { - cmd = "${cfg.trash.cmd}", - }, - - actions = { - use_system_clipboard = ${boolToString cfg.actions.useSystemClipboard}, - change_dir = { - enable = ${boolToString cfg.actions.changeDir.enable}, - global = ${boolToString cfg.actions.changeDir.global}, - restrict_above_cwd = ${boolToString cfg.actions.changeDir.restrictAboveCwd}, - }, - - expand_all = { - max_folder_discovery = ${toString cfg.actions.expandAll.maxFolderDiscovery}, - exclude = ${listToLuaTable cfg.actions.expandAll.exclude}, - }, - - file_popup = { - open_win_config = ${expToLua cfg.actions.filePopup.openWinConfig}, - }, - - open_file = { - quit_on_open = ${boolToString cfg.actions.openFile.quitOnOpen}, - eject = ${boolToString cfg.actions.openFile.eject}, - resize_window = ${boolToString cfg.actions.openFile.resizeWindow}, - window_picker = { - enable = ${boolToString cfg.actions.openFile.windowPicker.enable}, - picker = "${cfg.actions.openFile.windowPicker.picker}", - chars = "${cfg.actions.openFile.windowPicker.chars}", - exclude = { - filetype = ${listToLuaTable cfg.actions.openFile.windowPicker.exclude.filetype}, - buftype = ${listToLuaTable cfg.actions.openFile.windowPicker.exclude.buftype}, - }, - }, - }, - - remove_file = { - close_window = ${boolToString cfg.actions.removeFile.closeWindow}, - }, - }, - - live_filter = { - prefix = "${cfg.liveFilter.prefix}", - always_show_folders = ${boolToString cfg.liveFilter.alwaysShowFolders}, - }, - - tab = { - sync = { - open = ${boolToString cfg.tab.sync.open}, - close = ${boolToString cfg.tab.sync.close}, - ignore = ${listToLuaTable cfg.tab.sync.ignore}, - }, - }, - - notify = { - threshold = vim.log.levels.${cfg.notify.threshold}, - absolute_path = ${boolToString cfg.notify.absolutePath}, - }, - - ui = { - confirm = { - remove = ${boolToString cfg.ui.confirm.remove}, - trash = ${boolToString cfg.ui.confirm.trash}, - }, - }, - }) + require'nvim-tree'.setup(${toLuaObject cfg.setupOpts}) ${ optionalString cfg.openOnSetup '' diff --git a/modules/filetree/nvimtree/nvimtree.nix b/modules/filetree/nvimtree/nvimtree.nix index ecd74b5..216f098 100644 --- a/modules/filetree/nvimtree/nvimtree.nix +++ b/modules/filetree/nvimtree/nvimtree.nix @@ -4,7 +4,8 @@ ... }: let inherit (lib.options) mkEnableOption mkOption literalExpression; - inherit (lib.types) nullOr str bool int listOf enum attrs oneOf addCheck submodule; + inherit (lib.types) nullOr str bool int submodule listOf enum oneOf attrs addCheck; + inherit (lib.nvim.types) mkPluginSetupOption; in { options.vim.filetree.nvimTree = { enable = mkEnableOption "filetree via nvim-tree.lua"; @@ -38,708 +39,453 @@ in { type = bool; }; - hijackNetrw = mkOption { - default = true; - description = "Prevents netrw from automatically opening when opening directories"; - type = bool; - }; - - autoreloadOnWrite = mkOption { - default = true; - description = "Auto reload tree on write"; - type = bool; - }; - - updateFocusedFile = mkOption { - description = '' - Update the focused file on `BufEnter`, un-collapses the folders recursively - until it finds the file. - ''; - default = {}; - type = submodule { - options = { - enable = mkOption { - type = bool; - default = false; - description = "update focused file"; - }; - - updateRoot = mkOption { - type = bool; - default = false; - description = '' - Update the root directory of the tree if the file is not under current - root directory. It prefers vim's cwd and `root_dirs`. - Otherwise it falls back to the folder containing the file. - Only relevant when `update_focused_file.enable` is `true` - ''; - }; - - ignoreList = mkOption { - type = listOf str; - default = []; - description = '' - List of buffer names and filetypes that will not update the root dir - of the tree if the file isn't found under the current root directory. - Only relevant when `update_focused_file.update_root` and - `update_focused_file.enable` are `true`. - ''; - }; - }; - }; - }; - - sort = { - # TODO: function as a possible type - sorter = mkOption { - default = "name"; - description = "How files within the same directory are sorted."; - type = enum ["name" "extension" "modification_time" "case_sensitive" "suffix" "filetype"]; - }; - - foldersFirst = mkOption { + setupOpts = mkPluginSetupOption "Nvim Tree" { + hijack_netrw = mkOption { default = true; - description = "Sort folders before files. Has no effect when `sort.sorter` is a function."; + description = "Prevents netrw from automatically opening when opening directories"; type = bool; }; - }; - hijackCursor = mkOption { - default = false; - description = "Hijack the cursor in the tree to put it at the start of the filename"; - type = bool; - }; - - hijackUnnamedBufferWhenOpening = mkOption { - default = false; - description = "Open nvimtree in place of the unnamed buffer if it's empty."; - type = bool; - }; - - rootDirs = mkOption { - default = []; - description = '' - Preferred root directories. Only relevant when `updateFocusedFile.updateRoot` is `true` - ''; - type = listOf str; - }; - - preferStartupRoot = mkOption { - default = false; - description = '' - Prefer startup root directory when updating root directory of the tree. - Only relevant when `update_focused_file.update_root` is `true` - ''; - type = bool; - }; - - syncRootWithCwd = mkOption { - type = bool; - default = false; - description = '' - Changes the tree root directory on `DirChanged` and refreshes the tree. - Only relevant when `updateFocusedFile.updateRoot` is `true` - - (previously `update_cwd`) - ''; - }; - - reloadOnBufEnter = mkOption { - default = false; - type = bool; - description = "Automatically reloads the tree on `BufEnter` nvim-tree."; - }; - - respectBufCwd = mkOption { - default = false; - type = bool; - description = "Will change cwd of nvim-tree to that of new buffer's when opening nvim-tree."; - }; - - hijackDirectories = mkOption { - description = "hijack new directory buffers when they are opened (`:e dir`)."; - - default = { - enable = true; - autoOpen = false; - }; - - type = submodule { - options = { - enable = mkOption { - type = bool; - description = '' - Enable the `hijack_directories` feature. Disable this option if you use vim-dirvish or dirbuf.nvim. - If `hijack_netrw` and `disable_netrw` are `false`, this feature will be disabled. - ''; - }; - - autoOpen = mkOption { - type = bool; - description = '' - Opens the tree if the tree was previously closed. - ''; - }; - }; - }; - }; - - systemOpen = { - args = mkOption { - default = []; - description = "Optional argument list."; - type = listOf str; - }; - - cmd = mkOption { - default = - if pkgs.stdenv.isDarwin - then "open" - else if pkgs.stdenv.isLinux - then "${pkgs.xdg-utils}/bin/xdg-open" - else throw "NvimTree: No default system open command for this platform, please set `vim.filetree.nvimTree.systemOpen.cmd`"; - description = "The open command itself"; - type = str; - }; - }; - - diagnostics = mkOption { - description = '' - Show LSP and COC diagnostics in the signcolumn - Note that the modified sign will take precedence over the diagnostics signs. - ''; - - default = {}; - - type = submodule { - options = { - enable = mkEnableOption "diagnostics view in the signcolumn."; - - debounceDelay = mkOption { - description = "Idle milliseconds between diagnostic event and update."; - type = int; - default = 50; - }; - - showOnDirs = mkOption { - description = "Show diagnostic icons on parent directories."; - default = false; - }; - - showOnOpenDirs = mkOption { - type = bool; - default = true; - description = '' - Show diagnostics icons on directories that are open. - Only relevant when `diagnostics.show_on_dirs` is `true`. - ''; - }; - - icons = mkOption { - description = "Icons for diagnostic severity."; - default = {}; - type = submodule { - options = { - hint = mkOption { - description = "Icon used for `hint` diagnostic."; - type = str; - default = ""; - }; - info = mkOption { - description = "Icon used for `info` diagnostic."; - type = str; - default = ""; - }; - warning = mkOption { - description = "Icon used for `warning` diagnostic."; - type = str; - default = ""; - }; - error = mkOption { - description = "Icon used for `error` diagnostic."; - type = str; - default = ""; - }; - }; - }; - }; - - severity = mkOption { - description = "Severity for which the diagnostics will be displayed. See `:help diagnostic-severity`"; - default = {}; - type = submodule { - options = { - min = mkOption { - description = "Minimum severity."; - type = enum ["HINT" "INFO" "WARNING" "ERROR"]; - default = "HINT"; - }; - - max = mkOption { - description = "Maximum severity."; - type = enum ["HINT" "INFO" "WARNING" "ERROR"]; - default = "ERROR"; - }; - }; - }; - }; - }; - }; - }; - - git = { - enable = mkEnableOption "Git integration with icons and colors."; - - showOnDirs = mkOption { - type = bool; + autoreload_on_write = mkOption { default = true; - description = "Show git icons on parent directories."; - }; - - showOnOpenDirs = mkOption { - type = bool; - default = true; - description = "Show git icons on directories that are open."; - }; - - disableForDirs = mkOption { - type = listOf str; - default = []; - description = '' - Disable git integration when git top-level matches these paths. - May be relative, evaluated via `":p"` - ''; - }; - - timeout = mkOption { - type = int; - default = 400; - description = '' - Kills the git process after some time if it takes too long. - Git integration will be disabled after 10 git jobs exceed this timeout. - ''; - }; - }; - - modified = mkOption { - description = "Indicate which file have unsaved modification."; - default = {}; - type = submodule { - options = { - enable = mkEnableOption "Modified files with icons and color highlight."; - - showOnDirs = mkOption { - type = bool; - description = "Show modified icons on parent directories."; - default = true; - }; - - showOnOpenDirs = mkOption { - type = bool; - description = "Show modified icons on directories that are open."; - default = true; - }; - }; - }; - }; - - filesystemWatchers = mkOption { - description = '' - Will use file system watcher (libuv fs_event) to watch the filesystem for changes. - Using this will disable BufEnter / BufWritePost events in nvim-tree which - were used to update the whole tree. With this feature, the tree will be - updated only for the appropriate folder change, resulting in better - performance. - ''; - default = {}; - type = submodule { - options = { - enable = mkOption { - description = "Enable filesystem watchers."; - type = bool; - default = true; - }; - - debounceDelay = mkOption { - description = "Idle milliseconds between filesystem change and action."; - type = int; - default = 50; - }; - - ignoreDirs = mkOption { - type = listOf str; - default = []; - description = '' - List of vim regex for absolute directory paths that will not be watched. - Backslashes must be escaped e.g. `"my-project/\\.build$"`. - Useful when path is not in `.gitignore` or git integration is disabled. - ''; - }; - }; - }; - }; - - selectPrompts = mkEnableOption '' - Use `vim.ui.select` style prompts. Necessary when using a UI prompt decorator such as dressing.nvim or telescope-ui-select.nvim - ''; - - view = mkOption { - description = "Window / buffer setup."; - default = {}; - type = submodule { - options = { - centralizeSelection = mkOption { - description = "If true, reposition the view so that the current node is initially centralized when entering nvim-tree."; - type = bool; - default = false; - }; - - cursorline = mkOption { - description = "Enable cursorline in nvim-tree window."; - type = bool; - default = true; - }; - - debounceDelay = mkOption { - type = int; - default = 15; - description = '' - Idle milliseconds before some reload / refresh operations. - Increase if you experience performance issues around screen refresh. - ''; - }; - - width = mkOption { - description = '' - Width of the window: can be a `%` string, a number representing columns, a - function or a table. - - A table (an attribute set in our case, see example) indicates that the view should be dynamically sized based on the - longest line. - ''; - type = oneOf [int attrs]; - default = 30; - example = literalExpression '' - { - min = 30; - max = -1; - padding = 1; - } - ''; - }; - - side = mkOption { - description = "Side of the tree."; - type = enum ["left" "right"]; - default = "left"; - }; - - preserveWindowProportions = mkOption { - description = '' - Preserves window proportions when opening a file. - If `false`, the height and width of windows other than nvim-tree will be equalized. - ''; - type = bool; - default = false; - }; - - number = mkOption { - description = "Print the line number in front of each line."; - type = bool; - default = false; - }; - - relativenumber = mkOption { - description = '' - Show the line number relative to the line with the cursor in front of each line. - If the option `view.number` is also `true`, the number on the cursor line - will be the line number instead of `0`. - ''; - type = bool; - default = false; - }; - - signcolumn = mkOption { - description = ''Show diagnostic sign column. Value can be `"yes"`, `"auto"` or`"no"`.''; - type = enum ["yes" "auto" "no"]; - default = "yes"; - }; - - float = mkOption { - description = "Configuration options for floating window."; - - default = {}; - type = submodule { - options = { - enable = mkOption { - description = "If true, tree window will be floating."; - type = bool; - default = false; - }; - - quitOnFocusLoss = mkOption { - description = "Close the floating tree window when it loses focus."; - type = bool; - default = true; - }; - - openWinConfig = mkOption { - description = "Floating window config. See `:h nvim_open_win()` for more details."; - type = attrs; - default = { - relative = "editor"; - border = "rounded"; - width = 30; - height = 30; - row = 1; - col = 1; - }; - }; - }; - }; - }; - }; - }; - }; - - renderer = { - addTrailing = mkOption { - default = false; - description = "Appends a trailing slash to folder names."; + description = "Auto reload tree on write"; type = bool; }; - groupEmpty = mkOption { - default = false; - description = "Compact folders that only contain a single folder into one node in the file tree."; - type = bool; - }; - - fullName = mkOption { - default = false; - description = "Display node whose name length is wider than the width of nvim-tree window in floating window."; - type = bool; - }; - - highlightGit = mkOption { - type = bool; - default = false; + update_focused_file = mkOption { description = '' - Enable file highlight for git attributes using `NvimTreeGit` highlight groups. - Requires `nvimTree.git.enable` - This can be used with or without the icons. + Update the focused file on `BufEnter`, un-collapses the folders recursively + until it finds the file. ''; - }; - - highlightOpenedFiles = mkOption { - type = enum ["none" "icon" "name" "all"]; - default = "none"; - description = '' - Highlight icons and/or names for bufloaded() files using the - `NvimTreeOpenedFile` highlight group. - ''; - }; - - highlightModified = mkOption { - type = enum ["none" "icon" "name" "all"]; - default = "none"; - description = '' - Highlight modified files in the tree using `NvimTreeNormal` highlight group. - Requires `nvimTree.view.highlightOpenedFiles` - ''; - }; - - rootFolderLabel = mkOption { - type = oneOf [str bool]; - default = false; - example = ''"":~:s?$?/..?"''; - description = '' - In what format to show root folder. See `:help filename-modifiers` for - available `string` options. - Set to `false` to hide the root folder. - - Function is passed the absolute path of the root folder and should - return a string. e.g. - my_root_folder_label = function(path) - return ".../" .. vim.fn.fnamemodify(path, ":t") - end - ''; - }; - - indentWidth = mkOption { - type = addCheck int (x: x >= 1); - default = 2; - description = "Number of spaces for an each tree nesting level. Minimum 1."; - }; - - indentMarkers = mkOption { - description = "Configuration options for tree indent markers."; default = {}; type = submodule { options = { - enable = mkEnableOption "Display indent markers when folders are open."; - inlineArrows = mkOption { + enable = mkOption { + type = bool; + default = false; + description = "update focused file"; + }; + + update_root = mkOption { + type = bool; + default = false; + description = '' + Update the root directory of the tree if the file is not under current + root directory. It prefers vim's cwd and `root_dirs`. + Otherwise it falls back to the folder containing the file. + Only relevant when `update_focused_file.enable` is `true` + ''; + }; + + ignore_list = mkOption { + type = listOf str; + default = []; + description = '' + List of buffer names and filetypes that will not update the root dir + of the tree if the file isn't found under the current root directory. + Only relevant when `update_focused_file.update_root` and + `update_focused_file.enable` are `true`. + ''; + }; + }; + }; + }; + + sort = { + # TODO: function as a possible type + sorter = mkOption { + default = "name"; + description = "How files within the same directory are sorted."; + type = enum ["name" "extension" "modification_time" "case_sensitive" "suffix" "filetype"]; + }; + + folders_first = mkOption { + default = true; + description = "Sort folders before files. Has no effect when `sort.sorter` is a function."; + type = bool; + }; + }; + + hijack_cursor = mkOption { + default = false; + description = "Hijack the cursor in the tree to put it at the start of the filename"; + type = bool; + }; + + hijack_unnamed_buffer_when_opening = mkOption { + default = false; + description = "Open nvimtree in place of the unnamed buffer if it's empty."; + type = bool; + }; + + root_dirs = mkOption { + default = []; + description = '' + Preferred root directories. Only relevant when `updateFocusedFile.updateRoot` is `true` + ''; + type = listOf str; + }; + + prefer_startup_root = mkOption { + default = false; + description = '' + Prefer startup root directory when updating root directory of the tree. + Only relevant when `update_focused_file.update_root` is `true` + ''; + type = bool; + }; + + sync_root_with_cwd = mkOption { + type = bool; + default = false; + description = '' + Changes the tree root directory on `DirChanged` and refreshes the tree. + Only relevant when `updateFocusedFile.updateRoot` is `true` + + (previously `update_cwd`) + ''; + }; + + reload_on_buf_enter = mkOption { + default = false; + type = bool; + description = "Automatically reloads the tree on `BufEnter` nvim-tree."; + }; + + respect_buf_cwd = mkOption { + default = false; + type = bool; + description = "Will change cwd of nvim-tree to that of new buffer's when opening nvim-tree."; + }; + + hijack_directories = { + enable = mkOption { + type = bool; + description = '' + Enable the `hijack_directories` feature. Disable this option if you use vim-dirvish or dirbuf.nvim. + If `hijack_netrw` and `disable_netrw` are `false`, this feature will be disabled. + ''; + default = true; + }; + + auto_open = mkOption { + type = bool; + description = '' + Opens the tree if the tree was previously closed. + ''; + default = false; + }; + }; + + system_open = { + args = mkOption { + default = []; + description = "Optional argument list."; + type = listOf str; + }; + + cmd = mkOption { + default = + if pkgs.stdenv.isDarwin + then "open" + else if pkgs.stdenv.isLinux + then "${pkgs.xdg-utils}/bin/xdg-open" + else throw "NvimTree: No default system open command for this platform, please set `vim.filetree.nvimTree.systemOpen.cmd`"; + description = "The open command itself"; + type = str; + }; + }; + + diagnostics = mkOption { + description = '' + Show LSP and COC diagnostics in the signcolumn + Note that the modified sign will take precedence over the diagnostics signs. + ''; + + default = {}; + + type = submodule { + options = { + enable = mkEnableOption "diagnostics view in the signcolumn."; + + debounce_delay = mkOption { + description = "Idle milliseconds between diagnostic event and update."; + type = int; + default = 50; + }; + + show_on_dirs = mkOption { + description = "Show diagnostic icons on parent directories."; + default = false; + }; + + show_on_open_dirs = mkOption { type = bool; default = true; - description = "Display folder arrows in the same column as indent marker when using `renderer.icons.show.folder_arrow`"; + description = '' + Show diagnostics icons on directories that are open. + Only relevant when `diagnostics.show_on_dirs` is `true`. + ''; }; icons = mkOption { - type = attrs; - description = "Individual elements of the indent markers"; - default = { - corner = "└"; - edge = "│"; - item = "│"; - bottom = "─"; - none = ""; - }; - }; - }; - }; - }; - - specialFiles = mkOption { - type = listOf str; - default = ["Cargo.toml" "README.md" "readme.md" "Makefile" "MAKEFILE" "flake.nix"]; # ;) - description = "A list of filenames that gets highlighted with `NvimTreeSpecialFile"; - }; - - symlinkDestination = mkOption { - type = bool; - default = true; - description = "Whether to show the destination of the symlink."; - }; - - icons = mkOption { - description = "Configuration options for icons."; - default = {}; - type = submodule { - options = { - webdevColors = mkOption { - type = bool; - description = " Use the webdev icon colors, otherwise `NvimTreeFileIcon`"; - default = true; - }; - - gitPlacement = mkOption { - type = enum ["before" "after" "signcolumn"]; - description = "Place where the git icons will be rendered. `signcolumn` requires `view.signcolumn` to be enabled."; - default = "before"; - }; - - modifiedPlacement = mkOption { - type = enum ["before" "after" "signcolumn"]; - description = "Place where the modified icons will be rendered. `signcolumn` requires `view.signcolumn` to be enabled."; - default = "after"; - }; - - padding = mkOption { - type = str; - description = "Inserted between icon and filename"; - default = " "; - }; - - symlinkArrow = mkOption { - type = str; - description = "Used as a separator between symlinks' source and target."; - default = " ➛ "; - }; - - show = { - file = mkOption { - type = bool; - description = "Show an icon before the file name. `nvim-web-devicons` will be used if available."; - default = true; - }; - - folder = mkOption { - type = bool; - description = "Show an icon before the folder name."; - default = true; - }; - - folderArrow = mkOption { - type = bool; - default = true; - description = '' - Show a small arrow before the folder node. Arrow will be a part of the - node when using `renderer.indent_markers`. - ''; - }; - - git = mkOption { - type = bool; - default = false; - description = '' - Show a git status icon, see `renderer.icons.gitPlacement` - Requires `git.enable` to be true. - ''; - }; - - modified = mkOption { - type = bool; - default = true; - description = '' - Show a modified icon, see `renderer.icons.modifiedPlacement` - Requires `modified.enable` to be true. - ''; - }; - }; - glyphs = mkOption { - description = '' - Configuration options for icon glyphs. - NOTE: Do not set any glyphs to more than two characters if it's going - to appear in the signcolumn. - ''; + description = "Icons for diagnostic severity."; default = {}; type = submodule { options = { - default = mkOption { + hint = mkOption { + description = "Icon used for `hint` diagnostic."; type = str; - description = "Glyph for files. Will be overridden by `nvim-web-devicons` if available."; - default = ""; + default = ""; + }; + info = mkOption { + description = "Icon used for `info` diagnostic."; + type = str; + default = ""; + }; + warning = mkOption { + description = "Icon used for `warning` diagnostic."; + type = str; + default = ""; + }; + error = mkOption { + description = "Icon used for `error` diagnostic."; + type = str; + default = ""; + }; + }; + }; + }; + + severity = mkOption { + description = "Severity for which the diagnostics will be displayed. See `:help diagnostic-severity`"; + default = {}; + type = submodule { + options = { + min = mkOption { + description = "Minimum severity."; + type = enum ["HINT" "INFO" "WARNING" "ERROR"]; + default = "HINT"; }; - symlink = mkOption { - type = str; - description = "Glyph for symlinks."; - default = ""; + max = mkOption { + description = "Maximum severity."; + type = enum ["HINT" "INFO" "WARNING" "ERROR"]; + default = "ERROR"; + }; + }; + }; + }; + }; + }; + }; + + git = { + enable = mkEnableOption "Git integration with icons and colors."; + + show_on_dirs = mkOption { + type = bool; + default = true; + description = "Show git icons on parent directories."; + }; + + show_on_open_dirs = mkOption { + type = bool; + default = true; + description = "Show git icons on directories that are open."; + }; + + disable_for_dirs = mkOption { + type = listOf str; + default = []; + description = '' + Disable git integration when git top-level matches these paths. + May be relative, evaluated via `":p"` + ''; + }; + + timeout = mkOption { + type = int; + default = 400; + description = '' + Kills the git process after some time if it takes too long. + Git integration will be disabled after 10 git jobs exceed this timeout. + ''; + }; + }; + + modified = mkOption { + description = "Indicate which file have unsaved modification."; + default = {}; + type = submodule { + options = { + enable = mkEnableOption "Modified files with icons and color highlight."; + + show_on_dirs = mkOption { + type = bool; + description = "Show modified icons on parent directories."; + default = true; + }; + + show_on_open_dirs = mkOption { + type = bool; + description = "Show modified icons on directories that are open."; + default = true; + }; + }; + }; + }; + + filesystem_watchers = mkOption { + description = '' + Will use file system watcher (libuv fs_event) to watch the filesystem for changes. + Using this will disable BufEnter / BufWritePost events in nvim-tree which + were used to update the whole tree. With this feature, the tree will be + updated only for the appropriate folder change, resulting in better + performance. + ''; + default = {}; + type = submodule { + options = { + enable = mkOption { + description = "Enable filesystem watchers."; + type = bool; + default = true; + }; + + debounce_delay = mkOption { + description = "Idle milliseconds between filesystem change and action."; + type = int; + default = 50; + }; + + ignore_dirs = mkOption { + type = listOf str; + default = []; + description = '' + List of vim regex for absolute directory paths that will not be watched. + Backslashes must be escaped e.g. `"my-project/\\.build$"`. + Useful when path is not in `.gitignore` or git integration is disabled. + ''; + }; + }; + }; + }; + + selectPrompts = mkEnableOption '' + Use `vim.ui.select` style prompts. Necessary when using a UI prompt decorator such as dressing.nvim or telescope-ui-select.nvim + ''; + + view = mkOption { + description = "Window / buffer setup."; + default = {}; + type = submodule { + options = { + centralize_selection = mkOption { + description = "If true, reposition the view so that the current node is initially centralized when entering nvim-tree."; + type = bool; + default = false; + }; + + cursorline = mkOption { + description = "Enable cursorline in nvim-tree window."; + type = bool; + default = true; + }; + + debounce_delay = mkOption { + type = int; + default = 15; + description = '' + Idle milliseconds before some reload / refresh operations. + Increase if you experience performance issues around screen refresh. + ''; + }; + + width = mkOption { + description = '' + Width of the window: can be a `%` string, a number representing columns, a + function or a table. + + A table (an attribute set in our case, see example) indicates that the view should be dynamically sized based on the + longest line. + ''; + type = oneOf [int attrs]; + default = 30; + example = literalExpression '' + { + min = 30; + max = -1; + padding = 1; + } + ''; + }; + + side = mkOption { + description = "Side of the tree."; + type = enum ["left" "right"]; + default = "left"; + }; + + preserve_window_proportions = mkOption { + description = '' + Preserves window proportions when opening a file. + If `false`, the height and width of windows other than nvim-tree will be equalized. + ''; + type = bool; + default = false; + }; + + number = mkOption { + description = "Print the line number in front of each line."; + type = bool; + default = false; + }; + + relativenumber = mkOption { + description = '' + Show the line number relative to the line with the cursor in front of each line. + If the option `view.number` is also `true`, the number on the cursor line + will be the line number instead of `0`. + ''; + type = bool; + default = false; + }; + + signcolumn = mkOption { + description = ''Show diagnostic sign column. Value can be `"yes"`, `"auto"` or`"no"`.''; + type = enum ["yes" "auto" "no"]; + default = "yes"; + }; + + float = mkOption { + description = "Configuration options for floating window."; + + default = {}; + type = submodule { + options = { + enable = mkOption { + description = "If true, tree window will be floating."; + type = bool; + default = false; }; - modified = mkOption { - type = str; - description = "Icon to display for modified files."; - default = ""; + quit_on_focus_loss = mkOption { + description = "Close the floating tree window when it loses focus."; + type = bool; + default = true; }; - # TODO: hardcode each attribute - folder = mkOption { + open_win_config = mkOption { + description = "Floating window config. See `:h nvim_open_win()` for more details."; type = attrs; - description = "Glyphs for directories. Recommended to use the defaults unless you know what you are doing."; default = { - default = ""; - open = ""; - arrowOpen = ""; - arrowClosed = ""; - empty = ""; - emptyOpen = ""; - symlink = ""; - symlinkOpen = ""; - }; - }; - - git = mkOption { - type = attrs; - description = "Glyphs for git status."; - default = { - unstaged = "✗"; - staged = "✓"; - unmerged = ""; - renamed = "➜"; - untracked = "★"; - deleted = ""; - ignored = "◌"; + relative = "editor"; + border = "rounded"; + width = 30; + height = 30; + row = 1; + col = 1; }; }; }; @@ -748,235 +494,245 @@ in { }; }; }; - }; - filters = mkOption { - description = "Filtering options."; + renderer = { + add_trailing = mkOption { + default = false; + description = "Appends a trailing slash to folder names."; + type = bool; + }; - default = { - gitIgnored = false; - dotfiles = false; - gitClean = false; - noBuffer = false; - exclude = []; - }; - type = submodule { - options = { - gitIgnored = mkOption { - type = bool; - description = "Ignore files based on `.gitignore`. Requires git.enable` to be `true`"; - default = false; - }; + group_empty = mkOption { + default = false; + description = "Compact folders that only contain a single folder into one node in the file tree."; + type = bool; + }; - dotfiles = mkOption { - type = bool; - description = "Do not show dotfiles: files starting with a `.`"; - default = false; - }; + full_name = mkOption { + default = false; + description = "Display node whose name length is wider than the width of nvim-tree window in floating window."; + type = bool; + }; - gitClean = mkOption { - type = bool; - default = false; + highlight_git = mkOption { + type = bool; + default = false; + description = '' + Enable file highlight for git attributes using `NvimTreeGit` highlight groups. + Requires `nvimTree.git.enable` + This can be used with or without the icons. + ''; + }; - description = '' - Do not show files with no git status. This will show ignored files when - `nvimTree.filters.gitIgnored` is set, as they are effectively dirty. - ''; - }; + highlight_opened_files = mkOption { + type = enum ["none" "icon" "name" "all"]; + default = "none"; + description = '' + Highlight icons and/or names for bufloaded() files using the + `NvimTreeOpenedFile` highlight group. + ''; + }; - noBuffer = mkOption { - type = bool; - default = false; - description = "Do not show files that have no `buflisted()` buffer."; - }; + highlight_modified = mkOption { + type = enum ["none" "icon" "name" "all"]; + default = "none"; + description = '' + Highlight modified files in the tree using `NvimTreeNormal` highlight group. + Requires `nvimTree.view.highlightOpenedFiles` + ''; + }; - exclude = mkOption { - type = listOf str; - default = []; - description = "List of directories or files to exclude from filtering: always show them."; + root_folder_label = mkOption { + type = oneOf [str bool]; + default = false; + example = ''"":~:s?$?/..?"''; + description = '' + In what format to show root folder. See `:help filename-modifiers` for + available `string` options. + Set to `false` to hide the root folder. + + Function is passed the absolute path of the root folder and should + return a string. e.g. + my_root_folder_label = function(path) + return ".../" .. vim.fn.fnamemodify(path, ":t") + end + ''; + }; + + indent_width = mkOption { + type = addCheck int (x: x >= 1); + default = 2; + description = "Number of spaces for an each tree nesting level. Minimum 1."; + }; + + indent_markers = mkOption { + description = "Configuration options for tree indent markers."; + default = {}; + type = submodule { + options = { + enable = mkEnableOption "Display indent markers when folders are open."; + inline_arrows = mkOption { + type = bool; + default = true; + description = "Display folder arrows in the same column as indent marker when using `renderer.icons.show.folder_arrow`"; + }; + + icons = mkOption { + type = attrs; + description = "Individual elements of the indent markers"; + default = { + corner = "└"; + edge = "│"; + item = "│"; + bottom = "─"; + none = ""; + }; + }; + }; }; }; - }; - }; - trash = mkOption { - description = "Configuration options for trashing."; - default = { - cmd = "${pkgs.glib}/bin/gio trash"; - }; - - type = submodule { - options = { - cmd = mkOption { - type = str; - description = "The command used to trash items"; - }; + special_files = mkOption { + type = listOf str; + default = ["Cargo.toml" "README.md" "readme.md" "Makefile" "MAKEFILE" "flake.nix"]; # ;) + description = "A list of filenames that gets highlighted with `NvimTreeSpecialFile"; }; - }; - }; - actions = mkOption { - description = "Configuration for various actions."; - default = {}; - type = submodule { - options = { - useSystemClipboard = mkOption { - type = bool; - default = true; - description = '' - A boolean value that toggle the use of system clipboard when copy/paste - function are invoked. When enabled, copied text will be stored in registers - '+' (system), otherwise, it will be stored in '1' and '"'. - ''; - }; + symlink_destination = mkOption { + type = bool; + default = true; + description = "Whether to show the destination of the symlink."; + }; - # change_dir actions - changeDir = mkOption { - description = "vim `change-directory` behaviour"; - default = {}; - type = submodule { - options = { - enable = mkOption { + icons = mkOption { + description = "Configuration options for icons."; + default = {}; + type = submodule { + options = { + webdev_colors = mkOption { + type = bool; + description = " Use the webdev icon colors, otherwise `NvimTreeFileIcon`"; + default = true; + }; + + git_placement = mkOption { + type = enum ["before" "after" "signcolumn"]; + description = "Place where the git icons will be rendered. `signcolumn` requires `view.signcolumn` to be enabled."; + default = "before"; + }; + + modified_placement = mkOption { + type = enum ["before" "after" "signcolumn"]; + description = "Place where the modified icons will be rendered. `signcolumn` requires `view.signcolumn` to be enabled."; + default = "after"; + }; + + padding = mkOption { + type = str; + description = "Inserted between icon and filename"; + default = " "; + }; + + symlink_arrow = mkOption { + type = str; + description = "Used as a separator between symlinks' source and target."; + default = " ➛ "; + }; + + show = { + file = mkOption { + type = bool; + description = "Show an icon before the file name. `nvim-web-devicons` will be used if available."; + default = true; + }; + + folder = mkOption { + type = bool; + description = "Show an icon before the folder name."; + default = true; + }; + + folder_arrow = mkOption { type = bool; default = true; - description = "Change the working directory when changing directories in the tree."; - }; - - global = mkOption { - type = bool; - default = false; description = '' - Use `:cd` instead of `:lcd` when changing directories. - Consider that this might cause issues with the `nvimTree.syncRootWithCwd` option. + Show a small arrow before the folder node. Arrow will be a part of the + node when using `renderer.indent_markers`. ''; }; - restrictAboveCwd = mkOption { + git = mkOption { type = bool; default = false; description = '' - Restrict changing to a directory above the global current working directory. + Show a git status icon, see `renderer.icons.gitPlacement` + Requires `git.enable` to be true. ''; }; - }; - }; - }; - # expand_all actions - expandAll = mkOption { - description = "Configuration for expand_all behaviour."; - default = {}; - type = submodule { - options = { - maxFolderDiscovery = mkOption { - type = int; - default = 300; + modified = mkOption { + type = bool; + default = true; description = '' - Limit the number of folders being explored when expanding every folders. - Avoids hanging neovim when running this action on very large folders. + Show a modified icon, see `renderer.icons.modifiedPlacement` + Requires `modified.enable` to be true. ''; }; - exclude = mkOption { - type = listOf str; - description = "A list of directories that should not be expanded automatically."; - default = [".git" "target" "build" "result"]; - }; }; - }; - }; + glyphs = mkOption { + description = '' + Configuration options for icon glyphs. + NOTE: Do not set any glyphs to more than two characters if it's going + to appear in the signcolumn. + ''; + default = {}; + type = submodule { + options = { + default = mkOption { + type = str; + description = "Glyph for files. Will be overridden by `nvim-web-devicons` if available."; + default = ""; + }; - # file_popup actions - filePopup = mkOption { - description = "Configuration for file_popup behaviour."; - default = {}; - type = submodule { - options = { - openWinConfig = mkOption { - type = attrs; - default = { - col = 1; - row = 1; - relative = "cursor"; - border = "rounded"; - style = "minimal"; - }; - description = "Floating window config for file_popup. See |nvim_open_win| for more details."; - }; - }; - }; - }; + symlink = mkOption { + type = str; + description = "Glyph for symlinks."; + default = ""; + }; - # open_file actions - openFile = mkOption { - description = "Configuration options for opening a file from nvim-tree."; - default = {}; - type = submodule { - options = { - quitOnOpen = mkOption { - type = bool; - description = "Closes the explorer when opening a file."; - default = false; - }; + modified = mkOption { + type = str; + description = "Icon to display for modified files."; + default = ""; + }; - eject = mkOption { - type = bool; - description = "Prevent new opened file from opening in the same window as the tree."; - default = false; - }; - - resizeWindow = mkOption { - type = bool; - default = false; - - description = "Resizes the tree when opening a file. Previously `view.auto_resize`"; - }; - - windowPicker = mkOption { - description = "window_picker"; - default = {}; - type = submodule { - options = { - enable = mkOption { - type = bool; - description = "Enable the window picker. If this feature is not enabled, files will open in window from which you last opened the tree."; - default = false; + # TODO: hardcode each attribute + folder = mkOption { + type = attrs; + description = "Glyphs for directories. Recommended to use the defaults unless you know what you are doing."; + default = { + default = ""; + open = ""; + arrowOpen = ""; + arrowClosed = ""; + empty = ""; + emptyOpen = ""; + symlink = ""; + symlinkOpen = ""; }; + }; - picker = mkOption { - type = str; - default = "default"; - description = '' - Change the default window picker, can be a string `"default"` or a function. - The function should return the window id that will open the node, - or `nil` if an invalid window is picked or user cancelled the action. - - The picker may create a new window. - ''; - - example = literalExpression '' - -- with s1n7ax/nvim-window-picker plugin - require('window-picker').pick_window, - ''; - }; - - chars = mkOption { - type = str; - description = "A string of chars used as identifiers by the window picker."; - default = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; - }; - - exclude = { - filetype = mkOption { - type = listOf str; - description = "A list of filetypes to exclude from the window picker."; - default = ["notify" "packer" "qf" "diff" "fugitive" "fugitiveblame"]; - }; - - buftype = mkOption { - type = listOf str; - description = "A list of buftypes to exclude from the window picker."; - default = ["nofile" "terminal" "help"]; - }; + git = mkOption { + type = attrs; + description = "Glyphs for git status."; + default = { + unstaged = "✗"; + staged = "✓"; + unmerged = ""; + renamed = "➜"; + untracked = "★"; + deleted = ""; + ignored = "◌"; }; }; }; @@ -984,122 +740,360 @@ in { }; }; }; + }; + }; - removeFile = { - closeWindow = mkOption { + filters = mkOption { + description = "Filtering options."; + + default = { + git_ignored = false; + dotfiles = false; + git_clean = false; + no_buffer = false; + exclude = []; + }; + type = submodule { + options = { + git_ignored = mkOption { type = bool; - default = true; - description = "Close any window displaying a file when removing the file from the tree"; + description = "Ignore files based on `.gitignore`. Requires git.enable` to be `true`"; + default = false; + }; + + dotfiles = mkOption { + type = bool; + description = "Do not show dotfiles: files starting with a `.`"; + default = false; + }; + + git_clean = mkOption { + type = bool; + default = false; + + description = '' + Do not show files with no git status. This will show ignored files when + `nvimTree.filters.gitIgnored` is set, as they are effectively dirty. + ''; + }; + + no_buffer = mkOption { + type = bool; + default = false; + description = "Do not show files that have no `buflisted()` buffer."; + }; + + exclude = mkOption { + type = listOf str; + default = []; + description = "List of directories or files to exclude from filtering: always show them."; }; }; }; }; - }; - liveFilter = mkOption { - description = '' - Configurations for the live_filtering feature. - The live filter allows you to filter the tree nodes dynamically, based on - regex matching (see `vim.regex`). - This feature is bound to the `f` key by default. - The filter can be cleared with the `F` key by default. - ''; - default = {}; - type = submodule { - options = { - prefix = mkOption { - type = str; - description = "Prefix of the filter displayed in the buffer."; - default = "[FILTER]: "; - }; + trash = mkOption { + description = "Configuration options for trashing."; + default = { + cmd = "${pkgs.glib}/bin/gio trash"; + }; - alwaysShowFolders = mkOption { - type = bool; - description = "Whether to filter folders or not."; - default = true; + type = submodule { + options = { + cmd = mkOption { + type = str; + description = "The command used to trash items"; + }; }; }; }; - }; - tab = mkOption { - description = "Configuration for tab behaviour."; - default = {}; - type = submodule { - options = { - sync = mkOption { - description = "Configuration for syncing nvim-tree across tabs."; - default = {}; - type = submodule { - options = { - open = mkOption { - type = bool; - default = false; - description = '' - Opens the tree automatically when switching tabpage or opening a new - tabpage if the tree was previously open. - ''; + actions = mkOption { + description = "Configuration for various actions."; + default = {}; + type = submodule { + options = { + use_system_clipboard = mkOption { + type = bool; + default = true; + description = '' + A boolean value that toggle the use of system clipboard when copy/paste + function are invoked. When enabled, copied text will be stored in registers + '+' (system), otherwise, it will be stored in '1' and '"'. + ''; + }; + + # change_dir actions + change_dir = mkOption { + description = "vim `change-directory` behaviour"; + default = {}; + type = submodule { + options = { + enable = mkOption { + type = bool; + default = true; + description = "Change the working directory when changing directories in the tree."; + }; + + global = mkOption { + type = bool; + default = false; + description = '' + Use `:cd` instead of `:lcd` when changing directories. + Consider that this might cause issues with the `nvimTree.syncRootWithCwd` option. + ''; + }; + + restrict_above_cwd = mkOption { + type = bool; + default = false; + description = '' + Restrict changing to a directory above the global current working directory. + ''; + }; }; + }; + }; - close = mkOption { - type = bool; - default = false; - description = '' - Closes the tree across all tabpages when the tree is closed. - ''; + # expand_all actions + expand_all = mkOption { + description = "Configuration for expand_all behaviour."; + default = {}; + type = submodule { + options = { + max_folder_discovery = mkOption { + type = int; + default = 300; + description = '' + Limit the number of folders being explored when expanding every folders. + Avoids hanging neovim when running this action on very large folders. + ''; + }; + exclude = mkOption { + type = listOf str; + description = "A list of directories that should not be expanded automatically."; + default = [".git" "target" "build" "result"]; + }; }; + }; + }; - ignore = mkOption { - type = listOf str; - default = []; - description = '' - List of filetypes or buffer names on new tab that will prevent - `nvimTree.tab.sync.open` and `nvimTree.tab.sync.close` - ''; + # file_popup actions + file_popup = mkOption { + description = "Configuration for file_popup behaviour."; + default = {}; + type = submodule { + options = { + open_win_config = mkOption { + type = attrs; + default = { + col = 1; + row = 1; + relative = "cursor"; + border = "rounded"; + style = "minimal"; + }; + description = "Floating window config for file_popup. See |nvim_open_win| for more details."; + }; + }; + }; + }; + + # open_file actions + open_file = mkOption { + description = "Configuration options for opening a file from nvim-tree."; + default = {}; + type = submodule { + options = { + quit_on_open = mkOption { + type = bool; + description = "Closes the explorer when opening a file."; + default = false; + }; + + eject = mkOption { + type = bool; + description = "Prevent new opened file from opening in the same window as the tree."; + default = false; + }; + + resize_window = mkOption { + type = bool; + default = false; + + description = "Resizes the tree when opening a file. Previously `view.auto_resize`"; + }; + + window_picker = mkOption { + description = "window_picker"; + default = {}; + type = submodule { + options = { + enable = mkOption { + type = bool; + description = "Enable the window picker. If this feature is not enabled, files will open in window from which you last opened the tree."; + default = false; + }; + + picker = mkOption { + type = str; + default = "default"; + description = '' + Change the default window picker, can be a string `"default"` or a function. + The function should return the window id that will open the node, + or `nil` if an invalid window is picked or user cancelled the action. + + The picker may create a new window. + ''; + + example = literalExpression '' + -- with s1n7ax/nvim-window-picker plugin + require('window-picker').pick_window, + ''; + }; + + chars = mkOption { + type = str; + description = "A string of chars used as identifiers by the window picker."; + default = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; + }; + + exclude = { + filetype = mkOption { + type = listOf str; + description = "A list of filetypes to exclude from the window picker."; + default = ["notify" "packer" "qf" "diff" "fugitive" "fugitiveblame"]; + }; + + buftype = mkOption { + type = listOf str; + description = "A list of buftypes to exclude from the window picker."; + default = ["nofile" "terminal" "help"]; + }; + }; + }; + }; + }; + }; + }; + }; + + remove_file = { + close_window = mkOption { + type = bool; + default = true; + description = "Close any window displaying a file when removing the file from the tree"; + }; + }; + }; + }; + }; + + live_filter = mkOption { + description = '' + Configurations for the live_filtering feature. + The live filter allows you to filter the tree nodes dynamically, based on + regex matching (see `vim.regex`). + This feature is bound to the `f` key by default. + The filter can be cleared with the `F` key by default. + ''; + default = {}; + type = submodule { + options = { + prefix = mkOption { + type = str; + description = "Prefix of the filter displayed in the buffer."; + default = "[FILTER]: "; + }; + + always_show_folders = mkOption { + type = bool; + description = "Whether to filter folders or not."; + default = true; + }; + }; + }; + }; + + tab = mkOption { + description = "Configuration for tab behaviour."; + default = {}; + type = submodule { + options = { + sync = mkOption { + description = "Configuration for syncing nvim-tree across tabs."; + default = {}; + type = submodule { + options = { + open = mkOption { + type = bool; + default = false; + description = '' + Opens the tree automatically when switching tabpage or opening a new + tabpage if the tree was previously open. + ''; + }; + + close = mkOption { + type = bool; + default = false; + description = '' + Closes the tree across all tabpages when the tree is closed. + ''; + }; + + ignore = mkOption { + type = listOf str; + default = []; + description = '' + List of filetypes or buffer names on new tab that will prevent + `nvimTree.tab.sync.open` and `nvimTree.tab.sync.close` + ''; + }; }; }; }; }; }; }; - }; - notify = mkOption { - description = "Configuration for notifications."; - default = {}; - type = submodule { - options = { - threshold = mkOption { - type = enum ["ERROR" "WARNING" "INFO" "DEBUG"]; - description = "Specify minimum notification level, uses the values from `vim.log.levels`"; - default = "INFO"; - }; + notify = mkOption { + description = "Configuration for notifications."; + default = {}; + type = submodule { + options = { + threshold = mkOption { + type = enum ["ERROR" "WARNING" "INFO" "DEBUG"]; + description = "Specify minimum notification level, uses the values from `vim.log.levels`"; + default = "INFO"; + }; - absolutePath = mkOption { - type = bool; - description = "Whether to use absolute paths or item names in fs action notifications."; - default = true; + absolute_path = mkOption { + type = bool; + description = "Whether to use absolute paths or item names in fs action notifications."; + default = true; + }; }; }; }; - }; - ui = mkOption { - description = "General UI configuration."; - default = {}; - type = submodule { - options = { - confirm = { - remove = mkOption { - type = bool; - description = "Prompt before removing."; - default = true; - }; + ui = mkOption { + description = "General UI configuration."; + default = {}; + type = submodule { + options = { + confirm = { + remove = mkOption { + type = bool; + description = "Prompt before removing."; + default = true; + }; - trash = mkOption { - type = bool; - description = "Prompt before trash."; - default = true; + trash = mkOption { + type = bool; + description = "Prompt before trash."; + default = true; + }; }; }; }; From 376c8bafd0c096ce295ba1ea74420048765d05db Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Wed, 3 Jan 2024 00:55:15 +0100 Subject: [PATCH 052/193] feat(lualine): add custom setup options --- modules/statusline/lualine/config.nix | 115 ++++++++++++------------- modules/statusline/lualine/lualine.nix | 22 +++++ 2 files changed, 77 insertions(+), 60 deletions(-) diff --git a/modules/statusline/lualine/config.nix b/modules/statusline/lualine/config.nix index 04f123d..9ab576e 100644 --- a/modules/statusline/lualine/config.nix +++ b/modules/statusline/lualine/config.nix @@ -3,75 +3,70 @@ lib, ... }: let - inherit (lib.modules) mkIf; + inherit (lib.modules) mkIf mkMerge; inherit (lib.trivial) boolToString; - inherit (lib.strings) optionalString; - inherit (lib.nvim.lua) luaTable listToLuaTable; inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.statusline.lualine; breadcrumbsCfg = config.vim.ui.breadcrumbs; + rawLua = code: {"__raw" = code;}; in { - config = (mkIf cfg.enable) { - vim.startPlugins = [ - "lualine" - ]; + config = mkMerge [ + # TODO: move into nvim-tree file + (mkIf (config.vim.filetree.nvimTree.enable) { + vim.statusline.lualine.setupOpts = { + extensions = ["nvim-tree"]; + }; + }) + (mkIf (breadcrumbsCfg.enable && breadcrumbsCfg.source == "nvim-navic") { + vim.statusline.lualine.setupOpts = { + # TODO: rewrite in new syntax + winbar.lualine_c = [ + "navic" + (rawLua "draw_empty = ${boolToString config.vim.ui.breadcrumbs.alwaysRender}") + ]; + }; + }) + (mkIf cfg.enable { + vim.startPlugins = [ + "lualine" + ]; - vim.luaConfigRC.lualine = entryAnywhere '' - local lualine = require('lualine') - lualine.setup { + vim.luaConfigRC.lualine = entryAnywhere '' + local lualine = require('lualine') + lualine.setup ${toLuaObject cfg.setupOpts} + ''; + + # this is for backwards-compatibility + vim.statusline.lualine.setupOpts = { options = { - icons_enabled = ${boolToString cfg.icons.enable}, - theme = "${cfg.theme}", - component_separators = {"${cfg.componentSeparator.left}","${cfg.componentSeparator.right}"}, - section_separators = {"${cfg.sectionSeparator.left}","${cfg.sectionSeparator.right}"}, - disabled_filetypes = ${listToLuaTable cfg.disabledFiletypes}, - always_divide_middle = ${boolToString cfg.alwaysDivideMiddle}, - globalstatus = ${boolToString cfg.globalStatus}, - ignore_focus = ${listToLuaTable cfg.ignoreFocus}, - extensions = {${optionalString config.vim.filetree.nvimTree.enable "'nvim-tree'"}}, - refresh = { - statusline = ${toString cfg.refresh.statusline}, - tabline = ${toString cfg.refresh.tabline}, - winbar = ${toString cfg.refresh.winbar}, - }, - }, + icons_enabled = cfg.icons.enable; + theme = cfg.theme; + component_separators = [cfg.componentSeparator.left cfg.componentSeparator.right]; + section_separators = [cfg.sectionSeparator.left cfg.sectionSeparator.right]; + globalstatus = cfg.globalStatus; + refresh = cfg.refresh; + }; - -- active sections sections = { - lualine_a = ${luaTable (cfg.activeSection.a ++ cfg.extraActiveSection.a)}, - lualine_b = ${luaTable (cfg.activeSection.b ++ cfg.extraActiveSection.b)}, - lualine_c = ${luaTable (cfg.activeSection.c ++ cfg.extraActiveSection.c)}, - lualine_x = ${luaTable (cfg.activeSection.x ++ cfg.extraActiveSection.x)}, - lualine_y = ${luaTable (cfg.activeSection.y ++ cfg.extraActiveSection.y)}, - lualine_z = ${luaTable (cfg.activeSection.z ++ cfg.extraActiveSection.z)}, - }, - - -- inactive sections + lualine_a = builtins.map rawLua (cfg.activeSection.a ++ cfg.extraActiveSection.a); + lualine_b = builtins.map rawLua (cfg.activeSection.b ++ cfg.extraActiveSection.b); + lualine_c = builtins.map rawLua (cfg.activeSection.c ++ cfg.extraActiveSection.c); + lualine_x = builtins.map rawLua (cfg.activeSection.x ++ cfg.extraActiveSection.x); + lualine_y = builtins.map rawLua (cfg.activeSection.y ++ cfg.extraActiveSection.y); + lualine_z = builtins.map rawLua (cfg.activeSection.z ++ cfg.extraActiveSection.z); + }; inactive_sections = { - lualine_a = ${luaTable (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a)}, - lualine_b = ${luaTable (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b)}, - lualine_c = ${luaTable (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c)}, - lualine_x = ${luaTable (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x)}, - lualine_y = ${luaTable (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y)}, - lualine_z = ${luaTable (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z)}, - }, - - -- tabline (currently unsupported) - tabline = {}, - - ${optionalString (breadcrumbsCfg.enable && breadcrumbsCfg.source == "nvim-navic") '' - -- enable winbar if nvim-navic is enabled - winbar = { - lualine_c = { - { - "navic", - draw_empty = ${boolToString config.vim.ui.breadcrumbs.alwaysRender} - } - } - }, - ''} - } - ''; - }; + lualine_a = builtins.map rawLua (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a); + lualine_b = builtins.map rawLua (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b); + lualine_c = builtins.map rawLua (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c); + lualine_x = builtins.map rawLua (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x); + lualine_y = builtins.map rawLua (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y); + lualine_z = builtins.map rawLua (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z); + }; + # probably don't need this? + tabline = []; + }; + }) + ]; } diff --git a/modules/statusline/lualine/lualine.nix b/modules/statusline/lualine/lualine.nix index 9f5b583..ac18fbd 100644 --- a/modules/statusline/lualine/lualine.nix +++ b/modules/statusline/lualine/lualine.nix @@ -7,14 +7,36 @@ inherit (lib.options) mkOption mkEnableOption; inherit (lib.types) int bool str listOf enum; inherit (lib.lists) optional; + inherit (lib.nvim.types) mkPluginSetupOption; supported_themes = import ./supported_themes.nix; colorPuccin = if config.vim.statusline.lualine.theme == "catppuccin" then "#181825" else "none"; + tempDesc = "see plugin docs for more info"; in { options.vim.statusline.lualine = { + setupOpts = mkPluginSetupOption "Lualine" { + options = { + disabled_filetypes = mkOption { + description = tempDesc; + type = listOf str; + default = ["alpha"]; + }; + always_divide_middle = mkOption { + description = tempDesc; + type = bool; + default = true; + }; + ignore_focus = mkOption { + description = tempDesc; + type = listOf str; + default = ["NvimTree"]; + }; + }; + }; + enable = mkEnableOption "lualine statusline plugin"; icons = { From df8784c65f29e866e8dce16482f77b471fb16720 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Wed, 3 Jan 2024 00:55:32 +0100 Subject: [PATCH 053/193] feat(telescope): add custom setup options --- modules/utility/telescope/config.nix | 49 +------------------ modules/utility/telescope/telescope.nix | 62 ++++++++++++++++++++++++- 2 files changed, 62 insertions(+), 49 deletions(-) diff --git a/modules/utility/telescope/config.nix b/modules/utility/telescope/config.nix index d9a156f..4e60f22 100644 --- a/modules/utility/telescope/config.nix +++ b/modules/utility/telescope/config.nix @@ -11,7 +11,7 @@ inherit (lib) pushDownDefault; cfg = config.vim.telescope; - self = import ./telescope.nix {inherit lib;}; + self = import ./telescope.nix {inherit pkgs lib;}; mappingDefinitions = self.options.vim.telescope.mappings; mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; @@ -66,52 +66,7 @@ in { vim.luaConfigRC.telescope = entryAnywhere '' local telescope = require('telescope') - telescope.setup { - defaults = { - vimgrep_arguments = { - "${pkgs.ripgrep}/bin/rg", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case", - "--hidden", - "--no-ignore", - }, - pickers = { - find_command = { - "${pkgs.fd}/bin/fd", - }, - }, - }, - prompt_prefix = "  ", - selection_caret = " ", - entry_prefix = " ", - initial_mode = "insert", - selection_strategy = "reset", - sorting_strategy = "ascending", - layout_strategy = "horizontal", - layout_config = { - horizontal = { - prompt_position = "top", - preview_width = 0.55, - results_width = 0.8, - }, - vertical = { - mirror = false, - }, - width = 0.8, - height = 0.8, - preview_cutoff = 120, - }, - file_ignore_patterns = { "node_modules", ".git/", "dist/", "build/", "target/", "result/" }, -- TODO: make this configurable - color_devicons = true, - path_display = { "absolute" }, - set_env = { ["COLORTERM"] = "truecolor" }, - winblend = 0, - border = {}, - } + telescope.setup(${nvim.lua.toLuaObject cfg.setupOpts}) ${ if config.vim.ui.noice.enable diff --git a/modules/utility/telescope/telescope.nix b/modules/utility/telescope/telescope.nix index fd8d2f3..27fa98a 100644 --- a/modules/utility/telescope/telescope.nix +++ b/modules/utility/telescope/telescope.nix @@ -1,6 +1,62 @@ -{lib, ...}: let - inherit (lib.options) mkEnableOption; +{ + pkgs, + lib, + ... +}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) int str listOf float bool; inherit (lib.nvim.binds) mkMappingOption; + inherit (lib.nvim.types) mkPluginSetupOption; + mkOptOfType = type: default: + mkOption { + # TODO: description + description = "See plugin docs for more info"; + inherit type default; + }; + + setupOptions = { + defaults = { + vimgrep_arguments = mkOptOfType (listOf str) [ + "${pkgs.ripgrep}/bin/rg" + "--color=never" + "--no-heading" + "--with-filename" + "--line-number" + "--column" + "--smart-case" + "--hidden" + "--no-ignore" + ]; + pickers.find_command = mkOptOfType (listOf str) ["${pkgs.fd}/bin/fd"]; + prompt_prefix = mkOptOfType str "  "; + selection_caret = mkOptOfType str " "; + entry_prefix = mkOptOfType str " "; + initial_mode = mkOptOfType str "insert"; + selection_strategy = mkOptOfType str "reset"; + sorting_strategy = mkOptOfType str "ascending"; + layout_strategy = mkOptOfType str "horizontal"; + layout_config = { + horizontal = { + prompt_position = mkOptOfType str "top"; + preview_width = mkOptOfType float 0.55; + results_width = mkOptOfType float 0.8; + }; + vertical = { + mirror = mkOptOfType bool false; + }; + width = mkOptOfType float 0.8; + height = mkOptOfType float 0.8; + preview_cutoff = mkOptOfType int 120; + }; + file_ignore_patterns = mkOptOfType (listOf str) ["node_modules" ".git/" "dist/" "build/" "target/" "result/"]; + color_devicons = mkOptOfType bool true; + path_display = mkOptOfType (listOf str) ["absolute"]; + set_env = { + COLORTERM = mkOptOfType str "truecolor"; + }; + winblend = mkOptOfType int 0; + }; + }; in { options.vim.telescope = { mappings = { @@ -30,5 +86,7 @@ in { }; enable = mkEnableOption "telescope.nvim: multi-purpose search and picker utility"; + + setupOpts = mkPluginSetupOption "Telescope" setupOptions; }; } From 379231b43d4a4f6b39b897adb8e9ab85d7ca52f8 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 17 Feb 2024 15:41:09 +0100 Subject: [PATCH 054/193] feat(lsp-signature): custom setup --- modules/lsp/lsp-signature/config.nix | 16 +++++++--------- modules/lsp/lsp-signature/lsp-signature.nix | 3 ++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/modules/lsp/lsp-signature/config.nix b/modules/lsp/lsp-signature/config.nix index 5b231bd..c194912 100644 --- a/modules/lsp/lsp-signature/config.nix +++ b/modules/lsp/lsp-signature/config.nix @@ -5,7 +5,7 @@ }: let inherit (lib.modules) mkIf; inherit (lib.nvim.dag) entryAnywhere; - inherit (lib.strings) optionalString; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.lsp; in { @@ -15,16 +15,14 @@ in { "lsp-signature" ]; + lsp.lspSignature.setupOpts = { + bind = config.vim.ui.borders.plugins.lsp-signature.enable; + handler_opts.border = config.vim.ui.borders.plugins.lsp-signature.style; + }; + luaConfigRC.lsp-signature = entryAnywhere '' -- Enable lsp signature viewer - require("lsp_signature").setup({ - ${optionalString config.vim.ui.borders.plugins.lsp-signature.enable '' - bind = true, -- This is mandatory, otherwise border config won't get registered. - handler_opts = { - border = "${config.vim.ui.borders.plugins.lsp-signature.style}" - } - ''} - }) + require("lsp_signature").setup(${toLuaObject cfg.lspSignature.setupOpts}) ''; }; }; diff --git a/modules/lsp/lsp-signature/lsp-signature.nix b/modules/lsp/lsp-signature/lsp-signature.nix index 981526b..be7b6cd 100644 --- a/modules/lsp/lsp-signature/lsp-signature.nix +++ b/modules/lsp/lsp-signature/lsp-signature.nix @@ -3,7 +3,8 @@ in { options.vim.lsp = { lspSignature = { - enable = mkEnableOption "lsp signature viewer [lsp-signature]"; + enable = mkEnableOption "lsp signature viewer"; + setupOpts = lib.nvim.types.mkPluginSetupOption "lsp-signature" {}; }; }; } From 62b0791b75f22af776e560e0dafa0d2463beb26e Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 17 Feb 2024 16:10:45 +0100 Subject: [PATCH 055/193] feat(docs-view): custom setup --- modules/lsp/nvim-docs-view/config.nix | 11 +-- modules/lsp/nvim-docs-view/nvim-docs-view.nix | 76 +++++++++++-------- 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/modules/lsp/nvim-docs-view/config.nix b/modules/lsp/nvim-docs-view/config.nix index 008eee8..45de200 100644 --- a/modules/lsp/nvim-docs-view/config.nix +++ b/modules/lsp/nvim-docs-view/config.nix @@ -3,10 +3,10 @@ lib, ... }: let - inherit (builtins) toString; inherit (lib.modules) mkIf mkMerge; - inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.lsp.nvim-docs-view; self = import ./nvim-docs-view.nix {inherit lib;}; @@ -20,12 +20,7 @@ in { startPlugins = ["nvim-docs-view"]; luaConfigRC.nvim-docs-view = entryAnywhere '' - require("docs-view").setup { - position = "${cfg.position}", - width = ${toString cfg.width}, - height = ${toString cfg.height}, - update_mode = "${cfg.updateMode}", - } + require("docs-view").setup ${toLuaObject cfg.setupOpts} ''; maps.normal = mkMerge [ diff --git a/modules/lsp/nvim-docs-view/nvim-docs-view.nix b/modules/lsp/nvim-docs-view/nvim-docs-view.nix index 6b59a27..e75c385 100644 --- a/modules/lsp/nvim-docs-view/nvim-docs-view.nix +++ b/modules/lsp/nvim-docs-view/nvim-docs-view.nix @@ -1,45 +1,57 @@ {lib, ...}: let inherit (lib.options) mkEnableOption mkOption; - inherit (lib.types) enum int; inherit (lib.nvim.binds) mkMappingOption; + inherit (lib) types mkRenamedOptionModule; in { + imports = let + renamedSetupOption = oldPath: newPath: + mkRenamedOptionModule + (["vim" "lsp" "nvim-docs-view"] ++ oldPath) + (["vim" "lsp" "nvim-docs-view" "setupOpts"] ++ newPath); + in [ + (renamedSetupOption ["position"] ["position"]) + (renamedSetupOption ["width"] ["width"]) + (renamedSetupOption ["height"] ["height"]) + (renamedSetupOption ["updateMode"] ["update_mode"]) + ]; + options.vim.lsp.nvim-docs-view = { enable = mkEnableOption "nvim-docs-view, for displaying lsp hover documentation in a side panel."; - position = mkOption { - type = enum ["left" "right" "top" "bottom"]; - default = "right"; - description = '' - Where to open the docs view panel - ''; - }; + setupOpts = lib.nvim.types.mkPluginSetupOption "nvim-docs-view" { + position = mkOption { + type = types.enum ["left" "right" "top" "bottom"]; + default = "right"; + description = '' + Where to open the docs view panel + ''; + }; - height = mkOption { - type = int; - default = 10; - description = '' - Height of the docs view panel if the position is set to either top or bottom - ''; - }; + height = mkOption { + type = types.int; + default = 10; + description = '' + Height of the docs view panel if the position is set to either top or bottom + ''; + }; - width = mkOption { - type = int; - default = 60; - description = '' - Width of the docs view panel if the position is set to either left or right - ''; - }; + width = mkOption { + type = types.int; + default = 60; + description = '' + Width of the docs view panel if the position is set to either left or right + ''; + }; - updateMode = mkOption { - type = enum ["auto" "manual"]; - default = "auto"; - description = '' - Determines the mechanism used to update the docs view panel content - - Possible values: - - auto: the content will update upon cursor move. - - manual: the content will only update once :DocsViewUpdate is called - ''; + update_mode = mkOption { + type = types.enum ["auto" "manual"]; + default = "auto"; + description = '' + Determines the mechanism used to update the docs view panel content. + - If auto, the content will update upon cursor move. + - If manual, the content will only update once :DocsViewUpdate is called + ''; + }; }; mappings = { From 88c22ef026ebbd47444a952b84fa9ad04df9e28b Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 17 Feb 2024 13:51:05 +0100 Subject: [PATCH 056/193] feat(copilot): custom setup opts --- modules/assistant/copilot/config.nix | 56 +++++++++----------- modules/assistant/copilot/copilot.nix | 75 +++++++++++++++------------ 2 files changed, 65 insertions(+), 66 deletions(-) diff --git a/modules/assistant/copilot/config.nix b/modules/assistant/copilot/config.nix index 5cfe955..0d3ee28 100644 --- a/modules/assistant/copilot/config.nix +++ b/modules/assistant/copilot/config.nix @@ -4,10 +4,10 @@ ... }: let inherit (builtins) toJSON; + inherit (lib.nvim.lua) toLuaObject; 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; @@ -28,55 +28,47 @@ in { vim.startPlugins = [ "copilot-lua" - cfg.copilotNodePackage + # cfg.copilotNodePackage ] ++ optionals (cfg.cmp.enable) [ "copilot-cmp" ]; vim.luaConfigRC.copilot = entryAnywhere '' - require("copilot").setup({ - -- available options: https://github.com/zbirenbaum/copilot.lua - copilot_node_command = "${cfg.copilotNodeCommand}", - panel = { - enabled = ${boolToString (!cfg.cmp.enable)}, - keymap = { - jump_prev = false, - jump_next = false, - accept = false, - refresh = false, - open = false, - }, - layout = { - position = "${cfg.panel.position}", - ratio = ${toString cfg.panel.ratio}, - }, - }, - suggestion = { - enabled = ${boolToString (!cfg.cmp.enable)}, - keymap = { - accept = false, - accept_word = false, - accept_line = false, - next = false, - prev = false, - dismiss = false, - }, - }, - }) + require("copilot").setup(${toLuaObject cfg.setupOpts}) ${lib.optionalString (cfg.cmp.enable) '' require("copilot_cmp").setup() ''} ''; + # Disable plugin handled keymaps. + # Setting it here so that it doesn't show up in user docs + vim.assistant.copilot.setupOpts = { + panel.keymap = { + jump_prev = lib.mkDefault false; + jump_next = lib.mkDefault false; + accept = lib.mkDefault false; + refresh = lib.mkDefault false; + open = lib.mkDefault false; + }; + suggestion.keymap = { + accept = lib.mkDefault false; + accept_word = lib.mkDefault false; + accept_line = lib.mkDefault false; + next = lib.mkDefault false; + prev = lib.mkDefault false; + dismiss = lib.mkDefault false; + }; + }; + vim.maps.normal = mkMerge [ (mkLuaBinding cfg.mappings.panel.jumpPrev (wrapPanelBinding "require(\"copilot.panel\").jump_prev" cfg.mappings.panel.jumpPrev) "[copilot] Accept suggestion") (mkLuaBinding cfg.mappings.panel.jumpNext (wrapPanelBinding "require(\"copilot.panel\").jump_next" cfg.mappings.panel.jumpNext) "[copilot] Accept suggestion") (mkLuaBinding cfg.mappings.panel.accept (wrapPanelBinding ''require("copilot.panel").accept'' cfg.mappings.panel.accept) "[copilot] Accept suggestion") (mkLuaBinding cfg.mappings.panel.refresh (wrapPanelBinding "require(\"copilot.panel\").refresh" cfg.mappings.panel.refresh) "[copilot] Accept suggestion") (mkLuaBinding cfg.mappings.panel.open (wrapPanelBinding '' - function() require("copilot.panel").open({ position = "${cfg.panel.position}", ratio = ${toString cfg.panel.ratio}, }) end + function() require("copilot.panel").open({ position = "${cfg.setupOpts.panel.layout.position}", ratio = ${toString cfg.setupOpts.panel.layout.ratio}, }) end '' cfg.mappings.panel.open) "[copilot] Accept suggestion") ]; diff --git a/modules/assistant/copilot/copilot.nix b/modules/assistant/copilot/copilot.nix index 283a0b6..c8aba32 100644 --- a/modules/assistant/copilot/copilot.nix +++ b/modules/assistant/copilot/copilot.nix @@ -4,31 +4,56 @@ lib, ... }: let + inherit (lib) mkRenamedOptionModule; inherit (lib.options) mkEnableOption mkOption; - inherit (lib.types) enum float nullOr str package; - inherit (lib.meta) getExe; + inherit (lib.types) nullOr str enum float; + inherit (lib.nvim.types) mkPluginSetupOption; cfg = config.vim.assistant.copilot; in { + imports = [ + (mkRenamedOptionModule ["vim" "assistant" "copilot" "panel"] ["vim" "assistant" "copilot" "setupOpts" "panel"]) + (mkRenamedOptionModule ["vim" "assistant" "copilot" "copilotNodeCommand"] ["vim" "assistant" "copilot" "setupOpts" "copilot_node_command"]) + (mkRenamedOptionModule ["vim" "assistant" "copilot" "copilotNodePackage"] ["vim" "assistant" "copilot" "setupOpts" "copilot_node_command"]) + ]; + options.vim.assistant.copilot = { enable = mkEnableOption "GitHub Copilot AI assistant"; cmp.enable = mkEnableOption "nvim-cmp integration for GitHub Copilot"; - panel = { - position = mkOption { - type = enum [ - "bottom" - "top" - "left" - "right" - ]; - default = "bottom"; - description = "Panel position"; + setupOpts = mkPluginSetupOption "Copilot" { + copilot_node_command = mkOption { + type = str; + default = "${lib.getExe pkgs.nodejs-slim}"; + description = '' + The command that will be executed to initiate nodejs for GitHub Copilot. + Recommended to leave as default. + ''; }; - ratio = mkOption { - type = float; - default = 0.4; - description = "Panel size"; + panel = { + enabled = mkEnableOption "Completion Panel" // {default = !cfg.cmp.enable;}; + layout = { + position = mkOption { + type = enum [ + "bottom" + "top" + "left" + "right" + ]; + default = "bottom"; + description = "Panel position"; + }; + ratio = mkOption { + type = float; + default = 0.4; + description = "Panel size"; + }; + }; + }; + + suggestion = { + enabled = mkEnableOption "Suggestions" // {default = !cfg.cmp.enable;}; + # keymap = { }; }; }; @@ -102,23 +127,5 @@ in { }; }; }; - - copilotNodeCommand = mkOption { - type = str; - default = "${getExe cfg.copilotNodePackage}"; - description = '' - The command that will be executed to initiate nodejs for GitHub Copilot. - Recommended to leave as default. - ''; - }; - - copilotNodePackage = mkOption { - 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 - you may want to set this option to null so that the package is not pulled from nixpkgs. - ''; - }; }; } From e5fba518779a127052e188688cd22b75a461e6de Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 17 Feb 2024 16:30:26 +0100 Subject: [PATCH 057/193] feat(obsidian-nvim): custom setup --- modules/notes/obsidian/config.nix | 25 +---------- modules/notes/obsidian/obsidian.nix | 65 +++++++++++++++++++---------- 2 files changed, 44 insertions(+), 46 deletions(-) diff --git a/modules/notes/obsidian/config.nix b/modules/notes/obsidian/config.nix index 818d447..5ba005e 100644 --- a/modules/notes/obsidian/config.nix +++ b/modules/notes/obsidian/config.nix @@ -6,9 +6,9 @@ inherit (lib.modules) mkIf; inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.binds) pushDownDefault; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.notes.obsidian; - auto = config.vim.autocomplete; in { config = mkIf cfg.enable { vim = { @@ -23,28 +23,7 @@ in { }; luaConfigRC.obsidian = entryAnywhere '' - require("obsidian").setup({ - dir = "${cfg.dir}", - completion = { - nvim_cmp = ${ - if (auto.type == "nvim-cmp") - then "true" - else "false" - } - }, - daily_notes = { - folder = ${ - if (cfg.daily-notes.folder == "") - then "nil," - else "'${cfg.daily-notes.folder}'," - } - date_format = ${ - if (cfg.daily-notes.date-format == "") - then "nil," - else "'${cfg.daily-notes.date-format}'," - } - } - }) + require("obsidian").setup(${toLuaObject cfg.setupOpts}) ''; }; }; diff --git a/modules/notes/obsidian/obsidian.nix b/modules/notes/obsidian/obsidian.nix index 1b7bae6..c7152fb 100644 --- a/modules/notes/obsidian/obsidian.nix +++ b/modules/notes/obsidian/obsidian.nix @@ -1,33 +1,52 @@ -{lib, ...}: let - inherit (lib.options) mkEnableOption mkOption; - inherit (lib.types) str bool; +{ + config, + lib, + ... +}: let + inherit (lib) mkEnableOption mkOption types mkRenamedOptionModule; in { + imports = let + renamedSetupOption = oldPath: newPath: + mkRenamedOptionModule + (["vim" "notes" "obsidian"] ++ oldPath) + (["vim" "notes" "obsidian" "setupOpts"] ++ newPath); + in [ + (renamedSetupOption ["dir"] ["dir"]) + (renamedSetupOption ["daily-notes" "folder"] ["daily_notes" "folder"]) + (renamedSetupOption ["daily-notes" "date-format"] ["daily_notes" "date_format"]) + (renamedSetupOption ["completion"] ["completion"]) + ]; options.vim.notes = { obsidian = { enable = mkEnableOption "complementary neovim plugins for Obsidian editor"; - dir = mkOption { - type = str; - default = "~/my-vault"; - description = "Obsidian vault directory"; - }; - daily-notes = { - folder = mkOption { - type = str; - default = ""; - description = "Directory in which daily notes should be created"; + setupOpts = lib.nvim.types.mkPluginSetupOption "Obsidian.nvim" { + dir = mkOption { + type = types.str; + default = "~/my-vault"; + description = "Obsidian vault directory"; }; - date-format = mkOption { - type = str; - default = ""; - description = "Date format used for creating daily notes"; - }; - }; - completion = { - nvim_cmp = mkOption { - type = bool; - description = "If using nvim-cmp, otherwise set to false"; + daily_notes = { + folder = mkOption { + type = types.nullOr types.str; + default = null; + description = "Directory in which daily notes should be created"; + }; + date_format = mkOption { + type = types.nullOr types.str; + default = null; + description = "Date format used for creating daily notes"; + }; + }; + + completion = { + nvim_cmp = mkOption { + # if using nvim-cmp, otherwise set to false + type = types.bool; + description = "If using nvim-cmp, otherwise set to false"; + default = config.vim.autocomplete.type == "nvim-cmp"; + }; }; }; }; From 2feaadc26664ee4e7f10b81a7ad71f0261de8534 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 17 Feb 2024 16:46:16 +0100 Subject: [PATCH 058/193] feat(orgmode): custom setup --- modules/notes/orgmode/config.nix | 6 ++---- modules/notes/orgmode/orgmode.nix | 32 +++++++++++++++++++------------ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/modules/notes/orgmode/config.nix b/modules/notes/orgmode/config.nix index 635f0f1..19be11d 100644 --- a/modules/notes/orgmode/config.nix +++ b/modules/notes/orgmode/config.nix @@ -6,6 +6,7 @@ inherit (lib.modules) mkIf mkMerge; inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.binds) pushDownDefault; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.notes.orgmode; in { @@ -37,10 +38,7 @@ in { }, } - require('orgmode').setup({ - org_agenda_files = ${cfg.orgAgendaFiles}, - org_default_notes_file = '${cfg.orgDefaultNotesFile}', - }) + require('orgmode').setup(${toLuaObject cfg.setupOpts}) ''; }; } diff --git a/modules/notes/orgmode/orgmode.nix b/modules/notes/orgmode/orgmode.nix index 2a06605..1dad458 100644 --- a/modules/notes/orgmode/orgmode.nix +++ b/modules/notes/orgmode/orgmode.nix @@ -4,23 +4,31 @@ pkgs, ... }: let - inherit (lib.options) mkOption mkEnableOption; - inherit (lib.types) str; - inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.modules) mkRenamedOptionModule; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) str listOf; + inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption; in { + imports = [ + (mkRenamedOptionModule ["vim" "notes" "orgmode" "orgAgendaFiles"] ["vim" "notes" "orgmode" "setupOpts" "org_agenda_files"]) + (mkRenamedOptionModule ["vim" "notes" "orgmode" "orgDefaultNotesFile"] ["vim" "notes" "orgmode" "setupOpts" "org_default_notes_file"]) + ]; + options.vim.notes.orgmode = { enable = mkEnableOption "nvim-orgmode: Neovim plugin for Emac Orgmode. Get the best of both worlds"; - orgAgendaFiles = mkOption { - type = str; - default = "{'~/Documents/org/*', '~/my-orgs/**/*'}"; - description = "List of org files to be used as agenda files."; - }; + setupOpts = mkPluginSetupOption "Orgmode" { + org_agenda_files = mkOption { + type = listOf str; + default = ["~/Documents/org/*" "~/my-orgs/**/*"]; + description = "List of org files to be used as agenda files."; + }; - orgDefaultNotesFile = mkOption { - type = str; - default = "~/Documents/org/refile.org"; - description = "Default org file to be used for notes."; + org_default_notes_file = mkOption { + type = str; + default = "~/Documents/org/refile.org"; + description = "Default org file to be used for notes."; + }; }; treesitter = { From 3f4ef987ddef49f39ba45eae9075b1da2943cef3 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 17 Feb 2024 22:28:12 +0100 Subject: [PATCH 059/193] feat(todo-comments): custom setup --- modules/notes/todo-comments/config.nix | 29 ++-------- modules/notes/todo-comments/todo-comments.nix | 54 ++++++++++++++----- 2 files changed, 45 insertions(+), 38 deletions(-) diff --git a/modules/notes/todo-comments/config.nix b/modules/notes/todo-comments/config.nix index 8db653f..1fa5dde 100644 --- a/modules/notes/todo-comments/config.nix +++ b/modules/notes/todo-comments/config.nix @@ -4,11 +4,11 @@ lib, ... }: let - inherit (lib.modules) mkIf mkMerge; - inherit (lib.nvim.binds) mkBinding; + inherit (lib) mkMerge mkBinding mkIf; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.notes.todo-comments; - self = import ./todo-comments.nix {inherit lib;}; + self = import ./todo-comments.nix {inherit pkgs lib;}; inherit (self.options.vim.notes.todo-comments) mappings; in { config = mkIf cfg.enable { @@ -24,28 +24,7 @@ in { ]; luaConfigRC.todo-comments = '' - require('todo-comments').setup { - highlight = { - before = "", -- "fg" or "bg" or empty - keyword = "bg", -- "fg", "bg", "wide" or empty - after = "fg", -- "fg" or "bg" or empty - pattern = ${cfg.patterns.highlight}, - comments_only = true, -- uses treesitter to match keywords in comments only - max_line_len = 400, -- ignore lines longer than this - exclude = {}, -- list of file types to exclude highlighting - }, - search = { - command = "${pkgs.ripgrep}/bin/rg", - args = { - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - }, - pattern = ${cfg.patterns.search}, - }, - } + require('todo-comments').setup(${toLuaObject cfg.setupOpts}) ''; }; }; diff --git a/modules/notes/todo-comments/todo-comments.nix b/modules/notes/todo-comments/todo-comments.nix index ca4e4be..f92af7a 100644 --- a/modules/notes/todo-comments/todo-comments.nix +++ b/modules/notes/todo-comments/todo-comments.nix @@ -1,22 +1,50 @@ -{lib, ...}: let - inherit (lib.options) mkOption mkEnableOption; - inherit (lib.types) str; - inherit (lib.nvim.binds) mkMappingOption; +{ + pkgs, + lib, + ... +}: let + inherit (lib) mkEnableOption mkOption types mkMappingOption mkRenamedOptionModule; in { + imports = let + renamedSetupOption = oldPath: newPath: + mkRenamedOptionModule + (["vim" "notes" "todo-comments"] ++ oldPath) + (["vim" "notes" "todo-comments" "setupOpts"] ++ newPath); + in [ + (renamedSetupOption ["patterns" "highlight"] ["highlight" "pattern"]) + (renamedSetupOption ["patterns" "search"] ["search" "pattern"]) + ]; + options.vim.notes.todo-comments = { enable = mkEnableOption "todo-comments: highlight and search for todo comments like TODO, HACK, BUG in your code base"; - patterns = { - highlight = mkOption { - type = str; - default = ''[[.*<(KEYWORDS)(\([^\)]*\))?:]]''; - description = "vim regex pattern used for highlighting comments"; + setupOpts = lib.nvim.types.mkPluginSetupOption "todo-comments.nvim" { + highlight = { + pattern = mkOption { + type = types.str; + default = ''.*<(KEYWORDS)(\([^\)]*\))?:''; + description = "vim regex pattern used for highlighting comments"; + }; }; - search = mkOption { - type = str; - default = ''[[\b(KEYWORDS)(\([^\)]*\))?:]]''; - description = "ripgrep regex pattern used for searching comments"; + search = { + pattern = mkOption { + type = types.str; + default = ''\b(KEYWORDS)(\([^\)]*\))?:''; + description = "ripgrep regex pattern used for searching comments"; + }; + + command = mkOption { + type = types.str; + default = "${pkgs.ripgrep}/bin/rg"; + description = "search command"; + }; + + args = mkOption { + type = types.listOf types.str; + default = ["--color=never" "--no-heading" "--with-filename" "--line-number" "--column"]; + description = "arguments to pass to the search command"; + }; }; }; From 4db695055808a3d8fa155ebb6690fac289685e14 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 17 Feb 2024 23:29:58 +0100 Subject: [PATCH 060/193] feat(project-nvim): custom setup --- modules/projects/project-nvim/config.nix | 41 +------ .../projects/project-nvim/project-nvim.nix | 111 +++++++++++------- 2 files changed, 69 insertions(+), 83 deletions(-) diff --git a/modules/projects/project-nvim/config.nix b/modules/projects/project-nvim/config.nix index 5c036ef..435476d 100644 --- a/modules/projects/project-nvim/config.nix +++ b/modules/projects/project-nvim/config.nix @@ -3,10 +3,7 @@ lib, ... }: let - inherit (lib.modules) mkIf; - inherit (lib.trivial) boolToString; - inherit (lib.strings) concatStringsSep; - inherit (lib.nvim.dag) entryAnywhere; + inherit (lib) mkIf nvim; cfg = config.vim.projects.project-nvim; in { @@ -15,40 +12,8 @@ in { "project-nvim" ]; - vim.luaConfigRC.project-nvim = entryAnywhere '' - require('project_nvim').setup({ - manual_mode = ${boolToString cfg.manualMode}, - detection_methods = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.detectionMethods)} }, - - -- All the patterns used to detect root dir, when **"pattern"** is in - -- detection_methods - patterns = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.patterns)} }, - - -- Table of lsp clients to ignore by name - -- eg: { "efm", ... } - ignore_lsp = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.lspIgnored)} }, - - -- Don't calculate root dir on specific directories - -- Ex: { "~/.cargo/*", ... } - exclude_dirs = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.excludeDirs)} }, - - -- Show hidden files in telescope - show_hidden = ${boolToString cfg.showHidden}, - - -- When set to false, you will get a message when project.nvim changes your - -- directory. - silent_chdir = ${boolToString cfg.silentChdir}, - - -- What scope to change the directory, valid options are - -- * global (default) - -- * tab - -- * win - scope_chdir = '${toString cfg.scopeChdir}', - - -- Path where project.nvim will store the project history for use in - -- telescope - datapath = vim.fn.stdpath("data"), - }) + vim.luaConfigRC.project-nvim = nvim.dag.entryAnywhere '' + require('project_nvim').setup(${nvim.lua.toLuaObject cfg.setupOpts}) ''; }; } diff --git a/modules/projects/project-nvim/project-nvim.nix b/modules/projects/project-nvim/project-nvim.nix index 9331f37..234e4f0 100644 --- a/modules/projects/project-nvim/project-nvim.nix +++ b/modules/projects/project-nvim/project-nvim.nix @@ -1,59 +1,80 @@ -{lib, ...}: let - inherit (lib.options) mkEnableOption mkOption; - inherit (lib.types) enum bool listOf str; +{ + config, + lib, + ... +}: let + inherit (lib) mkEnableOption mkOption types mkRenamedOptionModule; in { + imports = let + renamedSetupOption = oldPath: newPath: + mkRenamedOptionModule + (["vim" "projects" "project-nvim"] ++ oldPath) + (["vim" "projects" "project-nvim" "setupOpts"] ++ newPath); + in [ + (renamedSetupOption ["manualMode"] ["manual_mode"]) + (renamedSetupOption ["detectionMethods"] ["detection_methods"]) + (renamedSetupOption ["patterns"] ["patterns"]) + (renamedSetupOption ["lspIgnored"] ["lsp_ignored"]) + (renamedSetupOption ["excludeDirs"] ["exclude_dirs"]) + (renamedSetupOption ["showHidden"] ["show_hidden"]) + (renamedSetupOption ["silentChdir"] ["silent_chdir"]) + (renamedSetupOption ["scopeChdir"] ["scope_chdir"]) + ]; + options.vim.projects.project-nvim = { enable = mkEnableOption "project-nvim for project management"; - manualMode = mkOption { - type = bool; - default = true; - description = "don't automatically change the root directory so the user has the option to manually do so using `:ProjectRoot` command"; - }; + setupOpts = lib.nvim.types.mkPluginSetupOption "Project.nvim" { + manual_mode = mkOption { + type = types.bool; + default = true; + description = "don't automatically change the root directory so the user has the option to manually do so using `:ProjectRoot` command"; + }; - # detection methods should accept one or more strings from a list - detectionMethods = mkOption { - type = listOf str; - default = ["lsp" "pattern"]; - description = "Detection methods to use"; - }; + # detection methods should accept one or more strings from a list + detection_methods = mkOption { + type = types.listOf types.str; + default = ["lsp" "pattern"]; + description = "Detection methods to use"; + }; - # patterns - patterns = mkOption { - type = listOf str; - default = [".git" "_darcs" ".hg" ".bzr" ".svn" "Makefile" "package.json" "flake.nix" "cargo.toml"]; - description = "Patterns to use for pattern detection method"; - }; + # patterns + patterns = mkOption { + type = types.listOf types.str; + default = [".git" "_darcs" ".hg" ".bzr" ".svn" "Makefile" "package.json" "flake.nix" "cargo.toml"]; + description = "Patterns to use for pattern detection method"; + }; - # table of lsp servers to ignore by name - lspIgnored = mkOption { - type = listOf str; - default = []; - description = "LSP servers no ignore by name"; - }; + # table of lsp servers to ignore by name + lsp_ignored = mkOption { + type = types.listOf types.str; + default = []; + description = "LSP servers no ignore by name"; + }; - excludeDirs = mkOption { - type = listOf str; - default = []; - description = "Directories to exclude from project root search"; - }; + exclude_dirs = mkOption { + type = types.listOf types.str; + default = []; + description = "Directories to exclude from project root search"; + }; - showHidden = mkOption { - type = bool; - default = false; - description = "Show hidden files in telescope picker"; - }; + show_hidden = mkOption { + type = types.bool; + default = false; + description = "Show hidden files in telescope picker"; + }; - silentChdir = mkOption { - type = bool; - default = true; - description = "Silently change directory when changing project"; - }; + silent_chdir = mkOption { + type = types.bool; + default = true; + description = "Silently change directory when changing project"; + }; - scopeChdir = mkOption { - type = enum ["global" "tab" "win"]; - default = "global"; - description = "What scope to change the directory"; + scope_chdir = mkOption { + type = types.enum ["global" "tab" "win"]; + default = "global"; + description = "What scope to change the directory"; + }; }; }; } From 6fd35972d9bb0e53dadd2d463f8ebe6f4537720f Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 17 Feb 2024 14:13:52 +0100 Subject: [PATCH 061/193] feat(autopairs): custom setup opts --- modules/autopairs/nvim-autopairs/config.nix | 11 +++-------- modules/autopairs/nvim-autopairs/nvim-autopairs.nix | 7 ++++++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/autopairs/nvim-autopairs/config.nix b/modules/autopairs/nvim-autopairs/config.nix index 1502db8..5cd18eb 100644 --- a/modules/autopairs/nvim-autopairs/config.nix +++ b/modules/autopairs/nvim-autopairs/config.nix @@ -4,9 +4,9 @@ ... }: let inherit (lib.modules) mkIf; - inherit (lib.nvim.dag) entryAnywhere; inherit (lib.strings) optionalString; - inherit (lib.trivial) boolToString; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.autopairs; in { @@ -16,12 +16,7 @@ in { 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}, - }) + require('nvim-autopairs.completion.compe').setup(${toLuaObject cfg.setupOpts}) ''} ''; }; diff --git a/modules/autopairs/nvim-autopairs/nvim-autopairs.nix b/modules/autopairs/nvim-autopairs/nvim-autopairs.nix index 940a60c..73b6bed 100644 --- a/modules/autopairs/nvim-autopairs/nvim-autopairs.nix +++ b/modules/autopairs/nvim-autopairs/nvim-autopairs.nix @@ -1,7 +1,12 @@ {lib, ...}: let + inherit (lib) mkRenamedOptionModule; inherit (lib.options) mkEnableOption mkOption; inherit (lib.types) enum bool; in { + imports = [ + # (mkRenamedOptionModule ["vim" "autopairs" "nvim-compe"] ["vim" "autopairs" "nvim-compe" "setupOpts"]) + ]; + options.vim = { autopairs = { enable = mkEnableOption "autopairs" // {default = false;}; @@ -12,7 +17,7 @@ in { description = "Set the autopairs type. Options: nvim-autopairs [nvim-autopairs]"; }; - nvim-compe = { + nvim-compe.setupOpts = lib.nvim.types.mkPluginSetupOption "nvim-compe" { map_cr = mkOption { type = bool; default = true; From 0e802c03ef3a5665065f491efb72688919d3aab5 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 17 Feb 2024 23:47:47 +0100 Subject: [PATCH 062/193] feat(neocord): custom setup --- modules/rich-presence/neocord/config.nix | 31 +---- modules/rich-presence/neocord/neocord.nix | 133 ++++++++++++---------- 2 files changed, 72 insertions(+), 92 deletions(-) diff --git a/modules/rich-presence/neocord/config.nix b/modules/rich-presence/neocord/config.nix index 3856db1..a6dcbb5 100644 --- a/modules/rich-presence/neocord/config.nix +++ b/modules/rich-presence/neocord/config.nix @@ -3,12 +3,9 @@ lib, ... }: let - inherit (builtins) toString; inherit (lib.modules) mkIf; - inherit (lib.trivial) boolToString; - inherit (lib.strings) escapeNixString; - inherit (lib.nvim.lua) listToLuaTable; inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.presence.neocord; in { @@ -17,31 +14,7 @@ in { vim.luaConfigRC.neocord = entryAnywhere '' -- Description of each option can be found in https://github.com/IogaMaster/neocord#lua - require("neocord").setup({ - -- General options - logo = "${cfg.logo}", - logo_tooltip = "${cfg.logo_tooltip}", - main_image = "${cfg.main_image}", - client_id = "${cfg.client_id}", - log_level = ${ - if cfg.log_level == null - then "nil" - else "${escapeNixString cfg.log_level}" - }, - debounce_timeout = ${toString cfg.debounce_timeout}, - blacklist = ${listToLuaTable cfg.blacklist}, - show_time = "${boolToString cfg.show_time}", - - -- Rich Presence text options - editing_text = "${cfg.rich_presence.editing_text}", - file_explorer_text = "${cfg.rich_presence.file_explorer_text}", - git_commit_text = "${cfg.rich_presence.git_commit_text}", - plugin_manager_text = "${cfg.rich_presence.plugin_manager_text}", - reading_text = "${cfg.rich_presence.reading_text}", - workspace_text = "${cfg.rich_presence.workspace_text}", - line_number_text = "${cfg.rich_presence.line_number_text}", - terminal_text = "${cfg.rich_presence.terminal_text}", - }) + require("neocord").setup(${toLuaObject cfg.setupOpts}) ''; }; } diff --git a/modules/rich-presence/neocord/neocord.nix b/modules/rich-presence/neocord/neocord.nix index c962d2d..28f89c7 100644 --- a/modules/rich-presence/neocord/neocord.nix +++ b/modules/rich-presence/neocord/neocord.nix @@ -1,86 +1,93 @@ {lib, ...}: let - inherit (lib.modules) mkRemovedOptionModule; + inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule; inherit (lib.options) mkEnableOption mkOption literalExpression; inherit (lib.types) bool int str enum nullOr listOf; in { - imports = [ - (mkRemovedOptionModule ["vim" "presence" "presence-nvim"] '' - The option vim.presence.presence-nvim has been deprecated in favor of the new neocord module. - Options provided by the plugin remain mostly the same, but manual migration is required. + imports = + [ + (mkRemovedOptionModule ["vim" "presence" "presence-nvim"] '' + The option vim.presence.presence-nvim has been deprecated in favor of the new neocord module. + Options provided by the plugin remain mostly the same, but manual migration is required. - Please see neocord documentation and the neovim-flake options for more info - '') - ]; + Please see neocord documentation and the neovim-flake options for more info + '') + ] + ++ (map + (optName: mkRenamedOptionModule ["vim" "presence" "neocord" "rich_presence" optName] ["vim" "presence" "neocord" "setupOpts" optName]) + ["debounce_timeout" "blacklist" "show_time" "editing_text" "file_explorer_text" "git_commit_text" "plugin_manager_text" "reading_text" "workspace_text" "line_number_text" "terminal_text"]) + ++ (map + (optName: mkRenamedOptionModule ["vim" "presence" "neocord" optName] ["vim" "presence" "neocord" "setupOpts" optName]) + ["logo" "logo_tooltip" "main_image" "client_id" "log_level" "debounce_timeout" "blacklist" "show_time"]); options.vim.presence.neocord = { enable = mkEnableOption "neocord plugin for discord rich presence"; - logo = mkOption { - type = str; # TODO: can the default be documented better, maybe with an enum? - default = "auto"; - description = '' - Logo to be displayed on the RPC item + setupOpts = lib.nvim.mkPluginSetupOption "neocord" { + logo = mkOption { + type = str; # TODO: can the default be documented better, maybe with an enum? + default = "auto"; + description = '' + Logo to be displayed on the RPC item - This must be either "auto" or an URL to your image of choice - ''; - }; + This must be either "auto" or an URL to your image of choice + ''; + }; - logo_tooltip = mkOption { - type = str; - default = "The One True Text Editor"; - description = "Text displayed when hovering over the Neovim image"; - }; + logo_tooltip = mkOption { + type = str; + default = "The One True Text Editor"; + description = "Text displayed when hovering over the Neovim image"; + }; - main_image = mkOption { - type = enum ["language" "logo"]; - default = "language"; - description = "Main image to be displayed"; - }; + main_image = mkOption { + type = enum ["language" "logo"]; + default = "language"; + description = "Main image to be displayed"; + }; - client_id = mkOption { - type = str; - default = "1157438221865717891"; - description = "Client ID of the application"; - }; + client_id = mkOption { + type = str; + default = "1157438221865717891"; + description = "Client ID of the application"; + }; - log_level = mkOption { - type = nullOr (enum ["debug" "info" "warn" "error"]); - default = null; - description = "Log level to be used by the plugin"; - }; + log_level = mkOption { + type = nullOr (enum ["debug" "info" "warn" "error"]); + default = null; + description = "Log level to be used by the plugin"; + }; - debounce_timeout = mkOption { - type = int; - default = 10; - description = "Number of seconds to debounce events"; - }; + debounce_timeout = mkOption { + type = int; + default = 10; + description = "Number of seconds to debounce events"; + }; - auto_update = mkOption { - type = bool; - default = true; - description = "Automatically update the presence"; - }; + auto_update = mkOption { + type = bool; + default = true; + description = "Automatically update the presence"; + }; - enable_line_number = mkOption { - type = bool; - default = false; - description = "Show line number on the RPC item"; - }; + enable_line_number = mkOption { + type = bool; + default = false; + description = "Show line number on the RPC item"; + }; - show_time = mkOption { - type = bool; - default = true; - description = "Show time on the RPC item"; - }; + show_time = mkOption { + type = bool; + default = true; + description = "Show time on the RPC item"; + }; - blacklist = mkOption { - type = listOf str; - default = []; - example = literalExpression ''["Alpha"]''; - description = "List of filetypes to ignore"; - }; + blacklist = mkOption { + type = listOf str; + default = []; + example = literalExpression ''["Alpha"]''; + description = "List of filetypes to ignore"; + }; - rich_presence = { editing_text = mkOption { type = str; default = "Editing %s"; From 47acf325d649c2f86a250821d0b93d08f926a8dd Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sun, 3 Mar 2024 11:47:58 +0000 Subject: [PATCH 063/193] dev: add custom type rawLua --- lib/types/default.nix | 2 +- lib/types/plugins.nix | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/types/default.nix b/lib/types/default.nix index 59a5181..22b728d 100644 --- a/lib/types/default.nix +++ b/lib/types/default.nix @@ -4,6 +4,6 @@ typesLanguage = import ./languages.nix {inherit lib;}; in { inherit (typesDag) dagOf; - inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption; + inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption rawLua; inherit (typesLanguage) diagnostics mkGrammarOption; } diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index da1d6ba..813108f 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -145,6 +145,18 @@ in { type = pluginsType; }; + rawLua = lib.mkOptionType { + name = "rawLua"; + check = val: isString val || val ? __raw; + merge = loc: defs: let + val = + if isString loc + then {__raw = val;} + else loc; + in + lib.mergeOneOption val defs; + }; + # opts is a attrset of options, example: # ``` # mkPluginSetupOption "telescope" { From 59d5ac0d63c74f1420fa7cb2c0ca17b0fc66dfc1 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sun, 3 Mar 2024 16:48:12 +0000 Subject: [PATCH 064/193] feat(session-manager): custom setup opts --- .../session/nvim-session-manager/config.nix | 35 ++------ .../nvim-session-manager.nix | 86 +++++++++++-------- 2 files changed, 56 insertions(+), 65 deletions(-) diff --git a/modules/session/nvim-session-manager/config.nix b/modules/session/nvim-session-manager/config.nix index 91072f1..729270e 100644 --- a/modules/session/nvim-session-manager/config.nix +++ b/modules/session/nvim-session-manager/config.nix @@ -3,12 +3,8 @@ lib, ... }: let - inherit (lib.modules) mkIf mkMerge; - inherit (lib.lists) optionals; - inherit (lib.strings) concatStringsSep; - inherit (lib.trivial) boolToString; - inherit (lib.nvim.binds) mkBinding; - inherit (lib.nvim.dag) entryAnywhere; + inherit (lib) mkIf optionals mkMerge mkBinding nvim; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.session.nvim-session-manager; in { @@ -19,7 +15,7 @@ in { "nvim-session-manager" "plenary-nvim" ] - ++ optionals (cfg.usePicker) ["dressing-nvim"]; + ++ optionals cfg.usePicker ["dressing-nvim"]; maps.normal = mkMerge [ (mkBinding cfg.mappings.loadSession ":SessionManager load_session" "Load session") @@ -29,31 +25,10 @@ in { # TODO: load_current_dir_session ]; - luaConfigRC.nvim-session-manager = entryAnywhere '' + luaConfigRC.nvim-session-manager = nvim.dag.entryAnywhere '' local Path = require('plenary.path') local sm = require('session_manager.config') - require('session_manager').setup({ - sessions_dir = Path:new(vim.fn.stdpath('data'), 'sessions'), - - path_replacer = '${toString cfg.pathReplacer}', - - colon_replacer = '${toString cfg.colonReplacer}', - - autoload_mode = sm.AutoloadMode.${toString cfg.autoloadMode}, - - autosave_last_session = ${boolToString cfg.autoSave.lastSession}, - - autosave_ignore_not_normal = ${boolToString cfg.autoSave.ignoreNotNormal}, - - autosave_ignore_dirs = {${concatStringsSep ", " (map (x: "\'" + x + "\'") cfg.autoSave.ignoreDirs)}}, - - autosave_ignore_filetypes = {${concatStringsSep ", " (map (x: "\'" + x + "\'") cfg.autoSave.ignoreFiletypes)}}, - - autosave_ignore_buftypes = {${concatStringsSep ", " (map (x: "\'" + x + "\'") cfg.autoSave.ignoreBufTypes)}}, - - autosave_only_in_session = ${boolToString cfg.autoSave.onlyInSession}, - max_path_length = ${toString cfg.maxPathLength}, - }) + require('session_manager').setup(${toLuaObject cfg.setupOpts}) ''; }; }; diff --git a/modules/session/nvim-session-manager/nvim-session-manager.nix b/modules/session/nvim-session-manager/nvim-session-manager.nix index 2182db3..8dce6ce 100644 --- a/modules/session/nvim-session-manager/nvim-session-manager.nix +++ b/modules/session/nvim-session-manager/nvim-session-manager.nix @@ -1,7 +1,23 @@ {lib, ...}: let - inherit (lib.options) mkOption mkEnableOption; - inherit (lib.types) nullOr str bool int listOf enum; + inherit (lib.types) nullOr str bool; + inherit (lib) mkEnableOption mkOption types mkRenamedOptionModule; in { + imports = let + renameSetupOpt = oldPath: newPath: + mkRenamedOptionModule (["vim" "session" "nvim-session-manager"] ++ oldPath) (["vim" "session" "nvim-session-manager" "setupOpts"] ++ newPath); + in [ + (renameSetupOpt ["pathReplacer"] ["path_replacer"]) + (renameSetupOpt ["colonReplacer"] ["colon_replacer"]) + (renameSetupOpt ["autoloadMode"] ["autoload_mode"]) + (renameSetupOpt ["maxPathLength"] ["max_path_length"]) + (renameSetupOpt ["autoSave" "lastSession"] ["autosave_last_session"]) + (renameSetupOpt ["autoSave" "ignoreNotNormal"] ["autosave_ignore_not_normal"]) + (renameSetupOpt ["autoSave" "ignoreDirs"] ["autosave_ignore_dirs"]) + (renameSetupOpt ["autoSave" "ignoreFiletypes"] ["autosave_ignore_filetypes"]) + (renameSetupOpt ["autoSave" "ignoreBufTypes"] ["autosave_ignore_buftypes"]) + (renameSetupOpt ["autoSave" "onlyInSession"] ["autosave_only_in_session"]) + ]; + options.vim.session.nvim-session-manager = { enable = mkEnableOption "nvim-session-manager: manage sessions like folders in VSCode"; @@ -37,63 +53,63 @@ in { description = "Whether or not we should use dressing.nvim to build a session picker UI"; }; - pathReplacer = mkOption { - type = str; - default = "__"; - description = "The character to which the path separator will be replaced for session files"; - }; + setupOpts = { + path_replacer = mkOption { + type = types.str; + default = "__"; + description = "The character to which the path separator will be replaced for session files"; + }; - colonReplacer = mkOption { - type = str; - default = "++"; - description = "The character to which the colon symbol will be replaced for session files"; - }; + colon_replacer = mkOption { + type = types.str; + default = "++"; + description = "The character to which the colon symbol will be replaced for session files"; + }; - autoloadMode = mkOption { - type = enum ["Disabled" "CurrentDir" "LastSession"]; - default = "LastSession"; - description = "Define what to do when Neovim is started without arguments. Possible values: Disabled, CurrentDir, LastSession"; - }; + autoload_mode = mkOption { + type = types.enum ["Disabled" "CurrentDir" "LastSession"]; + default = "LastSession"; + description = "Define what to do when Neovim is started without arguments. Possible values: Disabled, CurrentDir, LastSession"; + }; - maxPathLength = mkOption { - type = nullOr int; - default = 80; - description = "Shorten the display path if length exceeds this threshold. Use 0 if don't want to shorten the path at all"; - }; + max_path_length = mkOption { + type = types.nullOr types.int; + default = 80; + description = "Shorten the display path if length exceeds this threshold. Use 0 if don't want to shorten the path at all"; + }; - autoSave = { - lastSession = mkOption { - type = bool; + autosave_last_session = mkOption { + type = types.bool; default = true; description = "Automatically save last session on exit and on session switch"; }; - ignoreNotNormal = mkOption { - type = bool; + autosave_ignore_not_normal = mkOption { + type = types.bool; default = true; description = "Plugin will not save a session when no buffers are opened, or all of them aren't writable or listed"; }; - ignoreDirs = mkOption { - type = listOf str; + autosave_ignore_dirs = mkOption { + type = types.listOf types.str; default = []; description = "A list of directories where the session will not be autosaved"; }; - ignoreFiletypes = mkOption { - type = listOf str; + autosave_ignore_filetypes = mkOption { + type = types.listOf types.str; default = ["gitcommit"]; description = "All buffers of these file types will be closed before the session is saved"; }; - ignoreBufTypes = mkOption { - type = listOf str; + autosave_ignore_buftypes = mkOption { + type = types.listOf types.str; default = []; description = "All buffers of these bufer types will be closed before the session is saved"; }; - onlyInSession = mkOption { - type = bool; + autosave_only_in_session = mkOption { + type = types.bool; default = false; description = "Always autosaves session. If true, only autosaves after a session is active"; }; From daa10b508bf9bdeeaf58eba415a1cdedd6f37719 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 9 Mar 2024 13:55:44 +0000 Subject: [PATCH 065/193] feat(toggleterm): custom setup opts --- modules/terminal/toggleterm/config.nix | 20 +------- modules/terminal/toggleterm/toggleterm.nix | 59 ++++++++++++++++++---- 2 files changed, 51 insertions(+), 28 deletions(-) diff --git a/modules/terminal/toggleterm/config.nix b/modules/terminal/toggleterm/config.nix index 1ffec58..7f57358 100644 --- a/modules/terminal/toggleterm/config.nix +++ b/modules/terminal/toggleterm/config.nix @@ -9,6 +9,7 @@ inherit (lib.meta) getExe; inherit (lib.nvim.binds) mkBinding; inherit (lib.nvim.dag) entryAnywhere entryAfter; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.terminal.toggleterm; in { @@ -23,24 +24,7 @@ in { maps.normal = mkBinding cfg.mappings.open "execute v:count . \"ToggleTerm\"" "Toggle terminal"; luaConfigRC.toggleterm = entryAnywhere '' - require("toggleterm").setup({ - open_mapping = null, - direction = '${toString cfg.direction}', - -- TODO: this should probably be turned into a module that uses the lua function if and only if the user has not set it - size = function(term) - if term.direction == "horizontal" then - return 15 - elseif term.direction == "vertical" then - return vim.o.columns * 0.4 - end - end, - winbar = { - enabled = '${toString cfg.enable_winbar}', - name_formatter = function(term) -- term: Terminal - return term.name - end - }, - }) + require("toggleterm").setup(${toLuaObject cfg.setupOpts}) ''; }; } diff --git a/modules/terminal/toggleterm/toggleterm.nix b/modules/terminal/toggleterm/toggleterm.nix index dbc8e54..8b3f051 100644 --- a/modules/terminal/toggleterm/toggleterm.nix +++ b/modules/terminal/toggleterm/toggleterm.nix @@ -5,8 +5,15 @@ }: let inherit (lib.options) mkOption mkEnableOption; inherit (lib.nvim.binds) mkMappingOption; - inherit (lib.types) nullOr str enum bool package; + inherit (lib.types) nullOr str enum bool package either int; + inherit (lib) mkRenamedOptionModule; + inherit (lib.nvim.types) mkPluginSetupOption rawLua; in { + imports = [ + (mkRenamedOptionModule ["vim" "terminal" "toggleterm" "direction"] ["vim" "terminal" "toggleterm" "setupOpts" "direction"]) + (mkRenamedOptionModule ["vim" "terminal" "toggleterm" "enable_winbar"] ["vim" "terminal" "toggleterm" "setupOpts" "enable_winbar"]) + ]; + options.vim.terminal.toggleterm = { enable = mkEnableOption "toggleterm as a replacement to built-in terminal command"; mappings = { @@ -17,16 +24,48 @@ in { }; }; - direction = mkOption { - type = enum ["horizontal" "vertical" "tab" "float"]; - default = "horizontal"; - description = "Direction of the terminal"; - }; + setupOpts = mkPluginSetupOption "ToggleTerm" { + direction = mkOption { + type = enum ["horizontal" "vertical" "tab" "float"]; + default = "horizontal"; + description = "Direction of the terminal"; + }; - enable_winbar = mkOption { - type = bool; - default = false; - description = "Enable winbar"; + enable_winbar = mkOption { + type = bool; + default = false; + description = "Enable winbar"; + }; + + size = mkOption { + type = either rawLua int; + description = "Number or lua function which is passed to the current terminal"; + default = { + __raw = '' + function(term) + if term.direction == "horizontal" then + return 15 + elseif term.direction == "vertical" then + return vim.o.columns * 0.4 + end + end + ''; + }; + }; + winbar = { + enabled = mkEnableOption "winbar in terminal" // {default = true;}; + name_formatter = mkOption { + type = rawLua; + description = "Winbar formatter function."; + default = { + __raw = '' + function(term) + return term.name + end + ''; + }; + }; + }; }; lazygit = { From 4b79c50201fa9c8b6c41703890405270ea4e17ef Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sun, 10 Mar 2024 18:37:49 +0000 Subject: [PATCH 066/193] feat(breadcrumbs): custom setup opts --- modules/ui/breadcrumbs/breadcrumbs.nix | 557 +++++++++++++------------ modules/ui/breadcrumbs/config.nix | 177 +++----- 2 files changed, 342 insertions(+), 392 deletions(-) diff --git a/modules/ui/breadcrumbs/breadcrumbs.nix b/modules/ui/breadcrumbs/breadcrumbs.nix index f56223b..f3b1a28 100644 --- a/modules/ui/breadcrumbs/breadcrumbs.nix +++ b/modules/ui/breadcrumbs/breadcrumbs.nix @@ -5,7 +5,28 @@ }: let inherit (lib.options) mkOption mkEnableOption; inherit (lib.types) nullOr listOf enum bool str int; + inherit (lib.modules) mkRenamedOptionModule; + inherit (lib.nvim.types) mkPluginSetupOption; in { + imports = let + renameSetupOpt = oldPath: newPath: + mkRenamedOptionModule + (["vim" "ui" "breadcrumbs" "navbuddy"] ++ oldPath) + (["vim" "ui" "breadcrumbs" "navbuddy" "setupOpts"] ++ newPath); + in [ + (renameSetupOpt ["useDefaultMappings"] ["use_default_mappings"]) + (renameSetupOpt ["window"] ["window"]) + (renameSetupOpt ["nodeMarkers"] ["node_markers"]) + (renameSetupOpt ["lsp" "autoAttach"] ["lsp" "auto_attach"]) + (renameSetupOpt ["lsp" "preference"] ["lsp" "preference"]) + (renameSetupOpt ["sourceBuffer" "followNode"] ["source_buffer" "follow_node"]) + (renameSetupOpt ["sourceBuffer" "highlight"] ["source_buffer" "highlight"]) + (renameSetupOpt ["sourceBuffer" "reorient"] ["source_buffer" "reorient"]) + (renameSetupOpt ["sourceBuffer" "scrolloff"] ["source_buffer" "scrolloff"]) + # TODO: every option under icon is renamed to first letter capitalized + (renameSetupOpt ["icon"] ["icon"]) + ]; + options.vim.ui.breadcrumbs = { enable = mkEnableOption "breadcrumbs"; source = mkOption { @@ -27,13 +48,6 @@ in { navbuddy = { enable = mkEnableOption "navbuddy LSP helper UI. Enabling this option automatically loads and enables nvim-navic"; - # this option is interpreted as null if mkEnableOption is used, and therefore cannot be converted to a string in config.nix - useDefaultMappings = mkOption { - type = bool; - default = true; - description = "use default Navbuddy keybindings (disables user-specified keybinds)"; - }; - mappings = { close = mkOption { type = str; @@ -61,7 +75,7 @@ in { children = mkOption { type = str; - default = "h"; + default = "l"; description = "keybinding to navigate to the child node"; }; @@ -180,301 +194,310 @@ in { }; }; - window = { - # size = {} - # position = {} - - border = mkOption { - # TODO: let this type accept a custom string - type = enum ["single" "rounded" "double" "solid" "none"]; - default = config.vim.ui.borders.globalStyle; - description = "border style to use"; + setupOpts = mkPluginSetupOption "navbuddy" { + useDefaultMappings = mkOption { + type = bool; + default = true; + description = "use default Navbuddy keybindings (disables user-specified keybinds)"; }; - scrolloff = mkOption { - type = nullOr int; - default = null; - description = "Scrolloff value within navbuddy window"; - }; + window = { + # size = {} + # position = {} - sections = { - # left section - left = { - /* - size = { - type = with types; nullOr (intBetween 0 100); - default = null; - description = "size of the left section of Navbuddy UI in percentage (0-100)"; - }; - */ - - border = mkOption { - # TODO: let this type accept a custom string - type = nullOr (enum ["single" "rounded" "double" "solid" "none"]); - default = config.vim.ui.borders.globalStyle; - description = "border style to use for the left section of Navbuddy UI"; - }; + border = mkOption { + # TODO: let this type accept a custom string + type = enum ["single" "rounded" "double" "solid" "none"]; + default = config.vim.ui.borders.globalStyle; + description = "border style to use"; }; - # middle section - mid = { - /* - size = { - type = with types; nullOr (intBetween 0 100); - default = null; - description = "size of the left section of Navbuddy UI in percentage (0-100)"; - }; - */ - - border = mkOption { - # TODO: let this type accept a custom string - type = nullOr (enum ["single" "rounded" "double" "solid" "none"]); - default = config.vim.ui.borders.globalStyle; - description = "border style to use for the middle section of Navbuddy UI"; - }; + scrolloff = mkOption { + type = nullOr int; + default = null; + description = "Scrolloff value within navbuddy window"; }; - # right section - # there is no size option for the right section, it fills the remaining space - right = { - border = mkOption { - # TODO: let this type accept a custom string - type = nullOr (enum ["single" "rounded" "double" "solid" "none"]); - default = config.vim.ui.borders.globalStyle; - description = "border style to use for the right section of Navbuddy UI"; + sections = { + # left section + left = { + /* + size = mkOption { + type = nullOr (intBetween 0 100); + default = null; + description = "size of the left section of Navbuddy UI in percentage (0-100)"; + }; + */ + + border = mkOption { + # TODO: let this type accept a custom string + type = nullOr (enum ["single" "rounded" "double" "solid" "none"]); + default = config.vim.ui.borders.globalStyle; + description = "border style to use for the left section of Navbuddy UI"; + }; }; - preview = mkOption { - type = enum ["leaf" "always" "never"]; - default = "leaf"; - description = "display mode of the preview on the right section"; + # middle section + mid = { + /* + size = { + type = nullOr (intBetween 0 100); + default = null; + description = "size of the left section of Navbuddy UI in percentage (0-100)"; + }; + */ + + border = mkOption { + # TODO: let this type accept a custom string + type = nullOr (enum ["single" "rounded" "double" "solid" "none"]); + default = config.vim.ui.borders.globalStyle; + description = "border style to use for the middle section of Navbuddy UI"; + }; + }; + + # right section + # there is no size option for the right section, it fills the remaining space + right = { + border = mkOption { + # TODO: let this type accept a custom string + type = nullOr (enum ["single" "rounded" "double" "solid" "none"]); + default = config.vim.ui.borders.globalStyle; + description = "border style to use for the right section of Navbuddy UI"; + }; + + preview = mkOption { + type = enum ["leaf" "always" "never"]; + default = "leaf"; + description = "display mode of the preview on the right section"; + }; }; }; }; - }; - nodeMarkers = { - enable = mkEnableOption "node markers"; + node_markers = { + enable = mkEnableOption "node markers"; + icons = { + leaf = mkOption { + type = str; + default = " "; + description = ""; + }; + + leaf_selected = mkOption { + type = str; + default = " → "; + description = ""; + }; + + branch = mkOption { + type = str; + default = " "; + description = ""; + }; + }; + }; + + lsp = { + auto_attach = mkOption { + type = bool; + default = true; + description = "Whether to attach to LSP server manually"; + }; + + preference = mkOption { + type = nullOr (listOf str); + default = null; + description = "list of lsp server names in order of preference"; + }; + }; + + source_buffer = { + followNode = mkOption { + type = bool; + default = true; + description = "keep the current node in focus on the source buffer"; + }; + + highlight = mkOption { + type = bool; + default = true; + description = "highlight the currently focused node"; + }; + + reorient = mkOption { + type = enum ["smart" "top" "mid" "none"]; + default = "smart"; + description = "reorient buffer after changing nodes"; + }; + + scrolloff = mkOption { + type = nullOr int; + default = null; + description = "scrolloff value when navbuddy is open"; + }; + }; + icons = { - leaf = mkOption { + File = mkOption { type = str; - default = " "; + default = "󰈙 "; description = ""; }; - leafSelected = mkOption { + Module = mkOption { type = str; - default = " → "; + default = " "; description = ""; }; - branch = mkOption { + Namespace = mkOption { type = str; - default = " "; + default = "󰌗 "; description = ""; }; - }; - }; - lsp = { - autoAttach = mkOption { - type = bool; - default = true; - description = "Whether to attach to LSP server manually"; - }; + Package = mkOption { + type = str; + default = " "; + description = ""; + }; - preference = mkOption { - type = nullOr (listOf str); - default = null; - description = "list of lsp server names in order of preference"; - }; - }; + Class = mkOption { + type = str; + default = "󰌗 "; + description = ""; + }; - sourceBuffer = { - followNode = mkOption { - type = bool; - default = true; - description = "keep the current node in focus on the source buffer"; - }; + Property = mkOption { + type = str; + default = " "; + description = ""; + }; - highlight = mkOption { - type = bool; - default = true; - description = "highlight the currently focused node"; - }; + Field = mkOption { + type = str; + default = " "; + description = ""; + }; - reorient = mkOption { - type = enum ["smart" "top" "mid" "none"]; - default = "smart"; - description = "reorient buffer after changing nodes"; - }; + Constructor = mkOption { + type = str; + default = " "; + description = ""; + }; - scrolloff = mkOption { - type = nullOr int; - default = null; - description = "scrolloff value when navbuddy is open"; + Enum = mkOption { + type = str; + default = "󰕘"; + description = ""; + }; + + Interface = mkOption { + type = str; + default = "󰕘"; + description = ""; + }; + + Function = mkOption { + type = str; + default = "󰊕 "; + description = ""; + }; + + Variable = mkOption { + type = str; + default = "󰆧 "; + description = ""; + }; + + Constant = mkOption { + type = str; + default = "󰏿 "; + description = ""; + }; + + String = mkOption { + type = str; + default = " "; + description = ""; + }; + + Number = mkOption { + type = str; + default = "󰎠 "; + description = ""; + }; + + Boolean = mkOption { + type = str; + default = "◩ "; + description = ""; + }; + + Array = mkOption { + type = str; + default = "󰅪 "; + description = ""; + }; + + Object = mkOption { + type = str; + default = "󰅩 "; + description = ""; + }; + + Method = mkOption { + type = str; + default = "󰆧 "; + description = ""; + }; + + Key = mkOption { + type = str; + default = "󰌋 "; + description = ""; + }; + + Null = mkOption { + type = str; + default = "󰟢 "; + description = ""; + }; + + EnumMember = mkOption { + type = str; + default = "󰕘 "; + description = ""; + }; + + Struct = mkOption { + type = str; + default = "󰌗 "; + description = ""; + }; + + Event = mkOption { + type = str; + default = " "; + description = ""; + }; + + Operator = mkOption { + type = str; + default = "󰆕 "; + description = ""; + }; + + TypeParameter = mkOption { + type = str; + default = "󰊄 "; + description = ""; + }; }; }; # there probably is a better way to do this # alas, I am not a nix wizard - icons = { - file = mkOption { - type = str; - default = "󰈙 "; - description = "File icon"; - }; - - module = mkOption { - type = str; - default = " "; - description = "Module icon"; - }; - - namespace = mkOption { - type = str; - default = "󰌗 "; - description = "Namespace icon"; - }; - - package = mkOption { - type = str; - default = " "; - description = ""; - }; - - class = mkOption { - type = str; - default = "󰌗 "; - description = "Class icon"; - }; - - property = mkOption { - type = str; - default = " "; - description = ""; - }; - - field = mkOption { - type = str; - default = " "; - description = "Field icon"; - }; - - constructor = mkOption { - type = str; - default = " "; - description = "Constructor icon"; - }; - - enum = mkOption { - type = str; - default = "󰕘"; - description = "Enum icon"; - }; - - interface = mkOption { - type = str; - default = "󰕘"; - description = "Interface icon"; - }; - - function = mkOption { - type = str; - default = "󰊕 "; - description = "Function icon"; - }; - - variable = mkOption { - type = str; - default = "󰆧 "; - description = ""; - }; - - constant = mkOption { - type = str; - default = "󰏿 "; - description = "Constant icon"; - }; - - string = mkOption { - type = str; - default = " "; - description = ""; - }; - - number = mkOption { - type = str; - default = "󰎠 "; - description = "Number icon"; - }; - - boolean = mkOption { - type = str; - default = "◩ "; - description = ""; - }; - - array = mkOption { - type = str; - default = "󰅪 "; - description = "Array icon"; - }; - - object = mkOption { - type = str; - default = "󰅩 "; - description = "Object icon"; - }; - - method = mkOption { - type = str; - default = "󰆧 "; - description = "Method icon"; - }; - - key = mkOption { - type = str; - default = "󰌋 "; - description = "Key icon"; - }; - - null = mkOption { - type = str; - default = "󰟢 "; - description = "Null icon"; - }; - - enumMember = mkOption { - type = str; - default = "󰕘 "; - description = "Enum member icon"; - }; - - struct = mkOption { - type = str; - default = "󰌗 "; - description = "Struct icon"; - }; - - event = mkOption { - type = str; - default = " "; - description = "Event icon"; - }; - - operator = mkOption { - type = str; - default = "󰆕 "; - description = "Operator icon"; - }; - - typeParameter = mkOption { - type = str; - default = "󰊄 "; - description = "Type parameter icon"; - }; - }; }; }; } diff --git a/modules/ui/breadcrumbs/config.nix b/modules/ui/breadcrumbs/config.nix index 3dc3713..88ddddf 100644 --- a/modules/ui/breadcrumbs/config.nix +++ b/modules/ui/breadcrumbs/config.nix @@ -4,14 +4,13 @@ ... }: let inherit (lib.strings) optionalString; - inherit (lib.trivial) boolToString; inherit (lib.modules) mkIf; inherit (lib.lists) optionals; - inherit (lib.nvim.lua) nullString; inherit (lib.nvim.dag) entryAfter; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.ui.breadcrumbs; - nbcfg = cfg.navbuddy; + mkRawLua = code: {__raw = code;}; in { config = mkIf cfg.enable { vim.startPlugins = @@ -30,6 +29,55 @@ in { "nvim-navic" ]; + vim.ui.breadcrumbs.navbuddy.setupOpts = { + mappings = { + ${cfg.navbuddy.mappings.close} = mkRawLua "actions.close()"; + ${cfg.navbuddy.mappings.nextSibling} = mkRawLua "actions.next_sibling()"; + ${cfg.navbuddy.mappings.previousSibling} = mkRawLua "actions.previous_sibling()"; + ${cfg.navbuddy.mappings.parent} = mkRawLua "actions.parent()"; + ${cfg.navbuddy.mappings.children} = mkRawLua "actions.children()"; + ${cfg.navbuddy.mappings.root} = mkRawLua "actions.root()"; + + ${cfg.navbuddy.mappings.visualName} = mkRawLua "actions.visual_name()"; + ${cfg.navbuddy.mappings.visualScope} = mkRawLua "actions.visual_scope()"; + + ${cfg.navbuddy.mappings.yankName} = mkRawLua "actions.yank_name()"; + ${cfg.navbuddy.mappings.yankScope} = mkRawLua "actions.yank_scope()"; + + ${cfg.navbuddy.mappings.insertName} = mkRawLua "actions.insert_name()"; + ${cfg.navbuddy.mappings.insertScope} = mkRawLua "actions.insert_scope()"; + + ${cfg.navbuddy.mappings.appendName} = mkRawLua "actions.append_name()"; + ${cfg.navbuddy.mappings.appendScope} = mkRawLua "actions.append_scope()"; + + ${cfg.navbuddy.mappings.rename} = mkRawLua "actions.rename()"; + + ${cfg.navbuddy.mappings.delete} = mkRawLua "actions.delete()"; + + ${cfg.navbuddy.mappings.foldCreate} = mkRawLua "actions.fold_create()"; + ${cfg.navbuddy.mappings.foldDelete} = mkRawLua "actions.fold_delete()"; + + ${cfg.navbuddy.mappings.comment} = mkRawLua "actions.comment()"; + + ${cfg.navbuddy.mappings.select} = mkRawLua "actions.select()"; + + ${cfg.navbuddy.mappings.moveDown} = mkRawLua "actions.move_down()"; + ${cfg.navbuddy.mappings.moveUp} = mkRawLua "actions.move_up()"; + + ${cfg.navbuddy.mappings.telescope} = mkRawLua '' + actions.telescope({ + layout_strategy = "horizontal", + layout_config = { + height = 0.60, + width = 0.75, + prompt_position = "top", + preview_width = 0.50 + }, + })''; + ${cfg.navbuddy.mappings.help} = mkRawLua "actions.help()"; + }; + }; + vim.luaConfigRC.breadcrumbs = entryAfter ["lspconfig"] '' ${optionalString (cfg.source == "nvim-navic") '' @@ -42,128 +90,7 @@ in { ${optionalString cfg.navbuddy.enable '' local navbuddy = require("nvim-navbuddy") local actions = require("nvim-navbuddy.actions") - navbuddy.setup { - window = { - border = "${nbcfg.window.border}", -- "rounded", "double", "solid", "none" - size = "60%", - position = "50%", - scrolloff = ${(nullString nbcfg.window.scrolloff)}, - sections = { - left = { - size = "20%", - border = ${(nullString nbcfg.window.sections.left.border)}, - }, - - mid = { - size = "40%", - border = ${(nullString nbcfg.window.sections.mid.border)}, - }, - - right = { - border = ${(nullString nbcfg.window.sections.right.border)}, - preview = "leaf", - } - }, - }, - node_markers = { - enabled = ${boolToString nbcfg.nodeMarkers.enable}, - icons = { - leaf = "${nbcfg.nodeMarkers.icons.leaf}", - leaf_selected = "${nbcfg.nodeMarkers.icons.leafSelected}", - branch = "${nbcfg.nodeMarkers.icons.branch}", - }, - }, - - lsp = { - auto_attach = ${boolToString nbcfg.lsp.autoAttach}, - -- preference = nil, -- TODO: convert list to lua table if not null - }, - - source_buffer = { - follow_node = ${boolToString nbcfg.sourceBuffer.followNode}, - highlight = ${boolToString nbcfg.sourceBuffer.highlight}, - reorient = "${nbcfg.sourceBuffer.reorient}", - scrolloff = ${nullString nbcfg.sourceBuffer.scrolloff} - }, - - icons = { - File = "${cfg.navbuddy.icons.file}", - Module = "${cfg.navbuddy.icons.module}", - Namespace = "${cfg.navbuddy.icons.namespace}", - Package = "${cfg.navbuddy.icons.package}", - Class = "${cfg.navbuddy.icons.class}", - Method = "${cfg.navbuddy.icons.method}", - Property = "${cfg.navbuddy.icons.property}", - Field = "${cfg.navbuddy.icons.field}", - Constructor = "${cfg.navbuddy.icons.constructor}", - Enum = "${cfg.navbuddy.icons.enum}", - Interface = "${cfg.navbuddy.icons.interface}", - Function = "${cfg.navbuddy.icons.function}", - Variable = "${cfg.navbuddy.icons.variable}", - Constant = "${cfg.navbuddy.icons.constant}", - String = "${cfg.navbuddy.icons.string}", - Number = "${cfg.navbuddy.icons.number}", - Boolean = "${cfg.navbuddy.icons.boolean}", - Array = "${cfg.navbuddy.icons.array}", - Object = "${cfg.navbuddy.icons.object}", - Key = "${cfg.navbuddy.icons.key}", - Null = "${cfg.navbuddy.icons.null}", - EnumMember = "${cfg.navbuddy.icons.enumMember}", - Struct = "${cfg.navbuddy.icons.struct}", - Event = "${cfg.navbuddy.icons.event}", - Operator = "${cfg.navbuddy.icons.operator}", - TypeParameter = "${cfg.navbuddy.icons.typeParameter}" - }, - - -- make those configurable - use_default_mappings = ${boolToString cfg.navbuddy.useDefaultMappings}, - mappings = { - ["${cfg.navbuddy.mappings.close}"] = actions.close(), - ["${cfg.navbuddy.mappings.nextSibling}"] = actions.next_sibling(), - ["${cfg.navbuddy.mappings.previousSibling}"] = actions.previous_sibling(), - ["${cfg.navbuddy.mappings.close}"] = actions.parent(), - ["${cfg.navbuddy.mappings.children}"] = actions.children(), - ["${cfg.navbuddy.mappings.root}"] = actions.root(), - - ["${cfg.navbuddy.mappings.visualName}"] = actions.visual_name(), - ["${cfg.navbuddy.mappings.visualScope}"] = actions.visual_scope(), - - ["${cfg.navbuddy.mappings.yankName}"] = actions.yank_name(), - ["${cfg.navbuddy.mappings.yankScope}"] = actions.yank_scope(), - - ["${cfg.navbuddy.mappings.insertName}"] = actions.insert_name(), - ["${cfg.navbuddy.mappings.insertScope}"] = actions.insert_scope(), - - ["${cfg.navbuddy.mappings.appendName}"] = actions.append_name(), - ["${cfg.navbuddy.mappings.appendScope}"] = actions.append_scope(), - - ["${cfg.navbuddy.mappings.rename}"] = actions.rename(), - - ["${cfg.navbuddy.mappings.delete}"] = actions.delete(), - - ["${cfg.navbuddy.mappings.foldCreate}"] = actions.fold_create(), - ["${cfg.navbuddy.mappings.foldDelete}"] = actions.fold_delete(), - - ["${cfg.navbuddy.mappings.comment}"] = actions.comment(), - - ["${cfg.navbuddy.mappings.select}"] = actions.select(), - - ["${cfg.navbuddy.mappings.moveDown}"] = actions.move_down(), - ["${cfg.navbuddy.mappings.moveUp}"] = actions.move_up(), - - ["${cfg.navbuddy.mappings.telescope}"] = actions.telescope({ - layout_strategy = "horizontal", - layout_config = { - height = 0.60, - width = 0.75, - prompt_position = "top", - preview_width = 0.50 - }, - }), - - ["${cfg.navbuddy.mappings.help}"] = actions.help(), -- Open mappings help window - }, - } + navbuddy.setup ${toLuaObject cfg.navbuddy.setupOpts} ''} ''; }; From 7e16923952161f26f5cf79249f7127f95e1d6d4a Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sun, 10 Mar 2024 18:40:33 +0000 Subject: [PATCH 067/193] refactor: reduce duplicate code --- modules/ui/breadcrumbs/breadcrumbs.nix | 210 +++++-------------------- 1 file changed, 35 insertions(+), 175 deletions(-) diff --git a/modules/ui/breadcrumbs/breadcrumbs.nix b/modules/ui/breadcrumbs/breadcrumbs.nix index f3b1a28..18df8c0 100644 --- a/modules/ui/breadcrumbs/breadcrumbs.nix +++ b/modules/ui/breadcrumbs/breadcrumbs.nix @@ -7,6 +7,12 @@ inherit (lib.types) nullOr listOf enum bool str int; inherit (lib.modules) mkRenamedOptionModule; inherit (lib.nvim.types) mkPluginSetupOption; + mkSimpleIconOption = default: + mkOption { + inherit default; + type = str; + description = ""; + }; in { imports = let renameSetupOpt = oldPath: newPath: @@ -277,23 +283,9 @@ in { node_markers = { enable = mkEnableOption "node markers"; icons = { - leaf = mkOption { - type = str; - default = " "; - description = ""; - }; - - leaf_selected = mkOption { - type = str; - default = " → "; - description = ""; - }; - - branch = mkOption { - type = str; - default = " "; - description = ""; - }; + leaf = mkSimpleIconOption " "; + leaf_selected = mkSimpleIconOption " → "; + branch = mkSimpleIconOption " "; }; }; @@ -338,166 +330,34 @@ in { }; icons = { - File = mkOption { - type = str; - default = "󰈙 "; - description = ""; - }; - - Module = mkOption { - type = str; - default = " "; - description = ""; - }; - - Namespace = mkOption { - type = str; - default = "󰌗 "; - description = ""; - }; - - Package = mkOption { - type = str; - default = " "; - description = ""; - }; - - Class = mkOption { - type = str; - default = "󰌗 "; - description = ""; - }; - - Property = mkOption { - type = str; - default = " "; - description = ""; - }; - - Field = mkOption { - type = str; - default = " "; - description = ""; - }; - - Constructor = mkOption { - type = str; - default = " "; - description = ""; - }; - - Enum = mkOption { - type = str; - default = "󰕘"; - description = ""; - }; - - Interface = mkOption { - type = str; - default = "󰕘"; - description = ""; - }; - - Function = mkOption { - type = str; - default = "󰊕 "; - description = ""; - }; - - Variable = mkOption { - type = str; - default = "󰆧 "; - description = ""; - }; - - Constant = mkOption { - type = str; - default = "󰏿 "; - description = ""; - }; - - String = mkOption { - type = str; - default = " "; - description = ""; - }; - - Number = mkOption { - type = str; - default = "󰎠 "; - description = ""; - }; - - Boolean = mkOption { - type = str; - default = "◩ "; - description = ""; - }; - - Array = mkOption { - type = str; - default = "󰅪 "; - description = ""; - }; - - Object = mkOption { - type = str; - default = "󰅩 "; - description = ""; - }; - - Method = mkOption { - type = str; - default = "󰆧 "; - description = ""; - }; - - Key = mkOption { - type = str; - default = "󰌋 "; - description = ""; - }; - - Null = mkOption { - type = str; - default = "󰟢 "; - description = ""; - }; - - EnumMember = mkOption { - type = str; - default = "󰕘 "; - description = ""; - }; - - Struct = mkOption { - type = str; - default = "󰌗 "; - description = ""; - }; - - Event = mkOption { - type = str; - default = " "; - description = ""; - }; - - Operator = mkOption { - type = str; - default = "󰆕 "; - description = ""; - }; - - TypeParameter = mkOption { - type = str; - default = "󰊄 "; - description = ""; - }; + File = mkSimpleIconOption "󰈙 "; + Module = mkSimpleIconOption " "; + Namespace = mkSimpleIconOption "󰌗 "; + Package = mkSimpleIconOption " "; + Class = mkSimpleIconOption "󰌗 "; + Property = mkSimpleIconOption " "; + Field = mkSimpleIconOption " "; + Constructor = mkSimpleIconOption " "; + Enum = mkSimpleIconOption "󰕘"; + Interface = mkSimpleIconOption "󰕘"; + Function = mkSimpleIconOption "󰊕 "; + Variable = mkSimpleIconOption "󰆧 "; + Constant = mkSimpleIconOption "󰏿 "; + String = mkSimpleIconOption " "; + Number = mkSimpleIconOption "󰎠 "; + Boolean = mkSimpleIconOption "◩ "; + Array = mkSimpleIconOption "󰅪 "; + Object = mkSimpleIconOption "󰅩 "; + Method = mkSimpleIconOption "󰆧 "; + Key = mkSimpleIconOption "󰌋 "; + Null = mkSimpleIconOption "󰟢 "; + EnumMember = mkSimpleIconOption "󰕘 "; + Struct = mkSimpleIconOption "󰌗 "; + Event = mkSimpleIconOption " "; + Operator = mkSimpleIconOption "󰆕 "; + TypeParameter = mkSimpleIconOption "󰊄 "; }; }; - - # there probably is a better way to do this - # alas, I am not a nix wizard }; }; } From 5387ca2b5a13d728cf1a2fdfad2a62af5d8ea948 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sun, 10 Mar 2024 18:45:26 +0000 Subject: [PATCH 068/193] feat(colorizer): custom setup opts --- modules/ui/colorizer/colorizer.nix | 138 ++++++++++++++++++----------- modules/ui/colorizer/config.nix | 21 +---- 2 files changed, 89 insertions(+), 70 deletions(-) diff --git a/modules/ui/colorizer/colorizer.nix b/modules/ui/colorizer/colorizer.nix index de3281c..364abb9 100644 --- a/modules/ui/colorizer/colorizer.nix +++ b/modules/ui/colorizer/colorizer.nix @@ -1,68 +1,104 @@ -{lib, ...}: let +{ + config, + lib, + ... +}: let inherit (lib.options) mkOption mkEnableOption; inherit (lib.types) attrsOf attrs bool enum; + inherit (lib.modules) mkRenamedOptionModule; + inherit (lib.nvim.types) mkPluginSetupOption; in { + imports = [ + (mkRenamedOptionModule ["vim" "ui" "colorizer" "options"] ["vim" "ui" "colorizer" "setupOpts" "user_default_options"]) + (mkRenamedOptionModule ["vim" "ui" "colorizer" "filetypes"] ["vim" "ui" "colorizer" "setupOpts" "filetypes"]) + ]; + options.vim.ui.colorizer = { enable = mkEnableOption "color highlighting [nvim-colorizer.lua]"; - filetypes = mkOption { - type = attrsOf attrs; - default = { - css = {}; - scss = {}; - }; - description = "Filetypes to highlight on"; - }; - - options = { - alwaysUpdate = mkEnableOption "updating color values even if buffer is not focused, like when using cmp_menu, cmp_docs"; - - rgb = mkOption { - type = bool; - default = true; - description = "#RGB hex codes"; + setupOpts = mkPluginSetupOption "nvim-colorizer" { + filetypes = mkOption { + type = attrsOf attrs; + default = { + css = {}; + scss = {}; + }; + description = "Filetypes to highlight on"; }; - rrggbb = mkOption { - type = bool; - default = true; - description = "#RRGGBB hex codes"; - }; + user_default_options = { + rgb = mkOption { + type = bool; + default = true; + description = "#RGB hex codes"; + }; - names = mkOption { - type = bool; - default = true; - description = ''"Name" codes such as "Blue"''; - }; + rrggbb = mkOption { + type = bool; + default = true; + description = "#RRGGBB hex codes"; + }; - rgb_fn = mkOption { - type = bool; - default = false; - description = "CSS rgb() and rgba() functions"; - }; + names = mkOption { + type = bool; + default = true; + description = ''"Name" codes such as "Blue"''; + }; - rrggbbaa = mkOption { - type = bool; - default = false; - description = "#RRGGBBAA hex codes"; - }; + rgb_fn = mkOption { + type = bool; + default = false; + description = "CSS rgb() and rgba() functions"; + }; - hsl_fn = mkOption { - type = bool; - default = false; - description = "CSS hsl() and hsla() functions"; - }; + rrggbbaa = mkOption { + type = bool; + default = false; + description = "#RRGGBBAA hex codes"; + }; - mode = mkOption { - type = enum ["foreground" "background"]; - default = "background"; - description = "Set the display mode"; - }; + hsl_fn = mkOption { + type = bool; + default = false; + description = "CSS hsl() and hsla() functions"; + }; - tailwind = mkEnableOption "tailwind colors"; - sass = mkEnableOption "sass colors"; - css = mkEnableOption "all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB"; - css_fn = mkEnableOption "all CSS *functions*: rgb_fn, hsl_fn"; + css = mkOption { + type = bool; + default = false; + description = "Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB"; + }; + + css_fn = mkOption { + type = bool; + default = false; + description = "Enable all CSS *functions*: rgb_fn, hsl_fn"; + }; + + mode = mkOption { + type = enum ["foreground" "background"]; + default = "background"; + description = "Set the display mode"; + }; + + tailwind = mkOption { + type = bool; + default = false; + description = "Enable tailwind colors"; + }; + + sass = mkOption { + type = bool; + default = false; + description = "Enable sass colors"; + }; + + alwaysUpdate = mkOption { + type = bool; + default = false; + description = "Update color values even if buffer is not focused, like when using cmp_menu, cmp_docs"; + }; + }; }; }; } diff --git a/modules/ui/colorizer/config.nix b/modules/ui/colorizer/config.nix index a21644f..1ff45f6 100644 --- a/modules/ui/colorizer/config.nix +++ b/modules/ui/colorizer/config.nix @@ -4,9 +4,8 @@ ... }: let inherit (lib.modules) mkIf; - inherit (lib.trivial) boolToString; - inherit (lib.nvim.lua) attrsetToLuaTable; inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.ui.colorizer; in { @@ -16,23 +15,7 @@ in { ]; vim.luaConfigRC.colorizer = entryAnywhere '' - require('colorizer').setup({ - filetypes = ${attrsetToLuaTable cfg.filetypes}, - user_default_options = { - RGB = ${boolToString cfg.options.rgb}; - RRGGBB = ${boolToString cfg.options.rrggbb}; - RRGGBBAA = ${boolToString cfg.options.rrggbbaa}; - names = ${boolToString cfg.options.names}; - rgb_fn = ${boolToString cfg.options.rgb_fn}; - hsl_fn = ${boolToString cfg.options.hsl_fn}; - css = ${boolToString cfg.options.css}; - css_fn = ${boolToString cfg.options.css_fn}; - mode = '${toString cfg.options.mode}'; - tailwind = ${boolToString cfg.options.tailwind}; - sass = ${boolToString cfg.options.tailwind}; - always_update = ${boolToString cfg.options.alwaysUpdate}; - } - }) + require('colorizer').setup(${toLuaObject cfg.setupOpts}) ''; }; } From 64f167e7c513586e5df78e576e44822f64bd9ad3 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sun, 10 Mar 2024 19:02:04 +0000 Subject: [PATCH 069/193] feat(modes): custom setup opts --- modules/ui/modes/config.nix | 15 ++-------- modules/ui/modes/modes.nix | 60 +++++++++++++++++++++---------------- 2 files changed, 36 insertions(+), 39 deletions(-) diff --git a/modules/ui/modes/config.nix b/modules/ui/modes/config.nix index 25ee337..9f49dc4 100644 --- a/modules/ui/modes/config.nix +++ b/modules/ui/modes/config.nix @@ -4,8 +4,8 @@ ... }: let inherit (lib.modules) mkIf; - inherit (lib.trivial) boolToString; inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.ui.modes-nvim; in { @@ -15,18 +15,7 @@ in { ]; vim.luaConfigRC.modes-nvim = entryAnywhere '' - require('modes').setup({ - set_cursorline = ${boolToString cfg.setCursorline}, - line_opacity = { - visual = 0, - }, - colors = { - copy = "${toString cfg.colors.copy}", - delete = "${toString cfg.colors.delete}", - insert = "${toString cfg.colors.insert}", - visual = "${toString cfg.colors.visual}", - }, - }) + require('modes').setup(${toLuaObject cfg.setupOpts}) ''; }; } diff --git a/modules/ui/modes/modes.nix b/modules/ui/modes/modes.nix index af45d30..f73a298 100644 --- a/modules/ui/modes/modes.nix +++ b/modules/ui/modes/modes.nix @@ -1,39 +1,47 @@ {lib, ...}: let inherit (lib.options) mkOption mkEnableOption; - inherit (lib.types) str; + inherit (lib.types) bool str float; + inherit (lib.nvim.types) mkPluginSetupOption; in { options.vim.ui.modes-nvim = { enable = mkEnableOption "modes.nvim's prismatic line decorations"; - setCursorline = mkOption { - type = bool; - description = "Set a colored cursorline on current line"; - default = false; # looks ugly, disabled by default - }; - - colors = { - copy = mkOption { - type = str; - default = "#f5c359"; - description = "The #RRGGBB color code for the visual mode highlights"; + setupOpts = { + setCursorline = mkOption { + type = bool; + description = "Set a colored cursorline on current line"; + default = false; # looks ugly, disabled by default }; - delete = mkOption { - type = str; - default = "#c75c6a"; - description = "The #RRGGBB color code for the visual mode highlights"; + line_opacity = { + visual = mkOption { + type = float; + description = "Set opacity for cursorline and number background"; + default = 0.0; + }; }; - insert = mkOption { - type = str; - default = "#78ccc5"; - description = "The #RRGGBB color code for the visual mode highlights"; - }; - - visual = mkOption { - type = str; - default = "#9745be"; - description = "The #RRGGBB color code for the visual mode highlights"; + colors = mkPluginSetupOption "modes.nvim" { + copy = mkOption { + type = str; + description = "The #RRGGBB color code for the visual mode highlights"; + default = "#f5c359"; + }; + delete = mkOption { + type = str; + description = "The #RRGGBB color code for the visual mode highlights"; + default = "#c75c6a"; + }; + insert = mkOption { + type = str; + description = "The #RRGGBB color code for the visual mode highlights"; + default = "#78ccc5"; + }; + visual = mkOption { + type = str; + description = "The #RRGGBB color code for the visual mode highlights"; + default = "#9745be"; + }; }; }; }; From 80fee9dae724cc695d00c8937996eeb7dae893e9 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sun, 10 Mar 2024 20:41:33 +0000 Subject: [PATCH 070/193] feat(nvim-notify): custom setup opts --- .../ui/notifications/nvim-notify/config.nix | 16 +--- .../notifications/nvim-notify/nvim-notify.nix | 86 ++++++++++++------- 2 files changed, 57 insertions(+), 45 deletions(-) diff --git a/modules/ui/notifications/nvim-notify/config.nix b/modules/ui/notifications/nvim-notify/config.nix index 852b94d..7a11b6b 100644 --- a/modules/ui/notifications/nvim-notify/config.nix +++ b/modules/ui/notifications/nvim-notify/config.nix @@ -5,26 +5,16 @@ }: let inherit (lib.modules) mkIf; inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.notify.nvim-notify; in { config = mkIf cfg.enable { vim = { startPlugins = ["nvim-notify"]; + luaConfigRC.nvim-notify = entryAnywhere '' - require('notify').setup { - stages = "${cfg.stages}", - timeout = ${toString cfg.timeout}, - background_colour = "${cfg.background_colour}", - position = "${cfg.position}", - icons = { - ERROR = "${cfg.icons.ERROR}", - WARN = "${cfg.icons.WARN}", - INFO = "${cfg.icons.INFO}", - DEBUG = "${cfg.icons.DEBUG}", - TRACE = "${cfg.icons.TRACE}", - }, - } + require('notify').setup(${toLuaObject cfg.setupOpts}) -- required to fix offset_encoding errors local notify = vim.notify diff --git a/modules/ui/notifications/nvim-notify/nvim-notify.nix b/modules/ui/notifications/nvim-notify/nvim-notify.nix index 57683a4..86d15cd 100644 --- a/modules/ui/notifications/nvim-notify/nvim-notify.nix +++ b/modules/ui/notifications/nvim-notify/nvim-notify.nix @@ -1,42 +1,64 @@ -{lib, ...}: let - inherit (lib) mkOption mkEnableOption; - inherit (lib.types) enum int str attrsOf; +{ + config, + lib, + ... +}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkRenamedOptionModule; + inherit (lib.types) int str enum attrsOf; + inherit (lib.nvim.types) mkPluginSetupOption; in { + imports = let + renamedSetupOpt = name: + mkRenamedOptionModule + ["vim" "notify" "nvim-notify" name] + ["vim" "notify" "nvim-notify" "setupOpts" name]; + in [ + (renamedSetupOpt "stages") + (renamedSetupOpt "timeout") + (renamedSetupOpt "background_colour") + (renamedSetupOpt "position") + (renamedSetupOpt "icons") + ]; + options.vim.notify.nvim-notify = { enable = mkEnableOption "nvim-notify notifications"; - stages = mkOption { - type = enum ["fade_in_slide_out" "fade_in" "slide_out" "none"]; - default = "fade_in_slide_out"; - description = "The stages of the notification"; - }; - timeout = mkOption { - type = int; - default = 1000; - description = "The timeout of the notification"; - }; + setupOpts = mkPluginSetupOption "nvim-notify" { + stages = mkOption { + type = enum ["fade_in_slide_out" "fade_in" "slide_out" "none"]; + default = "fade_in_slide_out"; + description = "The stages of the notification"; + }; - background_colour = mkOption { - type = str; - default = "#000000"; - description = "The background colour of the notification"; - }; + timeout = mkOption { + type = int; + default = 1000; + description = "The timeout of the notification"; + }; - position = mkOption { - type = enum ["top_left" "top_right" "bottom_left" "bottom_right"]; - default = "top_right"; - description = "The position of the notification"; - }; + background_colour = mkOption { + type = str; + default = "#000000"; + description = "The background colour of the notification"; + }; - icons = mkOption { - type = attrsOf str; - description = "The icons of the notification"; - default = { - ERROR = ""; - WARN = ""; - INFO = ""; - DEBUG = ""; - TRACE = ""; + position = mkOption { + type = enum ["top_left" "top_right" "bottom_left" "bottom_right"]; + default = "top_right"; + description = "The position of the notification"; + }; + + icons = mkOption { + type = attrsOf str; + description = "The icons of the notification"; + default = { + ERROR = ""; + WARN = ""; + INFO = ""; + DEBUG = ""; + TRACE = ""; + }; }; }; }; From 5ea6272bee4a0e28ccf3835695da42143bcdb851 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sun, 10 Mar 2024 21:00:14 +0000 Subject: [PATCH 071/193] feat(smartcolumn): custom setup opts --- configuration.nix | 2 +- modules/ui/smartcolumn/config.nix | 11 ++----- modules/ui/smartcolumn/smartcolumn.nix | 44 ++++++++++++++++---------- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/configuration.nix b/configuration.nix index 8420bbf..de778d5 100644 --- a/configuration.nix +++ b/configuration.nix @@ -210,7 +210,7 @@ inputs: let }; smartcolumn = { enable = true; - columnAt.languages = { + setupOpts.custom_colorcolumn = { # this is a freeform module, it's `buftype = int;` for configuring column position nix = 110; ruby = 120; diff --git a/modules/ui/smartcolumn/config.nix b/modules/ui/smartcolumn/config.nix index 48b47d2..8aff4b0 100644 --- a/modules/ui/smartcolumn/config.nix +++ b/modules/ui/smartcolumn/config.nix @@ -4,9 +4,8 @@ ... }: let inherit (lib.modules) mkIf; - inherit (lib.strings) concatStringsSep; - inherit (lib.nvim.lua) attrsetToLuaTable; inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.ui.smartcolumn; in { @@ -15,13 +14,7 @@ in { startPlugins = ["smartcolumn"]; vim.luaConfigRC.smartcolumn = entryAnywhere '' - require("smartcolumn").setup({ - colorcolumn = "${toString cfg.showColumnAt}", - -- { "help", "text", "markdown", "NvimTree", "alpha"}, - disabled_filetypes = { ${concatStringsSep ", " (map (x: "\"" + x + "\"") cfg.disabledFiletypes)} }, - custom_colorcolumn = ${attrsetToLuaTable cfg.columnAt.languages}, - scope = "file", - }) + require("smartcolumn").setup(${toLuaObject cfg.setupOpts}) ''; }; } diff --git a/modules/ui/smartcolumn/smartcolumn.nix b/modules/ui/smartcolumn/smartcolumn.nix index bac4c7d..37d7a94 100644 --- a/modules/ui/smartcolumn/smartcolumn.nix +++ b/modules/ui/smartcolumn/smartcolumn.nix @@ -1,31 +1,41 @@ {lib, ...}: let inherit (lib.options) mkOption mkEnableOption literalExpression; - inherit (lib.types) nullOr int str submodule attrsOf either listOf; + inherit (lib.types) nullOr int str attrsOf either listOf; + inherit (lib.modules) mkRenamedOptionModule; + inherit (lib.nvim.types) mkPluginSetupOption; in { + imports = let + renamedSetupOpt = oldPath: newPath: + mkRenamedOptionModule (["vim" "ui" "smartcolumn"] ++ oldPath) (["vim" "ui" "smartcolumn" "setupOpts"] ++ newPath); + in [ + (renamedSetupOpt ["disabledFiletypes"] ["disabled_filetypes"]) + (renamedSetupOpt ["showColumnAt"] ["colorcolumn"]) + (renamedSetupOpt ["columnAt" "languages"] ["custom_colorcolumn"]) + ]; + options.vim.ui.smartcolumn = { enable = mkEnableOption "line length indicator"; - showColumnAt = mkOption { - type = nullOr int; - default = 120; - description = "The position at which the column will be displayed. Set to null to disable"; - }; + setupOpts = mkPluginSetupOption "smartcolumn.nvim" { + colorcolumn = mkOption { + type = nullOr (either str (listOf str)); + default = "120"; + description = "The position at which the column will be displayed. Set to null to disable"; + }; - disabledFiletypes = mkOption { - type = listOf str; - default = ["help" "text" "markdown" "NvimTree" "alpha"]; - description = "The filetypes smartcolumn will be disabled for."; - }; + disabled_filetypes = mkOption { + type = listOf str; + default = ["help" "text" "markdown" "NvimTree" "alpha"]; + description = "The filetypes smartcolumn will be disabled for."; + }; - columnAt = { - languages = mkOption { + custom_colorcolumn = mkOption { description = "The position at which smart column should be displayed for each individual buffer type"; - type = submodule { - freeformType = attrsOf (either int (listOf int)); - }; + type = attrsOf (either int (listOf int)); + default = {}; example = literalExpression '' - vim.ui.smartcolumn.columnAt.languages = { + vim.ui.smartcolumn.setupOpts.custom_colorcolumn = { nix = 110; ruby = 120; java = 130; From 77d3cd5e0c05bac3eacc6b9ebdb3ee478c393f69 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 16 Mar 2024 09:29:07 +0000 Subject: [PATCH 072/193] lib: switch to mkLuaInline --- lib/lua.nix | 6 ++++-- lib/types/default.nix | 2 +- lib/types/plugins.nix | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/lua.nix b/lib/lua.nix index d7dd982..eded8f3 100644 --- a/lib/lua.nix +++ b/lib/lua.nix @@ -48,11 +48,13 @@ in rec { # Convert a list of lua expressions to a lua table. The difference to listToLuaTable is that the elements here are expected to be lua expressions already, whereas listToLuaTable converts from nix types to lua first luaTable = items: ''{${concatStringsSep "," items}}''; + isLuaInline = {_type ? null, ...}: _type == "lua-inline"; + toLuaObject = args: if isAttrs args then - if hasAttr "__raw" args - then args.__raw + if isLuaInline args + then args.expr else if hasAttr "__empty" args then "{ }" else diff --git a/lib/types/default.nix b/lib/types/default.nix index 22b728d..89ce1ba 100644 --- a/lib/types/default.nix +++ b/lib/types/default.nix @@ -4,6 +4,6 @@ typesLanguage = import ./languages.nix {inherit lib;}; in { inherit (typesDag) dagOf; - inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption rawLua; + inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline; inherit (typesLanguage) diagnostics mkGrammarOption; } diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index 813108f..e8db87a 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -145,13 +145,13 @@ in { type = pluginsType; }; - rawLua = lib.mkOptionType { - name = "rawLua"; - check = val: isString val || val ? __raw; + luaInline = lib.mkOptionType { + name = "luaInline"; + check = x: lib.nvim.lua.isLuaInline x || builtins.isString x; merge = loc: defs: let val = if isString loc - then {__raw = val;} + then lib.generators.mkLuaInline loc else loc; in lib.mergeOneOption val defs; From 5d8eb192d7735c3d56c8a501a2e96958163b6373 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 16 Mar 2024 09:29:32 +0000 Subject: [PATCH 073/193] plugins: switch to mkLuaInline --- modules/core/default.nix | 3 +- modules/rich-presence/neocord/neocord.nix | 3 +- modules/statusline/lualine/config.nix | 29 +++++++------ modules/terminal/toggleterm/toggleterm.nix | 37 ++++++++-------- modules/ui/breadcrumbs/config.nix | 50 +++++++++++----------- modules/ui/smartcolumn/config.nix | 7 +-- modules/utility/telescope/config.nix | 3 +- modules/visuals/fidget/fidget.nix | 27 ++++++------ 8 files changed, 80 insertions(+), 79 deletions(-) diff --git a/modules/core/default.nix b/modules/core/default.nix index 682566c..954b9d9 100644 --- a/modules/core/default.nix +++ b/modules/core/default.nix @@ -12,6 +12,7 @@ inherit (lib.types) bool str listOf oneOf attrsOf nullOr attrs submodule unspecified lines; inherit (lib.nvim.types) dagOf pluginsOpt extraPluginType; inherit (lib.nvim.dag) entryAnywhere entryAfter topoSort; + inherit (lib.generators) mkLuaInline; inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.vim) valToVim; @@ -86,7 +87,7 @@ else config; action = if action.lua - then {"__raw" = action.action;} + then mkLuaInline action.action else action.action; }; in diff --git a/modules/rich-presence/neocord/neocord.nix b/modules/rich-presence/neocord/neocord.nix index 28f89c7..1d6e625 100644 --- a/modules/rich-presence/neocord/neocord.nix +++ b/modules/rich-presence/neocord/neocord.nix @@ -2,6 +2,7 @@ inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule; inherit (lib.options) mkEnableOption mkOption literalExpression; inherit (lib.types) bool int str enum nullOr listOf; + inherit (lib.nvim.types) mkPluginSetupOption; in { imports = [ @@ -22,7 +23,7 @@ in { options.vim.presence.neocord = { enable = mkEnableOption "neocord plugin for discord rich presence"; - setupOpts = lib.nvim.mkPluginSetupOption "neocord" { + setupOpts = mkPluginSetupOption "neocord" { logo = mkOption { type = str; # TODO: can the default be documented better, maybe with an enum? default = "auto"; diff --git a/modules/statusline/lualine/config.nix b/modules/statusline/lualine/config.nix index 9ab576e..96c874b 100644 --- a/modules/statusline/lualine/config.nix +++ b/modules/statusline/lualine/config.nix @@ -6,10 +6,11 @@ inherit (lib.modules) mkIf mkMerge; inherit (lib.trivial) boolToString; inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.generators) mkLuaInline; cfg = config.vim.statusline.lualine; breadcrumbsCfg = config.vim.ui.breadcrumbs; - rawLua = code: {"__raw" = code;}; in { config = mkMerge [ # TODO: move into nvim-tree file @@ -23,7 +24,7 @@ in { # TODO: rewrite in new syntax winbar.lualine_c = [ "navic" - (rawLua "draw_empty = ${boolToString config.vim.ui.breadcrumbs.alwaysRender}") + (mkLuaInline "draw_empty = ${boolToString config.vim.ui.breadcrumbs.alwaysRender}") ]; }; }) @@ -49,20 +50,20 @@ in { }; sections = { - lualine_a = builtins.map rawLua (cfg.activeSection.a ++ cfg.extraActiveSection.a); - lualine_b = builtins.map rawLua (cfg.activeSection.b ++ cfg.extraActiveSection.b); - lualine_c = builtins.map rawLua (cfg.activeSection.c ++ cfg.extraActiveSection.c); - lualine_x = builtins.map rawLua (cfg.activeSection.x ++ cfg.extraActiveSection.x); - lualine_y = builtins.map rawLua (cfg.activeSection.y ++ cfg.extraActiveSection.y); - lualine_z = builtins.map rawLua (cfg.activeSection.z ++ cfg.extraActiveSection.z); + lualine_a = builtins.map mkLuaInline (cfg.activeSection.a ++ cfg.extraActiveSection.a); + lualine_b = builtins.map mkLuaInline (cfg.activeSection.b ++ cfg.extraActiveSection.b); + lualine_c = builtins.map mkLuaInline (cfg.activeSection.c ++ cfg.extraActiveSection.c); + lualine_x = builtins.map mkLuaInline (cfg.activeSection.x ++ cfg.extraActiveSection.x); + lualine_y = builtins.map mkLuaInline (cfg.activeSection.y ++ cfg.extraActiveSection.y); + lualine_z = builtins.map mkLuaInline (cfg.activeSection.z ++ cfg.extraActiveSection.z); }; inactive_sections = { - lualine_a = builtins.map rawLua (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a); - lualine_b = builtins.map rawLua (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b); - lualine_c = builtins.map rawLua (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c); - lualine_x = builtins.map rawLua (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x); - lualine_y = builtins.map rawLua (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y); - lualine_z = builtins.map rawLua (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z); + lualine_a = builtins.map mkLuaInline (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a); + lualine_b = builtins.map mkLuaInline (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b); + lualine_c = builtins.map mkLuaInline (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c); + lualine_x = builtins.map mkLuaInline (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x); + lualine_y = builtins.map mkLuaInline (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y); + lualine_z = builtins.map mkLuaInline (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z); }; # probably don't need this? tabline = []; diff --git a/modules/terminal/toggleterm/toggleterm.nix b/modules/terminal/toggleterm/toggleterm.nix index 8b3f051..865e66f 100644 --- a/modules/terminal/toggleterm/toggleterm.nix +++ b/modules/terminal/toggleterm/toggleterm.nix @@ -7,7 +7,8 @@ inherit (lib.nvim.binds) mkMappingOption; inherit (lib.types) nullOr str enum bool package either int; inherit (lib) mkRenamedOptionModule; - inherit (lib.nvim.types) mkPluginSetupOption rawLua; + inherit (lib.nvim.types) mkPluginSetupOption luaInline; + inherit (lib.generators) mkLuaInline; in { imports = [ (mkRenamedOptionModule ["vim" "terminal" "toggleterm" "direction"] ["vim" "terminal" "toggleterm" "setupOpts" "direction"]) @@ -38,32 +39,28 @@ in { }; size = mkOption { - type = either rawLua int; + type = either luaInline int; description = "Number or lua function which is passed to the current terminal"; - default = { - __raw = '' - function(term) - if term.direction == "horizontal" then - return 15 - elseif term.direction == "vertical" then - return vim.o.columns * 0.4 - end + default = mkLuaInline '' + function(term) + if term.direction == "horizontal" then + return 15 + elseif term.direction == "vertical" then + return vim.o.columns * 0.4 end - ''; - }; + end + ''; }; winbar = { enabled = mkEnableOption "winbar in terminal" // {default = true;}; name_formatter = mkOption { - type = rawLua; + type = luaInline; description = "Winbar formatter function."; - default = { - __raw = '' - function(term) - return term.name - end - ''; - }; + default = mkLuaInline '' + function(term) + return term.name + end + ''; }; }; }; diff --git a/modules/ui/breadcrumbs/config.nix b/modules/ui/breadcrumbs/config.nix index 88ddddf..35c08ec 100644 --- a/modules/ui/breadcrumbs/config.nix +++ b/modules/ui/breadcrumbs/config.nix @@ -8,9 +8,9 @@ inherit (lib.lists) optionals; inherit (lib.nvim.dag) entryAfter; inherit (lib.nvim.lua) toLuaObject; + inherit (lib.generators) mkLuaInline; cfg = config.vim.ui.breadcrumbs; - mkRawLua = code: {__raw = code;}; in { config = mkIf cfg.enable { vim.startPlugins = @@ -31,40 +31,40 @@ in { vim.ui.breadcrumbs.navbuddy.setupOpts = { mappings = { - ${cfg.navbuddy.mappings.close} = mkRawLua "actions.close()"; - ${cfg.navbuddy.mappings.nextSibling} = mkRawLua "actions.next_sibling()"; - ${cfg.navbuddy.mappings.previousSibling} = mkRawLua "actions.previous_sibling()"; - ${cfg.navbuddy.mappings.parent} = mkRawLua "actions.parent()"; - ${cfg.navbuddy.mappings.children} = mkRawLua "actions.children()"; - ${cfg.navbuddy.mappings.root} = mkRawLua "actions.root()"; + ${cfg.navbuddy.mappings.close} = mkLuaInline "actions.close()"; + ${cfg.navbuddy.mappings.nextSibling} = mkLuaInline "actions.next_sibling()"; + ${cfg.navbuddy.mappings.previousSibling} = mkLuaInline "actions.previous_sibling()"; + ${cfg.navbuddy.mappings.parent} = mkLuaInline "actions.parent()"; + ${cfg.navbuddy.mappings.children} = mkLuaInline "actions.children()"; + ${cfg.navbuddy.mappings.root} = mkLuaInline "actions.root()"; - ${cfg.navbuddy.mappings.visualName} = mkRawLua "actions.visual_name()"; - ${cfg.navbuddy.mappings.visualScope} = mkRawLua "actions.visual_scope()"; + ${cfg.navbuddy.mappings.visualName} = mkLuaInline "actions.visual_name()"; + ${cfg.navbuddy.mappings.visualScope} = mkLuaInline "actions.visual_scope()"; - ${cfg.navbuddy.mappings.yankName} = mkRawLua "actions.yank_name()"; - ${cfg.navbuddy.mappings.yankScope} = mkRawLua "actions.yank_scope()"; + ${cfg.navbuddy.mappings.yankName} = mkLuaInline "actions.yank_name()"; + ${cfg.navbuddy.mappings.yankScope} = mkLuaInline "actions.yank_scope()"; - ${cfg.navbuddy.mappings.insertName} = mkRawLua "actions.insert_name()"; - ${cfg.navbuddy.mappings.insertScope} = mkRawLua "actions.insert_scope()"; + ${cfg.navbuddy.mappings.insertName} = mkLuaInline "actions.insert_name()"; + ${cfg.navbuddy.mappings.insertScope} = mkLuaInline "actions.insert_scope()"; - ${cfg.navbuddy.mappings.appendName} = mkRawLua "actions.append_name()"; - ${cfg.navbuddy.mappings.appendScope} = mkRawLua "actions.append_scope()"; + ${cfg.navbuddy.mappings.appendName} = mkLuaInline "actions.append_name()"; + ${cfg.navbuddy.mappings.appendScope} = mkLuaInline "actions.append_scope()"; - ${cfg.navbuddy.mappings.rename} = mkRawLua "actions.rename()"; + ${cfg.navbuddy.mappings.rename} = mkLuaInline "actions.rename()"; - ${cfg.navbuddy.mappings.delete} = mkRawLua "actions.delete()"; + ${cfg.navbuddy.mappings.delete} = mkLuaInline "actions.delete()"; - ${cfg.navbuddy.mappings.foldCreate} = mkRawLua "actions.fold_create()"; - ${cfg.navbuddy.mappings.foldDelete} = mkRawLua "actions.fold_delete()"; + ${cfg.navbuddy.mappings.foldCreate} = mkLuaInline "actions.fold_create()"; + ${cfg.navbuddy.mappings.foldDelete} = mkLuaInline "actions.fold_delete()"; - ${cfg.navbuddy.mappings.comment} = mkRawLua "actions.comment()"; + ${cfg.navbuddy.mappings.comment} = mkLuaInline "actions.comment()"; - ${cfg.navbuddy.mappings.select} = mkRawLua "actions.select()"; + ${cfg.navbuddy.mappings.select} = mkLuaInline "actions.select()"; - ${cfg.navbuddy.mappings.moveDown} = mkRawLua "actions.move_down()"; - ${cfg.navbuddy.mappings.moveUp} = mkRawLua "actions.move_up()"; + ${cfg.navbuddy.mappings.moveDown} = mkLuaInline "actions.move_down()"; + ${cfg.navbuddy.mappings.moveUp} = mkLuaInline "actions.move_up()"; - ${cfg.navbuddy.mappings.telescope} = mkRawLua '' + ${cfg.navbuddy.mappings.telescope} = mkLuaInline '' actions.telescope({ layout_strategy = "horizontal", layout_config = { @@ -74,7 +74,7 @@ in { preview_width = 0.50 }, })''; - ${cfg.navbuddy.mappings.help} = mkRawLua "actions.help()"; + ${cfg.navbuddy.mappings.help} = mkLuaInline "actions.help()"; }; }; diff --git a/modules/ui/smartcolumn/config.nix b/modules/ui/smartcolumn/config.nix index 8aff4b0..9edbdbb 100644 --- a/modules/ui/smartcolumn/config.nix +++ b/modules/ui/smartcolumn/config.nix @@ -13,8 +13,9 @@ in { vim = { startPlugins = ["smartcolumn"]; - vim.luaConfigRC.smartcolumn = entryAnywhere '' - require("smartcolumn").setup(${toLuaObject cfg.setupOpts}) - ''; + luaConfigRC.smartcolumn = entryAnywhere '' + require("smartcolumn").setup(${toLuaObject cfg.setupOpts}) + ''; + }; }; } diff --git a/modules/utility/telescope/config.nix b/modules/utility/telescope/config.nix index 4e60f22..f178158 100644 --- a/modules/utility/telescope/config.nix +++ b/modules/utility/telescope/config.nix @@ -9,6 +9,7 @@ inherit (lib.nvim.dag) entryAnywhere; # TODO: move this to its own module inherit (lib) pushDownDefault; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.telescope; self = import ./telescope.nix {inherit pkgs lib;}; @@ -66,7 +67,7 @@ in { vim.luaConfigRC.telescope = entryAnywhere '' local telescope = require('telescope') - telescope.setup(${nvim.lua.toLuaObject cfg.setupOpts}) + telescope.setup(${toLuaObject cfg.setupOpts}) ${ if config.vim.ui.noice.enable diff --git a/modules/visuals/fidget/fidget.nix b/modules/visuals/fidget/fidget.nix index 482391a..6897800 100644 --- a/modules/visuals/fidget/fidget.nix +++ b/modules/visuals/fidget/fidget.nix @@ -9,8 +9,7 @@ inherit (lib.strings) toUpper; inherit (lib.types) int float bool str enum listOf attrsOf; inherit (lib.nvim.types) mkPluginSetupOption; - - rawLua = lua: {__raw = lua;}; + inherit (lib.generators) mkLuaInline; in { imports = [ (mkRenamedOptionModule ["vim" "visuals" "fidget-nvim" "align" "bottom"] ["vim" "visuals" "fidget-nvim" "setupOpts" "notification" "window" "align"]) @@ -50,7 +49,7 @@ in { apply = clear: if clear then - rawLua '' + mkLuaInline '' function(client_id) local client = vim.lsp.get_client_by_id(client_id) return client and client.name or nil @@ -66,7 +65,7 @@ in { return msg.lsp_client.name end ''; - apply = rawLua; + apply = mkLuaInline; }; ignore = mkOption { description = "Ignore LSP servers by name"; @@ -177,7 +176,7 @@ in { default = '' require("fidget.progress.display").default_format_message ''; - apply = rawLua; + apply = mkLuaInline; }; format_annote = mkOption { description = "How to format a progress annotation"; @@ -185,7 +184,7 @@ in { default = '' function(msg) return msg.title end ''; - apply = rawLua; + apply = mkLuaInline; }; format_group_name = mkOption { description = "How to format a progress notification group's name"; @@ -193,13 +192,13 @@ in { default = '' function(group) return tostring(group) end ''; - apply = rawLua; + apply = mkLuaInline; }; overrides = mkOption { description = "Override options from the default notification config"; type = attrsOf str; default = {rust_analyzer = "{ name = 'rust-analyzer' }";}; - apply = mapAttrs (key: lua: rawLua lua); + apply = mapAttrs (key: lua: mkLuaInline lua); }; }; @@ -227,7 +226,7 @@ in { description = "Minimum notifications level"; type = enum ["debug" "info" "warn" "error"]; default = "info"; - apply = filter: rawLua "vim.log.levels.${toUpper filter}"; + apply = filter: mkLuaInline "vim.log.levels.${toUpper filter}"; }; history_size = mkOption { description = "Number of removed messages to retain in history"; @@ -243,7 +242,7 @@ in { description = "How to configure notification groups when instantiated"; type = attrsOf str; default = {default = "require('fidget.notification').default_config";}; - apply = mapAttrs (key: lua: rawLua lua); + apply = mapAttrs (key: lua: mkLuaInline lua); }; redirect = mkOption { description = "Conditionally redirect notifications to another backend"; @@ -255,7 +254,7 @@ in { end end ''; - apply = rawLua; + apply = mkLuaInline; }; view = { @@ -287,7 +286,7 @@ in { return cnt == 1 and msg or string.format("(%dx) %s", cnt, msg) end ''; - apply = rawLua; + apply = mkLuaInline; }; }; @@ -373,7 +372,7 @@ in { description = "Minimum logging level"; type = enum ["debug" "error" "info" "trace" "warn" "off"]; default = "warn"; - apply = logLevel: rawLua "vim.log.levels.${toUpper logLevel}"; + apply = logLevel: mkLuaInline "vim.log.levels.${toUpper logLevel}"; }; max_size = mkOption { description = "Maximum log file size, in KB"; @@ -391,7 +390,7 @@ in { default = '' string.format("%s/fidget.nvim.log", vim.fn.stdpath("cache")) ''; - apply = rawLua; + apply = mkLuaInline; }; }; }; From 29f78f78277ed41a871e7d8537b7c9a550685dbe Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 16 Mar 2024 10:32:20 +0000 Subject: [PATCH 074/193] fix(nvimtree): errors in refactor --- modules/filetree/nvimtree/nvimtree.nix | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/filetree/nvimtree/nvimtree.nix b/modules/filetree/nvimtree/nvimtree.nix index 216f098..fb9a9d0 100644 --- a/modules/filetree/nvimtree/nvimtree.nix +++ b/modules/filetree/nvimtree/nvimtree.nix @@ -4,6 +4,7 @@ ... }: let inherit (lib.options) mkEnableOption mkOption literalExpression; + inherit (lib.generators) mkLuaInline; inherit (lib.types) nullOr str bool int submodule listOf enum oneOf attrs addCheck; inherit (lib.nvim.types) mkPluginSetupOption; in { @@ -46,7 +47,7 @@ in { type = bool; }; - autoreload_on_write = mkOption { + auto_reload_on_write = mkOption { default = true; description = "Auto reload tree on write"; type = bool; @@ -146,7 +147,7 @@ in { ''; }; - reload_on_buf_enter = mkOption { + reload_on_bufenter = mkOption { default = false; type = bool; description = "Automatically reloads the tree on `BufEnter` nvim-tree."; @@ -266,12 +267,14 @@ in { description = "Minimum severity."; type = enum ["HINT" "INFO" "WARNING" "ERROR"]; default = "HINT"; + apply = x: mkLuaInline "vim.diagnostic.severity.${x}"; }; max = mkOption { description = "Maximum severity."; type = enum ["HINT" "INFO" "WARNING" "ERROR"]; default = "ERROR"; + apply = x: mkLuaInline "vim.diagnostic.severity.${x}"; }; }; }; @@ -372,7 +375,7 @@ in { }; }; - selectPrompts = mkEnableOption '' + select_prompts = mkEnableOption '' Use `vim.ui.select` style prompts. Necessary when using a UI prompt decorator such as dressing.nvim or telescope-ui-select.nvim ''; @@ -713,12 +716,12 @@ in { default = { default = ""; open = ""; - arrowOpen = ""; - arrowClosed = ""; + arrow_open = ""; + arrow_closed = ""; empty = ""; - emptyOpen = ""; + empty_open = ""; symlink = ""; - symlinkOpen = ""; + symlink_open = ""; }; }; @@ -1066,6 +1069,7 @@ in { type = enum ["ERROR" "WARNING" "INFO" "DEBUG"]; description = "Specify minimum notification level, uses the values from `vim.log.levels`"; default = "INFO"; + apply = x: mkLuaInline "vim.log.levels.${x}"; }; absolute_path = mkOption { From 2d9c1b34c6c4a504e1f43ee79c8203f05c0022ef Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Fri, 22 Mar 2024 15:06:45 +0000 Subject: [PATCH 075/193] cleanup: remove references to nvim-compe --- flake.lock | 17 ----------------- flake.nix | 6 ------ lib/types/plugins.nix | 1 - modules/autopairs/nvim-autopairs/config.nix | 3 --- 4 files changed, 27 deletions(-) diff --git a/flake.lock b/flake.lock index 4316578..387e831 100644 --- a/flake.lock +++ b/flake.lock @@ -1092,22 +1092,6 @@ "type": "github" } }, - "nvim-compe": { - "flake": false, - "locked": { - "lastModified": 1633188506, - "narHash": "sha256-Y2oqvsuAKM3qjmmtJVD9z34682eCRF25kPL+rxhhg7I=", - "owner": "hrsh7th", - "repo": "nvim-compe", - "rev": "d186d739c54823e0b010feb205c6f97792322c08", - "type": "github" - }, - "original": { - "owner": "hrsh7th", - "repo": "nvim-compe", - "type": "github" - } - }, "nvim-cursorline": { "flake": false, "locked": { @@ -1574,7 +1558,6 @@ "nvim-cmp": "nvim-cmp", "nvim-code-action-menu": "nvim-code-action-menu", "nvim-colorizer-lua": "nvim-colorizer-lua", - "nvim-compe": "nvim-compe", "nvim-cursorline": "nvim-cursorline", "nvim-dap": "nvim-dap", "nvim-dap-ui": "nvim-dap-ui", diff --git a/flake.nix b/flake.nix index 51c8861..b505b97 100644 --- a/flake.nix +++ b/flake.nix @@ -228,12 +228,6 @@ flake = false; }; - # Autocompletes - nvim-compe = { - url = "github:hrsh7th/nvim-compe"; - flake = false; - }; - nvim-cmp = { url = "github:hrsh7th/nvim-cmp"; flake = false; diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index e8db87a..f6eceaa 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -15,7 +15,6 @@ with lib; let "nvim-tree-lua" "nvim-bufferline-lua" "lualine" - "nvim-compe" "nvim-autopairs" "nvim-ts-autotag" "nvim-web-devicons" diff --git a/modules/autopairs/nvim-autopairs/config.nix b/modules/autopairs/nvim-autopairs/config.nix index 5cd18eb..4058590 100644 --- a/modules/autopairs/nvim-autopairs/config.nix +++ b/modules/autopairs/nvim-autopairs/config.nix @@ -15,9 +15,6 @@ in { vim.luaConfigRC.autopairs = entryAnywhere '' require("nvim-autopairs").setup{} - ${optionalString (config.vim.autocomplete.type == "nvim-compe") '' - require('nvim-autopairs.completion.compe').setup(${toLuaObject cfg.setupOpts}) - ''} ''; }; } From 87e8732461f1e2c20b7fe988e780b8d5d46412c2 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 6 Apr 2024 19:14:47 +0300 Subject: [PATCH 076/193] statusline/lualine: fix wrong type for nvim-navic --- modules/statusline/lualine/config.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/statusline/lualine/config.nix b/modules/statusline/lualine/config.nix index 96c874b..9578842 100644 --- a/modules/statusline/lualine/config.nix +++ b/modules/statusline/lualine/config.nix @@ -23,8 +23,10 @@ in { vim.statusline.lualine.setupOpts = { # TODO: rewrite in new syntax winbar.lualine_c = [ - "navic" - (mkLuaInline "draw_empty = ${boolToString config.vim.ui.breadcrumbs.alwaysRender}") + [ + "navic" + (mkLuaInline "draw_empty = ${boolToString config.vim.ui.breadcrumbs.alwaysRender}") + ] ]; }; }) From 1d5fa0afdc12c6687bb34abdd4fab82cb3c3b06b Mon Sep 17 00:00:00 2001 From: Pei Yang Ching Date: Sat, 6 Apr 2024 19:10:13 +0200 Subject: [PATCH 077/193] remove sub-options for lualine.setupOpts Having users to use setupOpts for lualine would suck since lualine uses the `{"module", option = value} lua syntax heavily and we don't have a good syntax for that --- modules/statusline/lualine/lualine.nix | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/modules/statusline/lualine/lualine.nix b/modules/statusline/lualine/lualine.nix index ac18fbd..7d1020f 100644 --- a/modules/statusline/lualine/lualine.nix +++ b/modules/statusline/lualine/lualine.nix @@ -14,28 +14,9 @@ if config.vim.statusline.lualine.theme == "catppuccin" then "#181825" else "none"; - tempDesc = "see plugin docs for more info"; in { options.vim.statusline.lualine = { - setupOpts = mkPluginSetupOption "Lualine" { - options = { - disabled_filetypes = mkOption { - description = tempDesc; - type = listOf str; - default = ["alpha"]; - }; - always_divide_middle = mkOption { - description = tempDesc; - type = bool; - default = true; - }; - ignore_focus = mkOption { - description = tempDesc; - type = listOf str; - default = ["NvimTree"]; - }; - }; - }; + setupOpts = mkPluginSetupOption "Lualine" {}; enable = mkEnableOption "lualine statusline plugin"; From 893742f6e9df239379df9fdfdd7785df689b8dc3 Mon Sep 17 00:00:00 2001 From: Pei Yang Ching Date: Sat, 6 Apr 2024 19:12:58 +0200 Subject: [PATCH 078/193] cleanup: remove more nvim-compe --- .../nvim-autopairs/nvim-autopairs.nix | 26 +++---------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/modules/autopairs/nvim-autopairs/nvim-autopairs.nix b/modules/autopairs/nvim-autopairs/nvim-autopairs.nix index 73b6bed..7e45606 100644 --- a/modules/autopairs/nvim-autopairs/nvim-autopairs.nix +++ b/modules/autopairs/nvim-autopairs/nvim-autopairs.nix @@ -1,10 +1,10 @@ {lib, ...}: let - inherit (lib) mkRenamedOptionModule; + inherit (lib) mkRemovedOptionModule; inherit (lib.options) mkEnableOption mkOption; - inherit (lib.types) enum bool; + inherit (lib.types) enum; in { imports = [ - # (mkRenamedOptionModule ["vim" "autopairs" "nvim-compe"] ["vim" "autopairs" "nvim-compe" "setupOpts"]) + (mkRemovedOptionModule ["vim" "autopairs" "nvim-compe"] "nvim-compe is deprecated and no longer suported.") ]; options.vim = { @@ -16,26 +16,6 @@ in { default = "nvim-autopairs"; description = "Set the autopairs type. Options: nvim-autopairs [nvim-autopairs]"; }; - - nvim-compe.setupOpts = lib.nvim.types.mkPluginSetupOption "nvim-compe" { - map_cr = mkOption { - type = bool; - default = true; - description = ''map on insert mode''; - }; - - map_complete = mkOption { - type = bool; - default = true; - description = "auto insert `(` after select function or method item"; - }; - - auto_select = mkOption { - type = bool; - default = false; - description = "auto select first item"; - }; - }; }; }; } From 01e35f98776623af5378f9562d33983e218ed36c Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 6 Apr 2024 18:07:53 +0000 Subject: [PATCH 079/193] fix: temp descriptions --- modules/utility/telescope/telescope.nix | 182 ++++++++++++++++++------ 1 file changed, 136 insertions(+), 46 deletions(-) diff --git a/modules/utility/telescope/telescope.nix b/modules/utility/telescope/telescope.nix index 27fa98a..bebe6c8 100644 --- a/modules/utility/telescope/telescope.nix +++ b/modules/utility/telescope/telescope.nix @@ -4,57 +4,147 @@ ... }: let inherit (lib.options) mkEnableOption mkOption; - inherit (lib.types) int str listOf float bool; + inherit (lib.types) int str listOf float bool either enum submodule attrsOf; inherit (lib.nvim.binds) mkMappingOption; - inherit (lib.nvim.types) mkPluginSetupOption; - mkOptOfType = type: default: - mkOption { - # TODO: description - description = "See plugin docs for more info"; - inherit type default; - }; - + inherit (lib.nvim.types) mkPluginSetupOption luaInline; setupOptions = { defaults = { - vimgrep_arguments = mkOptOfType (listOf str) [ - "${pkgs.ripgrep}/bin/rg" - "--color=never" - "--no-heading" - "--with-filename" - "--line-number" - "--column" - "--smart-case" - "--hidden" - "--no-ignore" - ]; - pickers.find_command = mkOptOfType (listOf str) ["${pkgs.fd}/bin/fd"]; - prompt_prefix = mkOptOfType str "  "; - selection_caret = mkOptOfType str " "; - entry_prefix = mkOptOfType str " "; - initial_mode = mkOptOfType str "insert"; - selection_strategy = mkOptOfType str "reset"; - sorting_strategy = mkOptOfType str "ascending"; - layout_strategy = mkOptOfType str "horizontal"; - layout_config = { - horizontal = { - prompt_position = mkOptOfType str "top"; - preview_width = mkOptOfType float 0.55; - results_width = mkOptOfType float 0.8; - }; - vertical = { - mirror = mkOptOfType bool false; - }; - width = mkOptOfType float 0.8; - height = mkOptOfType float 0.8; - preview_cutoff = mkOptOfType int 120; + vimgrep_arguments = mkOption { + description = '' + Defines the command that will be used for `live_grep` and `grep_string` pickers. + Make sure that color is set to `never` because telescope does not yet interpret color codes. + ''; + type = listOf str; + default = [ + "${pkgs.ripgrep}/bin/rg" + "--color=never" + "--no-heading" + "--with-filename" + "--line-number" + "--column" + "--smart-case" + "--hidden" + "--no-ignore" + ]; }; - file_ignore_patterns = mkOptOfType (listOf str) ["node_modules" ".git/" "dist/" "build/" "target/" "result/"]; - color_devicons = mkOptOfType bool true; - path_display = mkOptOfType (listOf str) ["absolute"]; - set_env = { - COLORTERM = mkOptOfType str "truecolor"; + pickers.find_command = mkOption { + description = "cmd to use for finding files"; + type = either (listOf str) luaInline; + default = ["${pkgs.fd}/bin/fd"]; + }; + prompt_prefix = mkOption { + description = "Shown in front of Telescope's prompt"; + type = str; + default = "  "; + }; + selection_caret = mkOption { + description = "Character(s) to show in front of the current selection"; + type = str; + default = " "; + }; + entry_prefix = mkOption { + description = "Prefix in front of each result entry. Current selection not included."; + type = str; + default = " "; + }; + initial_mode = mkOption { + description = "Determines in which mode telescope starts."; + type = enum ["insert" "normal"]; + default = "insert"; + }; + selection_strategy = mkOption { + description = "Determines how the cursor acts after each sort iteration."; + type = enum ["reset" "follow" "row" "closest" "none"]; + default = "reset"; + }; + sorting_strategy = mkOption { + description = ''Determines the direction "better" results are sorted towards.''; + type = enum ["descending" "ascending"]; + default = "ascending"; + }; + layout_strategy = mkOption { + description = "Determines the default layout of Telescope pickers. See `:help telescope.layout`."; + type = str; + default = "horizontal"; + }; + layout_config = mkOption { + description = '' + Determines the default configuration values for layout strategies. + See telescope.layout for details of the configurations options for + each strategy. + ''; + default = {}; + type = submodule { + options = { + horizontal = { + prompt_position = mkOption { + description = ""; + type = str; + default = "top"; + }; + preview_width = mkOption { + description = ""; + type = float; + default = 0.55; + }; + results_width = mkOption { + description = ""; + type = float; + default = 0.8; + }; + }; + vertical = { + mirror = mkOption { + description = ""; + type = bool; + default = false; + }; + }; + width = mkOption { + description = ""; + type = float; + default = 0.8; + }; + height = mkOption { + description = ""; + type = float; + default = 0.8; + }; + preview_cutoff = mkOption { + description = ""; + type = int; + default = 120; + }; + }; + }; + }; + file_ignore_patterns = mkOption { + description = "A table of lua regex that define the files that should be ignored."; + type = listOf str; + default = ["node_modules" ".git/" "dist/" "build/" "target/" "result/"]; + }; + color_devicons = mkOption { + description = "Boolean if devicons should be enabled or not."; + type = bool; + default = true; + }; + path_display = mkOption { + description = "Determines how file paths are displayed."; + type = listOf (enum ["hidden" "tail" "absolute" "smart" "shorten" "truncate"]); + default = ["absolute"]; + }; + set_env = mkOption { + description = "Set an envrionment for term_previewer"; + type = attrsOf str; + default = { + COLORTERM = "truecolor"; + }; + }; + winblend = mkOption { + description = "pseudo-transparency of keymap hints floating window"; + type = int; + default = 0; }; - winblend = mkOptOfType int 0; }; }; in { From 86443be8f17c39c7c6c5f5d3bacba761156fb877 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 6 Apr 2024 19:58:43 +0000 Subject: [PATCH 080/193] docs: update release notes --- docs/release-notes/rl-0.6.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/release-notes/rl-0.6.md b/docs/release-notes/rl-0.6.md index 532f5d9..95d4e94 100644 --- a/docs/release-notes/rl-0.6.md +++ b/docs/release-notes/rl-0.6.md @@ -12,6 +12,10 @@ Release notes for release 0.6 - Fixed empty winbar when breadcrumbs are disabled +- Added custom setupOpts for various plugins + +- Removed support for deprecated plugin "nvim-compe" + [donnerinoern](https://github.com/donnerinoern): - Added Gruvbox theme From 2be8db54d564fbeebde13417dbb71ee96a2077b8 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 6 Apr 2024 20:33:31 +0000 Subject: [PATCH 081/193] docs: developer docs on setupOpts --- docs/manual/hacking/additional-plugins.md | 92 +++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/docs/manual/hacking/additional-plugins.md b/docs/manual/hacking/additional-plugins.md index c70727d..07a972f 100644 --- a/docs/manual/hacking/additional-plugins.md +++ b/docs/manual/hacking/additional-plugins.md @@ -31,3 +31,95 @@ You can now reference this plugin using its string name: ```nix config.vim.startPlugins = ["neodev-nvim"]; ``` + +## Modular setup options {#sec-modular-setup-options} + +Most plugins is initialized with a call to `require('plugin').setup({...})`. + +We use a special function that lets you easily add support for such setup options in a modular way: +`mkPluginSetupOption`. + +Once you have added the source of the plugin as shown above, you can define the setup options like +this: + +```nix +# in modules/.../your-plugin/your-plugin.nix + +{lib, ...}: +let + inherit (lib.types) bool int; + inherit (lib.nvim.types) mkPluginSetupOption; +in { + options.vim.your-plugin = { + setupOpts = mkPluginSetupOption "plugin name" { + enable_feature_a = mkOption { + type = bool; + default = false; + # ... + }; + + number_option = mkOption { + type = int; + default = 3; + # ... + }; + }; + }; +} +``` + +```nix +# in modules/.../your-plugin/config.nix +{lib, config, ...}: +let + cfg = config.vim.your-plugin; +in { + vim.luaConfigRC = lib.nvim.dag.entryAnywhere '' + require('plugin-name').setup(${lib.nvim.lua.toLuaObject cfg.setupOpts}) + ''; +} +``` + +This above config will result in this lua script: + +```lua +require('plugin-name').setup({ + enable_feature_a = false, + number_option = 3, +}) +``` + +Now users can set any of the pre-defined option field, and can also add their own fields! + +```nix +# in user's config +{ + vim.your-plugin.setupOpts = { + enable_feature_a = true; + number_option = 4; + another_field = "hello"; + size = { # nested fields work as well + top = 10; + }; + }; +} +``` + +## Details of toLuaObject {#sec-details-of-toluaobject} + +As you've seen above, `toLuaObject` is used to convert our nix attrSet `cfg.setupOpts`, into a lua +table. Here are some rules of the conversion: + +1. nix `null` converts to lua `nil` +2. number and strings convert to their lua counterparts +3. nix attrSet/list converts into lua tables +4. you can write raw lua code using `lib.generators.mkLuaInline`. This function is part of nixpkgs. + ```nix + vim.your-plugin.setupOpts = { + on_init = lib.generators.mkLuaInline '' + function() + print('we can write lua!') + end + ''; + } + ``` From 7c730a78e5dab142e09feadac9bd9e4a23182ef3 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 7 Apr 2024 17:16:08 +0300 Subject: [PATCH 082/193] treewide: begin restructuring the module tree --- flake/modules/home-manager.nix | 20 +- lib/default.nix | 1 - modules/basic/config.nix | 188 --------- modules/core/build/config.nix | 322 ++++++++++++++ modules/{basic => core/build}/default.nix | 4 +- modules/core/build/options.nix | 87 ++++ modules/core/default.nix | 396 +----------------- modules/core/warnings/default.nix | 31 ++ modules/modules.nix | 75 ++-- .../module.nix => neovim/basic/configrc.nix} | 177 ++++++-- modules/neovim/basic/default.nix | 6 + modules/neovim/basic/spellcheck.nix | 38 ++ modules/neovim/config.nix | 5 + modules/neovim/default.nix | 8 + modules/neovim/mappings/default.nix | 55 +++ .../assistant/copilot/config.nix | 0 .../assistant/copilot/copilot.nix | 0 .../assistant/copilot/default.nix | 0 modules/{ => plugins}/assistant/default.nix | 0 modules/{ => plugins}/autopairs/default.nix | 0 .../autopairs/nvim-autopairs/config.nix | 0 .../autopairs/nvim-autopairs/default.nix | 0 .../nvim-autopairs/nvim-autopairs.nix | 0 .../comments/comment-nvim/comment-nvim.nix | 0 .../comments/comment-nvim/config.nix | 0 .../comments/comment-nvim/default.nix | 0 modules/{ => plugins}/comments/default.nix | 0 modules/{ => plugins}/completion/default.nix | 0 .../completion/nvim-cmp/config.nix | 0 .../completion/nvim-cmp/default.nix | 0 .../completion/nvim-cmp/nvim-cmp.nix | 0 .../{ => plugins}/dashboard/alpha/alpha.nix | 0 .../{ => plugins}/dashboard/alpha/config.nix | 0 .../{ => plugins}/dashboard/alpha/default.nix | 0 .../dashboard/dashboard-nvim/config.nix | 0 .../dashboard-nvim/dashboard-nvim.nix | 0 .../dashboard/dashboard-nvim/default.nix | 0 modules/{ => plugins}/dashboard/default.nix | 0 .../dashboard/startify/config.nix | 0 .../dashboard/startify/default.nix | 0 .../dashboard/startify/startify.nix | 0 modules/{ => plugins}/debugger/default.nix | 0 .../debugger/nvim-dap/config.nix | 0 .../debugger/nvim-dap/default.nix | 0 .../debugger/nvim-dap/nvim-dap.nix | 0 modules/{ => plugins}/filetree/default.nix | 0 .../filetree/nvimtree/config.nix | 0 .../filetree/nvimtree/default.nix | 0 .../filetree/nvimtree/nvimtree.nix | 0 modules/{ => plugins}/git/config.nix | 0 modules/{ => plugins}/git/default.nix | 0 modules/{ => plugins}/git/git.nix | 0 modules/{ => plugins}/languages/bash/bash.nix | 0 .../{ => plugins}/languages/bash/config.nix | 0 .../{ => plugins}/languages/bash/default.nix | 0 modules/{ => plugins}/languages/clang.nix | 0 modules/{ => plugins}/languages/css.nix | 0 .../{ => plugins}/languages/dart/config.nix | 0 modules/{ => plugins}/languages/dart/dart.nix | 0 .../{ => plugins}/languages/dart/default.nix | 0 modules/{ => plugins}/languages/default.nix | 0 .../{ => plugins}/languages/elixir/config.nix | 0 .../languages/elixir/default.nix | 0 .../languages/elixir/elixir-tools.nix | 0 modules/{ => plugins}/languages/go.nix | 0 modules/{ => plugins}/languages/html.nix | 0 modules/{ => plugins}/languages/java.nix | 0 modules/{ => plugins}/languages/lua.nix | 0 .../languages/markdown/config.nix | 0 .../languages/markdown/default.nix | 0 .../languages/markdown/markdown.nix | 0 modules/{ => plugins}/languages/nim.nix | 0 modules/{ => plugins}/languages/nix.nix | 0 modules/{ => plugins}/languages/php.nix | 0 modules/{ => plugins}/languages/python.nix | 0 modules/{ => plugins}/languages/rust.nix | 0 modules/{ => plugins}/languages/sql.nix | 0 modules/{ => plugins}/languages/svelte.nix | 0 modules/{ => plugins}/languages/tailwind.nix | 0 modules/{ => plugins}/languages/terraform.nix | 0 .../{ => plugins}/languages/tidal/config.nix | 0 .../{ => plugins}/languages/tidal/default.nix | 0 .../{ => plugins}/languages/tidal/tidal.nix | 0 modules/{ => plugins}/languages/ts.nix | 0 modules/{ => plugins}/languages/zig.nix | 0 modules/{ => plugins}/lsp/config.nix | 0 modules/{ => plugins}/lsp/default.nix | 0 .../{ => plugins}/lsp/lightbulb/config.nix | 0 .../{ => plugins}/lsp/lightbulb/default.nix | 0 .../{ => plugins}/lsp/lightbulb/lightbulb.nix | 0 .../lsp/lsp-signature/config.nix | 0 .../lsp/lsp-signature/default.nix | 0 .../lsp/lsp-signature/lsp-signature.nix | 0 .../{ => plugins}/lsp/lspconfig/config.nix | 0 .../{ => plugins}/lsp/lspconfig/default.nix | 0 .../{ => plugins}/lsp/lspconfig/lspconfig.nix | 0 modules/{ => plugins}/lsp/lspkind/config.nix | 0 modules/{ => plugins}/lsp/lspkind/default.nix | 0 modules/{ => plugins}/lsp/lspkind/lspkind.nix | 0 modules/{ => plugins}/lsp/lsplines/config.nix | 0 .../{ => plugins}/lsp/lsplines/default.nix | 0 .../{ => plugins}/lsp/lsplines/lsplines.nix | 0 modules/{ => plugins}/lsp/lspsaga/config.nix | 0 modules/{ => plugins}/lsp/lspsaga/default.nix | 0 modules/{ => plugins}/lsp/lspsaga/lspsaga.nix | 0 modules/{ => plugins}/lsp/module.nix | 0 modules/{ => plugins}/lsp/null-ls/config.nix | 0 modules/{ => plugins}/lsp/null-ls/default.nix | 0 modules/{ => plugins}/lsp/null-ls/null-ls.nix | 0 .../lsp/nvim-code-action-menu/config.nix | 0 .../lsp/nvim-code-action-menu/default.nix | 0 .../nvim-code-action-menu.nix | 0 .../lsp/nvim-docs-view/config.nix | 0 .../lsp/nvim-docs-view/default.nix | 0 .../lsp/nvim-docs-view/nvim-docs-view.nix | 0 modules/{ => plugins}/lsp/trouble/config.nix | 0 modules/{ => plugins}/lsp/trouble/default.nix | 0 modules/{ => plugins}/lsp/trouble/trouble.nix | 0 .../minimap/codewindow/codewindow.nix | 0 .../minimap/codewindow/config.nix | 0 .../minimap/codewindow/default.nix | 0 modules/{ => plugins}/minimap/default.nix | 0 .../minimap/minimap-vim/config.nix | 0 .../minimap/minimap-vim/default.nix | 0 .../minimap/minimap-vim/minimap-vim.nix | 0 modules/{ => plugins}/notes/default.nix | 0 .../{ => plugins}/notes/mind-nvim/config.nix | 0 .../{ => plugins}/notes/mind-nvim/default.nix | 0 .../notes/mind-nvim/mind-nvim.nix | 0 .../{ => plugins}/notes/obsidian/config.nix | 0 .../{ => plugins}/notes/obsidian/default.nix | 0 .../{ => plugins}/notes/obsidian/obsidian.nix | 0 .../{ => plugins}/notes/orgmode/config.nix | 0 .../{ => plugins}/notes/orgmode/default.nix | 0 .../{ => plugins}/notes/orgmode/orgmode.nix | 0 .../notes/todo-comments/config.nix | 0 .../notes/todo-comments/default.nix | 0 .../notes/todo-comments/todo-comments.nix | 0 modules/{ => plugins}/projects/default.nix | 0 .../projects/project-nvim/config.nix | 0 .../projects/project-nvim/default.nix | 0 .../projects/project-nvim/project-nvim.nix | 0 .../{ => plugins}/rich-presence/default.nix | 0 .../rich-presence/neocord/config.nix | 0 .../rich-presence/neocord/default.nix | 0 .../rich-presence/neocord/neocord.nix | 0 modules/{ => plugins}/session/default.nix | 0 .../session/nvim-session-manager/config.nix | 0 .../session/nvim-session-manager/default.nix | 0 .../nvim-session-manager.nix | 0 modules/{ => plugins}/snippets/default.nix | 0 .../{ => plugins}/snippets/vsnip/config.nix | 0 .../{ => plugins}/snippets/vsnip/default.nix | 0 .../{ => plugins}/snippets/vsnip/vsnip.nix | 0 modules/{ => plugins}/statusline/default.nix | 0 .../statusline/lualine/config.nix | 0 .../statusline/lualine/default.nix | 0 .../statusline/lualine/lualine.nix | 0 .../statusline/lualine/supported_themes.nix | 0 modules/{ => plugins}/tabline/default.nix | 0 .../tabline/nvim-bufferline/config.nix | 0 .../tabline/nvim-bufferline/default.nix | 0 .../nvim-bufferline/nvim-bufferline.nix | 0 modules/{ => plugins}/terminal/default.nix | 0 .../terminal/toggleterm/config.nix | 0 .../terminal/toggleterm/default.nix | 0 .../terminal/toggleterm/toggleterm.nix | 0 modules/{ => plugins}/theme/config.nix | 0 modules/{ => plugins}/theme/default.nix | 0 .../{ => plugins}/theme/supported_themes.nix | 0 modules/{ => plugins}/theme/theme.nix | 0 modules/{ => plugins}/treesitter/config.nix | 0 modules/{ => plugins}/treesitter/context.nix | 0 modules/{ => plugins}/treesitter/default.nix | 0 .../{ => plugins}/treesitter/treesitter.nix | 0 modules/{ => plugins}/ui/borders/borders.nix | 0 modules/{ => plugins}/ui/borders/default.nix | 0 .../ui/breadcrumbs/breadcrumbs.nix | 0 .../{ => plugins}/ui/breadcrumbs/config.nix | 0 .../{ => plugins}/ui/breadcrumbs/default.nix | 0 .../{ => plugins}/ui/colorizer/colorizer.nix | 0 modules/{ => plugins}/ui/colorizer/config.nix | 0 .../{ => plugins}/ui/colorizer/default.nix | 0 modules/{ => plugins}/ui/default.nix | 0 .../{ => plugins}/ui/illuminate/config.nix | 0 .../{ => plugins}/ui/illuminate/default.nix | 0 .../ui/illuminate/illuminate.nix | 0 modules/{ => plugins}/ui/modes/config.nix | 0 modules/{ => plugins}/ui/modes/default.nix | 0 modules/{ => plugins}/ui/modes/modes.nix | 0 modules/{ => plugins}/ui/noice/config.nix | 0 modules/{ => plugins}/ui/noice/default.nix | 0 modules/{ => plugins}/ui/noice/noice.nix | 0 .../ui/notifications/default.nix | 0 .../ui/notifications/nvim-notify/config.nix | 0 .../ui/notifications/nvim-notify/default.nix | 0 .../notifications/nvim-notify/nvim-notify.nix | 0 .../{ => plugins}/ui/smartcolumn/config.nix | 0 .../{ => plugins}/ui/smartcolumn/default.nix | 0 .../ui/smartcolumn/smartcolumn.nix | 0 .../utility/binds/cheatsheet/cheatsheet.nix | 0 .../utility/binds/cheatsheet/config.nix | 0 .../utility/binds/cheatsheet/default.nix | 0 .../{ => plugins}/utility/binds/default.nix | 0 .../utility/binds/which-key/config.nix | 0 .../utility/binds/which-key/default.nix | 0 .../utility/binds/which-key/which-key.nix | 0 modules/{ => plugins}/utility/ccc/ccc.nix | 0 modules/{ => plugins}/utility/ccc/config.nix | 0 modules/{ => plugins}/utility/ccc/default.nix | 0 modules/{ => plugins}/utility/default.nix | 0 .../{ => plugins}/utility/diffview/config.nix | 0 .../utility/diffview/default.nix | 0 .../utility/diffview/diffview.nix | 0 .../utility/gestures/default.nix | 0 .../utility/gestures/gesture-nvim/config.nix | 0 .../utility/gestures/gesture-nvim/default.nix | 0 .../gestures/gesture-nvim/gesture-nvim.nix | 0 .../utility/icon-picker/config.nix | 0 .../utility/icon-picker/default.nix | 0 .../utility/icon-picker/icon-picker.nix | 0 .../{ => plugins}/utility/images/default.nix | 0 .../utility/images/image-nvim/config.nix | 0 .../utility/images/image-nvim/default.nix | 0 .../utility/images/image-nvim/image-nvim.nix | 0 .../{ => plugins}/utility/motion/default.nix | 0 .../utility/motion/hop/config.nix | 0 .../utility/motion/hop/default.nix | 0 .../{ => plugins}/utility/motion/hop/hop.nix | 0 .../utility/motion/leap/config.nix | 0 .../utility/motion/leap/default.nix | 0 .../utility/motion/leap/leap.nix | 0 .../{ => plugins}/utility/preview/default.nix | 0 .../utility/preview/glow/config.nix | 0 .../utility/preview/glow/default.nix | 0 .../utility/preview/glow/glow.nix | 0 .../preview/markdown-preview/config.nix | 0 .../preview/markdown-preview/default.nix | 0 .../markdown-preview/markdown-preview.nix | 0 .../{ => plugins}/utility/surround/config.nix | 0 .../utility/surround/default.nix | 0 .../utility/surround/surround.nix | 0 .../utility/telescope/config.nix | 0 .../utility/telescope/default.nix | 0 .../utility/telescope/telescope.nix | 0 .../{ => plugins}/utility/wakatime/config.nix | 0 .../utility/wakatime/default.nix | 0 .../utility/wakatime/vim-wakatime.nix | 0 modules/{ => plugins}/visuals/config.nix | 0 modules/{ => plugins}/visuals/default.nix | 0 .../{ => plugins}/visuals/fidget/config.nix | 0 .../{ => plugins}/visuals/fidget/default.nix | 0 .../{ => plugins}/visuals/fidget/fidget.nix | 0 modules/{ => plugins}/visuals/visuals.nix | 0 254 files changed, 749 insertions(+), 664 deletions(-) delete mode 100644 modules/basic/config.nix create mode 100644 modules/core/build/config.nix rename modules/{basic => core/build}/default.nix (63%) create mode 100644 modules/core/build/options.nix create mode 100644 modules/core/warnings/default.nix rename modules/{basic/module.nix => neovim/basic/configrc.nix} (54%) create mode 100644 modules/neovim/basic/default.nix create mode 100644 modules/neovim/basic/spellcheck.nix create mode 100644 modules/neovim/config.nix create mode 100644 modules/neovim/default.nix create mode 100644 modules/neovim/mappings/default.nix rename modules/{ => plugins}/assistant/copilot/config.nix (100%) rename modules/{ => plugins}/assistant/copilot/copilot.nix (100%) rename modules/{ => plugins}/assistant/copilot/default.nix (100%) rename modules/{ => plugins}/assistant/default.nix (100%) rename modules/{ => plugins}/autopairs/default.nix (100%) rename modules/{ => plugins}/autopairs/nvim-autopairs/config.nix (100%) rename modules/{ => plugins}/autopairs/nvim-autopairs/default.nix (100%) rename modules/{ => plugins}/autopairs/nvim-autopairs/nvim-autopairs.nix (100%) rename modules/{ => plugins}/comments/comment-nvim/comment-nvim.nix (100%) rename modules/{ => plugins}/comments/comment-nvim/config.nix (100%) rename modules/{ => plugins}/comments/comment-nvim/default.nix (100%) rename modules/{ => plugins}/comments/default.nix (100%) rename modules/{ => plugins}/completion/default.nix (100%) rename modules/{ => plugins}/completion/nvim-cmp/config.nix (100%) rename modules/{ => plugins}/completion/nvim-cmp/default.nix (100%) rename modules/{ => plugins}/completion/nvim-cmp/nvim-cmp.nix (100%) rename modules/{ => plugins}/dashboard/alpha/alpha.nix (100%) rename modules/{ => plugins}/dashboard/alpha/config.nix (100%) rename modules/{ => plugins}/dashboard/alpha/default.nix (100%) rename modules/{ => plugins}/dashboard/dashboard-nvim/config.nix (100%) rename modules/{ => plugins}/dashboard/dashboard-nvim/dashboard-nvim.nix (100%) rename modules/{ => plugins}/dashboard/dashboard-nvim/default.nix (100%) rename modules/{ => plugins}/dashboard/default.nix (100%) rename modules/{ => plugins}/dashboard/startify/config.nix (100%) rename modules/{ => plugins}/dashboard/startify/default.nix (100%) rename modules/{ => plugins}/dashboard/startify/startify.nix (100%) rename modules/{ => plugins}/debugger/default.nix (100%) rename modules/{ => plugins}/debugger/nvim-dap/config.nix (100%) rename modules/{ => plugins}/debugger/nvim-dap/default.nix (100%) rename modules/{ => plugins}/debugger/nvim-dap/nvim-dap.nix (100%) rename modules/{ => plugins}/filetree/default.nix (100%) rename modules/{ => plugins}/filetree/nvimtree/config.nix (100%) rename modules/{ => plugins}/filetree/nvimtree/default.nix (100%) rename modules/{ => plugins}/filetree/nvimtree/nvimtree.nix (100%) rename modules/{ => plugins}/git/config.nix (100%) rename modules/{ => plugins}/git/default.nix (100%) rename modules/{ => plugins}/git/git.nix (100%) rename modules/{ => plugins}/languages/bash/bash.nix (100%) rename modules/{ => plugins}/languages/bash/config.nix (100%) rename modules/{ => plugins}/languages/bash/default.nix (100%) rename modules/{ => plugins}/languages/clang.nix (100%) rename modules/{ => plugins}/languages/css.nix (100%) rename modules/{ => plugins}/languages/dart/config.nix (100%) rename modules/{ => plugins}/languages/dart/dart.nix (100%) rename modules/{ => plugins}/languages/dart/default.nix (100%) rename modules/{ => plugins}/languages/default.nix (100%) rename modules/{ => plugins}/languages/elixir/config.nix (100%) rename modules/{ => plugins}/languages/elixir/default.nix (100%) rename modules/{ => plugins}/languages/elixir/elixir-tools.nix (100%) rename modules/{ => plugins}/languages/go.nix (100%) rename modules/{ => plugins}/languages/html.nix (100%) rename modules/{ => plugins}/languages/java.nix (100%) rename modules/{ => plugins}/languages/lua.nix (100%) rename modules/{ => plugins}/languages/markdown/config.nix (100%) rename modules/{ => plugins}/languages/markdown/default.nix (100%) rename modules/{ => plugins}/languages/markdown/markdown.nix (100%) rename modules/{ => plugins}/languages/nim.nix (100%) rename modules/{ => plugins}/languages/nix.nix (100%) rename modules/{ => plugins}/languages/php.nix (100%) rename modules/{ => plugins}/languages/python.nix (100%) rename modules/{ => plugins}/languages/rust.nix (100%) rename modules/{ => plugins}/languages/sql.nix (100%) rename modules/{ => plugins}/languages/svelte.nix (100%) rename modules/{ => plugins}/languages/tailwind.nix (100%) rename modules/{ => plugins}/languages/terraform.nix (100%) rename modules/{ => plugins}/languages/tidal/config.nix (100%) rename modules/{ => plugins}/languages/tidal/default.nix (100%) rename modules/{ => plugins}/languages/tidal/tidal.nix (100%) rename modules/{ => plugins}/languages/ts.nix (100%) rename modules/{ => plugins}/languages/zig.nix (100%) rename modules/{ => plugins}/lsp/config.nix (100%) rename modules/{ => plugins}/lsp/default.nix (100%) rename modules/{ => plugins}/lsp/lightbulb/config.nix (100%) rename modules/{ => plugins}/lsp/lightbulb/default.nix (100%) rename modules/{ => plugins}/lsp/lightbulb/lightbulb.nix (100%) rename modules/{ => plugins}/lsp/lsp-signature/config.nix (100%) rename modules/{ => plugins}/lsp/lsp-signature/default.nix (100%) rename modules/{ => plugins}/lsp/lsp-signature/lsp-signature.nix (100%) rename modules/{ => plugins}/lsp/lspconfig/config.nix (100%) rename modules/{ => plugins}/lsp/lspconfig/default.nix (100%) rename modules/{ => plugins}/lsp/lspconfig/lspconfig.nix (100%) rename modules/{ => plugins}/lsp/lspkind/config.nix (100%) rename modules/{ => plugins}/lsp/lspkind/default.nix (100%) rename modules/{ => plugins}/lsp/lspkind/lspkind.nix (100%) rename modules/{ => plugins}/lsp/lsplines/config.nix (100%) rename modules/{ => plugins}/lsp/lsplines/default.nix (100%) rename modules/{ => plugins}/lsp/lsplines/lsplines.nix (100%) rename modules/{ => plugins}/lsp/lspsaga/config.nix (100%) rename modules/{ => plugins}/lsp/lspsaga/default.nix (100%) rename modules/{ => plugins}/lsp/lspsaga/lspsaga.nix (100%) rename modules/{ => plugins}/lsp/module.nix (100%) rename modules/{ => plugins}/lsp/null-ls/config.nix (100%) rename modules/{ => plugins}/lsp/null-ls/default.nix (100%) rename modules/{ => plugins}/lsp/null-ls/null-ls.nix (100%) rename modules/{ => plugins}/lsp/nvim-code-action-menu/config.nix (100%) rename modules/{ => plugins}/lsp/nvim-code-action-menu/default.nix (100%) rename modules/{ => plugins}/lsp/nvim-code-action-menu/nvim-code-action-menu.nix (100%) rename modules/{ => plugins}/lsp/nvim-docs-view/config.nix (100%) rename modules/{ => plugins}/lsp/nvim-docs-view/default.nix (100%) rename modules/{ => plugins}/lsp/nvim-docs-view/nvim-docs-view.nix (100%) rename modules/{ => plugins}/lsp/trouble/config.nix (100%) rename modules/{ => plugins}/lsp/trouble/default.nix (100%) rename modules/{ => plugins}/lsp/trouble/trouble.nix (100%) rename modules/{ => plugins}/minimap/codewindow/codewindow.nix (100%) rename modules/{ => plugins}/minimap/codewindow/config.nix (100%) rename modules/{ => plugins}/minimap/codewindow/default.nix (100%) rename modules/{ => plugins}/minimap/default.nix (100%) rename modules/{ => plugins}/minimap/minimap-vim/config.nix (100%) rename modules/{ => plugins}/minimap/minimap-vim/default.nix (100%) rename modules/{ => plugins}/minimap/minimap-vim/minimap-vim.nix (100%) rename modules/{ => plugins}/notes/default.nix (100%) rename modules/{ => plugins}/notes/mind-nvim/config.nix (100%) rename modules/{ => plugins}/notes/mind-nvim/default.nix (100%) rename modules/{ => plugins}/notes/mind-nvim/mind-nvim.nix (100%) rename modules/{ => plugins}/notes/obsidian/config.nix (100%) rename modules/{ => plugins}/notes/obsidian/default.nix (100%) rename modules/{ => plugins}/notes/obsidian/obsidian.nix (100%) rename modules/{ => plugins}/notes/orgmode/config.nix (100%) rename modules/{ => plugins}/notes/orgmode/default.nix (100%) rename modules/{ => plugins}/notes/orgmode/orgmode.nix (100%) rename modules/{ => plugins}/notes/todo-comments/config.nix (100%) rename modules/{ => plugins}/notes/todo-comments/default.nix (100%) rename modules/{ => plugins}/notes/todo-comments/todo-comments.nix (100%) rename modules/{ => plugins}/projects/default.nix (100%) rename modules/{ => plugins}/projects/project-nvim/config.nix (100%) rename modules/{ => plugins}/projects/project-nvim/default.nix (100%) rename modules/{ => plugins}/projects/project-nvim/project-nvim.nix (100%) rename modules/{ => plugins}/rich-presence/default.nix (100%) rename modules/{ => plugins}/rich-presence/neocord/config.nix (100%) rename modules/{ => plugins}/rich-presence/neocord/default.nix (100%) rename modules/{ => plugins}/rich-presence/neocord/neocord.nix (100%) rename modules/{ => plugins}/session/default.nix (100%) rename modules/{ => plugins}/session/nvim-session-manager/config.nix (100%) rename modules/{ => plugins}/session/nvim-session-manager/default.nix (100%) rename modules/{ => plugins}/session/nvim-session-manager/nvim-session-manager.nix (100%) rename modules/{ => plugins}/snippets/default.nix (100%) rename modules/{ => plugins}/snippets/vsnip/config.nix (100%) rename modules/{ => plugins}/snippets/vsnip/default.nix (100%) rename modules/{ => plugins}/snippets/vsnip/vsnip.nix (100%) rename modules/{ => plugins}/statusline/default.nix (100%) rename modules/{ => plugins}/statusline/lualine/config.nix (100%) rename modules/{ => plugins}/statusline/lualine/default.nix (100%) rename modules/{ => plugins}/statusline/lualine/lualine.nix (100%) rename modules/{ => plugins}/statusline/lualine/supported_themes.nix (100%) rename modules/{ => plugins}/tabline/default.nix (100%) rename modules/{ => plugins}/tabline/nvim-bufferline/config.nix (100%) rename modules/{ => plugins}/tabline/nvim-bufferline/default.nix (100%) rename modules/{ => plugins}/tabline/nvim-bufferline/nvim-bufferline.nix (100%) rename modules/{ => plugins}/terminal/default.nix (100%) rename modules/{ => plugins}/terminal/toggleterm/config.nix (100%) rename modules/{ => plugins}/terminal/toggleterm/default.nix (100%) rename modules/{ => plugins}/terminal/toggleterm/toggleterm.nix (100%) rename modules/{ => plugins}/theme/config.nix (100%) rename modules/{ => plugins}/theme/default.nix (100%) rename modules/{ => plugins}/theme/supported_themes.nix (100%) rename modules/{ => plugins}/theme/theme.nix (100%) rename modules/{ => plugins}/treesitter/config.nix (100%) rename modules/{ => plugins}/treesitter/context.nix (100%) rename modules/{ => plugins}/treesitter/default.nix (100%) rename modules/{ => plugins}/treesitter/treesitter.nix (100%) rename modules/{ => plugins}/ui/borders/borders.nix (100%) rename modules/{ => plugins}/ui/borders/default.nix (100%) rename modules/{ => plugins}/ui/breadcrumbs/breadcrumbs.nix (100%) rename modules/{ => plugins}/ui/breadcrumbs/config.nix (100%) rename modules/{ => plugins}/ui/breadcrumbs/default.nix (100%) rename modules/{ => plugins}/ui/colorizer/colorizer.nix (100%) rename modules/{ => plugins}/ui/colorizer/config.nix (100%) rename modules/{ => plugins}/ui/colorizer/default.nix (100%) rename modules/{ => plugins}/ui/default.nix (100%) rename modules/{ => plugins}/ui/illuminate/config.nix (100%) rename modules/{ => plugins}/ui/illuminate/default.nix (100%) rename modules/{ => plugins}/ui/illuminate/illuminate.nix (100%) rename modules/{ => plugins}/ui/modes/config.nix (100%) rename modules/{ => plugins}/ui/modes/default.nix (100%) rename modules/{ => plugins}/ui/modes/modes.nix (100%) rename modules/{ => plugins}/ui/noice/config.nix (100%) rename modules/{ => plugins}/ui/noice/default.nix (100%) rename modules/{ => plugins}/ui/noice/noice.nix (100%) rename modules/{ => plugins}/ui/notifications/default.nix (100%) rename modules/{ => plugins}/ui/notifications/nvim-notify/config.nix (100%) rename modules/{ => plugins}/ui/notifications/nvim-notify/default.nix (100%) rename modules/{ => plugins}/ui/notifications/nvim-notify/nvim-notify.nix (100%) rename modules/{ => plugins}/ui/smartcolumn/config.nix (100%) rename modules/{ => plugins}/ui/smartcolumn/default.nix (100%) rename modules/{ => plugins}/ui/smartcolumn/smartcolumn.nix (100%) rename modules/{ => plugins}/utility/binds/cheatsheet/cheatsheet.nix (100%) rename modules/{ => plugins}/utility/binds/cheatsheet/config.nix (100%) rename modules/{ => plugins}/utility/binds/cheatsheet/default.nix (100%) rename modules/{ => plugins}/utility/binds/default.nix (100%) rename modules/{ => plugins}/utility/binds/which-key/config.nix (100%) rename modules/{ => plugins}/utility/binds/which-key/default.nix (100%) rename modules/{ => plugins}/utility/binds/which-key/which-key.nix (100%) rename modules/{ => plugins}/utility/ccc/ccc.nix (100%) rename modules/{ => plugins}/utility/ccc/config.nix (100%) rename modules/{ => plugins}/utility/ccc/default.nix (100%) rename modules/{ => plugins}/utility/default.nix (100%) rename modules/{ => plugins}/utility/diffview/config.nix (100%) rename modules/{ => plugins}/utility/diffview/default.nix (100%) rename modules/{ => plugins}/utility/diffview/diffview.nix (100%) rename modules/{ => plugins}/utility/gestures/default.nix (100%) rename modules/{ => plugins}/utility/gestures/gesture-nvim/config.nix (100%) rename modules/{ => plugins}/utility/gestures/gesture-nvim/default.nix (100%) rename modules/{ => plugins}/utility/gestures/gesture-nvim/gesture-nvim.nix (100%) rename modules/{ => plugins}/utility/icon-picker/config.nix (100%) rename modules/{ => plugins}/utility/icon-picker/default.nix (100%) rename modules/{ => plugins}/utility/icon-picker/icon-picker.nix (100%) rename modules/{ => plugins}/utility/images/default.nix (100%) rename modules/{ => plugins}/utility/images/image-nvim/config.nix (100%) rename modules/{ => plugins}/utility/images/image-nvim/default.nix (100%) rename modules/{ => plugins}/utility/images/image-nvim/image-nvim.nix (100%) rename modules/{ => plugins}/utility/motion/default.nix (100%) rename modules/{ => plugins}/utility/motion/hop/config.nix (100%) rename modules/{ => plugins}/utility/motion/hop/default.nix (100%) rename modules/{ => plugins}/utility/motion/hop/hop.nix (100%) rename modules/{ => plugins}/utility/motion/leap/config.nix (100%) rename modules/{ => plugins}/utility/motion/leap/default.nix (100%) rename modules/{ => plugins}/utility/motion/leap/leap.nix (100%) rename modules/{ => plugins}/utility/preview/default.nix (100%) rename modules/{ => plugins}/utility/preview/glow/config.nix (100%) rename modules/{ => plugins}/utility/preview/glow/default.nix (100%) rename modules/{ => plugins}/utility/preview/glow/glow.nix (100%) rename modules/{ => plugins}/utility/preview/markdown-preview/config.nix (100%) rename modules/{ => plugins}/utility/preview/markdown-preview/default.nix (100%) rename modules/{ => plugins}/utility/preview/markdown-preview/markdown-preview.nix (100%) rename modules/{ => plugins}/utility/surround/config.nix (100%) rename modules/{ => plugins}/utility/surround/default.nix (100%) rename modules/{ => plugins}/utility/surround/surround.nix (100%) rename modules/{ => plugins}/utility/telescope/config.nix (100%) rename modules/{ => plugins}/utility/telescope/default.nix (100%) rename modules/{ => plugins}/utility/telescope/telescope.nix (100%) rename modules/{ => plugins}/utility/wakatime/config.nix (100%) rename modules/{ => plugins}/utility/wakatime/default.nix (100%) rename modules/{ => plugins}/utility/wakatime/vim-wakatime.nix (100%) rename modules/{ => plugins}/visuals/config.nix (100%) rename modules/{ => plugins}/visuals/default.nix (100%) rename modules/{ => plugins}/visuals/fidget/config.nix (100%) rename modules/{ => plugins}/visuals/fidget/default.nix (100%) rename modules/{ => plugins}/visuals/fidget/fidget.nix (100%) rename modules/{ => plugins}/visuals/visuals.nix (100%) diff --git a/flake/modules/home-manager.nix b/flake/modules/home-manager.nix index 7da3e2a..66246e3 100644 --- a/flake/modules/home-manager.nix +++ b/flake/modules/home-manager.nix @@ -1,15 +1,19 @@ # Home Manager module packages: inputs: { - pkgs, config, + pkgs, lib ? pkgs.lib, - self, ... -}: -with lib; let +}: let + inherit (lib) maintainers; + inherit (lib.modules) mkIf; + inherit (lib.options) mkOption mkEnableOption literalExpression; + inherit (lib.types) attrsOf anything; + cfg = config.programs.neovim-flake; inherit (import ../../configuration.nix inputs) neovimConfiguration; - set = neovimConfiguration { + + builtPackage = neovimConfiguration { inherit pkgs; modules = [cfg.settings]; }; @@ -17,10 +21,10 @@ in { meta.maintainers = with maintainers; [NotAShelf]; options.programs.neovim-flake = { - enable = mkEnableOption "A NeoVim IDE with a focus on configurability and extensibility."; + enable = mkEnableOption "neovim-flake, the extensible neovim-wrapper"; settings = mkOption { - type = types.attrsOf types.anything; + type = attrsOf anything; default = {}; example = literalExpression '' { @@ -44,6 +48,6 @@ in { }; config = mkIf cfg.enable { - home.packages = [set.neovim]; + home.packages = [builtPackage]; }; } diff --git a/lib/default.nix b/lib/default.nix index 94db90b..333e832 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,6 +1,5 @@ {lib}: { types = import ./types {inherit lib;}; - binds = import ./binds.nix {inherit lib;}; dag = import ./dag.nix {inherit lib;}; languages = import ./languages.nix {inherit lib;}; diff --git a/modules/basic/config.nix b/modules/basic/config.nix deleted file mode 100644 index a74a6a9..0000000 --- a/modules/basic/config.nix +++ /dev/null @@ -1,188 +0,0 @@ -{ - lib, - config, - ... -}: let - inherit (builtins) concatStringsSep; - inherit (lib.modules) mkIf; - inherit (lib.lists) optionals; - inherit (lib.strings) optionalString; - inherit (lib.nvim.dag) entryAfter; - - cfg = config.vim; -in { - config = { - vim.startPlugins = ["plenary-nvim"] ++ optionals (cfg.spellChecking.enableProgrammingWordList) ["vim-dirtytalk"]; - - vim.maps.normal = - mkIf cfg.disableArrows { - "" = { - action = ""; - - noremap = false; - }; - "" = { - action = ""; - - noremap = false; - }; - "" = { - action = ""; - noremap = false; - }; - "" = { - action = ""; - noremap = false; - }; - } - // mkIf cfg.mapLeaderSpace { - "" = { - action = ""; - }; - }; - - vim.maps.insert = mkIf cfg.disableArrows { - "" = { - action = ""; - noremap = false; - }; - "" = { - action = ""; - noremap = false; - }; - "" = { - action = ""; - noremap = false; - }; - "" = { - action = ""; - noremap = false; - }; - }; - - vim.configRC.basic = entryAfter ["globalsScript"] '' - " Settings that are set for everything - set encoding=utf-8 - set mouse=${cfg.mouseSupport} - set tabstop=${toString cfg.tabWidth} - set shiftwidth=${toString cfg.tabWidth} - set softtabstop=${toString cfg.tabWidth} - set expandtab - set cmdheight=${toString cfg.cmdHeight} - set updatetime=${toString cfg.updateTime} - set shortmess+=c - set tm=${toString cfg.mapTimeout} - set hidden - set cursorlineopt=${toString cfg.cursorlineOpt} - set scrolloff=${toString cfg.scrollOffset} - - ${optionalString cfg.debugMode.enable '' - " Debug mode settings - set verbose=${toString cfg.debugMode.level} - set verbosefile=${cfg.debugMode.logFile} - ''} - - ${optionalString cfg.splitBelow '' - set splitbelow - ''} - - ${optionalString cfg.splitRight '' - set splitright - ''} - - ${optionalString cfg.showSignColumn '' - set signcolumn=yes - ''} - - ${optionalString cfg.autoIndent '' - set autoindent - ''} - - ${optionalString cfg.preventJunkFiles '' - set noswapfile - set nobackup - set nowritebackup - ''} - - ${optionalString (cfg.bell == "none") '' - set noerrorbells - set novisualbell - ''} - - ${optionalString (cfg.bell == "on") '' - set novisualbell - ''} - - ${optionalString (cfg.bell == "visual") '' - set noerrorbells - ''} - - ${optionalString (cfg.lineNumberMode == "relative") '' - set relativenumber - ''} - - ${optionalString (cfg.lineNumberMode == "number") '' - set number - ''} - - ${optionalString (cfg.lineNumberMode == "relNumber") '' - set number relativenumber - ''} - - ${optionalString cfg.useSystemClipboard '' - set clipboard+=unnamedplus - ''} - - ${optionalString cfg.mapLeaderSpace '' - let mapleader=" " - let maplocalleader=" " - ''} - - ${optionalString cfg.syntaxHighlighting '' - syntax on - ''} - - ${optionalString (!cfg.wordWrap) '' - set nowrap - ''} - - ${optionalString cfg.hideSearchHighlight '' - set nohlsearch - set incsearch - ''} - - ${optionalString cfg.colourTerm '' - set termguicolors - set t_Co=256 - ''} - - ${optionalString (!cfg.enableEditorconfig) '' - let g:editorconfig = v:false - ''} - - ${optionalString cfg.spellChecking.enable '' - set spell - set spelllang=${concatStringsSep "," cfg.spellChecking.languages}${optionalString cfg.spellChecking.enableProgrammingWordList ",programming"} - ''} - - ${optionalString (cfg.leaderKey != null) '' - let mapleader = "${toString cfg.leaderKey}" - ''} - - ${optionalString (cfg.searchCase == "ignore") '' - set nosmartcase - set ignorecase - ''} - - ${optionalString (cfg.searchCase == "smart") '' - set smartcase - set ignorecase - ''} - - ${optionalString (cfg.searchCase == "sensitive") '' - set nosmartcase - set noignorecase - ''} - ''; - }; -} diff --git a/modules/core/build/config.nix b/modules/core/build/config.nix new file mode 100644 index 0000000..068319e --- /dev/null +++ b/modules/core/build/config.nix @@ -0,0 +1,322 @@ +{ + config, + lib, + ... +}: let + inherit (builtins) attrValues attrNames map mapAttrs toJSON isString concatStringsSep filter; + inherit (lib.options) mkOption; + inherit (lib.attrsets) filterAttrs getAttrs; + inherit (lib.strings) optionalString; + inherit (lib.misc) mapAttrsFlatten; + inherit (lib.trivial) showWarnings; + inherit (lib.types) bool str oneOf attrsOf nullOr attrs submodule lines; + inherit (lib.nvim.types) dagOf; + inherit (lib.nvim.dag) entryAnywhere entryAfter topoSort; + inherit (lib.generators) mkLuaInline; + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.nvim.vim) valToVim; + + cfg = config.vim; + + wrapLuaConfig = luaConfig: '' + lua << EOF + ${optionalString cfg.enableLuaLoader '' + vim.loader.enable() + ''} + ${luaConfig} + EOF + ''; + + mkBool = value: description: + mkOption { + type = bool; + default = value; + inherit description; + }; + + # Most of the keybindings code is highly inspired by pta2002/nixvim. Thank you! + mapConfigOptions = { + silent = + mkBool false + "Whether this mapping should be silent. Equivalent to adding to a map."; + + nowait = + mkBool false + "Whether to wait for extra input on ambiguous mappings. Equivalent to adding to a map."; + + script = + mkBool false + "Equivalent to adding