Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/manual/release-notes/rl-0.9.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@

- Added Debugging support to `languages.php`.

- Added [mypy](https://www.mypy-lang.org/) to `languages.python` for extra
diagnostics.

[vagahbond](https://github.com/vagahbond): [codewindow.nvim]:
https://github.com/gorbit99/codewindow.nvim

Expand Down
29 changes: 28 additions & 1 deletion modules/plugins/languages/python.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) enum package bool;
inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (lib.nvim.types) deprecatedSingleOrListOf;
inherit (lib.nvim.types) deprecatedSingleOrListOf diagnostics;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.dag) entryBefore;
inherit (lib.trivial) warn;
Expand Down Expand Up @@ -278,6 +278,14 @@
'';
};
};
defaultDiagnosticsProvider = ["mypy"];
diagnosticsProviders = {
mypy = {
config = {
cmd = getExe' pkgs.mypy "mypy";
};
};
};
in {
options.vim.languages.python = {
enable = mkEnableOption "Python language support";
Expand Down Expand Up @@ -335,6 +343,15 @@ in {
'';
};
};

extraDiagnostics = {
enable = mkEnableOption "extra Python diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
types = diagnostics {
langDesc = "Python";
inherit diagnosticsProviders;
inherit defaultDiagnosticsProvider;
};
};
};

config = mkIf cfg.enable (mkMerge [
Expand Down Expand Up @@ -404,5 +421,15 @@ in {
vim.debugger.nvim-dap.enable = true;
vim.debugger.nvim-dap.sources.python-debugger = debuggers.${cfg.dap.debugger}.dapConfig;
})

(mkIf cfg.extraDiagnostics.enable {
vim.diagnostics.nvim-lint = {
enable = true;
linters_by_ft.python = cfg.extraDiagnostics.types;
linters =
mkMerge (map (name: {${name} = diagnosticsProviders.${name}.config;})
cfg.extraDiagnostics.types);
};
})
]);
}
Loading