mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-07 10:51:36 +00:00
new options perhaps?
This commit is contained in:
parent
79993c71d8
commit
852c378bf9
1 changed files with 67 additions and 64 deletions
|
@ -12,9 +12,10 @@
|
||||||
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 oneOf;
|
||||||
inherit (lib.nvim.types) mkGrammarOption diagnostics;
|
inherit (lib.nvim.types) mkGrammarOption diagnostics;
|
||||||
inherit (lib.nvim.lua) expToLua toLuaObject;
|
inherit (lib.nvim.lua) expToLua toLuaObject;
|
||||||
|
inherit (lib.nvim.languages) lspOptions;
|
||||||
|
|
||||||
cfg = config.vim.languages.nix;
|
cfg = config.vim.languages.nix;
|
||||||
|
|
||||||
|
@ -30,70 +31,70 @@
|
||||||
nil = {
|
nil = {
|
||||||
package = inputs.nil.packages.${pkgs.stdenv.system}.nil;
|
package = inputs.nil.packages.${pkgs.stdenv.system}.nil;
|
||||||
internalFormatter = true;
|
internalFormatter = true;
|
||||||
lspConfig = ''
|
# lspConfig = ''
|
||||||
lspconfig.nil_ls.setup{
|
# lspconfig.nil_ls.setup{
|
||||||
capabilities = capabilities,
|
# capabilities = capabilities,
|
||||||
${
|
# ${
|
||||||
if cfg.format.enable
|
# if cfg.format.enable
|
||||||
then useFormat
|
# then useFormat
|
||||||
else noFormat
|
# 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"},
|
||||||
},
|
# },
|
||||||
''}
|
# ''}
|
||||||
},
|
# },
|
||||||
},
|
# },
|
||||||
''}
|
# ''}
|
||||||
}
|
# }
|
||||||
'';
|
# '';
|
||||||
};
|
};
|
||||||
|
|
||||||
nixd = {
|
nixd = {
|
||||||
package = pkgs.nixd;
|
package = pkgs.nixd;
|
||||||
internalFormatter = true;
|
internalFormatter = true;
|
||||||
lspConfig = ''
|
# lspConfig = ''
|
||||||
lspconfig.nixd.setup{
|
# lspconfig.nixd.setup{
|
||||||
capabilities = capabilities,
|
# capabilities = capabilities,
|
||||||
${
|
# ${
|
||||||
if cfg.format.enable
|
# if cfg.format.enable
|
||||||
then useFormat
|
# then useFormat
|
||||||
else noFormat
|
# 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},
|
# options = ${toLuaObject cfg.lsp.options},
|
||||||
},
|
# },
|
||||||
},
|
# },
|
||||||
''}
|
# ''}
|
||||||
}
|
# }
|
||||||
'';
|
# '';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -146,8 +147,11 @@ in {
|
||||||
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(s) to use";
|
||||||
type = enum (attrNames servers);
|
type = listOf oneOf [
|
||||||
|
(attrsOf lspOptions)
|
||||||
|
(enum (attrNames servers))
|
||||||
|
];
|
||||||
default = defaultServer;
|
default = defaultServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -218,8 +222,7 @@ in {
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.lsp.enable {
|
(mkIf cfg.lsp.enable {
|
||||||
vim.lsp.lspconfig.enable = true;
|
vim.lsp.servers = cfg.lsp.server;
|
||||||
vim.lsp.lspconfig.sources.nix-lsp = servers.${cfg.lsp.server}.lspConfig;
|
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf (cfg.format.enable && (!cfg.lsp.enable || !servers.${cfg.lsp.server}.internalFormatter)) {
|
(mkIf (cfg.format.enable && (!cfg.lsp.enable || !servers.${cfg.lsp.server}.internalFormatter)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue