diff --git a/modules/plugins/utility/preview/default.nix b/modules/plugins/utility/preview/default.nix index 0228395cb..250458544 100644 --- a/modules/plugins/utility/preview/default.nix +++ b/modules/plugins/utility/preview/default.nix @@ -1,6 +1,7 @@ { imports = [ ./markdown-preview + ./live-preview ./glow ]; } diff --git a/modules/plugins/utility/preview/live-preview/config.nix b/modules/plugins/utility/preview/live-preview/config.nix new file mode 100644 index 000000000..e07a1209a --- /dev/null +++ b/modules/plugins/utility/preview/live-preview/config.nix @@ -0,0 +1,18 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.nvim.lua) toLuaObject; + + cfg = config.vim.utility.preview.livePreview; +in { + config.vim.lazy.plugins."live-preview-nvim" = mkIf cfg.enable { + package = "live-preview-nvim"; + cmd = ["LivePreview"]; + after = '' + require("livepreview.config").set(${toLuaObject cfg.setupOpts}) + ''; + }; +} diff --git a/modules/plugins/utility/preview/live-preview/default.nix b/modules/plugins/utility/preview/live-preview/default.nix new file mode 100644 index 000000000..c6e2f7893 --- /dev/null +++ b/modules/plugins/utility/preview/live-preview/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./live-preview.nix + ./config.nix + ]; +} diff --git a/modules/plugins/utility/preview/live-preview/live-preview.nix b/modules/plugins/utility/preview/live-preview/live-preview.nix new file mode 100644 index 000000000..11f14b8a0 --- /dev/null +++ b/modules/plugins/utility/preview/live-preview/live-preview.nix @@ -0,0 +1,61 @@ +{lib, ...}: let + inherit (lib.options) mkEnableOption mkOption; + inherit + (lib.types) + bool + enum + int + str + ; + inherit (lib.nvim.types) mkPluginSetupOption; +in { + options.vim.utility.preview.livePreview = { + enable = mkEnableOption "live preview in a web browser with live-preview.nvim"; + + setupOpts = mkPluginSetupOption "live-preview.nvim" { + port = mkOption { + type = int; + default = 5500; + description = "Port to run the live preview server on."; + }; + + browser = mkOption { + type = str; + default = "default"; + example = "firefox"; + description = "Terminal command to open the browser for live-previewing (eg. `firefox`, `flatpak run com.vivaldi.Vivaldi`). By default, it will use the system's default browser."; + }; + + dynamic_root = mkOption { + type = bool; + default = false; + description = "If `true`, the root directory of the server will be the parent directory of the current file. Otherwise, it will be the current directory."; + }; + + sync_scroll = mkOption { + type = bool; + default = true; + description = "If `true`, the plugin will sync the scrolling in the browser as you scroll in the Markdown files in Neovim."; + }; + + picker = mkOption { + type = enum [ + "" + "telescope" + "fzf-lua" + "mini.pick" + "snacks.picker" + "vim.ui.select" + ]; + default = ""; + description = "Picker to use for opening files. 5 choices are available: `telescope`, `fzf-lua`, `mini.pick`, `snacks.picker` or `vim.ui.select`. If `\"\"`, the plugin looks for the first available picker when you call the `pick` command."; + }; + + address = mkOption { + type = str; + default = "127.0.0.1"; + description = "Hostname/IP-address to bind the server to. Default: `127.0.0.1`."; + }; + }; + }; +} diff --git a/npins/sources.json b/npins/sources.json index 82498506f..44be781dd 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -1030,6 +1030,19 @@ "url": "https://github.com/kawre/leetcode.nvim/archive/4e8b3683940a8377379ce9398e7f329e3560b42c.tar.gz", "hash": "sha256-82ppJQURAJcffgWwPHjrU9hROIKgk1hVITxNTzGtY5o=" }, + "live-preview-nvim": { + "type": "Git", + "repository": { + "type": "GitHub", + "owner": "brianhuster", + "repo": "live-preview.nvim" + }, + "branch": "main", + "submodules": false, + "revision": "a6307fa340ed7c0d96f5c567afc8c991aad94ce0", + "url": "https://github.com/brianhuster/live-preview.nvim/archive/a6307fa340ed7c0d96f5c567afc8c991aad94ce0.tar.gz", + "hash": "sha256-xyeoz4lEqrinkqY5U4Fu1S2HlmCyXiNQ2l2+AJFozIc=" + }, "lsp-signature-nvim": { "type": "Git", "repository": {