mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 10:21:31 +00:00
More mkLuaInline
This commit is contained in:
parent
1b14e06f7e
commit
592de7979a
1 changed files with 42 additions and 59 deletions
|
@ -4,7 +4,8 @@
|
|||
lib,
|
||||
inputs,
|
||||
...
|
||||
}: let
|
||||
}:
|
||||
let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) concatStringsSep mkLuaInline;
|
||||
inherit (lib.meta) getExe;
|
||||
|
@ -12,8 +13,7 @@
|
|||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit
|
||||
(lib.types)
|
||||
inherit (lib.types)
|
||||
anything
|
||||
attrsOf
|
||||
enum
|
||||
|
@ -32,10 +32,9 @@
|
|||
noFormat = "on_attach = attach_keymaps";
|
||||
|
||||
defaultServer = "nil";
|
||||
packageToCmd = package: defaultCmd:
|
||||
if isList package
|
||||
then expToLua package
|
||||
else ''{"${package}/bin/${defaultCmd}"}'';
|
||||
packageToCmd =
|
||||
package: defaultCmd:
|
||||
if isList package then expToLua package else ''{"${package}/bin/${defaultCmd}"}'';
|
||||
servers = {
|
||||
nil = {
|
||||
package = inputs.nil.packages.${pkgs.stdenv.system}.nil;
|
||||
|
@ -43,24 +42,20 @@
|
|||
lspConfig = ''lspconfig.nil_ls.setup ${
|
||||
toLuaObject {
|
||||
capabilities = mkLuaInline "capabilities";
|
||||
on_attach =
|
||||
if cfg.format.enable
|
||||
then mkLuaInline "default_on_attach"
|
||||
else "attach_keymaps";
|
||||
on_attach = if cfg.format.enable then mkLuaInline "default_on_attach" else "attach_keymaps";
|
||||
cmd = mkLuaInline (packageToCmd cfg.lsp.package "nil");
|
||||
settings.nil =
|
||||
{
|
||||
settings.nil = {
|
||||
formatting.command =
|
||||
if cfg.format.enable
|
||||
then
|
||||
if cfg.format.type == "alejandra"
|
||||
then ''{"${cfg.format.package}/bin/alejandra", "--quiet"}''
|
||||
else if cfg.format.type == "nixfmt"
|
||||
then ''{"${cfg.format.package}/bin/nixfmt"}''
|
||||
else null
|
||||
else null;
|
||||
}
|
||||
// cfg.lsp.options;
|
||||
if cfg.format.enable then
|
||||
if cfg.format.type == "alejandra" then
|
||||
mkLuaInline ''{"${cfg.format.package}/bin/alejandra", "--quiet"}''
|
||||
else if cfg.format.type == "nixfmt" then
|
||||
mkLuaInline ''{"${cfg.format.package}/bin/nixfmt"}''
|
||||
else
|
||||
null
|
||||
else
|
||||
null;
|
||||
} // cfg.lsp.options;
|
||||
}
|
||||
}'';
|
||||
# lspConfig = ''
|
||||
|
@ -99,11 +94,7 @@
|
|||
lspConfig = ''
|
||||
lspconfig.nixd.setup{
|
||||
capabilities = capabilities,
|
||||
${
|
||||
if cfg.format.enable
|
||||
then useFormat
|
||||
else noFormat
|
||||
},
|
||||
${if cfg.format.enable then useFormat else noFormat},
|
||||
cmd = ${packageToCmd cfg.lsp.package "nixd"},
|
||||
${optionalString cfg.format.enable ''
|
||||
settings = {
|
||||
|
@ -167,23 +158,20 @@
|
|||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.vim.languages.nix = {
|
||||
enable = mkEnableOption "Nix language support";
|
||||
|
||||
treesitter = {
|
||||
enable =
|
||||
mkEnableOption "Nix treesitter"
|
||||
// {
|
||||
enable = mkEnableOption "Nix treesitter" // {
|
||||
default = config.vim.languages.enableTreesitter;
|
||||
};
|
||||
package = mkGrammarOption pkgs "nix";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable =
|
||||
mkEnableOption "Nix LSP support"
|
||||
// {
|
||||
enable = mkEnableOption "Nix LSP support" // {
|
||||
default = config.vim.lsp.enable;
|
||||
};
|
||||
server = mkOption {
|
||||
|
@ -207,9 +195,7 @@ in {
|
|||
};
|
||||
|
||||
format = {
|
||||
enable =
|
||||
mkEnableOption "Nix formatting"
|
||||
// {
|
||||
enable = mkEnableOption "Nix formatting" // {
|
||||
default = config.vim.languages.enableFormat;
|
||||
};
|
||||
|
||||
|
@ -227,9 +213,7 @@ in {
|
|||
};
|
||||
|
||||
extraDiagnostics = {
|
||||
enable =
|
||||
mkEnableOption "extra Nix diagnostics"
|
||||
// {
|
||||
enable = mkEnableOption "extra Nix diagnostics" // {
|
||||
default = config.vim.languages.enableExtraDiagnostics;
|
||||
};
|
||||
|
||||
|
@ -288,8 +272,7 @@ in {
|
|||
linters = mkMerge (
|
||||
map (name: {
|
||||
${name}.cmd = getExe diagnosticsProviders.${name}.package;
|
||||
})
|
||||
cfg.extraDiagnostics.types
|
||||
}) cfg.extraDiagnostics.types
|
||||
);
|
||||
};
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue