diff --git a/configurations/android/nix-on-droid.nix b/configurations/android/nix-on-droid.nix index 3cc85ab6..ac01d6fd 100644 --- a/configurations/android/nix-on-droid.nix +++ b/configurations/android/nix-on-droid.nix @@ -55,7 +55,6 @@ enableGolang = false; enableJava = false; enableNix = false; - enablePython = false; }; }; } diff --git a/devShells/neovim-shells/default.nix b/devShells/neovim-shells/default.nix index e88c51e0..a733726f 100644 --- a/devShells/neovim-shells/default.nix +++ b/devShells/neovim-shells/default.nix @@ -25,6 +25,7 @@ in "kotlin" "lua" "markdown" + "python" "qml" "rust" "web" diff --git a/flake.lock b/flake.lock index 6f2b6302..c5d38cb4 100644 --- a/flake.lock +++ b/flake.lock @@ -863,11 +863,11 @@ ] }, "locked": { - "lastModified": 1748609540, - "narHash": "sha256-fJXILZ07bFCW3pH6mVoKXr+LkZSMB2PSXObcQtDkWBg=", + "lastModified": 1748748278, + "narHash": "sha256-2lR5nVfPpxTta8H4F9bJaeZFZnG2AcrL/N14+Htv8l0=", "owner": "matt1432", "repo": "Kapowarr", - "rev": "aebda36b96c46bd5333f0d14e560557338eb226c", + "rev": "32c03c36afa87c3d1fddd99a5ada36d9a7bfaf10", "type": "github" }, "original": { diff --git a/homeManagerModules/neovim/default.nix b/homeManagerModules/neovim/default.nix index b17ad530..fd4bbdd8 100644 --- a/homeManagerModules/neovim/default.nix +++ b/homeManagerModules/neovim/default.nix @@ -37,10 +37,6 @@ in { type = types.bool; default = true; }; - enablePython = mkOption { - type = types.bool; - default = true; - }; }; }; diff --git a/homeManagerModules/neovim/langs/python/default.nix b/homeManagerModules/neovim/langs/python/default.nix index 8fe6f691..0ef2422c 100644 --- a/homeManagerModules/neovim/langs/python/default.nix +++ b/homeManagerModules/neovim/langs/python/default.nix @@ -1,68 +1,46 @@ { config, lib, - pkgs, ... }: let - inherit (lib) attrValues mkIf; + inherit (lib) mkIf; cfg = config.programs.neovim; - - # We keep the packages here because python is a bit complicated and common - pythonPkgs = p: - (attrValues { - inherit - (p) - python-lsp-server - pyls-isort - pylsp-mypy - python-lsp-ruff - python-lsp-jsonrpc - ; - }) - ++ p.python-lsp-server.optional-dependencies.all; + flakeEnv = config.programs.bash.sessionVariables.FLAKE; in { - config = mkIf (cfg.enable && cfg.ideConfig.enablePython) { + config = mkIf cfg.enable { programs = { neovim = { - withPython3 = true; - - extraPython3Packages = pythonPkgs; - extraPackages = pythonPkgs pkgs.python3Packages; - extraLuaConfig = # lua '' - require('lspconfig').pylsp.setup({ - capabilities = require('cmp_nvim_lsp').default_capabilities(), + local lsp = require('lspconfig'); + local default_capabilities = require('cmp_nvim_lsp').default_capabilities(); - settings = { - pylsp = { - plugins = { - -- auto-completion options - jedi_completion = { - fuzzy = true, - }, + lsp.basedpyright.setup({ + capabilities = default_capabilities, + autostart = false, + }); - -- import sorting - pyls_isort = { - enabled = true, - }, + lsp.ruff.setup({ + capabilities = default_capabilities, + autostart = false, + }); - -- type checker - pylsp_mypy = { - enabled = true, - }, + vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, { + pattern = { 'python' }, - -- linter - ruff = { - enabled = true, - formatEnabled = true, - lineLength = 100, - }, - }, - }, - }, + callback = function() + vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]]; + + if (devShells['python'] == nil) then + devShells['python'] = 1; + + require('nix-develop').nix_develop_extend({'${flakeEnv}#python'}, function() + vim.cmd[[LspStart]]; + end); + end + end, }); ''; }; diff --git a/homeManagerModules/neovim/langs/python/shell.nix b/homeManagerModules/neovim/langs/python/shell.nix new file mode 100644 index 00000000..b363edcb --- /dev/null +++ b/homeManagerModules/neovim/langs/python/shell.nix @@ -0,0 +1,12 @@ +{ + mkShell, + basedpyright, + ruff, + ... +}: +mkShell { + packages = [ + basedpyright + ruff + ]; +}