mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 10:21:31 +00:00
treewide: begin restructuring the module tree
This commit is contained in:
parent
e1835f6c46
commit
7c730a78e5
254 changed files with 749 additions and 664 deletions
6
modules/plugins/utility/preview/default.nix
Normal file
6
modules/plugins/utility/preview/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./markdown-preview
|
||||
./glow
|
||||
];
|
||||
}
|
36
modules/plugins/utility/preview/glow/config.nix
Normal file
36
modules/plugins/utility/preview/glow/config.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.binds) mkBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
# TODO: move this to its own module
|
||||
inherit (lib) pushDownDefault;
|
||||
|
||||
cfg = config.vim.utility.preview.glow;
|
||||
self = import ./glow.nix {
|
||||
inherit lib config pkgs;
|
||||
};
|
||||
mappings = self.options.vim.utility.preview.glow.mappings;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = ["glow-nvim"];
|
||||
|
||||
vim.maps.normal = mkMerge [
|
||||
(mkBinding cfg.mappings.openPreview ":Glow<CR>" mappings.openPreview.description)
|
||||
];
|
||||
|
||||
vim.binds.whichKey.register = pushDownDefault {
|
||||
"<leader>pm" = "+Preview Markdown";
|
||||
};
|
||||
|
||||
vim.luaConfigRC.glow = entryAnywhere ''
|
||||
require('glow').setup({
|
||||
glow_path = "${pkgs.glow}/bin/glow"
|
||||
});
|
||||
'';
|
||||
};
|
||||
}
|
6
modules/plugins/utility/preview/glow/default.nix
Normal file
6
modules/plugins/utility/preview/glow/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./glow.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
16
modules/plugins/utility/preview/glow/glow.nix
Normal file
16
modules/plugins/utility/preview/glow/glow.nix
Normal file
|
@ -0,0 +1,16 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.modules) mkRenamedOptionModule;
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
in {
|
||||
imports = [
|
||||
(mkRenamedOptionModule ["vim" "languages" "markdown" "glow" "enable"] ["vim" "utility" "preview" "glow" "enable"])
|
||||
];
|
||||
|
||||
options.vim.utility.preview = {
|
||||
glow = {
|
||||
enable = mkEnableOption "markdown preview in neovim with glow";
|
||||
mappings.openPreview = mkMappingOption "Open preview" "<leader>p";
|
||||
};
|
||||
};
|
||||
}
|
28
modules/plugins/utility/preview/markdown-preview/config.nix
Normal file
28
modules/plugins/utility/preview/markdown-preview/config.nix
Normal file
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.strings) optionalString stringLength concatMapStringsSep;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.vim) mkVimBool;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
||||
cfg = config.vim.utility.preview.markdownPreview;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [pkgs.vimPlugins.markdown-preview-nvim];
|
||||
|
||||
vim.configRC.markdown-preview = entryAnywhere ''
|
||||
let g:mkdp_auto_start = ${mkVimBool cfg.autoStart}
|
||||
let g:mkdp_auto_close = ${mkVimBool cfg.autoClose}
|
||||
let g:mkdp_refresh_slow = ${mkVimBool cfg.lazyRefresh}
|
||||
let g:mkdp_filetypes = [${concatMapStringsSep ", " (x: "'" + x + "'") cfg.filetypes}]
|
||||
let g:mkdp_command_for_global = ${mkVimBool cfg.alwaysAllowPreview}
|
||||
let g:mkdp_open_to_the_world = ${mkVimBool cfg.broadcastServer}
|
||||
${optionalString (stringLength cfg.customIP > 0) "let g:mkdp_open_ip = '${cfg.customIP}'"}
|
||||
${optionalString (stringLength cfg.customPort > 0) "let g:mkdp_port = '${cfg.customPort}'"}
|
||||
'';
|
||||
};
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./markdown-preview.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) bool str listOf;
|
||||
in {
|
||||
options.vim.utility.preview = {
|
||||
markdownPreview = {
|
||||
enable = mkEnableOption "Markdown preview in neovim with markdown-preview.nvim";
|
||||
|
||||
autoStart = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Automatically open the preview window after entering a Markdown buffer";
|
||||
};
|
||||
|
||||
autoClose = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "Automatically close the preview window after leaving a Markdown buffer";
|
||||
};
|
||||
|
||||
lazyRefresh = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Only update preview when saving or leaving insert mode";
|
||||
};
|
||||
|
||||
filetypes = mkOption {
|
||||
type = listOf str;
|
||||
default = ["markdown"];
|
||||
description = "Allowed filetypes";
|
||||
};
|
||||
|
||||
alwaysAllowPreview = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Allow preview on all filetypes";
|
||||
};
|
||||
|
||||
broadcastServer = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Allow for outside and network wide connections";
|
||||
};
|
||||
|
||||
customIP = mkOption {
|
||||
type = str;
|
||||
default = "";
|
||||
description = "IP-address to use";
|
||||
};
|
||||
|
||||
customPort = mkOption {
|
||||
type = str;
|
||||
default = "";
|
||||
description = "Port to use";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue