Skip to content

Commit d9055ab

Browse files
committed
plugins/markview: init
1 parent f13bdef commit d9055ab

File tree

3 files changed

+150
-0
lines changed

3 files changed

+150
-0
lines changed

plugins/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
./languages/ltex-extra.nix
7373
./languages/markdown/glow.nix
7474
./languages/markdown/markdown-preview.nix
75+
./languages/markdown/markview.nix
7576
./languages/markdown/preview.nix
7677
./languages/nix.nix
7778
./languages/nvim-jdtls.nix
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{
2+
lib,
3+
config,
4+
pkgs,
5+
...
6+
}:
7+
let
8+
inherit (lib.nixvim) defaultNullOpts;
9+
inherit (lib) types;
10+
in
11+
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
12+
name = "markview";
13+
originalName = "markview.nvim";
14+
defaultPackage = pkgs.vimPlugins.markview-nvim;
15+
16+
maintainers = [ lib.maintainers.khaneliman ];
17+
18+
description = ''
19+
An experimental markdown previewer for Neovim.
20+
21+
Supports a vast amount of rendering customization.
22+
Please refer to the plugin's [documentation](https://github.com/OXY2DEV/markview.nvim/wiki/Configuration-options) for more details.
23+
'';
24+
25+
# TODO: remove when https://github.com/NixOS/nixpkgs/pull/333587 is available
26+
extraPlugins = with pkgs.vimPlugins; [ nvim-web-devicons ];
27+
28+
settingsOptions = {
29+
buf_ignore = defaultNullOpts.mkListOf types.str [ "nofile" ] ''
30+
Buftypes to disable markview-nvim.
31+
'';
32+
33+
mode =
34+
defaultNullOpts.mkListOf types.str
35+
[
36+
"n"
37+
"no"
38+
]
39+
''
40+
Modes where preview is enabled.
41+
'';
42+
43+
hybrid_modes = defaultNullOpts.mkListOf types.str null ''
44+
Modes where hybrid mode is enabled.
45+
'';
46+
47+
callback = {
48+
on_enable = defaultNullOpts.mkLuaFn' {
49+
pluginDefault = # Lua
50+
''
51+
function(buf, win)
52+
vim.wo[window].conceallevel = 2;
53+
vim.wo[window].concealcursor = "nc";
54+
end
55+
'';
56+
description = ''
57+
Action to perform when markview is enabled.
58+
'';
59+
};
60+
61+
on_disable = defaultNullOpts.mkLuaFn' {
62+
pluginDefault = # Lua
63+
''
64+
function(buf, win)
65+
vim.wo[window].conceallevel = 0;
66+
vim.wo[window].concealcursor = "";
67+
end
68+
'';
69+
description = ''
70+
Action to perform when markview is disabled.
71+
'';
72+
};
73+
74+
on_mode_change = defaultNullOpts.mkLuaFn' {
75+
pluginDefault = # Lua
76+
''
77+
function(buf, win, mode)
78+
if vim.list_contains(markview.configuration.modes, mode) then
79+
vim.wo[window].conceallevel = 2;
80+
else
81+
vim.wo[window].conceallevel = 0;
82+
end
83+
end
84+
'';
85+
description = ''
86+
Action to perform when mode is changed, while the plugin is enabled.
87+
'';
88+
};
89+
};
90+
};
91+
92+
settingsExample = {
93+
buf_ignore = [ ];
94+
mode = [
95+
"n"
96+
"x"
97+
];
98+
hybrid_modes = [
99+
"i"
100+
"r"
101+
];
102+
};
103+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
_: {
2+
empty = {
3+
plugins.markview.enable = true;
4+
};
5+
6+
defaults = {
7+
plugins.markview = {
8+
enable = true;
9+
10+
settings = {
11+
buf_ignore = [ "nofile" ];
12+
mode = [
13+
"n"
14+
"no"
15+
];
16+
hybrid_modes = [ ];
17+
callback = {
18+
on_enable = # Lua
19+
''
20+
function(buf, win)
21+
vim.wo[window].conceallevel = 2;
22+
vim.wo[window].concealcursor = "nc";
23+
end
24+
'';
25+
on_disable = # Lua
26+
''
27+
function(buf, win)
28+
vim.wo[window].conceallevel = 0;
29+
vim.wo[window].concealcursor = "";
30+
end
31+
'';
32+
on_mode_change = # Lua
33+
''
34+
function(buf, win, mode)
35+
if vim.list_contains(markview.configuration.modes, mode) then
36+
vim.wo[window].conceallevel = 2;
37+
else
38+
vim.wo[window].conceallevel = 0;
39+
end
40+
end
41+
'';
42+
};
43+
};
44+
};
45+
};
46+
}

0 commit comments

Comments
 (0)