mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 10:59:49 +01:00
modules/languages: switch to explicit lib calls
This commit is contained in:
parent
d29934b859
commit
6d3f28283f
3 changed files with 34 additions and 24 deletions
|
@ -1,19 +1,25 @@
|
||||||
{
|
{
|
||||||
pkgs,
|
|
||||||
config,
|
config,
|
||||||
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames;
|
||||||
inherit (lib) isList nvim optionalString mkEnableOption mkOption types mkIf mkMerge;
|
inherit (lib.lists) isList;
|
||||||
|
inherit (lib) nvim;
|
||||||
|
inherit (lib.strings) optionalString;
|
||||||
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
|
inherit (lib.types) bool enum package either listOf str nullOr;
|
||||||
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
|
|
||||||
cfg = config.vim.languages.clang;
|
|
||||||
|
|
||||||
defaultServer = "ccls";
|
|
||||||
packageToCmd = package: defaultCmd:
|
packageToCmd = package: defaultCmd:
|
||||||
if isList cfg.lsp.package
|
if isList cfg.lsp.package
|
||||||
then nvim.lua.expToLua cfg.lsp.package
|
then nvim.lua.expToLua cfg.lsp.package
|
||||||
else ''{ "${cfg.lsp.package}/bin/${defaultCmd}" }'';
|
else ''{ "${cfg.lsp.package}/bin/${defaultCmd}" }'';
|
||||||
|
|
||||||
|
cfg = config.vim.languages.clang;
|
||||||
|
|
||||||
|
defaultServer = "ccls";
|
||||||
servers = {
|
servers = {
|
||||||
ccls = {
|
ccls = {
|
||||||
package = pkgs.ccls;
|
package = pkgs.ccls;
|
||||||
|
@ -79,7 +85,7 @@ in {
|
||||||
C syntax for headers. Can fix treesitter errors, see:
|
C syntax for headers. Can fix treesitter errors, see:
|
||||||
https://www.reddit.com/r/neovim/comments/orfpcd/question_does_the_c_parser_from_nvimtreesitter/
|
https://www.reddit.com/r/neovim/comments/orfpcd/question_does_the_c_parser_from_nvimtreesitter/
|
||||||
'';
|
'';
|
||||||
type = types.bool;
|
type = bool;
|
||||||
default = false;
|
default = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -94,20 +100,20 @@ in {
|
||||||
|
|
||||||
server = mkOption {
|
server = mkOption {
|
||||||
description = "The clang LSP server to use";
|
description = "The clang LSP server to use";
|
||||||
type = with types; enum (attrNames servers);
|
type = enum (attrNames servers);
|
||||||
default = defaultServer;
|
default = defaultServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "clang LSP server package, or the command to run as a list of strings";
|
description = "clang LSP server package, or the command to run as a list of strings";
|
||||||
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
|
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
|
||||||
type = with types; either package (listOf str);
|
type = either package (listOf str);
|
||||||
default = servers.${cfg.lsp.server}.package;
|
default = servers.${cfg.lsp.server}.package;
|
||||||
};
|
};
|
||||||
|
|
||||||
opts = mkOption {
|
opts = mkOption {
|
||||||
description = "Options to pass to clang LSP server";
|
description = "Options to pass to clang LSP server";
|
||||||
type = with types; nullOr str;
|
type = nullOr str;
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -115,17 +121,17 @@ in {
|
||||||
dap = {
|
dap = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
description = "Enable clang Debug Adapter";
|
description = "Enable clang Debug Adapter";
|
||||||
type = types.bool;
|
type = bool;
|
||||||
default = config.vim.languages.enableDAP;
|
default = config.vim.languages.enableDAP;
|
||||||
};
|
};
|
||||||
debugger = mkOption {
|
debugger = mkOption {
|
||||||
description = "clang debugger to use";
|
description = "clang debugger to use";
|
||||||
type = with types; enum (attrNames debuggers);
|
type = enum (attrNames debuggers);
|
||||||
default = defaultDebugger;
|
default = defaultDebugger;
|
||||||
};
|
};
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "clang debugger package.";
|
description = "clang debugger package.";
|
||||||
type = types.package;
|
type = package;
|
||||||
default = debuggers.${cfg.dap.debugger}.package;
|
default = debuggers.${cfg.dap.debugger}.package;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) nvim mkIf mkMerge isList;
|
inherit (lib.nvim.lua) expToLua;
|
||||||
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
|
inherit (lib.lists) isList;
|
||||||
|
|
||||||
cfg = config.vim.languages.markdown;
|
cfg = config.vim.languages.markdown;
|
||||||
servers = {
|
servers = {
|
||||||
|
@ -16,7 +18,7 @@
|
||||||
on_attach = default_on_attach;
|
on_attach = default_on_attach;
|
||||||
cmd = ${
|
cmd = ${
|
||||||
if isList cfg.lsp.package
|
if isList cfg.lsp.package
|
||||||
then nvim.lua.expToLua cfg.lsp.package
|
then expToLua cfg.lsp.package
|
||||||
else ''{"${cfg.lsp.package}/bin/marksman", "server"}''
|
else ''{"${cfg.lsp.package}/bin/marksman", "server"}''
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -27,13 +29,11 @@ in {
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
(mkIf cfg.treesitter.enable {
|
(mkIf cfg.treesitter.enable {
|
||||||
vim.treesitter.enable = true;
|
vim.treesitter.enable = true;
|
||||||
|
|
||||||
vim.treesitter.grammars = [cfg.treesitter.mdPackage cfg.treesitter.mdInlinePackage];
|
vim.treesitter.grammars = [cfg.treesitter.mdPackage cfg.treesitter.mdInlinePackage];
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.lsp.enable {
|
(mkIf cfg.lsp.enable {
|
||||||
vim.lsp.lspconfig.enable = true;
|
vim.lsp.lspconfig.enable = true;
|
||||||
|
|
||||||
vim.lsp.lspconfig.sources.markdown-lsp = servers.${cfg.lsp.server}.lspConfig;
|
vim.lsp.lspconfig.sources.markdown-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
{
|
{
|
||||||
pkgs,
|
|
||||||
config,
|
config,
|
||||||
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames;
|
||||||
inherit (lib) mkEnableOption mkOption types nvim isList;
|
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;
|
cfg = config.vim.languages.markdown;
|
||||||
defaultServer = "marksman";
|
defaultServer = "marksman";
|
||||||
|
@ -18,7 +22,7 @@
|
||||||
on_attach = default_on_attach;
|
on_attach = default_on_attach;
|
||||||
cmd = ${
|
cmd = ${
|
||||||
if isList cfg.lsp.package
|
if isList cfg.lsp.package
|
||||||
then nvim.lua.expToLua cfg.lsp.package
|
then expToLua cfg.lsp.package
|
||||||
else ''{"${cfg.lsp.package}/bin/marksman", "server"}''
|
else ''{"${cfg.lsp.package}/bin/marksman", "server"}''
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -32,11 +36,11 @@ in {
|
||||||
treesitter = {
|
treesitter = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
description = "Enable Markdown treesitter";
|
description = "Enable Markdown treesitter";
|
||||||
type = types.bool;
|
type = bool;
|
||||||
default = config.vim.languages.enableTreesitter;
|
default = config.vim.languages.enableTreesitter;
|
||||||
};
|
};
|
||||||
mdPackage = nvim.types.mkGrammarOption pkgs "markdown";
|
mdPackage = mkGrammarOption pkgs "markdown";
|
||||||
mdInlinePackage = nvim.types.mkGrammarOption pkgs "markdown-inline";
|
mdInlinePackage = mkGrammarOption pkgs "markdown-inline";
|
||||||
};
|
};
|
||||||
|
|
||||||
lsp = {
|
lsp = {
|
||||||
|
@ -44,14 +48,14 @@ in {
|
||||||
|
|
||||||
server = mkOption {
|
server = mkOption {
|
||||||
description = "Markdown LSP server to use";
|
description = "Markdown LSP server to use";
|
||||||
type = with types; enum (attrNames servers);
|
type = enum (attrNames servers);
|
||||||
default = defaultServer;
|
default = defaultServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "Markdown LSP server package, or the command to run as a list of strings";
|
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 "]'';
|
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
|
||||||
type = with types; either package (listOf str);
|
type = either package (listOf str);
|
||||||
default = servers.${cfg.lsp.server}.package;
|
default = servers.${cfg.lsp.server}.package;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue