mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-10 04:45:59 +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
|
}: let
|
||||||
inherit (builtins) attrNames concatLists;
|
inherit (builtins) attrNames concatLists;
|
||||||
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.lists) isList;
|
inherit (lib.lists) isList;
|
||||||
inherit (lib.types) bool enum either package listOf str;
|
inherit (lib.types) bool enum either package listOf str;
|
||||||
|
@ -38,7 +39,7 @@
|
||||||
table.insert(
|
table.insert(
|
||||||
ls_sources,
|
ls_sources,
|
||||||
null_ls.builtins.formatting.deno_fmt.with({
|
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",
|
command = "${cfg.format.package}/bin/deno",
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
@ -51,9 +52,9 @@ in {
|
||||||
|
|
||||||
treesitter = {
|
treesitter = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
description = "Enable Markdown treesitter";
|
|
||||||
type = bool;
|
type = bool;
|
||||||
default = config.vim.languages.enableTreesitter;
|
default = config.vim.languages.enableTreesitter;
|
||||||
|
description = "Enable Markdown treesitter";
|
||||||
};
|
};
|
||||||
mdPackage = mkGrammarOption pkgs "markdown";
|
mdPackage = mkGrammarOption pkgs "markdown";
|
||||||
mdInlinePackage = mkGrammarOption pkgs "markdown-inline";
|
mdInlinePackage = mkGrammarOption pkgs "markdown-inline";
|
||||||
|
@ -63,16 +64,16 @@ in {
|
||||||
enable = mkEnableOption "Enable Markdown LSP support" // {default = config.vim.languages.enableLSP;};
|
enable = mkEnableOption "Enable Markdown LSP support" // {default = config.vim.languages.enableLSP;};
|
||||||
|
|
||||||
server = mkOption {
|
server = mkOption {
|
||||||
description = "Markdown LSP server to use";
|
|
||||||
type = enum (attrNames servers);
|
type = enum (attrNames servers);
|
||||||
default = defaultServer;
|
default = defaultServer;
|
||||||
|
description = "Markdown LSP server to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
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);
|
type = either package (listOf str);
|
||||||
default = servers.${cfg.lsp.server}.package;
|
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;};
|
enable = mkEnableOption "Markdown formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
description = "Markdown formatter to use";
|
|
||||||
type = enum (attrNames formats);
|
type = enum (attrNames formats);
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
|
description = "Markdown formatter to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "Markdown formatter package";
|
|
||||||
type = package;
|
type = package;
|
||||||
default = formats.${cfg.format.type}.package;
|
default = formats.${cfg.format.type}.package;
|
||||||
|
description = "Markdown formatter package";
|
||||||
};
|
};
|
||||||
|
|
||||||
extraFiletypes = mkOption {
|
extraFiletypes = mkOption {
|
||||||
description = "Extra filetypes to format with the Markdown formatter";
|
|
||||||
type = listOf str;
|
type = listOf str;
|
||||||
default = [];
|
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