mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-10 09:14:31 +02:00
treewide: Reformat with nixfmt
This commit is contained in:
parent
c6281260dc
commit
62f32bfc71
459 changed files with 28139 additions and 26377 deletions
|
@ -5,21 +5,25 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lsp.servers.pylsp;
|
||||
in {
|
||||
in
|
||||
{
|
||||
# All settings are documented here:
|
||||
# https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md
|
||||
|
||||
options.plugins.lsp.servers.pylsp.settings = {
|
||||
configurationSources = mkOption {
|
||||
type = lib.types.nullOr (types.enum ["pycodestyle" "flake8"]);
|
||||
type = lib.types.nullOr (
|
||||
types.enum [
|
||||
"pycodestyle"
|
||||
"flake8"
|
||||
]
|
||||
);
|
||||
description = "List of configuration sources to use.";
|
||||
default = null;
|
||||
apply = value:
|
||||
if (value != null)
|
||||
then [value]
|
||||
else null;
|
||||
apply = value: if (value != null) then [ value ] else null;
|
||||
};
|
||||
|
||||
plugins = {
|
||||
|
@ -86,10 +90,8 @@ in {
|
|||
|
||||
jedi = {
|
||||
auto_import_modules =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(types.listOf types.str)
|
||||
"[ \"numpy\" ]"
|
||||
"List of module names for `jedi.settings.auto_import_modules`.";
|
||||
helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[ \"numpy\" ]"
|
||||
"List of module names for `jedi.settings.auto_import_modules`.";
|
||||
|
||||
extra_paths = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" ''
|
||||
Define extra paths for jedi.Script.
|
||||
|
@ -128,10 +130,9 @@ in {
|
|||
'';
|
||||
|
||||
cache_for =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(types.listOf types.str)
|
||||
"[ \"pandas\" \"numpy\" \"tensorflow\" \"matplotlib\" ]"
|
||||
"Modules for which labels and snippets should be cached.";
|
||||
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
|
||||
"[ \"pandas\" \"numpy\" \"tensorflow\" \"matplotlib\" ]"
|
||||
"Modules for which labels and snippets should be cached.";
|
||||
};
|
||||
|
||||
jedi_definition = {
|
||||
|
@ -236,15 +237,12 @@ in {
|
|||
(pydocstyle).
|
||||
'';
|
||||
|
||||
convention =
|
||||
helpers.mkNullOrOption
|
||||
(types.enum [
|
||||
"pep257"
|
||||
"numpy"
|
||||
"google"
|
||||
"None"
|
||||
])
|
||||
"Choose the basic list of checked errors by specifying an existing convention.";
|
||||
convention = helpers.mkNullOrOption (types.enum [
|
||||
"pep257"
|
||||
"numpy"
|
||||
"google"
|
||||
"None"
|
||||
]) "Choose the basic list of checked errors by specifying an existing convention.";
|
||||
|
||||
addIgnore = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" ''
|
||||
Ignore errors and warnings in addition to the specified convention.
|
||||
|
@ -356,17 +354,22 @@ in {
|
|||
|
||||
overrides =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(types.listOf
|
||||
(types.oneOf [types.bool types.str helpers.nixvimTypes.rawLua]))
|
||||
"[true]"
|
||||
''
|
||||
Specifies a list of alternate or supplemental command-line options.
|
||||
This modifies the options passed to mypy or the mypy-specific ones passed to dmypy run.
|
||||
When present, the special boolean member true is replaced with the command-line options that
|
||||
would've been passed had overrides not been specified.
|
||||
Later options take precedence, which allows for replacing or negating individual default
|
||||
options (see mypy.main:process_options and mypy --help | grep inverse).
|
||||
'';
|
||||
(types.listOf (
|
||||
types.oneOf [
|
||||
types.bool
|
||||
types.str
|
||||
helpers.nixvimTypes.rawLua
|
||||
]
|
||||
))
|
||||
"[true]"
|
||||
''
|
||||
Specifies a list of alternate or supplemental command-line options.
|
||||
This modifies the options passed to mypy or the mypy-specific ones passed to dmypy run.
|
||||
When present, the special boolean member true is replaced with the command-line options that
|
||||
would've been passed had overrides not been specified.
|
||||
Later options take precedence, which allows for replacing or negating individual default
|
||||
options (see mypy.main:process_options and mypy --help | grep inverse).
|
||||
'';
|
||||
|
||||
dmypy_status_file = helpers.defaultNullOpts.mkStr ".dmypy.json" ''
|
||||
Specifies which status file dmypy should use.
|
||||
|
@ -497,24 +500,21 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
config =
|
||||
mkIf cfg.enable
|
||||
{
|
||||
# WARNING: tricky stuff below:
|
||||
# We need to fix the `python-lsp-server` derivation by adding all of the (user enabled)
|
||||
# plugins to its `propagatedBuildInputs`.
|
||||
# See https://github.com/NixOS/nixpkgs/issues/229337
|
||||
plugins.lsp.servers.pylsp.package = let
|
||||
config = mkIf cfg.enable {
|
||||
# WARNING: tricky stuff below:
|
||||
# We need to fix the `python-lsp-server` derivation by adding all of the (user enabled)
|
||||
# plugins to its `propagatedBuildInputs`.
|
||||
# See https://github.com/NixOS/nixpkgs/issues/229337
|
||||
plugins.lsp.servers.pylsp.package =
|
||||
let
|
||||
isEnabled = x: (x.enabled != null && x.enabled);
|
||||
inherit (cfg.settings) plugins;
|
||||
|
||||
nativePlugins =
|
||||
(map
|
||||
(
|
||||
pluginName: (
|
||||
optionals (isEnabled plugins.${pluginName})
|
||||
cfg.package.optional-dependencies.${pluginName}
|
||||
)
|
||||
pluginName:
|
||||
(optionals (isEnabled plugins.${pluginName}) cfg.package.optional-dependencies.${pluginName})
|
||||
)
|
||||
[
|
||||
"autopep8"
|
||||
|
@ -525,114 +525,95 @@ in {
|
|||
"pyflakes"
|
||||
"pylint"
|
||||
"yapf"
|
||||
])
|
||||
++ (
|
||||
optionals
|
||||
(
|
||||
(isEnabled plugins.rope_autoimport)
|
||||
|| (isEnabled plugins.rope_completion)
|
||||
)
|
||||
cfg.package.optional-dependencies.rope
|
||||
);
|
||||
]
|
||||
)
|
||||
++ (optionals (
|
||||
(isEnabled plugins.rope_autoimport) || (isEnabled plugins.rope_completion)
|
||||
) cfg.package.optional-dependencies.rope);
|
||||
|
||||
# All of those plugins have `python-lsp-server` as a dependency.
|
||||
# We need to get rid of it to add them to the `python-lsp-server` derivation itself.
|
||||
thirdPartyPlugins = lists.flatten (
|
||||
mapAttrsToList
|
||||
(
|
||||
pluginName: nixPackage: (
|
||||
optional
|
||||
(isEnabled plugins.${pluginName})
|
||||
(
|
||||
nixPackage.overridePythonAttrs (
|
||||
old: {
|
||||
# Get rid of the python-lsp-server dependency
|
||||
propagatedBuildInputs =
|
||||
filter
|
||||
(dep: dep.pname != "python-lsp-server")
|
||||
old.propagatedBuildInputs;
|
||||
(
|
||||
pluginName: nixPackage:
|
||||
(optional (isEnabled plugins.${pluginName}) (
|
||||
nixPackage.overridePythonAttrs (old: {
|
||||
# Get rid of the python-lsp-server dependency
|
||||
propagatedBuildInputs = filter (dep: dep.pname != "python-lsp-server") old.propagatedBuildInputs;
|
||||
|
||||
# Skip testing because those naked dependencies will complain about missing pylsp
|
||||
doCheck = false;
|
||||
}
|
||||
)
|
||||
)
|
||||
# Skip testing because those naked dependencies will complain about missing pylsp
|
||||
doCheck = false;
|
||||
})
|
||||
))
|
||||
)
|
||||
)
|
||||
(with pkgs.python3Packages; {
|
||||
pylsp_mypy = pylsp-mypy.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch
|
||||
or ''''
|
||||
+ ''
|
||||
substituteInPlace setup.cfg \
|
||||
--replace-fail "python-lsp-server >=1.7.0" ""
|
||||
'';
|
||||
});
|
||||
isort = pyls-isort.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch
|
||||
or ''''
|
||||
+ ''
|
||||
substituteInPlace setup.py \
|
||||
--replace-fail 'install_requires=["python-lsp-server", "isort"],' 'install_requires=["isort"],'
|
||||
'';
|
||||
});
|
||||
black = python-lsp-black.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch
|
||||
or ''''
|
||||
+ ''
|
||||
substituteInPlace setup.cfg \
|
||||
--replace-fail "python-lsp-server>=1.4.0" ""
|
||||
'';
|
||||
});
|
||||
memestra = pyls-memestra.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch
|
||||
or ''''
|
||||
+ ''
|
||||
sed -i '/python-lsp-server/d' requirements.txt
|
||||
'';
|
||||
});
|
||||
rope = pylsp-rope.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch
|
||||
or ''''
|
||||
+ ''
|
||||
sed -i '/python-lsp-server/d' setup.cfg
|
||||
'';
|
||||
});
|
||||
ruff = python-lsp-ruff.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch
|
||||
or ''''
|
||||
+ ''
|
||||
sed -i '/python-lsp-server/d' pyproject.toml
|
||||
'';
|
||||
(
|
||||
with pkgs.python3Packages;
|
||||
{
|
||||
pylsp_mypy = pylsp-mypy.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch or ''''
|
||||
+ ''
|
||||
substituteInPlace setup.cfg \
|
||||
--replace-fail "python-lsp-server >=1.7.0" ""
|
||||
'';
|
||||
});
|
||||
isort = pyls-isort.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch or ''''
|
||||
+ ''
|
||||
substituteInPlace setup.py \
|
||||
--replace-fail 'install_requires=["python-lsp-server", "isort"],' 'install_requires=["isort"],'
|
||||
'';
|
||||
});
|
||||
black = python-lsp-black.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch or ''''
|
||||
+ ''
|
||||
substituteInPlace setup.cfg \
|
||||
--replace-fail "python-lsp-server>=1.4.0" ""
|
||||
'';
|
||||
});
|
||||
memestra = pyls-memestra.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch or ''''
|
||||
+ ''
|
||||
sed -i '/python-lsp-server/d' requirements.txt
|
||||
'';
|
||||
});
|
||||
rope = pylsp-rope.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch or ''''
|
||||
+ ''
|
||||
sed -i '/python-lsp-server/d' setup.cfg
|
||||
'';
|
||||
});
|
||||
ruff = python-lsp-ruff.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch or ''''
|
||||
+ ''
|
||||
sed -i '/python-lsp-server/d' pyproject.toml
|
||||
'';
|
||||
|
||||
build-system = [setuptools] ++ (old.build-system or []);
|
||||
});
|
||||
})
|
||||
build-system = [ setuptools ] ++ (old.build-system or [ ]);
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
# Final list of pylsp plugins to install
|
||||
pylspPlugins = nativePlugins ++ thirdPartyPlugins;
|
||||
in
|
||||
mkDefault (
|
||||
# This is the final default package for pylsp
|
||||
pkgs.python3Packages.python-lsp-server.overridePythonAttrs (
|
||||
old: {
|
||||
propagatedBuildInputs = pylspPlugins ++ old.dependencies;
|
||||
disabledTests =
|
||||
(old.disabledTests or [])
|
||||
++ [
|
||||
# Those tests fail when third-party plugins are loaded
|
||||
"test_notebook_document__did_open"
|
||||
"test_notebook_document__did_change"
|
||||
];
|
||||
}
|
||||
)
|
||||
);
|
||||
};
|
||||
mkDefault (
|
||||
# This is the final default package for pylsp
|
||||
pkgs.python3Packages.python-lsp-server.overridePythonAttrs (old: {
|
||||
propagatedBuildInputs = pylspPlugins ++ old.dependencies;
|
||||
disabledTests = (old.disabledTests or [ ]) ++ [
|
||||
# Those tests fail when third-party plugins are loaded
|
||||
"test_notebook_document__did_open"
|
||||
"test_notebook_document__did_change"
|
||||
];
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue