mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-08 03:11:36 +00:00
treewide: begin restructuring the module tree
This commit is contained in:
parent
e1835f6c46
commit
7c730a78e5
254 changed files with 749 additions and 664 deletions
40
modules/plugins/languages/markdown/config.nix
Normal file
40
modules/plugins/languages/markdown/config.nix
Normal file
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.lists) isList;
|
||||
|
||||
cfg = config.vim.languages.markdown;
|
||||
servers = {
|
||||
marksman = {
|
||||
package = pkgs.marksman;
|
||||
lspConfig = ''
|
||||
lspconfig.marksman.setup{
|
||||
capabilities = capabilities;
|
||||
on_attach = default_on_attach;
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/marksman", "server"}''
|
||||
},
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
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;
|
||||
})
|
||||
]);
|
||||
}
|
6
modules/plugins/languages/markdown/default.nix
Normal file
6
modules/plugins/languages/markdown/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./markdown.nix
|
||||
];
|
||||
}
|
63
modules/plugins/languages/markdown/markdown.nix
Normal file
63
modules/plugins/languages/markdown/markdown.nix
Normal file
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib.types) bool enum either package listOf str;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
|
||||
cfg = config.vim.languages.markdown;
|
||||
defaultServer = "marksman";
|
||||
servers = {
|
||||
marksman = {
|
||||
package = pkgs.marksman;
|
||||
lspConfig = ''
|
||||
lspconfig.marksman.setup{
|
||||
capabilities = capabilities;
|
||||
on_attach = default_on_attach;
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/marksman", "server"}''
|
||||
},
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.markdown = {
|
||||
enable = mkEnableOption "Markdown markup language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkOption {
|
||||
description = "Enable Markdown treesitter";
|
||||
type = bool;
|
||||
default = config.vim.languages.enableTreesitter;
|
||||
};
|
||||
mdPackage = mkGrammarOption pkgs "markdown";
|
||||
mdInlinePackage = mkGrammarOption pkgs "markdown-inline";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
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;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue