aws-iam-language-server 0.0.27 → 0.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-iam-language-server",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "type": "module",
5
5
  "bin": "./src/server.js",
6
6
  "publisher": "MichaelBarney",
@@ -20,6 +20,11 @@
20
20
  "configuration": {
21
21
  "title": "AWS IAM Language Server",
22
22
  "properties": {
23
+ "aws-iam-language-server.diagnostics.enabled": {
24
+ "type": "boolean",
25
+ "default": true,
26
+ "description": "Enable all diagnostics. When disabled, no diagnostics are reported."
27
+ },
23
28
  "aws-iam-language-server.diagnostics.DUPLICATE_KEY.enabled": {
24
29
  "type": "boolean",
25
30
  "default": true,
@@ -84,6 +89,16 @@
84
89
  "type": "boolean",
85
90
  "default": true,
86
91
  "description": "Warn when account ID is not 12 digits."
92
+ },
93
+ "aws-iam-language-server.hover.enabled": {
94
+ "type": "boolean",
95
+ "default": true,
96
+ "description": "Enable hover tooltips for IAM policy elements."
97
+ },
98
+ "aws-iam-language-server.documentLink.enabled": {
99
+ "type": "boolean",
100
+ "default": true,
101
+ "description": "Enable document links for IAM actions."
87
102
  }
88
103
  }
89
104
  }
package/readme.md CHANGED
@@ -19,8 +19,14 @@ Install the [extension](https://marketplace.visualstudio.com/items?itemName=Mich
19
19
 
20
20
  ```json
21
21
  {
22
- // replace ${DIAGNOSTIC_RULE} with a diganostic rule id, like DEPENDENT_ACTION
23
- "aws-iam-language-server.diagnostics.${DIAGNOSTIC_RULE}.enabled": true
22
+ // disable all diagnostics
23
+ "aws-iam-language-server.diagnostics.enabled": true,
24
+ // disable a specific diagnostic rule, replace ${DIAGNOSTIC_RULE} with a rule id like DEPENDENT_ACTION
25
+ "aws-iam-language-server.diagnostics.${DIAGNOSTIC_RULE}.enabled": true,
26
+ // disable hover tooltips
27
+ "aws-iam-language-server.hover.enabled": true,
28
+ // disable document links
29
+ "aws-iam-language-server.documentLink.enabled": true
24
30
  }
25
31
  ```
26
32
 
@@ -43,9 +49,15 @@ vim.lsp.config("aws-iam-language-server", {
43
49
  settings = {
44
50
  ["aws-iam-language-server"] = {
45
51
  diagnostics = {
46
- -- replace ${DIAGNOSTIC_RULE} with a diganostic rule id, like DEPENDENT_ACTION
52
+ -- disable all diagnostics
53
+ enabled = false,
54
+ -- or disable a specific rule, replace ${DIAGNOSTIC_RULE} with a rule id like DEPENDENT_ACTION
47
55
  ${DIAGNOSTIC_RULE} = { enabled = false },
48
56
  },
57
+ -- disable hover tooltips
58
+ hover = { enabled = false },
59
+ -- disable document links
60
+ documentLink = { enabled = false },
49
61
  },
50
62
  },
51
63
  })
@@ -1,4 +1,4 @@
1
- import { isRuleEnabled } from "../../lib/config.js";
1
+ import { getConfig, isRuleEnabled } from "../../lib/config.js";
2
2
  import { ActionValidator } from "./action.js";
3
3
  import { ConditionValidator } from "./condition.js";
4
4
  import { EffectValidator } from "./effect.js";
@@ -7,6 +7,10 @@ import { ResourceValidator } from "./resource.js";
7
7
  import { SidValidator } from "./sid.js";
8
8
  import { createDiagnostic } from "./utils.js";
9
9
  export async function diagnosticsHandler(document, treeManager, connection) {
10
+ if (!getConfig().diagnostics.enabled) {
11
+ await connection.sendDiagnostics({ uri: document.uri, diagnostics: [] });
12
+ return;
13
+ }
10
14
  const handler = treeManager.getLanguageHandler(document.uri);
11
15
  if (!handler)
12
16
  return;
@@ -1,5 +1,8 @@
1
+ import { getConfig } from "../../lib/config.js";
1
2
  import { ServiceReference } from "../../lib/iam-policy/reference/services.js";
2
3
  export function documentLinkHandler(params, documents, treeManager, connection) {
4
+ if (!getConfig().documentLink.enabled)
5
+ return [];
3
6
  const document = documents.get(params.textDocument.uri);
4
7
  if (!document)
5
8
  return [];
@@ -1,3 +1,4 @@
1
+ import { getConfig } from "../../lib/config.js";
1
2
  import { resolvePolicyLocation } from "../../lib/iam-policy/location.js";
2
3
  import { handleActionValueHover } from "./action-value.js";
3
4
  import { handleConditionBlockHover } from "./condition-block.js";
@@ -12,6 +13,8 @@ import { handleResourceValueHover } from "./resource-value.js";
12
13
  import { handleStatementBlockHover } from "./statement-block.js";
13
14
  import { handleStatementKeyHover } from "./statement-key.js";
14
15
  export function hoverHandler(params, treeManager, connection) {
16
+ if (!getConfig().hover.enabled)
17
+ return null;
15
18
  const handler = treeManager.getLanguageHandler(params.textDocument.uri);
16
19
  if (!handler)
17
20
  return null;
@@ -2,8 +2,17 @@ import { type DiagnosticRuleId } from './diagnostics.ts';
2
2
  export type DiagnosticRuleConfig = {
3
3
  enabled: boolean;
4
4
  };
5
+ export type DiagnosticsConfig = Record<DiagnosticRuleId, DiagnosticRuleConfig> & {
6
+ enabled: boolean;
7
+ };
5
8
  export type ServerConfig = {
6
- diagnostics: Record<DiagnosticRuleId, DiagnosticRuleConfig>;
9
+ diagnostics: DiagnosticsConfig;
10
+ hover: {
11
+ enabled: boolean;
12
+ };
13
+ documentLink: {
14
+ enabled: boolean;
15
+ };
7
16
  };
8
17
  export declare function getConfig(): ServerConfig;
9
18
  export declare function isRuleEnabled(ruleId: DiagnosticRuleId): boolean;
package/src/lib/config.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { diagnosticRules } from "./diagnostics.js";
2
2
  function createDefaults() {
3
- const diagnostics = {};
3
+ const diagnostics = { enabled: true };
4
4
  for (const key of Object.keys(diagnosticRules)) {
5
5
  diagnostics[key] = { enabled: true };
6
6
  }
7
- return { diagnostics };
7
+ return { diagnostics, hover: { enabled: true }, documentLink: { enabled: true } };
8
8
  }
9
9
  const config = createDefaults();
10
10
  export function getConfig() {
@@ -15,20 +15,34 @@ export function isRuleEnabled(ruleId) {
15
15
  }
16
16
  export function resetConfig() {
17
17
  const defaults = createDefaults();
18
+ config.diagnostics.enabled = defaults.diagnostics.enabled;
18
19
  for (const key of Object.keys(diagnosticRules)) {
19
20
  config.diagnostics[key] = defaults.diagnostics[key];
20
21
  }
22
+ config.hover = defaults.hover;
23
+ config.documentLink = defaults.documentLink;
21
24
  }
22
25
  export function updateConfig(settings) {
23
26
  if (!settings)
24
27
  return;
25
28
  const diagnostics = settings.diagnostics;
26
- if (!diagnostics)
27
- return;
28
- for (const key of Object.keys(diagnosticRules)) {
29
- const ruleConfig = diagnostics[key];
30
- if (ruleConfig && typeof ruleConfig.enabled === 'boolean') {
31
- config.diagnostics[key].enabled = ruleConfig.enabled;
29
+ if (diagnostics) {
30
+ if (typeof diagnostics.enabled === 'boolean') {
31
+ config.diagnostics.enabled = diagnostics.enabled;
32
+ }
33
+ for (const key of Object.keys(diagnosticRules)) {
34
+ const ruleConfig = diagnostics[key];
35
+ if (ruleConfig && typeof ruleConfig.enabled === 'boolean') {
36
+ config.diagnostics[key].enabled = ruleConfig.enabled;
37
+ }
32
38
  }
33
39
  }
40
+ const hover = settings.hover;
41
+ if (hover && typeof hover.enabled === 'boolean') {
42
+ config.hover.enabled = hover.enabled;
43
+ }
44
+ const documentLink = settings.documentLink;
45
+ if (documentLink && typeof documentLink.enabled === 'boolean') {
46
+ config.documentLink.enabled = documentLink.enabled;
47
+ }
34
48
  }