Skip to content

Commit 61b04b3

Browse files
committed
Add annotations for exporting VSCode settings
1 parent 3f233ad commit 61b04b3

File tree

14 files changed

+176
-79
lines changed

14 files changed

+176
-79
lines changed

crates/emmylua_code_analysis/resources/schema.json

Lines changed: 90 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
},
1818
"codeLens": {
19-
"$ref": "#/$defs/EmmyrcCodeLen",
19+
"$ref": "#/$defs/EmmyrcCodeLens",
2020
"default": {
2121
"enable": true
2222
}
@@ -438,19 +438,21 @@
438438
"type": "object",
439439
"properties": {
440440
"insertSpace": {
441-
"description": "Whether to insert space after '---'",
441+
"description": "Add space after `---` comments when inserting `@diagnostic disable-next-line`.",
442442
"type": "boolean",
443-
"default": false
443+
"default": false,
444+
"x-vscode-setting": true
444445
}
445446
}
446447
},
447-
"EmmyrcCodeLen": {
448+
"EmmyrcCodeLens": {
448449
"type": "object",
449450
"properties": {
450451
"enable": {
451-
"description": "Whether to enable code lens.",
452+
"description": "Enable code lens.",
452453
"type": "boolean",
453-
"default": true
454+
"default": true,
455+
"x-vscode-setting": true
454456
}
455457
}
456458
},
@@ -459,9 +461,10 @@
459461
"type": "object",
460462
"properties": {
461463
"autoRequire": {
462-
"description": "Whether to automatically require modules.",
464+
"description": "Automatically insert call to `require` when autocompletion\ninserts objects from other modules.",
463465
"type": "boolean",
464-
"default": true
466+
"default": true,
467+
"x-vscode-setting": true
465468
},
466469
"autoRequireFunction": {
467470
"description": "The function used for auto-requiring modules.",
@@ -479,24 +482,45 @@
479482
"default": "."
480483
},
481484
"baseFunctionIncludesName": {
482-
"description": "Whether to include the name in the base function completion. effect: `function () end` -> `function name() end`.",
485+
"description": "Whether to include the name in the base function completion. Effect: `function () end` -> `function name() end`.",
483486
"type": "boolean",
484-
"default": true
487+
"default": true,
488+
"x-vscode-setting": true
485489
},
486490
"callSnippet": {
487491
"description": "Whether to use call snippets in completions.",
488492
"type": "boolean",
489493
"default": false
490494
},
491495
"enable": {
492-
"description": "Whether to enable code completion.",
496+
"description": "Enable autocompletion.",
493497
"type": "boolean",
494-
"default": true
498+
"default": true,
499+
"x-vscode-setting": true
495500
},
496501
"postfix": {
497-
"description": "The postfix trigger used in completions.",
498-
"type": "string",
499-
"default": "@"
502+
"description": "Symbol that's used to trigger postfix autocompletion.",
503+
"type": "string",
504+
"default": "@",
505+
"x-vscode-setting": {
506+
"default": null,
507+
"enum": [
508+
null,
509+
"@",
510+
".",
511+
":"
512+
],
513+
"enumItemLabels": [
514+
"Default"
515+
],
516+
"markdownEnumDescriptions": [
517+
"%config.common.enum.default.description%"
518+
],
519+
"type": [
520+
"string",
521+
"null"
522+
]
523+
}
500524
}
501525
}
502526
},
@@ -505,13 +529,14 @@
505529
"type": "object",
506530
"properties": {
507531
"diagnosticInterval": {
508-
"description": "The interval in milliseconds to perform diagnostics.",
532+
"description": "Delay between opening/changing a file and scanning it for errors, in milliseconds.",
509533
"type": [
510534
"integer",
511535
"null"
512536
],
513537
"format": "uint64",
514-
"minimum": 0
538+
"minimum": 0,
539+
"x-vscode-setting": true
515540
},
516541
"disable": {
517542
"description": "A list of diagnostic codes that are disabled.",
@@ -585,9 +610,10 @@
585610
"type": "object",
586611
"properties": {
587612
"enable": {
588-
"description": "Whether to enable document color.",
613+
"description": "Enable parsing strings for color tags and showing a color picker next to them.",
589614
"type": "boolean",
590-
"default": true
615+
"default": true,
616+
"x-vscode-setting": true
591617
}
592618
}
593619
},
@@ -624,59 +650,68 @@
624650
"type": "object",
625651
"properties": {
626652
"enable": {
627-
"description": "Whether to enable hover.",
653+
"description": "Enable showing documentation on hover.",
628654
"type": "boolean",
629-
"default": true
655+
"default": true,
656+
"x-vscode-setting": true
630657
}
631658
}
632659
},
633660
"EmmyrcInlayHint": {
634661
"type": "object",
635662
"properties": {
636663
"enable": {
637-
"description": "Whether to enable inlay hints.",
664+
"description": "Enable inlay hints.",
638665
"type": "boolean",
639-
"default": true
666+
"default": true,
667+
"x-vscode-setting": true
640668
},
641669
"enumParamHint": {
642-
"description": "Whether to enable enum parameter hints.",
670+
"description": "Show name of enumerator when passing a literal value to a function\nthat expects an enum.\n\nExample:\n\n```lua\n--- @enum Level\nlocal Foo = {\n Info = 1,\n Error = 2,\n}\n\n--- @param l Level\nfunction print_level(l) end\n\nprint_level(1 --[[ Hint: Level.Info ]])\n```",
643671
"type": "boolean",
644-
"default": false
672+
"default": false,
673+
"x-vscode-setting": true
645674
},
646675
"indexHint": {
647-
"description": "Whether to enable index hints.",
676+
"description": "Show named array indexes.\n\nExample:\n\n```lua\nlocal array = {\n [1] = 1, -- [name]\n}\n\nprint(array[1] --[[ Hint: name ]])\n```",
648677
"type": "boolean",
649-
"default": true
678+
"default": true,
679+
"x-vscode-setting": true
650680
},
651681
"localHint": {
652-
"description": "Whether to enable local hints.\nWhether to enable override hints.",
682+
"description": "Show types of local variables.",
653683
"type": "boolean",
654-
"default": true
684+
"default": true,
685+
"x-vscode-setting": true
655686
},
656687
"metaCallHint": {
657-
"description": "Whether to enable meta __call operator hints.",
688+
"description": "Show hint when calling an object results in a call to\nits meta table's `__call` function.",
658689
"type": "boolean",
659-
"default": true
690+
"default": true,
691+
"x-vscode-setting": true
660692
},
661693
"overrideHint": {
662-
"description": "Whether to enable override hints.",
694+
"description": "Show methods that override functions from base class.",
663695
"type": "boolean",
664-
"default": true
696+
"default": true,
697+
"x-vscode-setting": true
665698
},
666699
"paramHint": {
667-
"description": "Whether to enable parameter hints.",
700+
"description": "Show parameter names in function calls and parameter types in function definitions.",
668701
"type": "boolean",
669-
"default": true
702+
"default": true,
703+
"x-vscode-setting": true
670704
}
671705
}
672706
},
673707
"EmmyrcInlineValues": {
674708
"type": "object",
675709
"properties": {
676710
"enable": {
677-
"description": "Whether to enable inline values.",
711+
"description": "Show inline values during debug.",
678712
"type": "boolean",
679-
"default": true
713+
"default": true,
714+
"x-vscode-setting": true
680715
}
681716
}
682717
},
@@ -723,19 +758,22 @@
723758
"type": "object",
724759
"properties": {
725760
"enable": {
726-
"description": "Whether to enable reference search.",
761+
"description": "Enable searching for symbol usages.",
727762
"type": "boolean",
728-
"default": true
763+
"default": true,
764+
"x-vscode-setting": true
729765
},
730766
"fuzzySearch": {
731-
"description": "Determines whether to enable fuzzy searching for fields where references cannot be found.",
767+
"description": "Use fuzzy search when searching for symbol usages\nand normal search didn't find anything.",
732768
"type": "boolean",
733-
"default": true
769+
"default": true,
770+
"x-vscode-setting": true
734771
},
735772
"shortStringSearch": {
736-
"description": "Cache Short string for search",
773+
"description": "Also search for usages in strings.",
737774
"type": "boolean",
738-
"default": false
775+
"default": false,
776+
"x-vscode-setting": true
739777
}
740778
}
741779
},
@@ -806,9 +844,10 @@
806844
"type": "object",
807845
"properties": {
808846
"enable": {
809-
"description": "Whether to enable semantic token.",
847+
"description": "Enable semantic tokens.",
810848
"type": "boolean",
811-
"default": true
849+
"default": true,
850+
"x-vscode-setting": true
812851
}
813852
}
814853
},
@@ -855,9 +894,10 @@
855894
"type": "object",
856895
"properties": {
857896
"enableReindex": {
858-
"description": "Enable reindex.",
897+
"description": "Enable full project reindex after changing a file.",
859898
"type": "boolean",
860-
"default": false
899+
"default": false,
900+
"x-vscode-setting": true
861901
},
862902
"encoding": {
863903
"description": "Encoding. eg: \"utf-8\"",
@@ -902,11 +942,12 @@
902942
"default": 0
903943
},
904944
"reindexDuration": {
905-
"description": "when save a file, ls will reindex the workspace after reindex_duration milliseconds.",
945+
"description": "Delay between changing a file and full project reindex, in milliseconds.",
906946
"type": "integer",
907947
"format": "uint64",
908948
"default": 5000,
909-
"minimum": 0
949+
"minimum": 0,
950+
"x-vscode-setting": true
910951
},
911952
"workspaceRoots": {
912953
"description": "Workspace roots. eg: [\"src\", \"test\"]",

crates/emmylua_code_analysis/src/config/configs/code_action.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ use serde::{Deserialize, Serialize};
44
#[derive(Serialize, Deserialize, Debug, JsonSchema, Clone)]
55
#[serde(rename_all = "camelCase")]
66
pub struct EmmyrcCodeAction {
7-
/// Whether to insert space after '---'
7+
/// Add space after `---` comments when inserting `@diagnostic disable-next-line`.
88
#[serde(default = "default_false")]
9+
#[schemars(extend("x-vscode-setting" = true))]
910
pub insert_space: bool,
1011
}
1112

crates/emmylua_code_analysis/src/config/configs/codelen.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ use serde::{Deserialize, Serialize};
33

44
#[derive(Serialize, Deserialize, Debug, JsonSchema, Clone)]
55
#[serde(rename_all = "camelCase")]
6-
pub struct EmmyrcCodeLen {
7-
/// Whether to enable code lens.
6+
pub struct EmmyrcCodeLens {
7+
/// Enable code lens.
88
#[serde(default = "default_true")]
9+
#[schemars(extend("x-vscode-setting" = true))]
910
pub enable: bool,
1011
}
1112

12-
impl Default for EmmyrcCodeLen {
13+
impl Default for EmmyrcCodeLens {
1314
fn default() -> Self {
1415
Self {
1516
enable: default_true(),

crates/emmylua_code_analysis/src/config/configs/completion.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ use serde_with::{DefaultOnError, serde_as};
77
#[serde(rename_all = "camelCase")]
88
/// Configuration for EmmyLua code completion.
99
pub struct EmmyrcCompletion {
10-
/// Whether to enable code completion.
10+
/// Enable autocompletion.
1111
#[serde(default = "default_true")]
12+
#[schemars(extend("x-vscode-setting" = true))]
1213
pub enable: bool,
13-
/// Whether to automatically require modules.
14+
/// Automatically insert call to `require` when autocompletion
15+
/// inserts objects from other modules.
1416
#[serde(default = "default_true")]
17+
#[schemars(extend("x-vscode-setting" = true))]
1518
pub auto_require: bool,
1619
/// The function used for auto-requiring modules.
1720
#[serde(default = "default_require_function")]
@@ -26,11 +29,19 @@ pub struct EmmyrcCompletion {
2629
#[serde(default)]
2730
#[serde_as(deserialize_as = "DefaultOnError")]
2831
pub call_snippet: bool,
29-
/// The postfix trigger used in completions.
32+
/// Symbol that's used to trigger postfix autocompletion.
3033
#[serde(default = "default_postfix")]
34+
#[schemars(extend("x-vscode-setting" = {
35+
"type": ["string", "null"],
36+
"default": null,
37+
"enum": [null, "@", ".", ":"],
38+
"enumItemLabels": ["Default"],
39+
"markdownEnumDescriptions": ["%config.common.enum.default.description%"],
40+
}))]
3141
pub postfix: String,
32-
/// Whether to include the name in the base function completion. effect: `function () end` -> `function name() end`.
42+
/// Whether to include the name in the base function completion. Effect: `function () end` -> `function name() end`.
3343
#[serde(default = "default_true")]
44+
#[schemars(extend("x-vscode-setting" = true))]
3445
pub base_function_includes_name: bool,
3546
}
3647

crates/emmylua_code_analysis/src/config/configs/diagnostics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ pub struct EmmyrcDiagnostic {
2828
/// A list of diagnostic codes that are enabled.
2929
#[serde(default)]
3030
pub enables: Vec<DiagnosticCode>,
31-
/// The interval in milliseconds to perform diagnostics.
31+
/// Delay between opening/changing a file and scanning it for errors, in milliseconds.
32+
#[schemars(extend("x-vscode-setting" = true))]
3233
pub diagnostic_interval: Option<u64>,
3334
}
3435

crates/emmylua_code_analysis/src/config/configs/document_color.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ use serde::{Deserialize, Serialize};
44
#[derive(Serialize, Deserialize, Debug, JsonSchema, Clone)]
55
#[serde(rename_all = "camelCase")]
66
pub struct EmmyrcDocumentColor {
7-
/// Whether to enable document color.
7+
/// Enable parsing strings for color tags and showing a color picker next to them.
88
#[serde(default = "default_true")]
9+
#[schemars(extend("x-vscode-setting" = true))]
910
pub enable: bool,
1011
}
1112

crates/emmylua_code_analysis/src/config/configs/hover.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ use serde::{Deserialize, Serialize};
44
#[derive(Serialize, Deserialize, Debug, JsonSchema, Clone)]
55
#[serde(rename_all = "camelCase")]
66
pub struct EmmyrcHover {
7-
/// Whether to enable hover.
7+
/// Enable showing documentation on hover.
88
#[serde(default = "default_true")]
9+
#[schemars(extend("x-vscode-setting" = true))]
910
pub enable: bool,
1011
}
1112

0 commit comments

Comments
 (0)