diff --git a/CHANGELOG.md b/CHANGELOG.md index 52dd74f..c0aad54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,37 +1,47 @@ -# openHAB VS Code Extension Change Log - -## 0.2.1 - 2017-11-02 -- Language Server Protocol with a custom port parameter (#42) -- Fixed "switch" icon coloring (#18) -- "Set openHAB host" button on error message (#42) -- Insert into Sitemap feature -- **Breaking change**: `openhab.port` parameter is now a number (e.g. `8080` instead of `"8080"`). -Please change it in your settings after upgrade. - -## 0.2.0 - 2017-10-17 -- Language Server Protocol support -- You can now disable REST API connection -- Updated logo icons -- Better error handling -- Fixed REST connection with Basic Authentication -- Paper UI URL is now dynamically detected -- More new snippets - -## 0.1.0 - 2017-07-07 -- Completely new openHAB Items Explorer view in the sidebar! - - Preview **all** of your items thanks to the REST API - - Dynamic rules from the Items Explorer view - including the current state - - Ability to copy Item's name and state - - Clicking non-Group item opens it in the Paper UI by default - - Note: Currently in VS Code stable Items Explorer is permanently visible. VS Code Insiders allows you to hide the tree view thanks to [vscode#29436](https://github.com/Microsoft/vscode/issues/29436) -- Added Items autocompletion (with IntelliSense documentation) (#7) -- Quick search in the Community Forum -- Added icon theme - -## 0.0.2 - 2017-06-21 -- openHAB hostname and port are now configurable through user or workspace settings (#14) -- Added "openhab.searchCommunity" action allowing to search selected text in the openHAB Community (#13) -- Minor tweaks in the code and documentation (#6 #13) - -## 0.0.1 - 2017-06-19 +# openHAB VS Code Extension Change Log + +## 0.3.0 - 2017-11-15 +- Introduced openHAB **Things Explorer** view in the sidebar! + - Create Items directly from Thing's channels. + - Quick copy name and Thing UID directly from the sidebar + - Quick access to the binding documentation +- Insert into Sitemap feature in the openHAB Items view +- Various Language Server Protocol fixes +- New configuration parameters: + - `restCompletions` - toggles completions from REST API + - `paperPath` - defaults to `paperui`. Change it to `ui` if you're using from before 9th Jan 2017 + - `paperInBrowser` - if set to `true`, will open Paper UI in a browser instead of VSCode window + - `lspEnabled` - if `true`, will enable communication with openHAB's Language Server. Note that `misc-lsp` add-on needs to be installed. + - `lspPort` - defaults to `5007`, custom LSP port parameter (#42) +- Fixed "switch" icon coloring (#18) +- "Set openHAB host" button on error message (#42) +- **Breaking change**: `openhab.port` parameter is now a number (e.g. `8080` instead of `"8080"`). +Please change it in your settings after upgrade. + +## 0.2.0 - 2017-10-17 +- Language Server Protocol support +- You can now disable REST API connection +- Updated logo icons +- Better error handling +- Fixed REST connection with Basic Authentication +- Paper UI URL is now dynamically detected +- More new snippets + +## 0.1.0 - 2017-07-07 +- Completely new openHAB Items Explorer view in the sidebar! + - Preview **all** of your items thanks to the REST API + - Dynamic rules from the Items Explorer view - including the current state + - Ability to copy Item's name and state + - Clicking non-Group item opens it in the Paper UI by default + - Note: Currently in VS Code stable Items Explorer is permanently visible. VS Code Insiders allows you to hide the tree view thanks to [vscode#29436](https://github.com/Microsoft/vscode/issues/29436) +- Added Items autocompletion (with IntelliSense documentation) (#7) +- Quick search in the Community Forum +- Added icon theme + +## 0.0.2 - 2017-06-21 +- openHAB hostname and port are now configurable through user or workspace settings (#14) +- Added "openhab.searchCommunity" action allowing to search selected text in the openHAB Community (#13) +- Minor tweaks in the code and documentation (#6 #13) + +## 0.0.1 - 2017-06-19 - Initial release \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a4a4637..a96ecb4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "openhab", - "version": "0.2.1", + "version": "0.3.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 0ad651f..9da2ffa 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "openhab", "displayName": "openHAB", - "description": "openHAB syntax highlight, code snippets, integrated Basic UI preview and docs search", - "version": "0.2.1", + "description": "Robust tool for openHAB textual configurations. Includes code snippets, syntax highlighting, language server integration and more.", + "version": "0.3.0", "publisher": "openhab", "icon": "openhab.png", "repository": { @@ -208,7 +208,7 @@ "default": true, "description": "Enables communication with Language Server Protocol - installed in openHAB as 'misc-lsp' add-on" }, - "openhab.lspCompletions": { + "openhab.restCompletions": { "type": [ "boolean" ], diff --git a/src/extension.ts b/src/extension.ts index 7efafe4..175a6fe 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,161 +1,161 @@ -'use strict'; - -import { - commands, - CompletionItem, - Disposable, - ExtensionContext, - languages, - TextDocumentChangeEvent, - Uri, - ViewColumn, - window, - workspace -} from 'vscode' - -import { - SCHEME, - OpenHABContentProvider -} from './ContentProvider/openHAB' - -import { - getHost, - isOpenHABWorkspace, - hasExtension, - getBuildVersion, - openBrowser, - openHtml, - openUI, - pathExists -} from './Utils' - -import { ItemsExplorer } from './ItemsExplorer/ItemsExplorer' -import { ThingsExplorer } from './ThingsExplorer/ThingsExplorer' -import { ItemsProvider } from './ThingsExplorer/ItemsProvider' -import { ItemsCompletion } from './ItemsExplorer/ItemsCompletion' -import { RuleProvider } from './ItemsExplorer/RuleProvider' -import { SitemapPartialProvider } from './ItemsExplorer/SitemapPartialProvider' -import { LanguageClientProvider } from './LanguageClient/LanguageClientProvider' -import { Item } from './ItemsExplorer/Item' -import { Thing } from './ThingsExplorer/Thing' -import { Channel } from './ThingsExplorer/Channel' - -import * as _ from 'lodash' -import * as ncp from 'copy-paste' -import * as path from 'path' - -async function init(context: ExtensionContext, disposables: Disposable[]): Promise { - let ui = new OpenHABContentProvider() - let registration = workspace.registerTextDocumentContentProvider(SCHEME, ui) - let config = workspace.getConfiguration('openhab') - const itemsExplorer = new ItemsExplorer(getHost()) - const thingsExplorer = new ThingsExplorer(getHost()) - const itemsCompletion = new ItemsCompletion(getHost()) - - disposables.push(commands.registerCommand('openhab.basicUI', () => { - let editor = window.activeTextEditor - if (!editor) { - window.showInformationMessage('No editor is active') - return - } - - let absolutePath = editor.document.fileName - let fileName = path.basename(absolutePath) - - if (fileName.split('.')[1] === 'sitemap') { - let sitemap = fileName.split('.')[0] - return openUI({ - route: `/basicui/app?sitemap=${sitemap}`, - }, `${sitemap} - Basic UI`) - } - - return openUI() - })) - - disposables.push(commands.registerCommand('openhab.searchDocs', () => openBrowser())) - - disposables.push(commands.registerCommand('openhab.searchCommunity', (phrase?) => { - let query: string = phrase || '%s' - openBrowser(`https://community.openhab.org/search?q=${query}`) - })) - - disposables.push(commands.registerCommand('openhab.command.showInPaperUI', (query?) => { - let param: string = query.name ? query.name : query - let title = `${param} - Paper UI` - let config = workspace.getConfiguration('openhab') - let paperPath = config.paperPath - let route = `/${paperPath}/index.html%23/configuration/` - - if (query.UID) { - title = `${query.label} - Paper UI` - route += `things/view/${query.UID}` - } else { - route += `item/edit/${param}` - } - - let options = { - route: route - } - - return config.paperInBrowser ? openBrowser(route.replace(/%23/g, '#')) : openUI(options, title) - })) - - if (isOpenHABWorkspace()) { - disposables.push(window.registerTreeDataProvider('openhabItems', itemsExplorer)) - disposables.push(window.registerTreeDataProvider('openhabThings', thingsExplorer)) - disposables.push(languages.registerCompletionItemProvider('openhab', itemsCompletion)) - - if (config.lspEnabled) { - let languageClientProvider = new LanguageClientProvider() - disposables.push(languageClientProvider.connect()) - } - - if (!config.lspCompletions) { - disposables.push(languages.registerCompletionItemProvider('openhab', new ItemsCompletion(getHost()))) - } - } - - disposables.push(commands.registerCommand('openhab.command.refreshEntry', (query) => { - itemsExplorer.refresh() - thingsExplorer.refresh() - })) - - disposables.push(commands.registerCommand('openhab.command.copyName', (query) => - ncp.copy(query.name || query.label))) - - disposables.push(commands.registerCommand('openhab.command.items.copyState', (query: Item) => - ncp.copy(query.state))) - - disposables.push(commands.registerCommand('openhab.command.items.addRule', (query: Item) => { - let ruleProvider = new RuleProvider(query) - ruleProvider.addRule() - })) - - disposables.push(commands.registerCommand('openhab.command.items.addToSitemap', (query: Item) => { - let sitemapProvider = new SitemapPartialProvider(query) - sitemapProvider.addToSitemap() - })) - - disposables.push(commands.registerCommand('openhab.command.things.docs', (query: Thing) => - openBrowser(`http://docs.openhab.org/addons/bindings/${query.binding}/readme.html`))) - - disposables.push(commands.registerCommand('openhab.command.things.addItems', (query: Thing | Channel) => { - let itemsProvider = new ItemsProvider(query) - itemsProvider.addToItems() - })) - - disposables.push(commands.registerCommand('openhab.command.things.copyUID', (query) => - ncp.copy(query.UID || query.uid))) - -} -export function activate(context: ExtensionContext) { - const disposables: Disposable[] = []; - context.subscriptions.push(new Disposable(() => Disposable.from(...disposables).dispose())) - - init(context, disposables) - .catch(err => console.error(err)); -} - -// this method is called when your extension is deactivated -export function deactivate() { +'use strict'; + +import { + commands, + CompletionItem, + Disposable, + ExtensionContext, + languages, + TextDocumentChangeEvent, + Uri, + ViewColumn, + window, + workspace +} from 'vscode' + +import { + SCHEME, + OpenHABContentProvider +} from './ContentProvider/openHAB' + +import { + getHost, + isOpenHABWorkspace, + hasExtension, + getBuildVersion, + openBrowser, + openHtml, + openUI, + pathExists +} from './Utils' + +import { ItemsExplorer } from './ItemsExplorer/ItemsExplorer' +import { ThingsExplorer } from './ThingsExplorer/ThingsExplorer' +import { ItemsProvider } from './ThingsExplorer/ItemsProvider' +import { ItemsCompletion } from './ItemsExplorer/ItemsCompletion' +import { RuleProvider } from './ItemsExplorer/RuleProvider' +import { SitemapPartialProvider } from './ItemsExplorer/SitemapPartialProvider' +import { LanguageClientProvider } from './LanguageClient/LanguageClientProvider' +import { Item } from './ItemsExplorer/Item' +import { Thing } from './ThingsExplorer/Thing' +import { Channel } from './ThingsExplorer/Channel' + +import * as _ from 'lodash' +import * as ncp from 'copy-paste' +import * as path from 'path' + +async function init(context: ExtensionContext, disposables: Disposable[]): Promise { + let ui = new OpenHABContentProvider() + let registration = workspace.registerTextDocumentContentProvider(SCHEME, ui) + let config = workspace.getConfiguration('openhab') + const itemsExplorer = new ItemsExplorer(getHost()) + const thingsExplorer = new ThingsExplorer(getHost()) + const itemsCompletion = new ItemsCompletion(getHost()) + + disposables.push(commands.registerCommand('openhab.basicUI', () => { + let editor = window.activeTextEditor + if (!editor) { + window.showInformationMessage('No editor is active') + return + } + + let absolutePath = editor.document.fileName + let fileName = path.basename(absolutePath) + + if (fileName.split('.')[1] === 'sitemap') { + let sitemap = fileName.split('.')[0] + return openUI({ + route: `/basicui/app?sitemap=${sitemap}`, + }, `${sitemap} - Basic UI`) + } + + return openUI() + })) + + disposables.push(commands.registerCommand('openhab.searchDocs', () => openBrowser())) + + disposables.push(commands.registerCommand('openhab.searchCommunity', (phrase?) => { + let query: string = phrase || '%s' + openBrowser(`https://community.openhab.org/search?q=${query}`) + })) + + disposables.push(commands.registerCommand('openhab.command.showInPaperUI', (query?) => { + let param: string = query.name ? query.name : query + let title = `${param} - Paper UI` + let config = workspace.getConfiguration('openhab') + let paperPath = config.paperPath + let route = `/${paperPath}/index.html%23/configuration/` + + if (query.UID) { + title = `${query.label} - Paper UI` + route += `things/view/${query.UID}` + } else { + route += `item/edit/${param}` + } + + let options = { + route: route + } + + return config.paperInBrowser ? openBrowser(route.replace(/%23/g, '#')) : openUI(options, title) + })) + + if (isOpenHABWorkspace()) { + disposables.push(window.registerTreeDataProvider('openhabItems', itemsExplorer)) + disposables.push(window.registerTreeDataProvider('openhabThings', thingsExplorer)) + disposables.push(languages.registerCompletionItemProvider('openhab', itemsCompletion)) + + if (config.lspEnabled) { + let languageClientProvider = new LanguageClientProvider() + disposables.push(languageClientProvider.connect()) + } + + if (config.restCompletions) { + disposables.push(languages.registerCompletionItemProvider('openhab', new ItemsCompletion(getHost()))) + } + } + + disposables.push(commands.registerCommand('openhab.command.refreshEntry', (query) => { + itemsExplorer.refresh() + thingsExplorer.refresh() + })) + + disposables.push(commands.registerCommand('openhab.command.copyName', (query) => + ncp.copy(query.name || query.label))) + + disposables.push(commands.registerCommand('openhab.command.items.copyState', (query: Item) => + ncp.copy(query.state))) + + disposables.push(commands.registerCommand('openhab.command.items.addRule', (query: Item) => { + let ruleProvider = new RuleProvider(query) + ruleProvider.addRule() + })) + + disposables.push(commands.registerCommand('openhab.command.items.addToSitemap', (query: Item) => { + let sitemapProvider = new SitemapPartialProvider(query) + sitemapProvider.addToSitemap() + })) + + disposables.push(commands.registerCommand('openhab.command.things.docs', (query: Thing) => + openBrowser(`http://docs.openhab.org/addons/bindings/${query.binding}/readme.html`))) + + disposables.push(commands.registerCommand('openhab.command.things.addItems', (query: Thing | Channel) => { + let itemsProvider = new ItemsProvider(query) + itemsProvider.addToItems() + })) + + disposables.push(commands.registerCommand('openhab.command.things.copyUID', (query) => + ncp.copy(query.UID || query.uid))) + +} +export function activate(context: ExtensionContext) { + const disposables: Disposable[] = []; + context.subscriptions.push(new Disposable(() => Disposable.from(...disposables).dispose())) + + init(context, disposables) + .catch(err => console.error(err)); +} + +// this method is called when your extension is deactivated +export function deactivate() { } \ No newline at end of file