Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: WebFreak001 <janju007@web.de>
  • Loading branch information
WebFreak001 committed Nov 27, 2015
0 parents commit dfc36a1
Show file tree
Hide file tree
Showing 18 changed files with 1,270 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
out
node_modules
28 changes: 28 additions & 0 deletions .vscode/launch.json
@@ -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": "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": "out/test",
"preLaunchTask": "npm"
}
]
}
10 changes: 10 additions & 0 deletions .vscode/settings.json
@@ -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
}
30 changes: 30 additions & 0 deletions .vscode/tasks.json
@@ -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"
}
9 changes: 9 additions & 0 deletions .vscodeignore
@@ -0,0 +1,9 @@
.vscode/**
typings/**
out/test/**
test/**
src/**
**/*.map
.gitignore
tsconfig.json
vsc-extension-quickstart.md
21 changes: 21 additions & 0 deletions LICENSE.md
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Jan Jurzitza

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.
14 changes: 14 additions & 0 deletions README.md
@@ -0,0 +1,14 @@
# Code-D

Adds D language support for vscode

Also [available for Atom](https://github.com/Vild/atomize-d)!

## License

MIT - Look in [LICENSE.md](LICENSE.md) for more information

## Authors

* Dan "Wild" Printzell
* "WebFreak001"
70 changes: 70 additions & 0 deletions package.json
@@ -0,0 +1,70 @@
{
"name": "code-d",
"description": "D support for vscode",
"version": "0.0.1",
"publisher": "WebFreak",
"engines": {
"vscode": "^0.10.1"
},
"categories": [
"Other"
],
"activationEvents": [
"onLanguage:d"
],
"main": "./out/src/extension",
"contributes": {
"languages": [
{
"id": "d",
"extensions": [
".d",
".di"
]
}
],
"grammars": [
{
"language": "d",
"scopeName": "source.d",
"path": "./syntaxes/d.json"
}
],
"snippets": [
{
"language": "d",
"path": "./snippets/d.json"
}
],
"commands": [
{
"command": "extension.sayHello",
"title": "Hello World"
}
],
"configuration": {
"title": "D configuration",
"type": "object",
"properties": {
"d.dcdClientPath": {
"type": "string",
"default": "dcd-client",
"description": "Path of dcd-client executable. Path can be omitted if in $PATH"
},
"d.dcdServerPath": {
"type": "string",
"default": "dcd-server",
"description": "Path of dcd-server executable. Path can be omitted if in $PATH"
}
}
}
},
"scripts": {
"vscode:prepublish": "node ./node_modules/vscode/bin/compile",
"compile": "node ./node_modules/vscode/bin/compile -watch -p ./"
},
"devDependencies": {
"typescript": "^1.6.2",
"vscode": "0.10.x"
}
}
65 changes: 65 additions & 0 deletions src/dcd-comletion.ts
@@ -0,0 +1,65 @@
"use strict";

import * as vscode from "vscode";
import * as ChildProcess from "child_process"

var currentPort = 9166;

export class DCDCompletionProvider implements vscode.CompletionItemProvider {
private port: number;
private projectRoot: string;
private dcdClientPath: string;

provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): Thenable<vscode.CompletionItem[]> {
let self = this;
return new Promise((resolve, reject) => {
let offset = document.offsetAt(position);
let dcdClient = ChildProcess.spawn(self.dcdClientPath, ["-p", "" + self.port, "-c", "" + offset], {
cwd: self.projectRoot
});
dcdClient.stdin.end(document.getText());

var data = "";

dcdClient.stdout.on("data", (out) => {
data += out.toString("utf8");
});

dcdClient.stderr.on("data", (data) => {
if (data.indexOf("Unable to connect socket: Connection refused") != -1 ||
data.indexOf("Server closed the connection") != -1)
self.start();
else
reject(data);
});
});
}

constructor() {
this.dcdClientPath = vscode.workspace.getConfiguration("d")["dcdClientPath"];
}

start() {
this.port = currentPort;
currentPort++;

let checkDCD = ChildProcess.spawn(this.dcdClientPath, ["-q", "-p", "" + this.port]);

let self = this;

checkDCD.stdout.on("data", (data) => {});
checkDCD.on("exit", (code) => {
if(code == 1)
self.startServer();
});
}

startServer() {
let self = this;

}

dispose() {
ChildProcess.spawn(this.dcdClientPath, ["--shutdown", "-p", "" + this.port]);
}
}
3 changes: 3 additions & 0 deletions src/dmode.ts
@@ -0,0 +1,3 @@
import vscode = require("vscode");

export const D_MODE: vscode.DocumentFilter = { language: "d", scheme: "file" }
14 changes: 14 additions & 0 deletions src/extension.ts
@@ -0,0 +1,14 @@
import * as vscode from 'vscode';
import { D_MODE } from "./dmode"
import { WorkspaceD } from "./workspace-d"

export function activate(context: vscode.ExtensionContext) {
if (!vscode.workspace.rootPath) {
console.warn("Could not initialize code-d");
return;
}
let subs = context.subscriptions;
let workspaced = new WorkspaceD(vscode.workspace.rootPath);
subs.push(vscode.languages.registerCompletionItemProvider(D_MODE, workspaced));
console.log("Initialized code-d");
}

0 comments on commit dfc36a1

Please sign in to comment.