I use file-based JS scripting (conf/automation/js) for many of my rules,
and the openHAB VS Code extension for editing.
One feature I miss there: hovering over an Item name to see its current state.
It works in .rules, .items, .things and .sitemap, but not in a .js file - the
extension only treats files with the “openhab” language id as openHAB content,
and a .js file is plain JavaScript to VS Code.
For me this is the single most useful feature of the extension. While writing a
rule I constantly want to check what an Item is actually called and what it
currently holds, and in JS I have to switch to MainUI or to the Items explorer
in the sidebar for that.
Changing files.associations is not a workaround: it costs all JavaScript
support and fills the file with syntax errors.
My questions:
-
Is there an existing way to get Item hover (or go-to-definition) in JS
scripting files that I have missed? I already usenpm i openhabfor API
completion, which helps for the library but not for my own Items. -
If not, would it be feasible for the extension to also look for Item names
inside .js files under conf/automation/js? A simple word-under-cursor lookup
against the Item registry would already be enough - it does not need to
understand JavaScript syntax. -
Is the VS Code extension still the recommended editing route for file-based
JS scripting, or is there another setup people use?
Setup: openHAB 5.2.0 in Docker, file-based items/things/rules plus JS scripting,
VS Code with the openHAB extension and the language server on port 5007.
Happy to open a feature request on GitHub - openhab/openhab-vscode: VS Code extension for openHAB configuration files · GitHub if that is
the better place - I wanted to ask here first in case this is already solved.