From b3c563af54c50359e50b523b9925a387daef6dcf Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Wed, 2 Oct 2024 22:47:59 -0400 Subject: [PATCH] Added python capabilities --- config/python/debugging.nix | 1 + config/python/default.nix | 16 ++++++++++++++++ config/python/language.nix | 27 +++++++++++++++++++++++++++ flake.nix | 11 +++++++++++ 4 files changed, 55 insertions(+) create mode 100644 config/python/debugging.nix create mode 100644 config/python/default.nix create mode 100644 config/python/language.nix diff --git a/config/python/debugging.nix b/config/python/debugging.nix new file mode 100644 index 0000000..f2f0707 --- /dev/null +++ b/config/python/debugging.nix @@ -0,0 +1 @@ +{ plugins.dap.extensions.dap-python.enable = true; } diff --git a/config/python/default.nix b/config/python/default.nix new file mode 100644 index 0000000..3d7eebc --- /dev/null +++ b/config/python/default.nix @@ -0,0 +1,16 @@ +let + # Read all files in the current directory + files = builtins.readDir ./.; + + # Filter out default.nix and non-.nix files + nixFiles = builtins.filter + (name: name != "default.nix" && builtins.match ".*\\.nix" name != null) + (builtins.attrNames files); + + # Create a list of import statements + imports = map (name: ./. + "/${name}") nixFiles; +in { + # Import all configuration modules automatically + imports = imports; +} + diff --git a/config/python/language.nix b/config/python/language.nix new file mode 100644 index 0000000..d02e0d8 --- /dev/null +++ b/config/python/language.nix @@ -0,0 +1,27 @@ +{ + plugins = { + conform-nvim = { + enable = true; + settings = { formatters_by_ft.python = [ "black" ]; }; + }; + lsp.servers.pylsp = { + enable = true; + # pythonPackage = "pkgs.python312Full"; + settings.plugins = { + black.enabled = true; + flake8.enabled = true; + isort.enabled = true; + jedi.enabled = true; + mccabe.enabled = true; + pycodestyle.enabled = true; + pydocstyle.enabled = true; + pyflakes.enabled = true; + pylint.enabled = true; + rope.enabled = true; + yapf.enabled = true; + }; + }; + none-ls.sources.formatting.black.enable = true; + }; +} + diff --git a/flake.nix b/flake.nix index f09b6b0..9f2d2f2 100644 --- a/flake.nix +++ b/flake.nix @@ -50,6 +50,14 @@ }; extraSpecialArgs = { }; }; + pythonNixvimModule = { + inherit pkgs; + module = { pkgs, ... }: { + imports = [ ./config ./config/python ]; + extraPackages = with pkgs; [ sops ]; + }; + extraSpecialArgs = { }; + }; pkgs = import inputs.nixpkgs { inherit system overlays; config.allowUnfree = true; @@ -58,6 +66,7 @@ rustNvim = nixvim'.makeNixvimWithModule rustNixvimModule; csharpNvim = nixvim'.makeNixvimWithModule csharpNixvimModule; goNvim = nixvim'.makeNixvimWithModule goNixvimModule; + pythonNvim = nixvim'.makeNixvimWithModule pythonNixvimModule; in { checks = { # Run `nix flake check .` to verify that your config is not broken @@ -73,6 +82,8 @@ csharp = csharpNvim; # Lets you run `nix run .#golang` to start nixvim with Go configuration golang = goNvim; + # Lets you run `nix run .#python` to start nixvim with Python configuration + python = pythonNvim; }; }; };