mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-09 14:45:58 +01:00
Compare commits
2 commits
a85bf963e6
...
ea5f229efd
Author | SHA1 | Date | |
---|---|---|---|
ea5f229efd | |||
41f7abcdc3 |
1 changed files with 26 additions and 8 deletions
|
@ -5,6 +5,7 @@
|
|||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames concatLists;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib.types) bool enum either package listOf str;
|
||||
|
@ -38,7 +39,7 @@
|
|||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.formatting.deno_fmt.with({
|
||||
filetypes = ${concatLists cfg.format.extraFiletypes ["markdown"]},
|
||||
filetypes = ${expToLua (concatLists [cfg.format.extraFiletypes ["markdown"]])},
|
||||
command = "${cfg.format.package}/bin/deno",
|
||||
})
|
||||
)
|
||||
|
@ -51,9 +52,9 @@ in {
|
|||
|
||||
treesitter = {
|
||||
enable = mkOption {
|
||||
description = "Enable Markdown treesitter";
|
||||
type = bool;
|
||||
default = config.vim.languages.enableTreesitter;
|
||||
description = "Enable Markdown treesitter";
|
||||
};
|
||||
mdPackage = mkGrammarOption pkgs "markdown";
|
||||
mdInlinePackage = mkGrammarOption pkgs "markdown-inline";
|
||||
|
@ -63,16 +64,16 @@ in {
|
|||
enable = mkEnableOption "Enable Markdown LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
server = mkOption {
|
||||
description = "Markdown LSP server to use";
|
||||
type = enum (attrNames servers);
|
||||
default = defaultServer;
|
||||
description = "Markdown LSP server to use";
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Markdown LSP server package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
|
||||
type = either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
|
||||
description = "Markdown LSP server package, or the command to run as a list of strings";
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -80,22 +81,39 @@ in {
|
|||
enable = mkEnableOption "Markdown formatting" // {default = config.vim.languages.enableFormat;};
|
||||
|
||||
type = mkOption {
|
||||
description = "Markdown formatter to use";
|
||||
type = enum (attrNames formats);
|
||||
default = defaultFormat;
|
||||
description = "Markdown formatter to use";
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Markdown formatter package";
|
||||
type = package;
|
||||
default = formats.${cfg.format.type}.package;
|
||||
description = "Markdown formatter package";
|
||||
};
|
||||
|
||||
extraFiletypes = mkOption {
|
||||
description = "Extra filetypes to format with the Markdown formatter";
|
||||
type = listOf str;
|
||||
default = [];
|
||||
description = "Extra filetypes to format with the Markdown formatter";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.mdPackage cfg.treesitter.mdInlinePackage];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.markdown-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||
})
|
||||
|
||||
(mkIf cfg.format.enable {
|
||||
vim.lsp.null-ls.enable = true;
|
||||
vim.lsp.null-ls.sources.markdown-format = formats.${cfg.format.type}.nullConfig;
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue