From a185de17031e8122b6fddba6938b5cc1c4a9de02 Mon Sep 17 00:00:00 2001 From: Basile Marchand Date: Wed, 25 Mar 2026 21:21:35 +0100 Subject: [PATCH 1/3] Add language configuration and keybindings for comment functionality --- .husky/pre-commit | 4 +- language-configuration.json | 16 ++++++++ package-lock.json | 81 ------------------------------------- package.json | 7 ++++ 4 files changed, 25 insertions(+), 83 deletions(-) create mode 100644 language-configuration.json diff --git a/.husky/pre-commit b/.husky/pre-commit index 0cd5fd7..f232cc0 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -5,5 +5,5 @@ npx prettier --write "src/**/*.ts" "webviews/viewer/src/**/*.{ts,svelte}" "webvi git add -u npx eslint --max-warnings=0 src/ webviews/export/ npx svelte-check --tsconfig webviews/viewer/tsconfig.json --fail-on-warnings -python3 -m ruff check python/lsp/ python/med2obj.py -python3 -m ruff format --check python/lsp/ python/med2obj.py +# python3 -m ruff check python/lsp/ python/med2obj.py +# python3 -m ruff format --check python/lsp/ python/med2obj.py diff --git a/language-configuration.json b/language-configuration.json new file mode 100644 index 0000000..c5cda9f --- /dev/null +++ b/language-configuration.json @@ -0,0 +1,16 @@ +{ + "comments": { + "lineComment": "#" + }, + "brackets": [ + ["(", ")"], + ["[", "]"], + ["{", "}"] + ], + "autoClosingPairs": [ + { "open": "(", "close": ")" }, + { "open": "[", "close": "]" }, + { "open": "{", "close": "}" }, + { "open": "\"", "close": "\"" } + ] +} diff --git a/package-lock.json b/package-lock.json index 3417108..f67a39c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -901,9 +901,6 @@ "cpu": [ "arm" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -924,9 +921,6 @@ "cpu": [ "arm" ], - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -947,9 +941,6 @@ "cpu": [ "arm64" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -970,9 +961,6 @@ "cpu": [ "arm64" ], - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -993,9 +981,6 @@ "cpu": [ "x64" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1016,9 +1001,6 @@ "cpu": [ "x64" ], - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1184,9 +1166,6 @@ "arm" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1201,9 +1180,6 @@ "arm" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1218,9 +1194,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1235,9 +1208,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1252,9 +1222,6 @@ "loong64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1269,9 +1236,6 @@ "loong64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1286,9 +1250,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1303,9 +1264,6 @@ "ppc64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1320,9 +1278,6 @@ "riscv64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1337,9 +1292,6 @@ "riscv64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1354,9 +1306,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1371,9 +1320,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1388,9 +1334,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1673,9 +1616,6 @@ "cpu": [ "arm64" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1692,9 +1632,6 @@ "cpu": [ "arm64" ], - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1711,9 +1648,6 @@ "cpu": [ "x64" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1730,9 +1664,6 @@ "cpu": [ "x64" ], - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -4282,9 +4213,6 @@ "cpu": [ "arm64" ], - "libc": [ - "glibc" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -4305,9 +4233,6 @@ "cpu": [ "arm64" ], - "libc": [ - "musl" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -4328,9 +4253,6 @@ "cpu": [ "x64" ], - "libc": [ - "glibc" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -4351,9 +4273,6 @@ "cpu": [ "x64" ], - "libc": [ - "musl" - ], "license": "MPL-2.0", "optional": true, "os": [ diff --git a/package.json b/package.json index d4f1f75..cbd26a5 100644 --- a/package.json +++ b/package.json @@ -91,6 +91,13 @@ "path": "./syntaxes/comm.tmLanguage.json" } ], + "keybindings": [ + { + "command": "editor.action.commentLine", + "key": "ctrl+shift+;", + "when": "editorTextFocus && editorLangId == comm" + } + ], "menus": { "editor/title": [ { From 23d7a713c05410ee19bc436bef0289ac2ea7922b Mon Sep 17 00:00:00 2001 From: Basile Marchand Date: Wed, 25 Mar 2026 22:02:35 +0100 Subject: [PATCH 2/3] Add possibility to attach to code_aster embeded python for windows install --- python/med2obj.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/python/med2obj.py b/python/med2obj.py index 264d459..ade6053 100644 --- a/python/med2obj.py +++ b/python/med2obj.py @@ -7,6 +7,46 @@ import argparse import pathlib as pl +import os +import sys + +python_version = sys.version_info + +if sys.platform == "win32" and python_version >= (3, 8): + # On Windows, we need to ensure that the DLLs are found, from Python 3.8 we need to + # use os.add_dll_directory to add the directory containing the DLLs. + # Add the directory of the current script to the DLL search path + # This is necessary for Python 3.8+ on Windows to find the DLLs. + # To simplify we use the LD_LIBRARY_PATH environment variable like on Unix systems. + #ld_library_path = os.getenv("LD_LIBRARY_PATH", "") + + + appdata = os.environ["LOCALAPPDATA"] + + if (pl.Path(appdata)/"code_aster").exists(): + ### Attach to code_aster windows install + python_path = fr"{appdata}\code_aster\external\medcoupling-9.11.0\lib\python3.10\site-packages" + sys.path.append(python_path) + + + ld_library_path = [ + fr"{appdata}\code_aster\Python3.10", + fr"{appdata}\code_aster\external\hdf51.10.5\bin", + fr"{appdata}\code_aster\external\hdf51.10.5\lib", + fr"{appdata}\code_aster\external\MED-4.4.1\lib", + fr"{appdata}\code_aster\external\medcoupling-9.11.0\lib", + fr"{appdata}\code_aster\external\medcoupling-9.11.0\libpython3.10\site-packages", + fr"{appdata}\code_aster\external", + ] + + if ld_library_path: + # Split the LD_LIBRARY_PATH and add each directory + for path in ld_library_path: + print("Adding directory:", path) + if os.path.isdir(path): + print(os.add_dll_directory(os.path.abspath(path))) + sys.path.append(path) + import medcoupling as mc From 8f61eddb270b595709714ca0de7436c299b76c4e Mon Sep 17 00:00:00 2001 From: Basile Marchand Date: Wed, 25 Mar 2026 22:16:50 +0100 Subject: [PATCH 3/3] Restore precommit and fix ruff error --- .husky/pre-commit | 4 ++-- python/med2obj.py | 29 ++++++++++++++--------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index f232cc0..0cd5fd7 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -5,5 +5,5 @@ npx prettier --write "src/**/*.ts" "webviews/viewer/src/**/*.{ts,svelte}" "webvi git add -u npx eslint --max-warnings=0 src/ webviews/export/ npx svelte-check --tsconfig webviews/viewer/tsconfig.json --fail-on-warnings -# python3 -m ruff check python/lsp/ python/med2obj.py -# python3 -m ruff format --check python/lsp/ python/med2obj.py +python3 -m ruff check python/lsp/ python/med2obj.py +python3 -m ruff format --check python/lsp/ python/med2obj.py diff --git a/python/med2obj.py b/python/med2obj.py index ade6053..9996568 100644 --- a/python/med2obj.py +++ b/python/med2obj.py @@ -5,9 +5,8 @@ import argparse -import pathlib as pl - import os +import pathlib as pl import sys python_version = sys.version_info @@ -18,25 +17,25 @@ # Add the directory of the current script to the DLL search path # This is necessary for Python 3.8+ on Windows to find the DLLs. # To simplify we use the LD_LIBRARY_PATH environment variable like on Unix systems. - #ld_library_path = os.getenv("LD_LIBRARY_PATH", "") - + # ld_library_path = os.getenv("LD_LIBRARY_PATH", "") appdata = os.environ["LOCALAPPDATA"] - if (pl.Path(appdata)/"code_aster").exists(): + if (pl.Path(appdata) / "code_aster").exists(): ### Attach to code_aster windows install - python_path = fr"{appdata}\code_aster\external\medcoupling-9.11.0\lib\python3.10\site-packages" + python_path = ( + rf"{appdata}\code_aster\external\medcoupling-9.11.0\lib\python3.10\site-packages" + ) sys.path.append(python_path) - ld_library_path = [ - fr"{appdata}\code_aster\Python3.10", - fr"{appdata}\code_aster\external\hdf51.10.5\bin", - fr"{appdata}\code_aster\external\hdf51.10.5\lib", - fr"{appdata}\code_aster\external\MED-4.4.1\lib", - fr"{appdata}\code_aster\external\medcoupling-9.11.0\lib", - fr"{appdata}\code_aster\external\medcoupling-9.11.0\libpython3.10\site-packages", - fr"{appdata}\code_aster\external", + rf"{appdata}\code_aster\Python3.10", + rf"{appdata}\code_aster\external\hdf51.10.5\bin", + rf"{appdata}\code_aster\external\hdf51.10.5\lib", + rf"{appdata}\code_aster\external\MED-4.4.1\lib", + rf"{appdata}\code_aster\external\medcoupling-9.11.0\lib", + rf"{appdata}\code_aster\external\medcoupling-9.11.0\libpython3.10\site-packages", + rf"{appdata}\code_aster\external", ] if ld_library_path: @@ -47,7 +46,7 @@ print(os.add_dll_directory(os.path.abspath(path))) sys.path.append(path) -import medcoupling as mc +import medcoupling as mc # noqa E402 def parse_args():