From fdca3b1e7e66ffe8d499ea661037dbb1aec3be83 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 18 Apr 2023 00:38:57 +0300 Subject: [PATCH] feat(languages: move markdown and tidal to languages module) --- extra.nix | 6 +++- modules/languages/default.nix | 3 ++ modules/languages/markdown/config.nix | 24 ++++++++++++++ modules/{ => languages}/markdown/default.nix | 3 +- modules/languages/markdown/markdown.nix | 20 ++++++++++++ modules/languages/nix.nix | 2 +- modules/{ => languages}/tidal/config.nix | 0 modules/{ => languages}/tidal/default.nix | 0 modules/{ => languages}/tidal/tidal.nix | 0 modules/lsp/default.nix | 2 +- modules/markdown/config.nix | 12 ------- modules/markdown/glow/config.nix | 33 -------------------- modules/markdown/glow/default.nix | 6 ---- modules/markdown/glow/glow.nix | 33 -------------------- modules/markdown/module.nix | 19 ----------- modules/modules.nix | 2 -- modules/utility/binds/which-key/config.nix | 2 +- 17 files changed, 56 insertions(+), 111 deletions(-) create mode 100644 modules/languages/markdown/config.nix rename modules/{ => languages}/markdown/default.nix (62%) create mode 100644 modules/languages/markdown/markdown.nix rename modules/{ => languages}/tidal/config.nix (100%) rename modules/{ => languages}/tidal/default.nix (100%) rename modules/{ => languages}/tidal/tidal.nix (100%) delete mode 100644 modules/markdown/config.nix delete mode 100644 modules/markdown/glow/config.nix delete mode 100644 modules/markdown/glow/default.nix delete mode 100644 modules/markdown/glow/glow.nix delete mode 100644 modules/markdown/module.nix diff --git a/extra.nix b/extra.nix index 5fba36b..f7e48d5 100644 --- a/extra.nix +++ b/extra.nix @@ -13,6 +13,10 @@ inputs: let configuration.imports = modules; }; + tidalConfig = { + config.vim.languages.tidal.enable = true; + }; + mainConfig = isMaximal: { config = { vim = { @@ -191,5 +195,5 @@ inputs: let }; }; in { - inherit neovimConfiguration mainConfig; + inherit neovimConfiguration mainConfig tidalConfig; } diff --git a/modules/languages/default.nix b/modules/languages/default.nix index 3b26e35..5e370cc 100644 --- a/modules/languages/default.nix +++ b/modules/languages/default.nix @@ -8,6 +8,9 @@ with lib; let }; in { imports = [ + ./markdown + ./tidal + ./clang.nix ./go.nix ./nix.nix diff --git a/modules/languages/markdown/config.nix b/modules/languages/markdown/config.nix new file mode 100644 index 0000000..8f6e626 --- /dev/null +++ b/modules/languages/markdown/config.nix @@ -0,0 +1,24 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.languages.markdown; +in { + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.glow.enable { + vim.startPlugins = ["glow-nvim"]; + + vim.globals = { + "glow_binary_path" = "${pkgs.glow}/bin"; + }; + + vim.configRC.glow = nvim.dag.entryAnywhere '' + autocmd FileType markdown noremap p :Glow + ''; + }) + ]); +} diff --git a/modules/markdown/default.nix b/modules/languages/markdown/default.nix similarity index 62% rename from modules/markdown/default.nix rename to modules/languages/markdown/default.nix index e975149..3834589 100644 --- a/modules/markdown/default.nix +++ b/modules/languages/markdown/default.nix @@ -1,7 +1,6 @@ {...}: { imports = [ - ./glow ./config.nix - ./module.nix + ./markdown.nix ]; } diff --git a/modules/languages/markdown/markdown.nix b/modules/languages/markdown/markdown.nix new file mode 100644 index 0000000..706bf5d --- /dev/null +++ b/modules/languages/markdown/markdown.nix @@ -0,0 +1,20 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.languages.markdown; +in { + options.vim.languages.markdown = { + enable = mkEnableOption "Markdown language support"; + + glow.enable = mkOption { + type = types.bool; + default = true; + description = "Enable markdown preview in neovim with glow"; + }; + }; +} diff --git a/modules/languages/nix.nix b/modules/languages/nix.nix index 5063f6b..f7273ac 100644 --- a/modules/languages/nix.nix +++ b/modules/languages/nix.nix @@ -8,7 +8,7 @@ with lib; with builtins; let cfg = config.vim.languages.nix; - useFormat = "on_attach = default_on_attatch"; + useFormat = "on_attach = default_on_attach"; noFormat = "on_attach = attach_keymaps"; defaultServer = "nil"; diff --git a/modules/tidal/config.nix b/modules/languages/tidal/config.nix similarity index 100% rename from modules/tidal/config.nix rename to modules/languages/tidal/config.nix diff --git a/modules/tidal/default.nix b/modules/languages/tidal/default.nix similarity index 100% rename from modules/tidal/default.nix rename to modules/languages/tidal/default.nix diff --git a/modules/tidal/tidal.nix b/modules/languages/tidal/tidal.nix similarity index 100% rename from modules/tidal/tidal.nix rename to modules/languages/tidal/tidal.nix diff --git a/modules/lsp/default.nix b/modules/lsp/default.nix index cd18221..16b7f47 100644 --- a/modules/lsp/default.nix +++ b/modules/lsp/default.nix @@ -4,7 +4,7 @@ ./config.nix ./module.nix - ./lspconfig + ./lspconfig ./lspsaga ./null-ls diff --git a/modules/markdown/config.nix b/modules/markdown/config.nix deleted file mode 100644 index c8929ce..0000000 --- a/modules/markdown/config.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ - config, - lib, - ... -}: -with lib; { - config = { - vim.markdown = { - enable = mkDefault false; - }; - }; -} diff --git a/modules/markdown/glow/config.nix b/modules/markdown/glow/config.nix deleted file mode 100644 index f0019f2..0000000 --- a/modules/markdown/glow/config.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ - pkgs, - config, - lib, - ... -}: -with lib; let - cfg = config.vim.markdown.glow; -in { - config = (mkIf cfg.enable) { - vim.startPlugins = [ - "glow-nvim" - ]; - - vim.globals = { - "glow_binary_path" = "${pkgs.glow}/bin"; - }; - - vim.configRC.glow-nvim = nvim.dag.entryAnywhere '' - autocmd FileType markdown noremap pm :Glow - ''; - - vim.luaConfigRC.glow-nvim = nvim.dag.entryAnywhere '' - require('glow').setup({ - -- use glow path from vim.globals - path = vim.g.glow_binary_path, - border = "${toString cfg.border}", - pager = ${boolToString cfg.pager}, - width = 120, - }) - ''; - }; -} diff --git a/modules/markdown/glow/default.nix b/modules/markdown/glow/default.nix deleted file mode 100644 index 9b128a3..0000000 --- a/modules/markdown/glow/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -_: { - imports = [ - ./glow.nix - ./config.nix - ]; -} diff --git a/modules/markdown/glow/glow.nix b/modules/markdown/glow/glow.nix deleted file mode 100644 index ad20b65..0000000 --- a/modules/markdown/glow/glow.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ - config, - lib, - ... -}: -with lib; -with builtins; { - options.vim.markdown.glow = { - enable = mkOption { - type = types.bool; - default = false; - description = "Enable markdown preview in neovim with glow"; - }; - border = mkOption { - type = types.enum ["shadow" "rounded" "single" "double" "none"]; - default = "double"; - description = "Border style for glow preview"; - }; - - # style should be either light or dark - style = mkOption { - type = types.enum ["light" "dark"]; - default = "dark"; - description = "Style for glow preview"; - }; - - pager = mkOption { - type = types.bool; - default = false; - description = "Enable pager for glow preview"; - }; - }; -} diff --git a/modules/markdown/module.nix b/modules/markdown/module.nix deleted file mode 100644 index 761f58c..0000000 --- a/modules/markdown/module.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ - config, - lib, - ... -}: -with lib; -with builtins; let - cfg = config.vim.markdown; -in { - options.vim.markdown = { - enable = mkEnableOption "Enable markdown tools and plugins"; - }; - - config = mkIf (cfg.enable) { - /* - ... - */ - }; -} diff --git a/modules/modules.nix b/modules/modules.nix index 86d137f..a23241c 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -14,10 +14,8 @@ ./visuals ./lsp ./treesitter - ./tidal ./autopairs ./snippets - ./markdown ./git ./minimap ./dashboard diff --git a/modules/utility/binds/which-key/config.nix b/modules/utility/binds/which-key/config.nix index e2f5ae1..2a7b4b8 100644 --- a/modules/utility/binds/which-key/config.nix +++ b/modules/utility/binds/which-key/config.nix @@ -106,7 +106,7 @@ in { } ${ - if config.vim.markdown.glow.enable + if config.vim.languages.markdown.glow.enable then '' -- Markdown ["pm"] = { name = "+Preview Markdown" },