From 3cd71e08d014ffaa837b3a3d603c1eacee380504 Mon Sep 17 00:00:00 2001 From: Snoweuph Date: Tue, 12 May 2026 00:34:38 +0200 Subject: [PATCH] diagnostics/presets/cpplint: init --- docs/manual/release-notes/rl-0.9.md | 2 ++ .../plugins/diagnostics/presets/cpplint.nix | 20 +++++++++++++ .../plugins/diagnostics/presets/default.nix | 1 + modules/plugins/languages/clang.nix | 30 +++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 modules/plugins/diagnostics/presets/cpplint.nix diff --git a/docs/manual/release-notes/rl-0.9.md b/docs/manual/release-notes/rl-0.9.md index 10cc5425..4699d3bd 100644 --- a/docs/manual/release-notes/rl-0.9.md +++ b/docs/manual/release-notes/rl-0.9.md @@ -300,6 +300,8 @@ - Moved extra diagnostic modules under `diagnostics.presets.` this will allow for more flexibility in the future for nvf. +- Added {option}`vim.diagnostics.presets.cpplint.enable`. + - Added {option}`vim.treesitter.queries` to support adding custom queries. - Added injections for `query = '' ... ''` as `query` and `mkLualine '' ... ''`, diff --git a/modules/plugins/diagnostics/presets/cpplint.nix b/modules/plugins/diagnostics/presets/cpplint.nix new file mode 100644 index 00000000..153a53b7 --- /dev/null +++ b/modules/plugins/diagnostics/presets/cpplint.nix @@ -0,0 +1,20 @@ +{ + config, + lib, + pkgs, + ... +}: let + inherit (lib.meta) getExe; + inherit (lib.modules) mkIf; + inherit (lib.nvim.types) mkDiagnosticsPresetEnableOption; + + cfg = config.vim.diagnostics.presets.cpplint; +in { + options.vim.diagnostics.presets.cpplint = { + enable = mkDiagnosticsPresetEnableOption "cpplint" "cpplint"; + }; + + config = mkIf cfg.enable { + vim.diagnostics.nvim-lint.linters.cpplint.cmd = getExe pkgs.cpplint; + }; +} diff --git a/modules/plugins/diagnostics/presets/default.nix b/modules/plugins/diagnostics/presets/default.nix index 57c70e8c..cdb370e2 100644 --- a/modules/plugins/diagnostics/presets/default.nix +++ b/modules/plugins/diagnostics/presets/default.nix @@ -2,6 +2,7 @@ imports = [ ./biomejs.nix ./checkmake.nix + ./cpplint.nix ./deadnix.nix ./djlint.nix ./dotenv-linter.nix diff --git a/modules/plugins/languages/clang.nix b/modules/plugins/languages/clang.nix index 844074a5..57061c57 100644 --- a/modules/plugins/languages/clang.nix +++ b/modules/plugins/languages/clang.nix @@ -45,6 +45,8 @@ ''; }; }; + defaultDiagnosticsProvider = ["cpplint"]; + diagnosticsProviders = ["cpplint"]; in { options.vim.languages.clang = { enable = mkEnableOption "C/C++ language support"; @@ -102,6 +104,21 @@ in { default = debuggers.${cfg.dap.debugger}.package; }; }; + + extraDiagnostics = { + enable = + mkEnableOption "extra C/C++ diagnostics" + // { + default = config.vim.languages.enableExtraDiagnostics; + defaultText = literalExpression "config.vim.languages.enableExtraDiagnostics"; + }; + + types = mkOption { + type = listOf (enum diagnosticsProviders); + default = defaultDiagnosticsProvider; + description = "extra C/C++ diagnostics providers"; + }; + }; }; config = mkIf cfg.enable (mkMerge [ @@ -127,5 +144,18 @@ in { vim.debugger.nvim-dap.enable = true; vim.debugger.nvim-dap.sources.clang-debugger = debuggers.${cfg.dap.debugger}.dapConfig; }) + + (mkIf cfg.extraDiagnostics.enable { + vim.diagnostics = { + presets = genAttrs cfg.extraDiagnostics.types (_: {enable = true;}); + nvim-lint = { + enable = true; + linters_by_ft = { + c = cfg.extraDiagnostics.types; + cpp = cfg.extraDiagnostics.types; + }; + }; + }; + }) ]); }