Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
896e9f6c1f | ||
|
|
52a2b2f774 | ||
|
|
ee5240c861 | ||
|
|
61fb0bc5d2 | ||
|
|
95ddae6d13 | ||
|
|
a6f616a89d | ||
|
|
632fc32c3e | ||
|
|
9c5b76510d | ||
|
|
1b6b25c137 | ||
|
|
e84a08e22b |
@@ -78,7 +78,8 @@ export async function getWorkspaceSettings(
|
|||||||
path: resolveVariables(config.get<string[]>(`path`) ?? [], workspace),
|
path: resolveVariables(config.get<string[]>(`path`) ?? [], workspace),
|
||||||
interpreter: resolveVariables(interpreter, workspace),
|
interpreter: resolveVariables(interpreter, workspace),
|
||||||
importStrategy: config.get<string>(`importStrategy`) ?? "useBundled",
|
importStrategy: config.get<string>(`importStrategy`) ?? "useBundled",
|
||||||
showNotifications: config.get<string>(`showNotifications`) ?? "off"
|
showNotifications: config.get<string>(`showNotifications`) ?? "off",
|
||||||
|
formatter: config.get<boolean>(`formatter`) ?? false
|
||||||
}
|
}
|
||||||
return workspaceSetting
|
return workspaceSetting
|
||||||
}
|
}
|
||||||
@@ -109,7 +110,8 @@ export async function getGlobalSettings(
|
|||||||
path: getGlobalValue<string[]>(config, "path", []),
|
path: getGlobalValue<string[]>(config, "path", []),
|
||||||
interpreter: interpreter,
|
interpreter: interpreter,
|
||||||
importStrategy: getGlobalValue<string>(config, "importStrategy", "useBundled"),
|
importStrategy: getGlobalValue<string>(config, "importStrategy", "useBundled"),
|
||||||
showNotifications: getGlobalValue<string>(config, "showNotifications", "off")
|
showNotifications: getGlobalValue<string>(config, "showNotifications", "off"),
|
||||||
|
formatter: config.get<boolean>(`formatter`) ?? false
|
||||||
}
|
}
|
||||||
return setting
|
return setting
|
||||||
}
|
}
|
||||||
@@ -123,7 +125,8 @@ export function checkIfConfigurationChanged(
|
|||||||
`${namespace}.path`,
|
`${namespace}.path`,
|
||||||
`${namespace}.interpreter`,
|
`${namespace}.interpreter`,
|
||||||
`${namespace}.importStrategy`,
|
`${namespace}.importStrategy`,
|
||||||
`${namespace}.showNotifications`
|
`${namespace}.showNotifications`,
|
||||||
|
`${namespace}.formatter`
|
||||||
]
|
]
|
||||||
const changed = settings.map((s) => e.affectsConfiguration(s))
|
const changed = settings.map((s) => e.affectsConfiguration(s))
|
||||||
return changed.includes(true)
|
return changed.includes(true)
|
||||||
|
|||||||
+6
-1
@@ -2,7 +2,7 @@
|
|||||||
"name": "nx-post-support",
|
"name": "nx-post-support",
|
||||||
"displayName": "NX Postprocessor Support",
|
"displayName": "NX Postprocessor Support",
|
||||||
"description": "",
|
"description": "",
|
||||||
"version": "0.4.3",
|
"version": "0.4.6",
|
||||||
"publisher": "Christoph",
|
"publisher": "Christoph",
|
||||||
"serverInfo": {
|
"serverInfo": {
|
||||||
"name": "NX Postprocessor Support",
|
"name": "NX Postprocessor Support",
|
||||||
@@ -79,6 +79,11 @@
|
|||||||
],
|
],
|
||||||
"configuration": {
|
"configuration": {
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"nx-post-support.formatter": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Use the TCL formatter from `NX Postprocessor Support`"
|
||||||
|
},
|
||||||
"nx-post-support.importStrategy": {
|
"nx-post-support.importStrategy": {
|
||||||
"default": "useBundled",
|
"default": "useBundled",
|
||||||
"description": "Defines where `NX Postprocessor Support` is imported from.",
|
"description": "Defines where `NX Postprocessor Support` is imported from.",
|
||||||
|
|||||||
@@ -15,43 +15,48 @@ def format_tcl(src: str, indent_str=" ") -> str:
|
|||||||
for raw_line in src.splitlines():
|
for raw_line in src.splitlines():
|
||||||
stripped = raw_line.strip()
|
stripped = raw_line.strip()
|
||||||
|
|
||||||
# 1) Single-line 'if {cond} {action}' → no indent change
|
# Comments are ignored
|
||||||
|
if stripped.startswith("#"):
|
||||||
|
out_lines.append(indent_str * level + stripped)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Single-line 'if {cond} {action}' → no indent change
|
||||||
if re.match(r"^(if|elseif)\s*\{[^}]+\}\s*\{[^}]+\}$", stripped):
|
if re.match(r"^(if|elseif)\s*\{[^}]+\}\s*\{[^}]+\}$", stripped):
|
||||||
out_lines.append(indent_str * level + stripped)
|
out_lines.append(indent_str * level + stripped)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# 2) Combined '} else {' → dedent, print, then indent
|
# Combined '} else {' → dedent, print, then indent
|
||||||
if re.match(r"^\}\s*(elseif|else)\b.*\{$", stripped):
|
if re.match(r"^\}\s*(elseif|else)\b.*\{$", stripped):
|
||||||
level = max(level - 1, 0)
|
level = max(level - 1, 0)
|
||||||
out_lines.append(indent_str * level + stripped)
|
out_lines.append(indent_str * level + stripped)
|
||||||
level += 1
|
level += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# 3) SPECIAL: closing brace plus tag on same line: '} Tag'
|
# SPECIAL: closing brace plus tag on same line: '} Tag'
|
||||||
m = re.match(r"^\}\s+\w+.*", stripped)
|
m = re.match(r"^\}\s+(.+)", stripped)
|
||||||
if m:
|
if m and not stripped.startswith("#"):
|
||||||
# close one block
|
# close one block
|
||||||
level = max(level - 1, 0)
|
level = max(level - 1, 0)
|
||||||
# stay on one line: "} Tag"
|
# stay on one line: "} Tag"
|
||||||
out_lines.append(f"{indent_str * level}}} {m.group(1)}")
|
out_lines.append(f"{indent_str * level}}} {m.group(1)}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# 4) Pure '}' → dedent then print
|
# Pure '}' → dedent then print
|
||||||
if stripped == "}":
|
if stripped == "}":
|
||||||
level = max(level - 1, 0)
|
level = max(level - 1, 0)
|
||||||
out_lines.append(f"{indent_str * level}{stripped}")
|
out_lines.append(f"{indent_str * level}{stripped}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# 5) 'elseif' or 'else' alone → align with matching 'if'
|
# 'elseif' or 'else' alone → align with matching 'if'
|
||||||
if re.match(r"^(elseif|else)\b(?!.*\{)", stripped):
|
if re.match(r"^(elseif|else)\b(?!.*\{)", stripped):
|
||||||
level = max(level - 1, 0)
|
level = max(level - 1, 0)
|
||||||
out_lines.append(f"{indent_str * level}{stripped}")
|
out_lines.append(f"{indent_str * level}{stripped}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# 6) Default: print at current indent
|
# Default: print at current indent
|
||||||
out_lines.append(f"{indent_str * level}{stripped}")
|
out_lines.append(f"{indent_str * level}{stripped}")
|
||||||
|
|
||||||
# 7) Open a new block on lines ending with '{'
|
# Open a new block on lines ending with '{'
|
||||||
if re.match(r"^(if|elseif)\b.*\{$", stripped) or stripped.endswith("{"):
|
if re.match(r"^(if|elseif)\b.*\{$", stripped) or stripped.endswith("{"):
|
||||||
level += 1
|
level += 1
|
||||||
|
|
||||||
|
|||||||
@@ -54,9 +54,6 @@ LSP_SERVER = server.LanguageServer(
|
|||||||
name="NX Postprocessor Support", version="0.0.1", max_workers=MAX_WORKERS
|
name="NX Postprocessor Support", version="0.0.1", max_workers=MAX_WORKERS
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
NX_PROC_LIST = []
|
|
||||||
|
|
||||||
# **********************************************************
|
# **********************************************************
|
||||||
# Tool specific code goes below this.
|
# Tool specific code goes below this.
|
||||||
# **********************************************************
|
# **********************************************************
|
||||||
@@ -185,6 +182,7 @@ def _get_global_defaults():
|
|||||||
"args": GLOBAL_SETTINGS.get("args", []),
|
"args": GLOBAL_SETTINGS.get("args", []),
|
||||||
"importStrategy": GLOBAL_SETTINGS.get("importStrategy", "useBundled"),
|
"importStrategy": GLOBAL_SETTINGS.get("importStrategy", "useBundled"),
|
||||||
"showNotifications": GLOBAL_SETTINGS.get("showNotifications", "off"),
|
"showNotifications": GLOBAL_SETTINGS.get("showNotifications", "off"),
|
||||||
|
"formatter": GLOBAL_SETTINGS.get("formatter", False),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user