From 69a19b5e79e4e8f4f5945db6bce9997506b78398 Mon Sep 17 00:00:00 2001 From: Gabriel Volpe Date: Tue, 17 Sep 2024 19:29:08 +0200 Subject: [PATCH] set up render-markdown.nvim plugin --- README.md | 2 +- flake.lock | 17 ++++++++++++ flake.nix | 5 ++++ lib/ide.nix | 1 + modules/markdown/config.nix | 12 -------- modules/markdown/default.nix | 54 ++++++++++++++++++++++++++++++++---- modules/markdown/glow.nix | 38 ------------------------- 7 files changed, 73 insertions(+), 56 deletions(-) delete mode 100644 modules/markdown/config.nix delete mode 100644 modules/markdown/glow.nix diff --git a/README.md b/README.md index 195c2a9..1779eaf 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Nix flake for [neovim](https://neovim.io/) with configuration options highly foc ## Documentation -- [https://gvolpe.com/neovim-flake](https://gvolpe.com/neovim-flake). +- [gvolpe.com/neovim-flake](https://gvolpe.com/neovim-flake) ## Credits diff --git a/flake.lock b/flake.lock index 120c96e..5c99ea0 100644 --- a/flake.lock +++ b/flake.lock @@ -1131,6 +1131,22 @@ "type": "github" } }, + "render-markdown-nvim": { + "flake": false, + "locked": { + "lastModified": 1726511696, + "narHash": "sha256-l0k39OXcpoH7D6UmuQy0LNLj+8HCkKz9R/4zVH4bEt0=", + "owner": "MeanderingProgrammer", + "repo": "render-markdown.nvim", + "rev": "2424693c7a4c79641a7ea1e2a838dbc9238d6066", + "type": "github" + }, + "original": { + "owner": "MeanderingProgrammer", + "repo": "render-markdown.nvim", + "type": "github" + } + }, "root": { "inputs": { "bufdelete-nvim": "bufdelete-nvim", @@ -1191,6 +1207,7 @@ "onedark": "onedark", "plenary-nvim": "plenary-nvim", "promise-async": "promise-async", + "render-markdown-nvim": "render-markdown-nvim", "rosepine": "rosepine", "rust-tools": "rust-tools", "sqls-nvim": "sqls-nvim", diff --git a/flake.nix b/flake.nix index 6fa8798..549e23a 100644 --- a/flake.nix +++ b/flake.nix @@ -337,6 +337,11 @@ flake = false; }; + render-markdown-nvim = { + url = github:MeanderingProgrammer/render-markdown.nvim; + flake = false; + }; + # Organized notes in trees mind-nvim = { url = github:gvolpe/mind.nvim; diff --git a/lib/ide.nix b/lib/ide.nix index 8e93dbf..1c69e2a 100644 --- a/lib/ide.nix +++ b/lib/ide.nix @@ -107,6 +107,7 @@ let markdown = { enable = true; glow.enable = true; + render.enable = true; }; git = { enable = true; diff --git a/modules/markdown/config.nix b/modules/markdown/config.nix deleted file mode 100644 index 52a50f9..0000000 --- a/modules/markdown/config.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ lib, ... }: - -with lib; - -{ - config = { - vim.markdown = { - enable = mkDefault false; - glow.enable = mkDefault false; - }; - }; -} diff --git a/modules/markdown/default.nix b/modules/markdown/default.nix index 960db50..e703e8f 100644 --- a/modules/markdown/default.nix +++ b/modules/markdown/default.nix @@ -1,8 +1,52 @@ -{ ... }: +{ pkgs, config, lib, ... }: +with lib; +with builtins; + +let + cfg = config.vim.markdown; +in { - imports = [ - ./config.nix - ./glow.nix - ]; + options.vim.markdown = { + enable = mkEnableOption "markdown tools and plugins"; + + glow.enable = mkOption { + type = types.bool; + default = false; + description = "Enable markdown preview in neovim with glow"; + }; + + render.enable = mkOption { + type = types.bool; + default = false; + description = "Enable render-markdown.nvim plugin"; + }; + }; + + config = mkIf cfg.enable { + vim.startPlugins = + withPlugins cfg.glow.enable [ pkgs.neovimPlugins.glow-nvim ] ++ + withPlugins cfg.render.enable [ pkgs.neovimPlugins.render-markdown-nvim ]; + + vim.luaConfigRC = + writeIf cfg.glow.enable '' + require('glow').setup({ + glow_path = "${pkgs.glow}/bin/glow", + border = "shadow", + pager = false, + width = 120, + }) + '' + + writeIf cfg.render.enable '' + require('render-markdown').setup({}) + ''; + + vim.configRC = + writeIf cfg.glow.enable '' + autocmd FileType markdown noremap p Glow + '' + + writeIf cfg.render.enable '' + autocmd FileType markdown noremap rt RenderMarkdown toggle + ''; + }; } diff --git a/modules/markdown/glow.nix b/modules/markdown/glow.nix deleted file mode 100644 index 2b1906a..0000000 --- a/modules/markdown/glow.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ pkgs, config, lib, ... }: - -with lib; -with builtins; - -let - cfg = config.vim.markdown; -in -{ - options.vim.markdown = { - enable = mkEnableOption "markdown tools and plugins"; - - glow.enable = mkOption { - type = types.bool; - default = true; - description = "Enable markdown preview in neovim with glow"; - }; - }; - - config = mkIf cfg.enable { - vim.startPlugins = - withPlugins cfg.glow.enable [ pkgs.neovimPlugins.glow-nvim ]; - - vim.luaConfigRC = writeIf cfg.glow.enable '' - require('glow').setup({ - glow_path = "${pkgs.glow}/bin/glow", - border = "shadow", - pager = false, - width = 120, - }) - ''; - - vim.configRC = - writeIf cfg.glow.enable '' - autocmd FileType markdown noremap p Glow - ''; - }; -}