-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Furkan Duman
authored and
Furkan Duman
committed
Jul 5, 2016
0 parents
commit 7cf3161
Showing
29 changed files
with
3,675 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Copyright (c) Furkan Duman | ||
|
||
All rights reserved. | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files | ||
(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, | ||
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE | ||
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# NodeMCU Development Tools For Visual Studio Code | ||
## Features | ||
|
||
* Intellisense supported for some NodeMCU modules. | ||
* Lua error detection supported. (It can only detect the first error because of luaparse's limitations) | ||
* Uploading lua file to NodeMCU-ESP 8266 device supported. | ||
|
||
## TODO's | ||
|
||
* Improve intellisense support for modules. | ||
* Add signature support. | ||
* Add documentation for modules. | ||
* Support configurable baudrate, etc.. | ||
* Add more NodeMCU commands other than upload. | ||
|
||
## Release Notes | ||
Detailed release notes are available [here](https://github.com/fduman/vscode-nodemcu/releases). | ||
|
||
## Issues | ||
Run into a bug? Report it [here](https://github.com/fduman/vscode-nodemcu/issues). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
out | ||
server | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// A launch configuration that compiles the extension and then opens it inside a new window | ||
{ | ||
"version": "0.1.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch Extension", | ||
"type": "extensionHost", | ||
"request": "launch", | ||
"runtimeExecutable": "${execPath}", | ||
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ], | ||
"stopOnEntry": false, | ||
"sourceMaps": true, | ||
"outDir": "${workspaceRoot}/out/src", | ||
"preLaunchTask": "npm" | ||
}, | ||
{ | ||
"name": "Launch Tests", | ||
"type": "extensionHost", | ||
"request": "launch", | ||
"runtimeExecutable": "${execPath}", | ||
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ], | ||
"stopOnEntry": false, | ||
"sourceMaps": true, | ||
"outDir": "${workspaceRoot}/out/test", | ||
"preLaunchTask": "npm" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Place your settings in this file to overwrite default and user settings. | ||
{ | ||
"files.exclude": { | ||
"out": false // set this to true to hide the "out" folder with the compiled JS files | ||
}, | ||
"search.exclude": { | ||
"out": true // set this to false to include "out" folder in search results | ||
}, | ||
"typescript.tsdk": "./node_modules/typescript/lib" // we want to use the TS server from our node_modules folder to control its version | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Available variables which can be used inside of strings. | ||
// ${workspaceRoot}: the root folder of the team | ||
// ${file}: the current opened file | ||
// ${fileBasename}: the current opened file's basename | ||
// ${fileDirname}: the current opened file's dirname | ||
// ${fileExtname}: the current opened file's extension | ||
// ${cwd}: the current working directory of the spawned process | ||
|
||
// A task runner that calls a custom npm script that compiles the extension. | ||
{ | ||
"version": "0.1.0", | ||
|
||
// we want to run npm | ||
"command": "npm", | ||
|
||
// the command is a shell script | ||
"isShellCommand": true, | ||
|
||
// show the output window only if unrecognized errors occur. | ||
"showOutput": "silent", | ||
|
||
// we run the custom script "compile" as defined in package.json | ||
"args": ["run", "compile", "--loglevel", "silent"], | ||
|
||
// The tsc compiler is started in watching mode | ||
"isWatching": true, | ||
|
||
// use the standard tsc in watch mode problem matcher to find compile problems in the output. | ||
"problemMatcher": "$tsc-watch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.vscode/** | ||
typings/** | ||
out/test/** | ||
test/** | ||
src/** | ||
**/*.map | ||
.gitignore | ||
tsconfig.json | ||
vsc-extension-quickstart.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"name": "vscode-nodemcu", | ||
"description": "Supports NodeMCU upload over serial port, lua error detection and lua optimization", | ||
"author": "Furkan Duman", | ||
"license": "MIT", | ||
"version": "0.0.1", | ||
"publisher": "Furkan Duman", | ||
"engines": { | ||
"vscode": "^0.10.10" | ||
}, | ||
"categories": [ | ||
"Other" | ||
], | ||
"activationEvents": [ | ||
"onLanguage:lua" | ||
], | ||
"main": "./out/src/extension", | ||
"contributes": { | ||
"commands": [ | ||
{ | ||
"command": "nodemcu.upload", | ||
"title": "Upload file to NodeMCU Device" | ||
} | ||
] | ||
}, | ||
"scripts": { | ||
"vscode:prepublish": "node ./node_modules/vscode/bin/compile", | ||
"compile": "node ./node_modules/vscode/bin/compile -watch -p ./", | ||
"postinstall": "node ./node_modules/vscode/bin/install" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^1.8.9", | ||
"vscode": "^0.11.0" | ||
}, | ||
"dependencies": { | ||
"vscode-languageclient": "^2.2.1", | ||
"nodemcu-tool": "1.6.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
'use strict'; | ||
|
||
import * as path from 'path'; | ||
|
||
import { window, commands, workspace, Disposable, ExtensionContext } from 'vscode'; | ||
import { LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, TransportKind } from 'vscode-languageclient'; | ||
import * as nodemanager from "./nodeMcuManager"; | ||
|
||
export function activate(context: ExtensionContext) { | ||
|
||
// The server is implemented in node | ||
let serverModule = context.asAbsolutePath(path.join('server', 'server.js')); | ||
// The debug options for the server | ||
let debugOptions = { execArgv: ["--nolazy", "--debug=6004"] }; | ||
|
||
// If the extension is launched in debug mode then the debug server options are used | ||
// Otherwise the run options are used | ||
let serverOptions: ServerOptions = { | ||
run: { module: serverModule, transport: TransportKind.ipc }, | ||
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions } | ||
} | ||
|
||
// Options to control the language client | ||
let clientOptions: LanguageClientOptions = { | ||
// Register the server for plain text documents | ||
documentSelector: ['lua'], | ||
synchronize: { | ||
// Synchronize the setting section 'languageServerExample' to the server | ||
configurationSection: 'languageServerExample', | ||
// Notify the server about file changes to '.clientrc files contain in the workspace | ||
fileEvents: workspace.createFileSystemWatcher('**/.clientrc') | ||
} | ||
} | ||
|
||
// Create the language client and start the client. | ||
let disposable = new LanguageClient('Language Server Example', serverOptions, clientOptions).start(); | ||
let command = commands.registerCommand('nodemcu.upload', () => { | ||
if (window.activeTextEditor && window.activeTextEditor.document.languageId == "lua") { | ||
nodemanager.findDevice((device) => { | ||
nodemanager.uploadFile(device, window.activeTextEditor.document.fileName); | ||
} | ||
); | ||
} else{ | ||
window.showErrorMessage("There must be an opened lua file"); | ||
} | ||
}); | ||
|
||
// Push the disposable to the context's subscriptions so that the | ||
// client can be deactivated on extension deactivation | ||
context.subscriptions.push(disposable); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import * as nodemcu from "nodemcu-tool"; | ||
import { window } from "vscode"; | ||
import * as path from "path"; | ||
|
||
export function uploadFile(device: string, filename: string) { | ||
let connector = new nodemcu.Connector(device, 9600); | ||
|
||
connector.connect((err, deviceInfo) => { | ||
if (err) { | ||
window.showErrorMessage("NodeMCU connection error: " + err); | ||
} | ||
else { | ||
window.showInformationMessage("NodeMCU device connected: " + deviceInfo); | ||
|
||
connector.upload(filename, path.basename(filename), { optimize: true }, (err, data) => { | ||
if (err) { | ||
window.showErrorMessage("NodeMCU upload error: " + err); | ||
} | ||
else { | ||
window.showInformationMessage("NodeMCU upload has completed"); | ||
} | ||
|
||
connector.disconnect(); | ||
}, (current, total) => { | ||
window.setStatusBarMessage("Upload completed: %" + Math.trunc(current / total * 100)); | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
export function findDevice(cb: any): void { | ||
let connector = new nodemcu.Connector("", 9600); | ||
|
||
connector.deviceInfo(false, (err, devices) => { | ||
if (err) { | ||
window.showErrorMessage('Serial device connection error: ' + err); | ||
} else { | ||
if (devices.length == 0) { | ||
window.showErrorMessage('No Connected Devices found'); | ||
} else if (devices.length > 1) { | ||
window.showErrorMessage("Many devices found. Connect only once"); | ||
} | ||
else { | ||
window.showInformationMessage('Device found at: ' + devices[0].comName); | ||
cb(devices[0].comName); | ||
} | ||
} | ||
}); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// Note: This example test is leveraging the Mocha test framework. | ||
// Please refer to their documentation on https://mochajs.org/ for help. | ||
// | ||
|
||
// The module 'assert' provides assertion methods from node | ||
import * as assert from 'assert'; | ||
|
||
// You can import and use all API from the 'vscode' module | ||
// as well as import your extension to test it | ||
import * as vscode from 'vscode'; | ||
import * as myExtension from '../src/extension'; | ||
|
||
// Defines a Mocha test suite to group tests of similar kind together | ||
suite("Extension Tests", () => { | ||
|
||
// Defines a Mocha unit test | ||
test("Something 1", () => { | ||
assert.equal(-1, [1, 2, 3].indexOf(5)); | ||
assert.equal(-1, [1, 2, 3].indexOf(0)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING | ||
// | ||
// This file is providing the test runner to use when running extension tests. | ||
// By default the test runner in use is Mocha based. | ||
// | ||
// You can provide your own test runner if you want to override it by exporting | ||
// a function run(testRoot: string, clb: (error:Error) => void) that the extension | ||
// host can call to run the tests. The test runner is expected to use console.log | ||
// to report the results back to the caller. When the tests are finished, return | ||
// a possible error to the callback or null if none. | ||
|
||
var testRunner = require('vscode/lib/testrunner'); | ||
|
||
// You can directly control Mocha options by uncommenting the following lines | ||
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info | ||
testRunner.configure({ | ||
ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.) | ||
useColors: true // colored output from test results | ||
}); | ||
|
||
module.exports = testRunner; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES5", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"outDir": "out", | ||
"noLib": true, | ||
"sourceMap": true | ||
}, | ||
"exclude": [ | ||
"node_modules", | ||
"server" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference path="../node_modules/vscode/typings/node.d.ts" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
declare module "nodemcu-tool" { | ||
export class Connector{ | ||
constructor(devicename: string, baudrate: number); | ||
|
||
connect(cb: any) : void; | ||
|
||
onError(cb : any) : void; | ||
|
||
deviceInfo(showAll: boolean, cb : any) : void; | ||
|
||
checkConnection(cb: any) : void; | ||
|
||
fetchDeviceInfo(cb : any) : void; | ||
|
||
upload(localName: string, remoteName: string, options: any, completeCb: any, progressCb: any): void; | ||
|
||
fsinfo(cb: any) : void; | ||
|
||
removeFile(remoteName: string, cb: any) : void; | ||
|
||
format(cb: any) : void; | ||
|
||
compile(remoteName: string, cb: any) : void; | ||
|
||
run(remoteName: string, cb: any) : void; | ||
|
||
executeCommand(cmd: any, cb: any) : void; | ||
|
||
download(remoteName: string, cb: any) : void; | ||
|
||
disconnect() : void; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference path="../node_modules/vscode/typings/index.d.ts" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
out | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"version": "0.1.0", | ||
// List of configurations. Add new configurations or edit existing ones. | ||
"configurations": [ | ||
{ | ||
"name": "Attach", | ||
"type": "node", | ||
"request": "attach", | ||
"port": 6004, | ||
"sourceMaps": true, | ||
"outDir": "${workspaceRoot}/../client/server" | ||
} | ||
] | ||
} |
Oops, something went wrong.