plugins/lsp/pylsp: Add python option to generate obtain the pylsp from.

Currently, pkgs.python3Packges is used by default and is unable to be
changed. This stops consumers from using different/newer python
versions.
This commit is contained in:
purepani 2024-06-30 18:48:41 -05:00 committed by Matt Sturgeon
parent 100ae4027d
commit 079c2c479b

View file

@ -10,10 +10,16 @@ let
cfg = config.plugins.lsp.servers.pylsp;
in
{
options.plugins.lsp.servers.pylsp = {
pythonPackage = mkOption {
type = lib.types.package;
description = "Python package to use for lsp.";
default = pkgs.python3;
};
# All settings are documented here:
# https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md
options.plugins.lsp.servers.pylsp.settings = {
settings = {
configurationSources = mkOption {
type = lib.types.nullOr (
types.enum [
@ -491,6 +497,7 @@ in
'';
};
};
};
config = mkIf cfg.enable {
# WARNING: tricky stuff below:
@ -540,7 +547,7 @@ in
))
)
(
with pkgs.python3Packages;
with cfg.pythonPackage.pkgs;
{
pylsp_mypy = pylsp-mypy.overridePythonAttrs (old: {
postPatch =
@ -598,7 +605,7 @@ in
in
mkDefault (
# This is the final default package for pylsp
pkgs.python3Packages.python-lsp-server.overridePythonAttrs (old: {
cfg.pythonPackage.pkgs.python-lsp-server.overridePythonAttrs (old: {
propagatedBuildInputs = pylspPlugins ++ old.dependencies;
disabledTests = (old.disabledTests or [ ]) ++ [
# Those tests fail when third-party plugins are loaded