-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #217 from Donnerinoern/language/markdown
utility/preview: added markdown-previewer.nvim and moved glow
- Loading branch information
Showing
11 changed files
with
145 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,6 @@ _: { | |
./diffview | ||
./wakatime | ||
./surround | ||
./preview | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
imports = [ | ||
./markdown-preview | ||
./glow | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
pkgs, | ||
config, | ||
lib, | ||
... | ||
}: let | ||
inherit (lib) nvim mkIf mkMerge mkBinding; | ||
|
||
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.luaConfigRC.glow = nvim.dag.entryAnywhere '' | ||
require('glow').setup({ | ||
glow_path = "${pkgs.glow}/bin/glow" | ||
}); | ||
''; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
imports = [ | ||
./glow.nix | ||
./config.nix | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{lib, ...}: let | ||
inherit (lib) mkEnableOption mkMappingOption; | ||
in { | ||
options.vim.utility.preview = { | ||
glow = { | ||
enable = mkEnableOption "markdown preview in neovim with glow"; | ||
mappings = { | ||
openPreview = mkMappingOption "Open preview" "<leader>p"; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
pkgs, | ||
config, | ||
lib, | ||
... | ||
}: let | ||
inherit (lib) nvim mkIf concatMapStringsSep optionalString stringLength; | ||
inherit (nvim.vim) mkVimBool; | ||
|
||
cfg = config.vim.utility.preview.markdownPreview; | ||
in { | ||
config = mkIf cfg.enable { | ||
vim.startPlugins = [pkgs.vimPlugins.markdown-preview-nvim]; | ||
|
||
vim.configRC.markdown-preview = nvim.dag.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}'"} | ||
''; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
imports = [ | ||
./markdown-preview.nix | ||
./config.nix | ||
]; | ||
} |
57 changes: 57 additions & 0 deletions
57
modules/utility/preview/markdown-preview/markdown-preview.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{lib, ...}: let | ||
inherit (lib) types mkEnableOption mkOption; | ||
in { | ||
options.vim.utility.preview = { | ||
markdownPreview = { | ||
enable = mkEnableOption "Markdown preview in neovim with markdown-preview.nvim"; | ||
|
||
autoStart = mkOption { | ||
type = types.bool; | ||
default = false; | ||
description = "Automatically open the preview window after entering a Markdown buffer"; | ||
}; | ||
|
||
autoClose = mkOption { | ||
type = types.bool; | ||
default = true; | ||
description = "Automatically close the preview window after leaving a Markdown buffer"; | ||
}; | ||
|
||
lazyRefresh = mkOption { | ||
type = types.bool; | ||
default = false; | ||
description = "Only update preview when saving or leaving insert mode"; | ||
}; | ||
|
||
filetypes = mkOption { | ||
type = with types; listOf str; | ||
default = ["markdown"]; | ||
description = "Allowed filetypes"; | ||
}; | ||
|
||
alwaysAllowPreview = mkOption { | ||
type = types.bool; | ||
default = false; | ||
description = "Allow preview on all filetypes"; | ||
}; | ||
|
||
broadcastServer = mkOption { | ||
type = types.bool; | ||
default = false; | ||
description = "Allow for outside and network wide connections"; | ||
}; | ||
|
||
customIP = mkOption { | ||
type = types.str; | ||
default = ""; | ||
description = "IP-address to use"; | ||
}; | ||
|
||
customPort = mkOption { | ||
type = types.str; | ||
default = ""; | ||
description = "Port to use"; | ||
}; | ||
}; | ||
}; | ||
} |