Compare commits

..
10 Commits
Author SHA1 Message Date
Christoph 896e9f6c1f Merge pull request 'tcl_language_support' (#15) from tcl_language_support into main
/ build_and_publish (push) Successful in 39s
Reviewed-on: #15
2025-07-21 07:13:14 +00:00
Christoph Brandau 52a2b2f774 fix formatter 2025-07-21 09:12:36 +02:00
Christoph Brandau ee5240c861 add formatter settings 2025-07-21 09:08:53 +02:00
Christoph 61fb0bc5d2 Update version to 0.4.6 2025-07-21 05:39:02 +00:00
Christoph 95ddae6d13 Merge pull request 'fix buffer @ in formatter' (#14) from tcl_language_support into main
/ build_and_publish (push) Successful in 45s
Reviewed-on: #14
2025-07-21 05:38:09 +00:00
Christoph Brandau a6f616a89d fix buffer @ in formatter 2025-07-21 07:37:31 +02:00
Christoph 632fc32c3e Update version to 0.4.5 2025-07-21 05:16:43 +00:00
Christoph 9c5b76510d Merge pull request 'fix formatter for buffers' (#13) from tcl_language_support into main
/ build_and_publish (push) Successful in 27s
Reviewed-on: #13
2025-07-21 05:15:49 +00:00
Christoph Brandau 1b6b25c137 fix formatter for buffers 2025-07-21 07:15:27 +02:00
Christoph e84a08e22b Update version to 0.4.4 2025-07-21 04:53:41 +00:00
4 changed files with 28 additions and 17 deletions
+6 -3
View File
@@ -78,7 +78,8 @@ export async function getWorkspaceSettings(
path: resolveVariables(config.get<string[]>(`path`) ?? [], workspace),
interpreter: resolveVariables(interpreter, workspace),
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
}
@@ -109,7 +110,8 @@ export async function getGlobalSettings(
path: getGlobalValue<string[]>(config, "path", []),
interpreter: interpreter,
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
}
@@ -123,7 +125,8 @@ export function checkIfConfigurationChanged(
`${namespace}.path`,
`${namespace}.interpreter`,
`${namespace}.importStrategy`,
`${namespace}.showNotifications`
`${namespace}.showNotifications`,
`${namespace}.formatter`
]
const changed = settings.map((s) => e.affectsConfiguration(s))
return changed.includes(true)
+7 -2
View File
@@ -2,7 +2,7 @@
"name": "nx-post-support",
"displayName": "NX Postprocessor Support",
"description": "",
"version": "0.4.3",
"version": "0.4.6",
"publisher": "Christoph",
"serverInfo": {
"name": "NX Postprocessor Support",
@@ -79,6 +79,11 @@
],
"configuration": {
"properties": {
"nx-post-support.formatter": {
"type": "boolean",
"default": false,
"description": "Use the TCL formatter from `NX Postprocessor Support`"
},
"nx-post-support.importStrategy": {
"default": "useBundled",
"description": "Defines where `NX Postprocessor Support` is imported from.",
@@ -118,4 +123,4 @@
"prettier": "^3.4.2",
"typescript": "^5.7.2"
}
}
}
+14 -9
View File
@@ -15,43 +15,48 @@ def format_tcl(src: str, indent_str=" ") -> str:
for raw_line in src.splitlines():
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):
out_lines.append(indent_str * level + stripped)
continue
# 2) Combined '} else {' → dedent, print, then indent
# Combined '} else {' → dedent, print, then indent
if re.match(r"^\}\s*(elseif|else)\b.*\{$", stripped):
level = max(level - 1, 0)
out_lines.append(indent_str * level + stripped)
level += 1
continue
# 3) SPECIAL: closing brace plus tag on same line: '} Tag'
m = re.match(r"^\}\s+\w+.*", stripped)
if m:
# SPECIAL: closing brace plus tag on same line: '} Tag'
m = re.match(r"^\}\s+(.+)", stripped)
if m and not stripped.startswith("#"):
# close one block
level = max(level - 1, 0)
# stay on one line: "} Tag"
out_lines.append(f"{indent_str * level}}} {m.group(1)}")
continue
# 4) Pure '}' → dedent then print
# Pure '}' → dedent then print
if stripped == "}":
level = max(level - 1, 0)
out_lines.append(f"{indent_str * level}{stripped}")
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):
level = max(level - 1, 0)
out_lines.append(f"{indent_str * level}{stripped}")
continue
# 6) Default: print at current indent
# Default: print at current indent
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("{"):
level += 1
+1 -3
View File
@@ -54,9 +54,6 @@ LSP_SERVER = server.LanguageServer(
name="NX Postprocessor Support", version="0.0.1", max_workers=MAX_WORKERS
)
NX_PROC_LIST = []
# **********************************************************
# Tool specific code goes below this.
# **********************************************************
@@ -185,6 +182,7 @@ def _get_global_defaults():
"args": GLOBAL_SETTINGS.get("args", []),
"importStrategy": GLOBAL_SETTINGS.get("importStrategy", "useBundled"),
"showNotifications": GLOBAL_SETTINGS.get("showNotifications", "off"),
"formatter": GLOBAL_SETTINGS.get("formatter", False),
}