Skip to content

Commit 74c34c4

Browse files
committed
add more doc for config
1 parent e598c7b commit 74c34c4

File tree

8 files changed

+152
-22
lines changed

8 files changed

+152
-22
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,13 @@ fn default_postfix() -> String {
5252
#[derive(Serialize, Deserialize, Debug, JsonSchema, Clone, Copy)]
5353
#[serde(rename_all = "kebab-case")]
5454
pub enum EmmyrcFilenameConvention {
55+
/// Keep the original filename.
5556
Keep,
57+
/// Convert the filename to snake_case.
5658
SnakeCase,
59+
/// Convert the filename to PascalCase.
5760
PascalCase,
61+
/// Convert the filename to camelCase.
5862
CamelCase,
5963
}
6064

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,13 @@ fn default_true() -> bool {
5050
#[derive(Serialize, Deserialize, Debug, JsonSchema)]
5151
#[serde(rename_all = "camelCase")]
5252
pub enum DiagnosticSeveritySetting {
53+
/// Represents an error diagnostic severity.
5354
Error,
55+
/// Represents a warning diagnostic severity.
5456
Warning,
57+
/// Represents an information diagnostic severity.
5558
Information,
59+
/// Represents a hint diagnostic severity.
5660
Hint,
5761
}
5862

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize};
44
#[derive(Serialize, Deserialize, Debug, JsonSchema)]
55
#[serde(rename_all = "camelCase")]
66
pub struct EmmyrcHover {
7+
/// Whether to enable hover.
78
#[serde(default = "default_true")]
89
pub enable: bool,
910
}

crates/code_analysis/src/config/configs/inlayhint.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ use serde::{Deserialize, Serialize};
44
#[derive(Serialize, Deserialize, Debug, JsonSchema)]
55
#[serde(rename_all = "camelCase")]
66
pub struct EmmyrcInlayHint {
7+
/// Whether to enable inlay hints.
78
#[serde(default = "default_true")]
89
pub enable: bool,
10+
/// Whether to enable parameter hints.
911
#[serde(default = "default_true")]
1012
pub param_hint: bool,
13+
/// Whether to enable index hints.
1114
#[serde(default = "default_true")]
1215
pub index_hint: bool,
16+
/// Whether to enable local hints.
1317
#[serde(default = "default_true")]
18+
/// Whether to enable override hints.
1419
pub local_hint: bool,
20+
/// Whether to enable override hints.
1521
#[serde(default = "default_true")]
1622
pub override_hint: bool,
1723
}

crates/code_analysis/src/config/configs/runtime.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@ use serde::{Deserialize, Serialize};
44
#[derive(Serialize, Deserialize, Debug, JsonSchema)]
55
#[serde(rename_all = "camelCase")]
66
pub struct EmmyrcRuntime {
7+
/// Lua version.
78
#[serde(default)]
89
pub version: EmmyrcLuaVersion,
910
#[serde(default)]
11+
/// Functions that like require.
1012
pub require_like_function: Vec<String>,
1113
#[serde(default)]
14+
/// Framework versions.
1215
pub framework_versions: Vec<String>,
1316
#[serde(default)]
17+
/// file Extensions. eg: .lua, .lua.txt
1418
pub extensions: Vec<String>,
1519
#[serde(default)]
20+
/// Require pattern. eg. "?.lua", "?/init.lua"
1621
pub require_pattern: Vec<String>,
1722
}
1823

@@ -30,16 +35,22 @@ impl Default for EmmyrcRuntime {
3035

3136
#[derive(Serialize, Deserialize, Debug, JsonSchema)]
3237
pub enum EmmyrcLuaVersion {
38+
/// Lua 5.1
3339
#[serde(rename = "Lua5.1")]
3440
Lua51,
41+
/// LuaJIT
3542
#[serde(rename = "LuaJIT")]
3643
LuaJIT,
44+
/// Lua 5.2
3745
#[serde(rename = "Lua5.2")]
3846
Lua52,
47+
/// Lua 5.3
3948
#[serde(rename = "Lua5.3")]
4049
Lua53,
50+
/// Lua 5.4
4151
#[serde(rename = "Lua5.4")]
4252
Lua54,
53+
/// Lua 5.4
4354
#[serde(rename = "LuaLatest")]
4455
LuaLatest,
4556
}

crates/code_analysis/src/config/configs/workspace.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,22 @@ use serde::{Deserialize, Serialize};
44
#[derive(Serialize, Deserialize, Debug, JsonSchema)]
55
#[serde(rename_all = "camelCase")]
66
pub struct EmmyrcWorkspace {
7+
/// Ignore directories.
78
#[serde(default)]
89
pub ignore_dir: Vec<String>,
10+
/// Ignore globs. eg: ["**/*.lua"]
911
#[serde(default)]
1012
pub ignore_globs: Vec<String>,
1113
#[serde(default)]
14+
/// Library paths. eg: "/usr/local/share/lua/5.1"
1215
pub library: Vec<String>,
1316
#[serde(default)]
17+
/// Workspace roots. eg: ["src", "test"]
1418
pub workspace_roots: Vec<String>,
1519
// unused
1620
#[serde(default)]
1721
pub preload_file_size: i32,
22+
/// Encoding. eg: "utf-8"
1823
#[serde(default = "encoding_default")]
1924
pub encoding: String,
2025
}

crates/code_analysis/src/config/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ use crate::{semantic::LuaInferConfig, FileId};
88
pub use config_loader::load_configs;
99
pub use configs::EmmyrcFilenameConvention;
1010
use configs::{
11-
EmmyrcCodeLen, EmmyrcCompletion, EmmyrcDiagnostic, EmmyrcHover, EmmyrcInlayHint, EmmyrcLuaVersion, EmmyrcReference, EmmyrcResource, EmmyrcRuntime, EmmyrcSemanticToken, EmmyrcSignature, EmmyrcStrict, EmmyrcWorkspace
11+
EmmyrcCodeLen, EmmyrcCompletion, EmmyrcDiagnostic, EmmyrcHover, EmmyrcInlayHint,
12+
EmmyrcLuaVersion, EmmyrcReference, EmmyrcResource, EmmyrcRuntime, EmmyrcSemanticToken,
13+
EmmyrcSignature, EmmyrcStrict, EmmyrcWorkspace,
1214
};
1315
use emmylua_parser::{LuaLanguageLevel, ParserConfig};
1416
use rowan::NodeCache;
@@ -44,7 +46,7 @@ pub struct Emmyrc {
4446
#[serde(default)]
4547
pub references: EmmyrcReference,
4648
#[serde(default)]
47-
pub hover: EmmyrcHover
49+
pub hover: EmmyrcHover,
4850
}
4951

5052
impl Emmyrc {

resources/schema.json

Lines changed: 117 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,35 @@
182182
]
183183
},
184184
"DiagnosticSeveritySetting": {
185-
"type": "string",
186-
"enum": [
187-
"error",
188-
"warning",
189-
"information",
190-
"hint"
185+
"oneOf": [
186+
{
187+
"description": "Represents an error diagnostic severity.",
188+
"type": "string",
189+
"enum": [
190+
"error"
191+
]
192+
},
193+
{
194+
"description": "Represents a warning diagnostic severity.",
195+
"type": "string",
196+
"enum": [
197+
"warning"
198+
]
199+
},
200+
{
201+
"description": "Represents an information diagnostic severity.",
202+
"type": "string",
203+
"enum": [
204+
"information"
205+
]
206+
},
207+
{
208+
"description": "Represents a hint diagnostic severity.",
209+
"type": "string",
210+
"enum": [
211+
"hint"
212+
]
213+
}
191214
]
192215
},
193216
"EmmyrcCodeLen": {
@@ -292,18 +315,42 @@
292315
}
293316
},
294317
"EmmyrcFilenameConvention": {
295-
"type": "string",
296-
"enum": [
297-
"keep",
298-
"snake-case",
299-
"pascal-case",
300-
"camel-case"
318+
"oneOf": [
319+
{
320+
"description": "Keep the original filename.",
321+
"type": "string",
322+
"enum": [
323+
"keep"
324+
]
325+
},
326+
{
327+
"description": "Convert the filename to snake_case.",
328+
"type": "string",
329+
"enum": [
330+
"snake-case"
331+
]
332+
},
333+
{
334+
"description": "Convert the filename to PascalCase.",
335+
"type": "string",
336+
"enum": [
337+
"pascal-case"
338+
]
339+
},
340+
{
341+
"description": "Convert the filename to camelCase.",
342+
"type": "string",
343+
"enum": [
344+
"camel-case"
345+
]
346+
}
301347
]
302348
},
303349
"EmmyrcHover": {
304350
"type": "object",
305351
"properties": {
306352
"enable": {
353+
"description": "Whether to enable hover.",
307354
"default": true,
308355
"type": "boolean"
309356
}
@@ -313,36 +360,76 @@
313360
"type": "object",
314361
"properties": {
315362
"enable": {
363+
"description": "Whether to enable inlay hints.",
316364
"default": true,
317365
"type": "boolean"
318366
},
319367
"indexHint": {
368+
"description": "Whether to enable index hints.",
320369
"default": true,
321370
"type": "boolean"
322371
},
323372
"localHint": {
373+
"description": "Whether to enable local hints. Whether to enable override hints.",
324374
"default": true,
325375
"type": "boolean"
326376
},
327377
"overrideHint": {
378+
"description": "Whether to enable override hints.",
328379
"default": true,
329380
"type": "boolean"
330381
},
331382
"paramHint": {
383+
"description": "Whether to enable parameter hints.",
332384
"default": true,
333385
"type": "boolean"
334386
}
335387
}
336388
},
337389
"EmmyrcLuaVersion": {
338-
"type": "string",
339-
"enum": [
340-
"Lua5.1",
341-
"LuaJIT",
342-
"Lua5.2",
343-
"Lua5.3",
344-
"Lua5.4",
345-
"LuaLatest"
390+
"oneOf": [
391+
{
392+
"description": "Lua 5.1",
393+
"type": "string",
394+
"enum": [
395+
"Lua5.1"
396+
]
397+
},
398+
{
399+
"description": "LuaJIT",
400+
"type": "string",
401+
"enum": [
402+
"LuaJIT"
403+
]
404+
},
405+
{
406+
"description": "Lua 5.2",
407+
"type": "string",
408+
"enum": [
409+
"Lua5.2"
410+
]
411+
},
412+
{
413+
"description": "Lua 5.3",
414+
"type": "string",
415+
"enum": [
416+
"Lua5.3"
417+
]
418+
},
419+
{
420+
"description": "Lua 5.4",
421+
"type": "string",
422+
"enum": [
423+
"Lua5.4"
424+
]
425+
},
426+
{
427+
"description": "Lua 5.4",
428+
"type": "string",
429+
"enum": [
430+
"LuaLatest"
431+
]
432+
}
346433
]
347434
},
348435
"EmmyrcReference": {
@@ -376,34 +463,39 @@
376463
"type": "object",
377464
"properties": {
378465
"extensions": {
466+
"description": "file Extensions. eg: .lua, .lua.txt",
379467
"default": [],
380468
"type": "array",
381469
"items": {
382470
"type": "string"
383471
}
384472
},
385473
"frameworkVersions": {
474+
"description": "Framework versions.",
386475
"default": [],
387476
"type": "array",
388477
"items": {
389478
"type": "string"
390479
}
391480
},
392481
"requireLikeFunction": {
482+
"description": "Functions that like require.",
393483
"default": [],
394484
"type": "array",
395485
"items": {
396486
"type": "string"
397487
}
398488
},
399489
"requirePattern": {
490+
"description": "Require pattern. eg. \"?.lua\", \"?/init.lua\"",
400491
"default": [],
401492
"type": "array",
402493
"items": {
403494
"type": "string"
404495
}
405496
},
406497
"version": {
498+
"description": "Lua version.",
407499
"default": "LuaLatest",
408500
"allOf": [
409501
{
@@ -451,24 +543,28 @@
451543
"type": "object",
452544
"properties": {
453545
"encoding": {
546+
"description": "Encoding. eg: \"utf-8\"",
454547
"default": "utf-8",
455548
"type": "string"
456549
},
457550
"ignoreDir": {
551+
"description": "Ignore directories.",
458552
"default": [],
459553
"type": "array",
460554
"items": {
461555
"type": "string"
462556
}
463557
},
464558
"ignoreGlobs": {
559+
"description": "Ignore globs. eg: [\"**/*.lua\"]",
465560
"default": [],
466561
"type": "array",
467562
"items": {
468563
"type": "string"
469564
}
470565
},
471566
"library": {
567+
"description": "Library paths. eg: \"/usr/local/share/lua/5.1\"",
472568
"default": [],
473569
"type": "array",
474570
"items": {
@@ -481,6 +577,7 @@
481577
"format": "int32"
482578
},
483579
"workspaceRoots": {
580+
"description": "Workspace roots. eg: [\"src\", \"test\"]",
484581
"default": [],
485582
"type": "array",
486583
"items": {

0 commit comments

Comments
 (0)