|
7 | 7 | inherit (lib.options) mkEnableOption mkOption;
|
8 | 8 | inherit (lib.modules) mkIf mkMerge;
|
9 | 9 | inherit (lib.lists) isList;
|
10 |
| - inherit (lib.types) nullOr enum either attrsOf listOf package str; |
| 10 | + inherit (lib.types) nullOr enum either attrsOf listOf package str bool int; |
11 | 11 | inherit (lib.attrsets) attrNames;
|
12 | 12 | inherit (lib.meta) getExe;
|
| 13 | + inherit (lib.nvim.binds) mkMappingOption mkKeymap; |
13 | 14 | inherit (lib.nvim.lua) expToLua toLuaObject;
|
14 | 15 | inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption;
|
15 | 16 | inherit (lib.nvim.dag) entryAnywhere;
|
@@ -150,6 +151,57 @@ in {
|
150 | 151 | };
|
151 | 152 | };
|
152 | 153 | };
|
| 154 | + typst-concealer = { |
| 155 | + enable = mkEnableOption '' |
| 156 | + [typst-concealer]: https://github.com/PartyWumpus/typst-concealer |
| 157 | +
|
| 158 | + Inline typst preview for Neovim via [typst-concealer] |
| 159 | + ''; |
| 160 | + |
| 161 | + mappings = { |
| 162 | + toggleConcealing = mkMappingOption "Enable typst-concealer in buffer" "<leader>TT"; |
| 163 | + }; |
| 164 | + |
| 165 | + setupOpts = mkPluginSetupOption "typst-concealer" { |
| 166 | + do_diagnostics = mkOption { |
| 167 | + type = nullOr bool; |
| 168 | + default = !cfg.lsp.enable; |
| 169 | + description = "Should typst-concealer provide diagnostics on error?"; |
| 170 | + }; |
| 171 | + color = mkOption { |
| 172 | + type = nullOr str; |
| 173 | + default = null; |
| 174 | + example = "rgb(\"#f012be\")"; |
| 175 | + description = "What color should typst-concealer render text/stroke with? (only applies when styling_type is 'colorscheme')"; |
| 176 | + }; |
| 177 | + enabled_by_default = mkOption { |
| 178 | + type = nullOr bool; |
| 179 | + default = null; |
| 180 | + description = "Should typst-concealer conceal newly opened buffers by default?"; |
| 181 | + }; |
| 182 | + styling_type = mkOption { |
| 183 | + type = nullOr (enum ["simple" "none" "colorscheme"]); |
| 184 | + default = null; |
| 185 | + description = "What kind of styling should typst-concealer apply to your typst?"; |
| 186 | + }; |
| 187 | + ppi = mkOption { |
| 188 | + type = nullOr int; |
| 189 | + default = null; |
| 190 | + description = "What PPI should typst render at. Plugin default is 300, typst's normal default is 144."; |
| 191 | + }; |
| 192 | + typst_location = mkOption { |
| 193 | + type = str; |
| 194 | + default = getExe pkgs.typst; |
| 195 | + description = "Where should typst-concealer look for your typst binary?"; |
| 196 | + example = ''lib.getExe pkgs.typst''; |
| 197 | + }; |
| 198 | + conceal_in_normal = mkOption { |
| 199 | + type = nullOr bool; |
| 200 | + default = null; |
| 201 | + description = "Should typst-concealer still conceal when the normal mode cursor goes over a line."; |
| 202 | + }; |
| 203 | + }; |
| 204 | + }; |
153 | 205 | };
|
154 | 206 | };
|
155 | 207 | config = mkIf cfg.enable (mkMerge [
|
@@ -180,5 +232,18 @@ in {
|
180 | 232 | require("typst-preview").setup(${toLuaObject cfg.extensions.typst-preview-nvim.setupOpts})
|
181 | 233 | '';
|
182 | 234 | })
|
| 235 | + |
| 236 | + (mkIf cfg.extensions.typst-concealer.enable { |
| 237 | + vim.lazy.plugins.typst-concealer = { |
| 238 | + event = "BufRead *.typ"; |
| 239 | + package = "typst-concealer"; |
| 240 | + setupModule = "typst-concealer"; |
| 241 | + setupOpts = cfg.extensions.typst-concealer.setupOpts; |
| 242 | + |
| 243 | + keys = [ |
| 244 | + (mkKeymap "n" cfg.extensions.typst-concealer.mappings.toggleConcealing "<cmd>lua require('typst-concealer').toggle_buf()<CR>" {desc = "Toggle typst-concealer in buffer";}) |
| 245 | + ]; |
| 246 | + }; |
| 247 | + }) |
183 | 248 | ]);
|
184 | 249 | }
|
0 commit comments