From 3c174e874c06a3f86cd911e5bb48ca38fe958b51 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Fri, 9 Feb 2024 14:21:22 +0100 Subject: [PATCH] helpers/vim-plugin/mkVimPlugin: refactor --- lib/vim-plugin.nix | 6 +- plugins/completion/copilot-vim.nix | 67 +-- plugins/completion/nvim-cmp/cmp-helpers.nix | 2 +- plugins/git/fugitive.nix | 25 +- plugins/languages/ledger.nix | 8 +- plugins/languages/markdown-preview.nix | 9 +- plugins/languages/nix.nix | 23 +- plugins/languages/tagbar.nix | 19 +- plugins/languages/vim-slime.nix | 236 +++++----- plugins/languages/zig.nix | 36 +- plugins/statuslines/airline.nix | 8 +- plugins/utils/emmet.nix | 56 +-- plugins/utils/endwise.nix | 23 +- plugins/utils/goyo.nix | 58 +-- plugins/utils/instant.nix | 8 +- plugins/utils/magma-nvim.nix | 8 +- plugins/utils/molten.nix | 408 +++++++++--------- plugins/utils/startify.nix | 454 ++++++++++---------- plugins/utils/surround.nix | 21 +- plugins/utils/undotree.nix | 8 +- 20 files changed, 739 insertions(+), 744 deletions(-) diff --git a/lib/vim-plugin.nix b/lib/vim-plugin.nix index 62a5308b..045f4e61 100644 --- a/lib/vim-plugin.nix +++ b/lib/vim-plugin.nix @@ -3,11 +3,7 @@ nixvimOptions, }: with lib; { - mkVimPlugin = { - config, - lib, - ... - }: { + mkVimPlugin = config: { name, description ? null, package ? null, diff --git a/plugins/completion/copilot-vim.nix b/plugins/completion/copilot-vim.nix index 4d622415..0ad97dc3 100644 --- a/plugins/completion/copilot-vim.nix +++ b/plugins/completion/copilot-vim.nix @@ -1,42 +1,43 @@ { lib, + config, + helpers, pkgs, ... -} @ args: -with lib; ( - with (import ../helpers.nix {inherit lib;}).vim-plugin; - mkVimPlugin args { - name = "copilot-vim"; - description = "copilot.vim"; - package = pkgs.vimPlugins.copilot-vim; - globalPrefix = "copilot_"; +}: +with lib; +with helpers.vim-plugin; + helpers.vim-plugin.mkVimPlugin config { + name = "copilot-vim"; + description = "copilot.vim"; + package = pkgs.vimPlugins.copilot-vim; + globalPrefix = "copilot_"; - options = { - nodeCommand = mkDefaultOpt { - global = "node_command"; - type = types.str; - default = "${pkgs.nodejs-18_x}/bin/node"; - description = "Tell Copilot what `node` binary to use."; - }; + options = { + nodeCommand = mkDefaultOpt { + global = "node_command"; + type = types.str; + default = "${pkgs.nodejs-18_x}/bin/node"; + description = "Tell Copilot what `node` binary to use."; + }; - filetypes = mkDefaultOpt { - type = with types; attrsOf bool; - description = '' - A dictionary mapping file types to their enabled status + filetypes = mkDefaultOpt { + type = with types; attrsOf bool; + description = '' + A dictionary mapping file types to their enabled status - Default: `{}` - ''; - example = { - "*" = false; - python = true; - }; - }; - - proxy = mkDefaultOpt { - type = types.str; - description = "Tell Copilot what proxy server to use."; - example = "localhost:3128"; + Default: `{}` + ''; + example = { + "*" = false; + python = true; }; }; - } -) + + proxy = mkDefaultOpt { + type = types.str; + description = "Tell Copilot what proxy server to use."; + example = "localhost:3128"; + }; + }; + } diff --git a/plugins/completion/nvim-cmp/cmp-helpers.nix b/plugins/completion/nvim-cmp/cmp-helpers.nix index 855156ab..d98c9288 100644 --- a/plugins/completion/nvim-cmp/cmp-helpers.nix +++ b/plugins/completion/nvim-cmp/cmp-helpers.nix @@ -14,7 +14,7 @@ in useDefaultPackage ? true, ... }: - mkVimPlugin {inherit lib config pkgs;} { + mkVimPlugin config { inherit name; extraPlugins = extraPlugins ++ (lists.optional useDefaultPackage pkgs.vimPlugins.${name}); }; diff --git a/plugins/git/fugitive.nix b/plugins/git/fugitive.nix index 5d7ec83f..df0a256b 100644 --- a/plugins/git/fugitive.nix +++ b/plugins/git/fugitive.nix @@ -1,18 +1,15 @@ { - lib, + config, + helpers, pkgs, ... -} @ attrs: let - helpers = import ../helpers.nix {inherit lib;}; -in - with helpers.vim-plugin; - with lib; - mkVimPlugin attrs { - name = "fugitive"; - description = "vim-fugitive"; - package = pkgs.vimPlugins.vim-fugitive; - extraPackages = [pkgs.git]; +}: +helpers.vim-plugin.mkVimPlugin config { + name = "fugitive"; + description = "vim-fugitive"; + package = pkgs.vimPlugins.vim-fugitive; + extraPackages = [pkgs.git]; - # In typical tpope fashion, this plugin has no config options - options = {}; - } + # In typical tpope fashion, this plugin has no config options + options = {}; +} diff --git a/plugins/languages/ledger.nix b/plugins/languages/ledger.nix index 31316972..3097655a 100644 --- a/plugins/languages/ledger.nix +++ b/plugins/languages/ledger.nix @@ -1,11 +1,13 @@ { lib, + config, + helpers, pkgs, ... -} @ args: +}: with lib; -with (import ../helpers.nix {inherit lib;}).vim-plugin; - mkVimPlugin args { +with helpers.vim-plugin; + mkVimPlugin config { name = "ledger"; description = "ledger language features"; package = pkgs.vimPlugins.vim-ledger; diff --git a/plugins/languages/markdown-preview.nix b/plugins/languages/markdown-preview.nix index f3fdb580..ca966d1a 100644 --- a/plugins/languages/markdown-preview.nix +++ b/plugins/languages/markdown-preview.nix @@ -1,12 +1,13 @@ { lib, - pkgs, + config, helpers, + pkgs, ... -} @ args: +}: with lib; -with (import ../helpers.nix {inherit lib;}).vim-plugin; - mkVimPlugin args { +with helpers.vim-plugin; + mkVimPlugin config { name = "markdown-preview"; description = "markdown-preview.nvim"; package = pkgs.vimPlugins.markdown-preview-nvim; diff --git a/plugins/languages/nix.nix b/plugins/languages/nix.nix index 7bf4d315..5239509b 100644 --- a/plugins/languages/nix.nix +++ b/plugins/languages/nix.nix @@ -1,17 +1,14 @@ { - lib, + config, + helpers, pkgs, ... -} @ attrs: let - helpers = import ../helpers.nix {inherit lib;}; -in - with helpers.vim-plugin; - with lib; - mkVimPlugin attrs { - name = "nix"; - description = "vim-nix"; - package = pkgs.vimPlugins.vim-nix; +}: +helpers.vim-plugin.mkVimPlugin config { + name = "nix"; + description = "vim-nix"; + package = pkgs.vimPlugins.vim-nix; - # Possibly add option to disable Treesitter highlighting if this is installed - options = {}; - } + # Possibly add option to disable Treesitter highlighting if this is installed + options = {}; +} diff --git a/plugins/languages/tagbar.nix b/plugins/languages/tagbar.nix index 4936fa90..b5cb06b5 100644 --- a/plugins/languages/tagbar.nix +++ b/plugins/languages/tagbar.nix @@ -1,13 +1,12 @@ { - lib, + helpers, + config, pkgs, ... -} @ args: -with lib; -with (import ../helpers.nix {inherit lib;}).vim-plugin; - mkVimPlugin args { - name = "tagbar"; - package = pkgs.vimPlugins.tagbar; - globalPrefix = "tagbar_"; - extraPackages = [pkgs.ctags]; - } +}: +helpers.vim-plugin.mkVimPlugin config { + name = "tagbar"; + package = pkgs.vimPlugins.tagbar; + globalPrefix = "tagbar_"; + extraPackages = [pkgs.ctags]; +} diff --git a/plugins/languages/vim-slime.nix b/plugins/languages/vim-slime.nix index 29900895..c7c7f44d 100644 --- a/plugins/languages/vim-slime.nix +++ b/plugins/languages/vim-slime.nix @@ -1,125 +1,125 @@ { lib, + config, + helpers, pkgs, ... -} @ args: let - helpers = import ../helpers.nix {inherit lib;}; -in - with lib; - with helpers.vim-plugin; - mkVimPlugin args { - name = "vim-slime"; - package = pkgs.vimPlugins.vim-slime; - globalPrefix = "slime_"; +}: +with lib; +with helpers.vim-plugin; + mkVimPlugin config { + name = "vim-slime"; + package = pkgs.vimPlugins.vim-slime; + globalPrefix = "slime_"; - options = { - target = mkDefaultOpt { - type = types.enum [ - "dtach" - "kitty" - "neovim" - "screen" - "tmux" - "vimterminal" - "wezterm" - "whimrepl" - "x11" - "zellij" - ]; - description = '' - Which backend vim-slime should use. + options = { + target = mkDefaultOpt { + type = types.enum [ + "dtach" + "kitty" + "neovim" + "screen" + "tmux" + "vimterminal" + "wezterm" + "whimrepl" + "x11" + "zellij" + ]; + description = '' + Which backend vim-slime should use. - Default: "screen" - ''; - example = "dtach"; - }; - - vimterminalCmd = mkDefaultOpt { - global = "vimterminal_cmd"; - type = types.str; - description = "The vim terminal command to execute."; - }; - - noMappings = mkDefaultOpt { - global = "no_mappings"; - type = types.bool; - description = '' - Whether to disable the default mappings. - - Default: `false` - ''; - }; - - pasteFile = mkDefaultOpt { - global = "paste_file"; - type = types.str; - description = '' - Required to transfer data from vim to GNU screen or tmux. - Setting this explicitly can work around some occasional portability issues. - whimrepl does not require or support this setting. - - Default: "$HOME/.slime_paste" - ''; - }; - - preserveCurpos = mkDefaultOpt { - global = "preserve_curpos"; - type = types.bool; - description = '' - Whether to preserve cursor position when sending a line or paragraph. - - Default: `true` - ''; - }; - - defaultConfig = mkDefaultOpt { - global = "default_config"; - type = with helpers.nixvimTypes; attrsOf (either str rawLua); - description = '' - Pre-filled prompt answer. - - Default: `null` - - Examples: - - `tmux`: - ```nix - { - socket_name = "default"; - target_pane = "{last}"; - } - ``` - - `zellij`: - ```nix - { - session_id = "current"; - relative_pane = "right"; - } - ``` - ''; - }; - - dontAskDefault = mkDefaultOpt { - global = "dont_ask_default"; - type = types.bool; - description = '' - Whether to bypass the prompt and use the specified default configuration options. - - Default: `false` - ''; - }; - - bracketedPaste = mkDefaultOpt { - global = "bracketed_paste"; - type = with types; nullOr bool; - description = '' - Sometimes REPL are too smart for their own good, e.g. autocompleting a bracket that should - not be autocompleted when pasting code from a file. - In this case it can be useful to rely on bracketed-paste - (https://cirw.in/blog/bracketed-paste). - Luckily, tmux knows how to handle that. See tmux's manual. - - Default: `false` - ''; - }; + Default: "screen" + ''; + example = "dtach"; }; - } + + vimterminalCmd = mkDefaultOpt { + global = "vimterminal_cmd"; + type = types.str; + description = "The vim terminal command to execute."; + }; + + noMappings = mkDefaultOpt { + global = "no_mappings"; + type = types.bool; + description = '' + Whether to disable the default mappings. + + Default: `false` + ''; + }; + + pasteFile = mkDefaultOpt { + global = "paste_file"; + type = types.str; + description = '' + Required to transfer data from vim to GNU screen or tmux. + Setting this explicitly can work around some occasional portability issues. + whimrepl does not require or support this setting. + + Default: "$HOME/.slime_paste" + ''; + }; + + preserveCurpos = mkDefaultOpt { + global = "preserve_curpos"; + type = types.bool; + description = '' + Whether to preserve cursor position when sending a line or paragraph. + + Default: `true` + ''; + }; + + defaultConfig = mkDefaultOpt { + global = "default_config"; + type = with helpers.nixvimTypes; attrsOf (either str rawLua); + description = '' + Pre-filled prompt answer. + + Default: `null` + + Examples: + - `tmux`: + ```nix + { + socket_name = "default"; + target_pane = "{last}"; + } + ``` + - `zellij`: + ```nix + { + session_id = "current"; + relative_pane = "right"; + } + ``` + ''; + }; + + dontAskDefault = mkDefaultOpt { + global = "dont_ask_default"; + type = types.bool; + description = '' + Whether to bypass the prompt and use the specified default configuration options. + + Default: `false` + ''; + }; + + bracketedPaste = mkDefaultOpt { + global = "bracketed_paste"; + type = with types; nullOr bool; + description = '' + Sometimes REPL are too smart for their own good, e.g. autocompleting a bracket that should + not be autocompleted when pasting code from a file. + In this case it can be useful to rely on bracketed-paste + (https://cirw.in/blog/bracketed-paste). + Luckily, tmux knows how to handle that. See tmux's manual. + + Default: `false` + ''; + }; + }; + } diff --git a/plugins/languages/zig.nix b/plugins/languages/zig.nix index 61170f75..51beda8d 100644 --- a/plugins/languages/zig.nix +++ b/plugins/languages/zig.nix @@ -1,24 +1,24 @@ { lib, + config, + helpers, pkgs, ... -} @ attrs: let - helpers = import ../helpers.nix {inherit lib;}; -in - with helpers.vim-plugin; - with lib; - mkVimPlugin attrs { - name = "zig"; - description = "zig.vim"; - package = pkgs.vimPlugins.zig-vim; - globalPrefix = "zig_"; +}: +with lib; +with helpers.vim-plugin; + mkVimPlugin config { + name = "zig"; + description = "zig.vim"; + package = pkgs.vimPlugins.zig-vim; + globalPrefix = "zig_"; - # Possibly add option to disable Treesitter highlighting if this is installed - options = { - formatOnSave = mkDefaultOpt { - type = types.bool; - global = "fmt_autosave"; - description = "Run zig fmt on save"; - }; + # Possibly add option to disable Treesitter highlighting if this is installed + options = { + formatOnSave = mkDefaultOpt { + type = types.bool; + global = "fmt_autosave"; + description = "Run zig fmt on save"; }; - } + }; + } diff --git a/plugins/statuslines/airline.nix b/plugins/statuslines/airline.nix index a9e8a0ee..5a183451 100644 --- a/plugins/statuslines/airline.nix +++ b/plugins/statuslines/airline.nix @@ -1,11 +1,13 @@ { lib, + config, + helpers, pkgs, ... -} @ args: +}: with lib; -with (import ../helpers.nix {inherit lib;}).vim-plugin; - mkVimPlugin args { +with helpers.vim-plugin; + mkVimPlugin config { name = "airline"; description = "vim-airline"; package = pkgs.vimPlugins.vim-airline; diff --git a/plugins/utils/emmet.nix b/plugins/utils/emmet.nix index db523c70..efe610d4 100644 --- a/plugins/utils/emmet.nix +++ b/plugins/utils/emmet.nix @@ -1,34 +1,34 @@ { lib, + config, + helpers, pkgs, ... -} @ attrs: -with lib; let - helpers = import ../helpers.nix {inherit lib;}; -in - with helpers.vim-plugin; - mkVimPlugin attrs { - name = "emmet"; - package = pkgs.vimPlugins.emmet-vim; - globalPrefix = "user_emmet_"; +}: +with lib; +with helpers.vim-plugin; + mkVimPlugin config { + name = "emmet"; + package = pkgs.vimPlugins.emmet-vim; + globalPrefix = "user_emmet_"; - options = { - mode = mkDefaultOpt { - type = types.enum ["i" "n" "v" "a"]; - global = "mode"; - description = "Mode where emmet will enable"; - }; - - leader = mkDefaultOpt { - type = types.str; - global = "leader_key"; - description = "Set leader key"; - }; - - settings = mkDefaultOpt { - type = with types; attrsOf anything; - global = "settings"; - description = "Emmet settings"; - }; + options = { + mode = mkDefaultOpt { + type = types.enum ["i" "n" "v" "a"]; + global = "mode"; + description = "Mode where emmet will enable"; }; - } + + leader = mkDefaultOpt { + type = types.str; + global = "leader_key"; + description = "Set leader key"; + }; + + settings = mkDefaultOpt { + type = with types; attrsOf anything; + global = "settings"; + description = "Emmet settings"; + }; + }; + } diff --git a/plugins/utils/endwise.nix b/plugins/utils/endwise.nix index 77cc0071..10da8b3b 100644 --- a/plugins/utils/endwise.nix +++ b/plugins/utils/endwise.nix @@ -1,17 +1,14 @@ { - lib, + config, pkgs, + helpers, ... -} @ attrs: let - helpers = import ../helpers.nix {inherit lib;}; -in - with helpers.vim-plugin; - with lib; - mkVimPlugin attrs { - name = "endwise"; - description = "vim-endwise"; - package = pkgs.vimPlugins.vim-endwise; +}: +helpers.vim-plugin.mkVimPlugin config { + name = "endwise"; + description = "vim-endwise"; + package = pkgs.vimPlugins.vim-endwise; - # Yes it's really not configurable - options = {}; - } + # Yes it's really not configurable + options = {}; +} diff --git a/plugins/utils/goyo.nix b/plugins/utils/goyo.nix index ae4fa536..fac42548 100644 --- a/plugins/utils/goyo.nix +++ b/plugins/utils/goyo.nix @@ -1,35 +1,35 @@ { lib, + config, + helpers, pkgs, ... -} @ attrs: let - helpers = import ../helpers.nix {inherit lib;}; -in - with helpers.vim-plugin; - with lib; - mkVimPlugin attrs { - name = "goyo"; - description = "goyo.vim"; - package = pkgs.vimPlugins.goyo-vim; - globalPrefix = "goyo_"; +}: +with helpers.vim-plugin; +with lib; + mkVimPlugin config { + name = "goyo"; + description = "goyo.vim"; + package = pkgs.vimPlugins.goyo-vim; + globalPrefix = "goyo_"; - options = { - width = mkDefaultOpt { - description = "Width"; - global = "width"; - type = types.int; - }; - - height = mkDefaultOpt { - description = "Height"; - global = "height"; - type = types.int; - }; - - showLineNumbers = mkDefaultOpt { - description = "Show line numbers when in Goyo mode"; - global = "linenr"; - type = types.bool; - }; + options = { + width = mkDefaultOpt { + description = "Width"; + global = "width"; + type = types.int; }; - } + + height = mkDefaultOpt { + description = "Height"; + global = "height"; + type = types.int; + }; + + showLineNumbers = mkDefaultOpt { + description = "Show line numbers when in Goyo mode"; + global = "linenr"; + type = types.bool; + }; + }; + } diff --git a/plugins/utils/instant.nix b/plugins/utils/instant.nix index b0cb16ab..fdf735e8 100644 --- a/plugins/utils/instant.nix +++ b/plugins/utils/instant.nix @@ -1,11 +1,13 @@ { lib, + config, + helpers, pkgs, ... -} @ args: +}: with lib; -with (import ../helpers.nix {inherit lib;}).vim-plugin; - mkVimPlugin args { +with helpers.vim-plugin; + mkVimPlugin config { name = "instant"; description = "instant.nvim"; package = pkgs.vimPlugins.instant-nvim; diff --git a/plugins/utils/magma-nvim.nix b/plugins/utils/magma-nvim.nix index 8a0cd39c..332261ec 100644 --- a/plugins/utils/magma-nvim.nix +++ b/plugins/utils/magma-nvim.nix @@ -1,11 +1,13 @@ { lib, + config, + helpers, pkgs, ... -} @ args: +}: with lib; -with (import ../helpers.nix {inherit lib;}).vim-plugin; - mkVimPlugin args { +with helpers.vim-plugin; + mkVimPlugin config { name = "magma-nvim"; description = "magma-nvim"; package = pkgs.vimPlugins.magma-nvim-goose; diff --git a/plugins/utils/molten.nix b/plugins/utils/molten.nix index 8181bc25..59a83d83 100644 --- a/plugins/utils/molten.nix +++ b/plugins/utils/molten.nix @@ -1,211 +1,211 @@ { lib, + config, + helpers, pkgs, ... -} @ args: let - helpers = import ../helpers.nix {inherit lib;}; -in - with lib; - with helpers.vim-plugin; - mkVimPlugin args { - name = "molten"; - description = "molten-nvim"; - package = pkgs.vimPlugins.molten-nvim; - globalPrefix = "molten_"; +}: +with lib; +with helpers.vim-plugin; + mkVimPlugin config { + name = "molten"; + description = "molten-nvim"; + package = pkgs.vimPlugins.molten-nvim; + globalPrefix = "molten_"; - options = { - autoOpenOutput = mkDefaultOpt { - global = "auto_open_output"; - description = '' - Automatically open the output window when your cursor moves over a cell. + options = { + autoOpenOutput = mkDefaultOpt { + global = "auto_open_output"; + description = '' + Automatically open the output window when your cursor moves over a cell. - Default: `true` - ''; - type = types.bool; - example = false; - }; - - copyOutput = mkDefaultOpt { - global = "copy_output"; - description = '' - Copy evaluation output to clipboard automatically (requires pyperclip). - - Default: `false` - ''; - type = types.bool; - example = true; - }; - - enterOutputBehavior = mkDefaultOpt { - global = "enter_output_behavior"; - description = '' - The behavior of MoltenEnterOutput. - - Default: `"open_then_enter"` - ''; - type = types.enum ["open_then_enter" "open_and_enter" "no_open"]; - }; - - imageProvider = mkDefaultOpt { - global = "image_provider"; - description = '' - How images are displayed. - - Default: `"none"` - ''; - type = types.enum ["none" "image.nvim"]; - }; - - outputCropBorder = mkDefaultOpt { - global = "output_crop_border"; - description = '' - 'crops' the bottom border of the output window when it would otherwise just sit at the - bottom of the screen. - - Default: `true` - ''; - type = types.bool; - }; - - outputShowMore = mkDefaultOpt { - global = "output_show_more"; - description = '' - When the window can't display the entire contents of the output buffer, shows the number - of extra lines in the window footer (requires nvim 10.0+ and a window border). - - Default: `false` - ''; - type = types.bool; - }; - - outputVirtLines = mkDefaultOpt { - global = "output_virt_lines"; - description = '' - Pad the main buffer with virtual lines so the output doesn't cover anything while it's - open. - - Default: `false` - ''; - type = types.bool; - }; - - outputWinBorder = mkDefaultOpt { - global = "output_win_border"; - description = '' - Some border features will not work if you don't specify your border as a table. - See border option of `:h nvim_open_win()`. - - Default: `["" "━" "" ""]` - ''; - type = helpers.nixvimTypes.border; - }; - - outputWinCoverGutter = mkDefaultOpt { - global = "output_win_cover_gutter"; - description = '' - Should the output window cover the gutter (numbers and sign col), or not. - If you change this, you probably also want to change `outputWinStyle`. - - Default: `true` - ''; - type = types.bool; - }; - - outputWinHideOnLeave = mkDefaultOpt { - global = "output_win_hide_on_leave"; - description = '' - After leaving the output window (via `:q` or switching windows), do not attempt to redraw - the output window. - - Default: `true` - ''; - type = types.bool; - }; - - outputWinMaxHeight = mkDefaultOpt { - global = "output_win_max_height"; - description = '' - Max height of the output window. - - Default: `999999` - ''; - type = types.ints.unsigned; - }; - - outputWinMaxWidth = mkDefaultOpt { - global = "output_win_max_width"; - description = '' - Max width of the output window. - - Default: `999999` - ''; - type = types.ints.unsigned; - }; - - outputWinStyle = mkDefaultOpt { - global = "output_win_style"; - description = '' - Value passed to the `style` option in `:h nvim_open_win()` - - Default: `false` - ''; - type = types.enum [false "minimal"]; - }; - - savePath = mkDefaultOpt { - global = "save_path"; - description = '' - Where to save/load data with `:MoltenSave` and `:MoltenLoad`. - - Default: `{__raw = "vim.fn.stdpath('data')..'/molten'";}` - ''; - type = with helpers.nixvimTypes; either str rawLua; - }; - - useBorderHighlights = mkDefaultOpt { - global = "use_border_highlights"; - description = '' - When true, uses different highlights for output border depending on the state of the cell - (running, done, error). - See [highlights](https://github.com/benlubas/molten-nvim#highlights). - - Default: `false` - ''; - type = types.bool; - }; - - virtLinesOffBy1 = mkDefaultOpt { - global = "virt_lines_off_by_1"; - description = '' - _Only has effect when `outputVirtLines` is true._ - Allows the output window to cover exactly one line of the regular buffer. - (useful for running code in a markdown file where that covered line will just be ```) - - Default: `false` - ''; - type = types.bool; - }; - - wrapOutput = mkDefaultOpt { - global = "wrap_output"; - description = '' - Wrap text in output windows. - - Default: `false` - ''; - type = types.bool; - }; - - # Debug - showMimetypeDebug = mkDefaultOpt { - global = "show_mimetype_debug"; - description = '' - Before any non-iostream output chunk, the mime-type for that output chunk is shown. - Meant for debugging/plugin devlopment. - - Default: `false` - ''; - type = types.bool; - }; + Default: `true` + ''; + type = types.bool; + example = false; }; - } + + copyOutput = mkDefaultOpt { + global = "copy_output"; + description = '' + Copy evaluation output to clipboard automatically (requires pyperclip). + + Default: `false` + ''; + type = types.bool; + example = true; + }; + + enterOutputBehavior = mkDefaultOpt { + global = "enter_output_behavior"; + description = '' + The behavior of MoltenEnterOutput. + + Default: `"open_then_enter"` + ''; + type = types.enum ["open_then_enter" "open_and_enter" "no_open"]; + }; + + imageProvider = mkDefaultOpt { + global = "image_provider"; + description = '' + How images are displayed. + + Default: `"none"` + ''; + type = types.enum ["none" "image.nvim"]; + }; + + outputCropBorder = mkDefaultOpt { + global = "output_crop_border"; + description = '' + 'crops' the bottom border of the output window when it would otherwise just sit at the + bottom of the screen. + + Default: `true` + ''; + type = types.bool; + }; + + outputShowMore = mkDefaultOpt { + global = "output_show_more"; + description = '' + When the window can't display the entire contents of the output buffer, shows the number + of extra lines in the window footer (requires nvim 10.0+ and a window border). + + Default: `false` + ''; + type = types.bool; + }; + + outputVirtLines = mkDefaultOpt { + global = "output_virt_lines"; + description = '' + Pad the main buffer with virtual lines so the output doesn't cover anything while it's + open. + + Default: `false` + ''; + type = types.bool; + }; + + outputWinBorder = mkDefaultOpt { + global = "output_win_border"; + description = '' + Some border features will not work if you don't specify your border as a table. + See border option of `:h nvim_open_win()`. + + Default: `["" "━" "" ""]` + ''; + type = helpers.nixvimTypes.border; + }; + + outputWinCoverGutter = mkDefaultOpt { + global = "output_win_cover_gutter"; + description = '' + Should the output window cover the gutter (numbers and sign col), or not. + If you change this, you probably also want to change `outputWinStyle`. + + Default: `true` + ''; + type = types.bool; + }; + + outputWinHideOnLeave = mkDefaultOpt { + global = "output_win_hide_on_leave"; + description = '' + After leaving the output window (via `:q` or switching windows), do not attempt to redraw + the output window. + + Default: `true` + ''; + type = types.bool; + }; + + outputWinMaxHeight = mkDefaultOpt { + global = "output_win_max_height"; + description = '' + Max height of the output window. + + Default: `999999` + ''; + type = types.ints.unsigned; + }; + + outputWinMaxWidth = mkDefaultOpt { + global = "output_win_max_width"; + description = '' + Max width of the output window. + + Default: `999999` + ''; + type = types.ints.unsigned; + }; + + outputWinStyle = mkDefaultOpt { + global = "output_win_style"; + description = '' + Value passed to the `style` option in `:h nvim_open_win()` + + Default: `false` + ''; + type = types.enum [false "minimal"]; + }; + + savePath = mkDefaultOpt { + global = "save_path"; + description = '' + Where to save/load data with `:MoltenSave` and `:MoltenLoad`. + + Default: `{__raw = "vim.fn.stdpath('data')..'/molten'";}` + ''; + type = with helpers.nixvimTypes; either str rawLua; + }; + + useBorderHighlights = mkDefaultOpt { + global = "use_border_highlights"; + description = '' + When true, uses different highlights for output border depending on the state of the cell + (running, done, error). + See [highlights](https://github.com/benlubas/molten-nvim#highlights). + + Default: `false` + ''; + type = types.bool; + }; + + virtLinesOffBy1 = mkDefaultOpt { + global = "virt_lines_off_by_1"; + description = '' + _Only has effect when `outputVirtLines` is true._ + Allows the output window to cover exactly one line of the regular buffer. + (useful for running code in a markdown file where that covered line will just be ```) + + Default: `false` + ''; + type = types.bool; + }; + + wrapOutput = mkDefaultOpt { + global = "wrap_output"; + description = '' + Wrap text in output windows. + + Default: `false` + ''; + type = types.bool; + }; + + # Debug + showMimetypeDebug = mkDefaultOpt { + global = "show_mimetype_debug"; + description = '' + Before any non-iostream output chunk, the mime-type for that output chunk is shown. + Meant for debugging/plugin devlopment. + + Default: `false` + ''; + type = types.bool; + }; + }; + } diff --git a/plugins/utils/startify.nix b/plugins/utils/startify.nix index 63a7b0c4..3f5d7a72 100644 --- a/plugins/utils/startify.nix +++ b/plugins/utils/startify.nix @@ -1,233 +1,233 @@ { lib, + config, + helpers, pkgs, ... -} @ args: let - helpers = import ../helpers.nix {inherit lib;}; -in - with lib; - with helpers.vim-plugin; - mkVimPlugin args { - name = "startify"; - package = pkgs.vimPlugins.vim-startify; - globalPrefix = "startify_"; +}: +with lib; +with helpers.vim-plugin; + mkVimPlugin config { + name = "startify"; + package = pkgs.vimPlugins.vim-startify; + globalPrefix = "startify_"; - options = { - sessionDir = mkDefaultOpt { - description = "Directory to save/load session"; - global = "session_dir"; - type = types.str; - }; - - lists = mkDefaultOpt { - description = "Startify display lists. If it's a string, it'll be interpreted as literal lua code"; - global = "lists"; - type = types.listOf (types.oneOf [ - (types.submodule { - options = { - type = mkOption { - type = types.str; - description = "The type of the list"; - }; - # TODO the header should be a literal lua string! - header = mkOption { - type = types.nullOr (types.listOf types.str); - description = "Optional header. It's a list of strings"; - default = null; - }; - indices = mkOption { - type = types.nullOr (types.listOf types.str); - description = "Optional indices for the current list"; - default = null; - }; - }; - }) - types.str - ]); - - value = val: let - list = map (v: - if builtins.isAttrs v - then toLuaObject v - else v) - val; - in - "{" + (concatStringsSep "," list) + "}"; - }; - - bookmarks = mkDefaultOpt { - description = "A list of files or directories to bookmark."; - global = "bookmarks"; - type = with types; listOf (oneOf [str (attrsOf str)]); - }; - - commands = mkDefaultOpt { - description = "A list of commands to execute on selection"; - global = "commands"; - type = with types; listOf (oneOf [str (listOf str) attrs]); - }; - - filesNumber = mkDefaultOpt { - description = "The number of files to list"; - global = "files_number"; - type = types.int; - }; - - updateOldFiles = mkDefaultOpt { - description = "Update v:oldfiles on-the-fly, so that :Startify is always up-to-date"; - global = "update_oldfiles"; - type = types.bool; - }; - - sessionAutoload = mkDefaultOpt { - description = "Load Session.vim"; - global = "session_autoload"; - type = types.bool; - }; - - sessionBeforeSave = mkDefaultOpt { - description = "Commands to be executed before saving a session"; - global = "session_before_save"; - type = types.listOf types.str; - }; - - sessionPersistence = mkDefaultOpt { - description = "Automatically update sessions"; - global = "session_persistence"; - type = types.bool; - }; - - sessionDeleteBuffers = mkDefaultOpt { - description = "Delete all buffers when loading or closing a session"; - global = "session_delete_buffers"; - type = types.bool; - }; - - changeToDir = mkDefaultOpt { - description = "When opening a file or bookmark, change to its directory"; - global = "change_to_dir"; - type = types.bool; - }; - - changeToVcsRoot = mkDefaultOpt { - description = "When opening a file or bookmark, change to the root directory of the VCS"; - global = "change_to_vcs_root"; - type = types.bool; - }; - - changeCmd = mkDefaultOpt { - description = "The default command for switching directories"; - global = "change_cmd"; - type = types.enum ["cd" "lcd" "tcd"]; - }; - - skipList = mkDefaultOpt { - description = "A list of regexes that is used to filter recently used files"; - global = "skiplist"; - type = types.listOf types.str; - }; - - useUnicode = mkDefaultOpt { - description = "Use unicode box drawing characters for the fortune header"; - global = "fortune_use_unicode"; - type = types.bool; - }; - - paddingLeft = mkDefaultOpt { - description = "Number of spaces used for left padding"; - global = "padding_left"; - type = types.int; - }; - - skipListServer = mkDefaultOpt { - description = "Do not create the startify buffer if this is a Vim server instance with a name contained in this list"; - global = "skiplist_server"; - type = types.listOf types.str; - }; - - enableSpecial = mkDefaultOpt { - description = "Show <empty buffer> and <quit>"; - global = "enable_special"; - type = types.bool; - }; - - enableUnsafe = mkDefaultOpt { - description = "Improves start time but reduces accuracy of the file list"; - global = "enable_unsafe"; - type = types.bool; - }; - - sessionRemoveLines = mkDefaultOpt { - description = "Lines matching any of the patterns in this list will be removed from the session file"; - global = "session_remove_lines"; - type = types.listOf types.str; - }; - - sessionSaveVars = mkDefaultOpt { - description = "List of variables for Startify to save into the session file"; - global = "session_savevars"; - type = types.listOf types.str; - }; - - sessionSaveCmds = mkDefaultOpt { - description = "List of cmdline commands to run when loading the session"; - global = "session_savecmds"; - type = types.listOf types.str; - }; - - sessionNumber = mkDefaultOpt { - description = "Maximum number of sessions to display"; - global = "session_number"; - type = types.listOf types.str; - }; - - sessionSort = mkDefaultOpt { - description = "Sort sessions by modification time rather than alphabetically"; - global = "session_sort"; - type = types.bool; - }; - - customIndices = mkDefaultOpt { - description = "Use this list as indices instead of increasing numbers"; - global = "custom_indices"; - type = types.listOf types.str; - }; - - customHeader = mkDefaultOpt { - description = "Define your own header"; - global = "custom_header"; - type = types.oneOf [types.str (types.listOf types.str)]; - }; - - customQuotes = mkDefaultOpt { - description = "Own quotes for the cowsay header"; - global = "custom_header_quotes"; - # TODO this should also support funcrefs! - type = types.listOf (types.listOf types.str); - }; - - customFooter = mkDefaultOpt { - description = "Custom footer"; - global = "custom_footer"; - type = types.str; - }; - - disableAtVimEnter = mkDefaultOpt { - description = "Don't run Startify at Vim startup"; - global = "disable_at_vimenter"; - type = types.bool; - }; - - relativePath = mkDefaultOpt { - description = "If the file is in or below the current working directory, use a relative path"; - global = "relative_path"; - type = types.bool; - }; - - useEnv = mkDefaultOpt { - description = "Show environment variables in path, if their name is shorter than their value"; - global = "use_env"; - type = types.bool; - }; + options = { + sessionDir = mkDefaultOpt { + description = "Directory to save/load session"; + global = "session_dir"; + type = types.str; }; - } + + lists = mkDefaultOpt { + description = "Startify display lists. If it's a string, it'll be interpreted as literal lua code"; + global = "lists"; + type = types.listOf (types.oneOf [ + (types.submodule { + options = { + type = mkOption { + type = types.str; + description = "The type of the list"; + }; + # TODO the header should be a literal lua string! + header = mkOption { + type = types.nullOr (types.listOf types.str); + description = "Optional header. It's a list of strings"; + default = null; + }; + indices = mkOption { + type = types.nullOr (types.listOf types.str); + description = "Optional indices for the current list"; + default = null; + }; + }; + }) + types.str + ]); + + value = val: let + list = map (v: + if builtins.isAttrs v + then toLuaObject v + else v) + val; + in + "{" + (concatStringsSep "," list) + "}"; + }; + + bookmarks = mkDefaultOpt { + description = "A list of files or directories to bookmark."; + global = "bookmarks"; + type = with types; listOf (oneOf [str (attrsOf str)]); + }; + + commands = mkDefaultOpt { + description = "A list of commands to execute on selection"; + global = "commands"; + type = with types; listOf (oneOf [str (listOf str) attrs]); + }; + + filesNumber = mkDefaultOpt { + description = "The number of files to list"; + global = "files_number"; + type = types.int; + }; + + updateOldFiles = mkDefaultOpt { + description = "Update v:oldfiles on-the-fly, so that :Startify is always up-to-date"; + global = "update_oldfiles"; + type = types.bool; + }; + + sessionAutoload = mkDefaultOpt { + description = "Load Session.vim"; + global = "session_autoload"; + type = types.bool; + }; + + sessionBeforeSave = mkDefaultOpt { + description = "Commands to be executed before saving a session"; + global = "session_before_save"; + type = types.listOf types.str; + }; + + sessionPersistence = mkDefaultOpt { + description = "Automatically update sessions"; + global = "session_persistence"; + type = types.bool; + }; + + sessionDeleteBuffers = mkDefaultOpt { + description = "Delete all buffers when loading or closing a session"; + global = "session_delete_buffers"; + type = types.bool; + }; + + changeToDir = mkDefaultOpt { + description = "When opening a file or bookmark, change to its directory"; + global = "change_to_dir"; + type = types.bool; + }; + + changeToVcsRoot = mkDefaultOpt { + description = "When opening a file or bookmark, change to the root directory of the VCS"; + global = "change_to_vcs_root"; + type = types.bool; + }; + + changeCmd = mkDefaultOpt { + description = "The default command for switching directories"; + global = "change_cmd"; + type = types.enum ["cd" "lcd" "tcd"]; + }; + + skipList = mkDefaultOpt { + description = "A list of regexes that is used to filter recently used files"; + global = "skiplist"; + type = types.listOf types.str; + }; + + useUnicode = mkDefaultOpt { + description = "Use unicode box drawing characters for the fortune header"; + global = "fortune_use_unicode"; + type = types.bool; + }; + + paddingLeft = mkDefaultOpt { + description = "Number of spaces used for left padding"; + global = "padding_left"; + type = types.int; + }; + + skipListServer = mkDefaultOpt { + description = "Do not create the startify buffer if this is a Vim server instance with a name contained in this list"; + global = "skiplist_server"; + type = types.listOf types.str; + }; + + enableSpecial = mkDefaultOpt { + description = "Show <empty buffer> and <quit>"; + global = "enable_special"; + type = types.bool; + }; + + enableUnsafe = mkDefaultOpt { + description = "Improves start time but reduces accuracy of the file list"; + global = "enable_unsafe"; + type = types.bool; + }; + + sessionRemoveLines = mkDefaultOpt { + description = "Lines matching any of the patterns in this list will be removed from the session file"; + global = "session_remove_lines"; + type = types.listOf types.str; + }; + + sessionSaveVars = mkDefaultOpt { + description = "List of variables for Startify to save into the session file"; + global = "session_savevars"; + type = types.listOf types.str; + }; + + sessionSaveCmds = mkDefaultOpt { + description = "List of cmdline commands to run when loading the session"; + global = "session_savecmds"; + type = types.listOf types.str; + }; + + sessionNumber = mkDefaultOpt { + description = "Maximum number of sessions to display"; + global = "session_number"; + type = types.listOf types.str; + }; + + sessionSort = mkDefaultOpt { + description = "Sort sessions by modification time rather than alphabetically"; + global = "session_sort"; + type = types.bool; + }; + + customIndices = mkDefaultOpt { + description = "Use this list as indices instead of increasing numbers"; + global = "custom_indices"; + type = types.listOf types.str; + }; + + customHeader = mkDefaultOpt { + description = "Define your own header"; + global = "custom_header"; + type = types.oneOf [types.str (types.listOf types.str)]; + }; + + customQuotes = mkDefaultOpt { + description = "Own quotes for the cowsay header"; + global = "custom_header_quotes"; + # TODO this should also support funcrefs! + type = types.listOf (types.listOf types.str); + }; + + customFooter = mkDefaultOpt { + description = "Custom footer"; + global = "custom_footer"; + type = types.str; + }; + + disableAtVimEnter = mkDefaultOpt { + description = "Don't run Startify at Vim startup"; + global = "disable_at_vimenter"; + type = types.bool; + }; + + relativePath = mkDefaultOpt { + description = "If the file is in or below the current working directory, use a relative path"; + global = "relative_path"; + type = types.bool; + }; + + useEnv = mkDefaultOpt { + description = "Show environment variables in path, if their name is shorter than their value"; + global = "use_env"; + type = types.bool; + }; + }; + } diff --git a/plugins/utils/surround.nix b/plugins/utils/surround.nix index 2f5594c7..7be390b7 100644 --- a/plugins/utils/surround.nix +++ b/plugins/utils/surround.nix @@ -1,16 +1,13 @@ { - lib, + config, + helpers, pkgs, ... -} @ attrs: let - helpers = import ../helpers.nix {inherit lib;}; -in - with helpers.vim-plugin; - with lib; - mkVimPlugin attrs { - name = "surround"; - description = "surround.vim"; - package = pkgs.vimPlugins.surround; +}: +helpers.vim-plugin.mkVimPlugin config { + name = "surround"; + description = "surround.vim"; + package = pkgs.vimPlugins.surround; - options = {}; - } + options = {}; +} diff --git a/plugins/utils/undotree.nix b/plugins/utils/undotree.nix index 8ffd73ff..61884032 100644 --- a/plugins/utils/undotree.nix +++ b/plugins/utils/undotree.nix @@ -1,11 +1,13 @@ { lib, + config, + helpers, pkgs, ... -} @ args: +}: with lib; -with (import ../helpers.nix {inherit lib;}).vim-plugin; - mkVimPlugin args { +with helpers.vim-plugin; + mkVimPlugin config { name = "undotree"; package = pkgs.vimPlugins.undotree; globalPrefix = "undotree_";