mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 02:11:33 +00:00
Added workaround for nil configuration
This commit is contained in:
parent
5bad5dd94c
commit
3fa41b6d8b
1 changed files with 63 additions and 52 deletions
|
@ -4,7 +4,8 @@
|
||||||
lib,
|
lib,
|
||||||
inputs,
|
inputs,
|
||||||
...
|
...
|
||||||
}: let
|
}:
|
||||||
|
let
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames;
|
||||||
inherit (lib) concatStringsSep;
|
inherit (lib) concatStringsSep;
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
|
@ -12,7 +13,16 @@
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.lists) isList;
|
inherit (lib.lists) isList;
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.types) anything attrsOf enum either listOf nullOr package str;
|
inherit (lib.types)
|
||||||
|
anything
|
||||||
|
attrsOf
|
||||||
|
enum
|
||||||
|
either
|
||||||
|
listOf
|
||||||
|
nullOr
|
||||||
|
package
|
||||||
|
str
|
||||||
|
;
|
||||||
inherit (lib.nvim.types) mkGrammarOption diagnostics;
|
inherit (lib.nvim.types) mkGrammarOption diagnostics;
|
||||||
inherit (lib.nvim.lua) expToLua toLuaObject;
|
inherit (lib.nvim.lua) expToLua toLuaObject;
|
||||||
|
|
||||||
|
@ -22,10 +32,9 @@
|
||||||
noFormat = "on_attach = attach_keymaps";
|
noFormat = "on_attach = attach_keymaps";
|
||||||
|
|
||||||
defaultServer = "nil";
|
defaultServer = "nil";
|
||||||
packageToCmd = package: defaultCmd:
|
packageToCmd =
|
||||||
if isList package
|
package: defaultCmd:
|
||||||
then expToLua package
|
if isList package then expToLua package else ''{"${package}/bin/${defaultCmd}"}'';
|
||||||
else ''{"${package}/bin/${defaultCmd}"}'';
|
|
||||||
servers = {
|
servers = {
|
||||||
nil = {
|
nil = {
|
||||||
package = inputs.nil.packages.${pkgs.stdenv.system}.nil;
|
package = inputs.nil.packages.${pkgs.stdenv.system}.nil;
|
||||||
|
@ -33,27 +42,22 @@
|
||||||
lspConfig = ''
|
lspConfig = ''
|
||||||
lspconfig.nil_ls.setup{
|
lspconfig.nil_ls.setup{
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
${
|
${if cfg.format.enable then useFormat else noFormat},
|
||||||
if cfg.format.enable
|
|
||||||
then useFormat
|
|
||||||
else noFormat
|
|
||||||
},
|
|
||||||
cmd = ${packageToCmd cfg.lsp.package "nil"},
|
cmd = ${packageToCmd cfg.lsp.package "nil"},
|
||||||
${optionalString cfg.format.enable ''
|
${optionalString cfg.format.enable ''
|
||||||
settings = {
|
settings = {
|
||||||
["nil"] = {
|
["nil"] = {
|
||||||
${optionalString (cfg.format.type == "alejandra")
|
${optionalString (cfg.format.type == "alejandra") ''
|
||||||
''
|
|
||||||
formatting = {
|
formatting = {
|
||||||
command = {"${cfg.format.package}/bin/alejandra", "--quiet"},
|
command = {"${cfg.format.package}/bin/alejandra", "--quiet"},
|
||||||
},
|
},
|
||||||
''}
|
''}
|
||||||
${optionalString (cfg.format.type == "nixfmt")
|
${optionalString (cfg.format.type == "nixfmt") ''
|
||||||
''
|
|
||||||
formatting = {
|
formatting = {
|
||||||
command = {"${cfg.format.package}/bin/nixfmt"},
|
command = {"${cfg.format.package}/bin/nixfmt"},
|
||||||
},
|
},
|
||||||
''}
|
''}
|
||||||
|
nix = ${toLuaObject cfg.lsp.options},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
''}
|
''}
|
||||||
|
@ -67,28 +71,22 @@
|
||||||
lspConfig = ''
|
lspConfig = ''
|
||||||
lspconfig.nixd.setup{
|
lspconfig.nixd.setup{
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
${
|
${if cfg.format.enable then useFormat else noFormat},
|
||||||
if cfg.format.enable
|
|
||||||
then useFormat
|
|
||||||
else noFormat
|
|
||||||
},
|
|
||||||
cmd = ${packageToCmd cfg.lsp.package "nixd"},
|
cmd = ${packageToCmd cfg.lsp.package "nixd"},
|
||||||
${optionalString cfg.format.enable ''
|
${optionalString cfg.format.enable ''
|
||||||
settings = {
|
settings = {
|
||||||
nixd = {
|
nixd = {
|
||||||
${optionalString (cfg.format.type == "alejandra")
|
${optionalString (cfg.format.type == "alejandra") ''
|
||||||
''
|
|
||||||
formatting = {
|
formatting = {
|
||||||
command = {"${cfg.format.package}/bin/alejandra", "--quiet"},
|
command = {"${cfg.format.package}/bin/alejandra", "--quiet"},
|
||||||
},
|
},
|
||||||
''}
|
''}
|
||||||
${optionalString (cfg.format.type == "nixfmt")
|
${optionalString (cfg.format.type == "nixfmt") ''
|
||||||
''
|
|
||||||
formatting = {
|
formatting = {
|
||||||
command = {"${cfg.format.package}/bin/nixfmt"},
|
command = {"${cfg.format.package}/bin/nixfmt"},
|
||||||
},
|
},
|
||||||
''}
|
''}
|
||||||
options = ${toLuaObject cfg.lsp.options},
|
nix = ${toLuaObject cfg.lsp.options},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
''}
|
''}
|
||||||
|
@ -108,7 +106,10 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultDiagnosticsProvider = ["statix" "deadnix"];
|
defaultDiagnosticsProvider = [
|
||||||
|
"statix"
|
||||||
|
"deadnix"
|
||||||
|
];
|
||||||
diagnosticsProviders = {
|
diagnosticsProviders = {
|
||||||
statix = {
|
statix = {
|
||||||
package = pkgs.statix;
|
package = pkgs.statix;
|
||||||
|
@ -134,17 +135,22 @@
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
options.vim.languages.nix = {
|
options.vim.languages.nix = {
|
||||||
enable = mkEnableOption "Nix language support";
|
enable = mkEnableOption "Nix language support";
|
||||||
|
|
||||||
treesitter = {
|
treesitter = {
|
||||||
enable = mkEnableOption "Nix treesitter" // {default = config.vim.languages.enableTreesitter;};
|
enable = mkEnableOption "Nix treesitter" // {
|
||||||
|
default = config.vim.languages.enableTreesitter;
|
||||||
|
};
|
||||||
package = mkGrammarOption pkgs "nix";
|
package = mkGrammarOption pkgs "nix";
|
||||||
};
|
};
|
||||||
|
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = mkEnableOption "Nix LSP support" // {default = config.vim.lsp.enable;};
|
enable = mkEnableOption "Nix LSP support" // {
|
||||||
|
default = config.vim.lsp.enable;
|
||||||
|
};
|
||||||
server = mkOption {
|
server = mkOption {
|
||||||
description = "Nix LSP server to use";
|
description = "Nix LSP server to use";
|
||||||
type = enum (attrNames servers);
|
type = enum (attrNames servers);
|
||||||
|
@ -166,7 +172,9 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
format = {
|
format = {
|
||||||
enable = mkEnableOption "Nix formatting" // {default = config.vim.languages.enableFormat;};
|
enable = mkEnableOption "Nix formatting" // {
|
||||||
|
default = config.vim.languages.enableFormat;
|
||||||
|
};
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
description = "Nix formatter to use";
|
description = "Nix formatter to use";
|
||||||
|
@ -182,7 +190,9 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
extraDiagnostics = {
|
extraDiagnostics = {
|
||||||
enable = mkEnableOption "extra Nix diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
|
enable = mkEnableOption "extra Nix diagnostics" // {
|
||||||
|
default = config.vim.languages.enableExtraDiagnostics;
|
||||||
|
};
|
||||||
|
|
||||||
types = diagnostics {
|
types = diagnostics {
|
||||||
langDesc = "Nix";
|
langDesc = "Nix";
|
||||||
|
@ -236,10 +246,11 @@ in {
|
||||||
vim.diagnostics.nvim-lint = {
|
vim.diagnostics.nvim-lint = {
|
||||||
enable = true;
|
enable = true;
|
||||||
linters_by_ft.nix = cfg.extraDiagnostics.types;
|
linters_by_ft.nix = cfg.extraDiagnostics.types;
|
||||||
linters = mkMerge (map (name: {
|
linters = mkMerge (
|
||||||
|
map (name: {
|
||||||
${name}.cmd = getExe diagnosticsProviders.${name}.package;
|
${name}.cmd = getExe diagnosticsProviders.${name}.package;
|
||||||
})
|
}) cfg.extraDiagnostics.types
|
||||||
cfg.extraDiagnostics.types);
|
);
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue