Skip to content

Commit 1bebd35

Browse files
committed
plugins/utility/preview: init live-preview.nvim
1 parent f019fe8 commit 1bebd35

5 files changed

Lines changed: 99 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
imports = [
33
./markdown-preview
4+
./live-preview
45
./glow
56
];
67
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
config,
3+
lib,
4+
...
5+
}: let
6+
inherit (lib.modules) mkIf;
7+
inherit (lib.nvim.lua) toLuaObject;
8+
9+
cfg = config.vim.utility.preview.livePreview;
10+
in {
11+
config.vim.lazy.plugins."live-preview-nvim" = mkIf cfg.enable {
12+
package = "live-preview-nvim";
13+
cmd = ["LivePreview"];
14+
after = ''
15+
require("livepreview.config").set(${toLuaObject cfg.setupOpts})
16+
'';
17+
};
18+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
imports = [
3+
./live-preview.nix
4+
./config.nix
5+
];
6+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{lib, ...}: let
2+
inherit (lib.options) mkEnableOption mkOption;
3+
inherit
4+
(lib.types)
5+
bool
6+
enum
7+
int
8+
str
9+
;
10+
inherit (lib.nvim.types) mkPluginSetupOption;
11+
in {
12+
options.vim.utility.preview.livePreview = {
13+
enable = mkEnableOption "live preview in a web browser with live-preview.nvim";
14+
15+
setupOpts = mkPluginSetupOption "live-preview.nvim" {
16+
port = mkOption {
17+
type = int;
18+
default = 5500;
19+
description = "Port to run the live preview server on.";
20+
};
21+
22+
browser = mkOption {
23+
type = str;
24+
default = "default";
25+
example = "firefox";
26+
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.";
27+
};
28+
29+
dynamic_root = mkOption {
30+
type = bool;
31+
default = false;
32+
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.";
33+
};
34+
35+
sync_scroll = mkOption {
36+
type = bool;
37+
default = true;
38+
description = "If `true`, the plugin will sync the scrolling in the browser as you scroll in the Markdown files in Neovim.";
39+
};
40+
41+
picker = mkOption {
42+
type = enum [
43+
""
44+
"telescope"
45+
"fzf-lua"
46+
"mini.pick"
47+
"snacks.picker"
48+
"vim.ui.select"
49+
];
50+
default = "";
51+
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.";
52+
};
53+
54+
address = mkOption {
55+
type = str;
56+
default = "127.0.0.1";
57+
description = "Hostname/IP-address to bind the server to. Default: `127.0.0.1`.";
58+
};
59+
};
60+
};
61+
}

npins/sources.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,19 @@
10301030
"url": "https://github.com/kawre/leetcode.nvim/archive/4e8b3683940a8377379ce9398e7f329e3560b42c.tar.gz",
10311031
"hash": "sha256-82ppJQURAJcffgWwPHjrU9hROIKgk1hVITxNTzGtY5o="
10321032
},
1033+
"live-preview-nvim": {
1034+
"type": "Git",
1035+
"repository": {
1036+
"type": "GitHub",
1037+
"owner": "brianhuster",
1038+
"repo": "live-preview.nvim"
1039+
},
1040+
"branch": "main",
1041+
"submodules": false,
1042+
"revision": "a6307fa340ed7c0d96f5c567afc8c991aad94ce0",
1043+
"url": "https://github.com/brianhuster/live-preview.nvim/archive/a6307fa340ed7c0d96f5c567afc8c991aad94ce0.tar.gz",
1044+
"hash": "sha256-xyeoz4lEqrinkqY5U4Fu1S2HlmCyXiNQ2l2+AJFozIc="
1045+
},
10331046
"lsp-signature-nvim": {
10341047
"type": "Git",
10351048
"repository": {

0 commit comments

Comments
 (0)