mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 02:11:33 +00:00
Removed old code
This commit is contained in:
parent
592de7979a
commit
42dc74ae7b
1 changed files with 59 additions and 70 deletions
|
@ -4,8 +4,7 @@
|
||||||
lib,
|
lib,
|
||||||
inputs,
|
inputs,
|
||||||
...
|
...
|
||||||
}:
|
}: let
|
||||||
let
|
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames;
|
||||||
inherit (lib) concatStringsSep mkLuaInline;
|
inherit (lib) concatStringsSep mkLuaInline;
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
|
@ -13,7 +12,8 @@ let
|
||||||
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)
|
inherit
|
||||||
|
(lib.types)
|
||||||
anything
|
anything
|
||||||
attrsOf
|
attrsOf
|
||||||
enum
|
enum
|
||||||
|
@ -32,60 +32,37 @@ let
|
||||||
noFormat = "on_attach = attach_keymaps";
|
noFormat = "on_attach = attach_keymaps";
|
||||||
|
|
||||||
defaultServer = "nil";
|
defaultServer = "nil";
|
||||||
packageToCmd =
|
packageToCmd = package: defaultCmd:
|
||||||
package: defaultCmd:
|
if isList package
|
||||||
if isList package then expToLua package else ''{"${package}/bin/${defaultCmd}"}'';
|
then expToLua package
|
||||||
|
else ''{"${package}/bin/${defaultCmd}"}'';
|
||||||
servers = {
|
servers = {
|
||||||
nil = {
|
nil = {
|
||||||
package = inputs.nil.packages.${pkgs.stdenv.system}.nil;
|
package = inputs.nil.packages.${pkgs.stdenv.system}.nil;
|
||||||
internalFormatter = true;
|
internalFormatter = true;
|
||||||
lspConfig = ''lspconfig.nil_ls.setup ${
|
lspConfig = ''lspconfig.nil_ls.setup ${
|
||||||
toLuaObject {
|
toLuaObject {
|
||||||
capabilities = mkLuaInline "capabilities";
|
capabilities = mkLuaInline "capabilities";
|
||||||
on_attach = if cfg.format.enable then mkLuaInline "default_on_attach" else "attach_keymaps";
|
on_attach =
|
||||||
cmd = mkLuaInline (packageToCmd cfg.lsp.package "nil");
|
if cfg.format.enable
|
||||||
settings.nil = {
|
then mkLuaInline "default_on_attach"
|
||||||
formatting.command =
|
else "attach_keymaps";
|
||||||
if cfg.format.enable then
|
cmd = mkLuaInline (packageToCmd cfg.lsp.package "nil");
|
||||||
if cfg.format.type == "alejandra" then
|
settings.nil =
|
||||||
mkLuaInline ''{"${cfg.format.package}/bin/alejandra", "--quiet"}''
|
{
|
||||||
else if cfg.format.type == "nixfmt" then
|
formatting.command =
|
||||||
mkLuaInline ''{"${cfg.format.package}/bin/nixfmt"}''
|
if cfg.format.enable
|
||||||
else
|
then
|
||||||
null
|
if cfg.format.type == "alejandra"
|
||||||
else
|
then mkLuaInline ''{"${cfg.format.package}/bin/alejandra", "--quiet"}''
|
||||||
null;
|
else if cfg.format.type == "nixfmt"
|
||||||
} // cfg.lsp.options;
|
then mkLuaInline ''{"${cfg.format.package}/bin/nixfmt"}''
|
||||||
}
|
else null
|
||||||
}'';
|
else null;
|
||||||
# lspConfig = ''
|
}
|
||||||
# lspconfig.nil_ls.setup{
|
// cfg.lsp.options;
|
||||||
# capabilities = capabilities,
|
}
|
||||||
# ${
|
}'';
|
||||||
# if cfg.format.enable
|
|
||||||
# then useFormat
|
|
||||||
# else noFormat
|
|
||||||
# },
|
|
||||||
# cmd = ${packageToCmd cfg.lsp.package "nil"},
|
|
||||||
# ${optionalString cfg.format.enable ''
|
|
||||||
# settings = {
|
|
||||||
# ["nil"] = {
|
|
||||||
# ${optionalString (cfg.format.type == "alejandra") ''
|
|
||||||
# formatting = {
|
|
||||||
# command = {"${cfg.format.package}/bin/alejandra", "--quiet"},
|
|
||||||
# },
|
|
||||||
# ''}
|
|
||||||
# ${optionalString (cfg.format.type == "nixfmt") ''
|
|
||||||
# formatting = {
|
|
||||||
# command = {"${cfg.format.package}/bin/nixfmt"},
|
|
||||||
# },
|
|
||||||
# ''}
|
|
||||||
# nix = ${toLuaObject cfg.lsp.options},
|
|
||||||
# },
|
|
||||||
# },
|
|
||||||
# ''}
|
|
||||||
# }
|
|
||||||
# '';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nixd = {
|
nixd = {
|
||||||
|
@ -94,7 +71,11 @@ let
|
||||||
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 = {
|
||||||
|
@ -158,22 +139,25 @@ let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
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" // {
|
enable =
|
||||||
default = config.vim.languages.enableTreesitter;
|
mkEnableOption "Nix treesitter"
|
||||||
};
|
// {
|
||||||
|
default = config.vim.languages.enableTreesitter;
|
||||||
|
};
|
||||||
package = mkGrammarOption pkgs "nix";
|
package = mkGrammarOption pkgs "nix";
|
||||||
};
|
};
|
||||||
|
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = mkEnableOption "Nix LSP support" // {
|
enable =
|
||||||
default = config.vim.lsp.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);
|
||||||
|
@ -195,9 +179,11 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
format = {
|
format = {
|
||||||
enable = mkEnableOption "Nix formatting" // {
|
enable =
|
||||||
default = config.vim.languages.enableFormat;
|
mkEnableOption "Nix formatting"
|
||||||
};
|
// {
|
||||||
|
default = config.vim.languages.enableFormat;
|
||||||
|
};
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
description = "Nix formatter to use";
|
description = "Nix formatter to use";
|
||||||
|
@ -213,9 +199,11 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
extraDiagnostics = {
|
extraDiagnostics = {
|
||||||
enable = mkEnableOption "extra Nix diagnostics" // {
|
enable =
|
||||||
default = config.vim.languages.enableExtraDiagnostics;
|
mkEnableOption "extra Nix diagnostics"
|
||||||
};
|
// {
|
||||||
|
default = config.vim.languages.enableExtraDiagnostics;
|
||||||
|
};
|
||||||
|
|
||||||
types = diagnostics {
|
types = diagnostics {
|
||||||
langDesc = "Nix";
|
langDesc = "Nix";
|
||||||
|
@ -247,7 +235,7 @@ in
|
||||||
|
|
||||||
(mkIf cfg.treesitter.enable {
|
(mkIf cfg.treesitter.enable {
|
||||||
vim.treesitter.enable = true;
|
vim.treesitter.enable = true;
|
||||||
vim.treesitter.grammars = [ cfg.treesitter.package ];
|
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.lsp.enable {
|
(mkIf cfg.lsp.enable {
|
||||||
|
@ -258,7 +246,7 @@ in
|
||||||
(mkIf (cfg.format.enable && (!cfg.lsp.enable || !servers.${cfg.lsp.server}.internalFormatter)) {
|
(mkIf (cfg.format.enable && (!cfg.lsp.enable || !servers.${cfg.lsp.server}.internalFormatter)) {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.nix = [ cfg.format.type ];
|
setupOpts.formatters_by_ft.nix = [cfg.format.type];
|
||||||
setupOpts.formatters.${cfg.format.type} = {
|
setupOpts.formatters.${cfg.format.type} = {
|
||||||
command = getExe cfg.format.package;
|
command = getExe cfg.format.package;
|
||||||
};
|
};
|
||||||
|
@ -272,7 +260,8 @@ in
|
||||||
linters = mkMerge (
|
linters = mkMerge (
|
||||||
map (name: {
|
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