Skip to content

Commit 6c73350

Browse files
committed
modules/diagnostic: rename diagnostics -> diagnostic.config
Currently we represent `vim.diagnostic.config()` as a top-level `diagnostics` option. This means we have no clear namespace for (e.g.) `vim.diagnostic.<action>` keymap functions.
1 parent c3a42a7 commit 6c73350

File tree

6 files changed

+38
-30
lines changed

6 files changed

+38
-30
lines changed

modules/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
./colorscheme.nix
1111
./commands.nix
1212
./dependencies.nix
13-
./diagnostics.nix
13+
./diagnostic.nix
1414
./doc.nix
1515
./editorconfig.nix
1616
./files.nix

modules/diagnostic.nix

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
lib,
3+
config,
4+
...
5+
}:
6+
let
7+
cfg = config.diagnostic;
8+
in
9+
{
10+
options.diagnostic = {
11+
config = lib.mkOption {
12+
type = with lib.types; attrsOf anything;
13+
default = { };
14+
description = "The configuration diagnostic options, provided to `vim.diagnostic.config`.";
15+
example = {
16+
virtual_text = false;
17+
virtual_lines.current_line = true;
18+
};
19+
};
20+
};
21+
22+
imports = [
23+
# TODO: Added 2025-04-26; remove after 25.05
24+
(lib.mkRenamedOptionModule [ "diagnostics" ] [ "diagnostic" "config" ])
25+
];
26+
27+
config = {
28+
extraConfigLuaPre = lib.mkIf (cfg.config != { }) ''
29+
vim.diagnostic.config(${lib.nixvim.toLuaObject cfg.config})
30+
'';
31+
};
32+
}

modules/diagnostics.nix

Lines changed: 0 additions & 25 deletions
This file was deleted.

plugins/by-name/lsp-lines/default.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ lib.nixvim.plugins.mkNeovimPlugin {
2424
"currentLine"
2525
]
2626
[
27-
"diagnostics"
27+
"diagnostic"
28+
"config"
2829
"virtual_lines"
2930
"only_current_line"
3031
]
@@ -33,6 +34,6 @@ lib.nixvim.plugins.mkNeovimPlugin {
3334

3435
extraConfig = {
3536
# Strongly recommended by the plugin, to avoid duplication.
36-
diagnostics.virtual_text = mkDefault false;
37+
diagnostic.config.virtual_text = mkDefault false;
3738
};
3839
}

tests/test-sources/modules/diagnostics.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
example = {
3-
diagnostics = {
3+
diagnostic.config = {
44
virtual_text = false;
55
virtual_lines.current_line = true;
66
};

tests/test-sources/plugins/by-name/lsp-lines/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
example = {
77
plugins.lsp-lines.enable = true;
88

9-
diagnostics.virtual_lines = {
9+
diagnostic.config.virtual_lines = {
1010
only_current_line = true;
1111
highlight_whole_line = false;
1212
};

0 commit comments

Comments
 (0)