From 0f76a8cdfccd99d3a97d8fed493413c6fd671de5 Mon Sep 17 00:00:00 2001 From: seth Date: Sun, 7 Jul 2024 16:56:24 -0400 Subject: [PATCH] plugins/glow: init --- plugins/default.nix | 1 + plugins/languages/markdown/glow.nix | 87 +++++++++++++++++++ .../plugins/languages/markdown/glow.nix | 26 ++++++ 3 files changed, 114 insertions(+) create mode 100644 plugins/languages/markdown/glow.nix create mode 100644 tests/test-sources/plugins/languages/markdown/glow.nix diff --git a/plugins/default.nix b/plugins/default.nix index c0ca5858..da7b2c7a 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -68,6 +68,7 @@ ./languages/ledger.nix ./languages/lint.nix ./languages/ltex-extra.nix + ./languages/markdown/glow.nix ./languages/markdown/markdown-preview.nix ./languages/markdown/preview.nix ./languages/nix.nix diff --git a/plugins/languages/markdown/glow.nix b/plugins/languages/markdown/glow.nix new file mode 100644 index 00000000..f9b6c725 --- /dev/null +++ b/plugins/languages/markdown/glow.nix @@ -0,0 +1,87 @@ +{ + lib, + helpers, + config, + pkgs, + ... +}: +helpers.neovim-plugin.mkNeovimPlugin config { + name = "glow"; + originalName = "glow.nvim"; + defaultPackage = pkgs.vimPlugins.glow-nvim; + + maintainers = [ lib.maintainers.getchoo ]; + + settingsOptions = { + glow_path = helpers.defaultNullOpts.mkStr (helpers.mkRaw "vim.fn.exepath('glow')") '' + Path to `glow` binary. + + If null or `""`, `glow` in your `$PATH` with be used if available. + + Using `glowPackage` is the recommended way to make `glow` available in your `$PATH`. + ''; + + install_path = helpers.defaultNullOpts.mkStr "~/.local/bin" '' + Path for installing `glow` binary if one is not found at `glow_path` or in your `$PATH`. + + Consider using `glowPackage` instead. + ''; + + border = helpers.defaultNullOpts.mkEnumFirstDefault [ + "shadow" + "none" + "double" + "rounded" + "solid" + "single" + ] "Style of the floating window's border."; + + style = helpers.defaultNullOpts.mkEnum [ + "dark" + "light" + ] (helpers.mkRaw "vim.opt.background") "Glow style."; + + pager = helpers.defaultNullOpts.mkBool false '' + Display output in a pager style. + ''; + + width = helpers.defaultNullOpts.mkInt 100 '' + Width of the floating window. + ''; + + height = helpers.defaultNullOpts.mkInt 100 '' + Height of the floating window. + ''; + + width_ratio = helpers.defaultNullOpts.mkNum 0.7 '' + Maximum width of the floating window relative to the window size. + ''; + + height_ratio = helpers.defaultNullOpts.mkNum 0.7 '' + Maximum height of the floating window relative to the window size. + ''; + }; + + settingsExample = { + border = "shadow"; + style = "dark"; + pager = false; + width = 80; + height = 100; + width_ratio = 0.7; + height_ratio = 0.7; + }; + + extraOptions = { + glowPackage = helpers.mkPackageOption { + description = '' + Which package to use for `glow` in your `$PATH`. + Set to `null` to disable its automatic installation. + ''; + default = pkgs.glow; + defaultText = lib.literalExpression "pkgs.glow"; + }; + }; + + extraConfig = cfg: { extraPackages = [ cfg.glowPackage ]; }; +} diff --git a/tests/test-sources/plugins/languages/markdown/glow.nix b/tests/test-sources/plugins/languages/markdown/glow.nix new file mode 100644 index 00000000..a9c0d056 --- /dev/null +++ b/tests/test-sources/plugins/languages/markdown/glow.nix @@ -0,0 +1,26 @@ +{ pkgs, ... }: +{ + empty = { + plugins.glow.enable = true; + }; + + defaults = { + plugins.glow = { + enable = true; + + glowPackage = pkgs.glow; + + settings = { + glow_path.__raw = "vim.fn.exepath('glow')"; + install_path = "~/.local/bin"; + border = "shadow"; + style = "dark"; + pager = false; + width = 80; + height = 100; + width_ratio = 0.7; + height_ratio = 0.7; + }; + }; + }; +}