add lsp config
This commit is contained in:
parent
6bb41b8923
commit
4941b36a1e
10 changed files with 2083 additions and 74 deletions
|
@ -22,10 +22,10 @@
|
||||||
"flutter",
|
"flutter",
|
||||||
"fuchsia"
|
"fuchsia"
|
||||||
],
|
],
|
||||||
"_activationEvents": [
|
"activationEvents": [
|
||||||
"onCommand:extension.sayHello"
|
"onLanguage:jael"
|
||||||
],
|
],
|
||||||
"_main": "./out/extension",
|
"main": "./out/extension",
|
||||||
"contributes": {
|
"contributes": {
|
||||||
"_commands": [
|
"_commands": [
|
||||||
{
|
{
|
||||||
|
@ -67,9 +67,12 @@
|
||||||
"test": "npm run compile && node ./node_modules/vscode/bin/test"
|
"test": "npm run compile && node ./node_modules/vscode/bin/test"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^2.6.1",
|
"@types/mocha": "^2.2.42",
|
||||||
"vscode": "^1.1.6",
|
|
||||||
"@types/node": "^7.0.43",
|
"@types/node": "^7.0.43",
|
||||||
"@types/mocha": "^2.2.42"
|
"typescript": "^2.6.1",
|
||||||
|
"vscode": "^1.1.6"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"vscode-languageclient": "^5.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,40 @@
|
||||||
'use strict';
|
"use strict";
|
||||||
// The module 'vscode' contains the VS Code extensibility API
|
|
||||||
// Import the module and reference it with the alias vscode in your code below
|
import * as vscode from "vscode";
|
||||||
import * as vscode from 'vscode';
|
import { workspace } from "vscode";
|
||||||
|
import {
|
||||||
|
LanguageClient,
|
||||||
|
LanguageClientOptions,
|
||||||
|
ServerOptions,
|
||||||
|
TransportKind,
|
||||||
|
Executable
|
||||||
|
} from "vscode-languageclient";
|
||||||
|
|
||||||
// this method is called when your extension is activated
|
|
||||||
// your extension is activated the very first time the command is executed
|
|
||||||
export function activate(context: vscode.ExtensionContext) {
|
export function activate(context: vscode.ExtensionContext) {
|
||||||
|
const runOpts: Executable = {
|
||||||
|
command: "pub",
|
||||||
|
args: ["global", "run", "jael_language_server"]
|
||||||
|
};
|
||||||
|
const serverOptions: ServerOptions = {
|
||||||
|
run: runOpts,
|
||||||
|
debug: runOpts,
|
||||||
|
transport: TransportKind.stdio
|
||||||
|
};
|
||||||
|
const clientOptions: LanguageClientOptions = {
|
||||||
|
documentSelector: [
|
||||||
|
{
|
||||||
|
scheme: "file",
|
||||||
|
language: "jael"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
synchronize: {
|
||||||
|
configurationSection: "jael",
|
||||||
|
fileEvents: workspace.createFileSystemWatcher("**/.jael")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Use the console to output diagnostic information (console.log) and errors (console.error)
|
const lsp = new LanguageClient("jael", "Jael", serverOptions, clientOptions);
|
||||||
// This line of code will only be executed once when your extension is activated
|
context.subscriptions.push(lsp.start());
|
||||||
console.log('Congratulations, your extension "angel-dart-vscode" is now active!');
|
|
||||||
|
|
||||||
// The command has been defined in the package.json file
|
|
||||||
// Now provide the implementation of the command with registerCommand
|
|
||||||
// The commandId parameter must match the command field in package.json
|
|
||||||
let disposable = vscode.commands.registerCommand('extension.sayHello', () => {
|
|
||||||
// The code you place here will be executed every time your command is executed
|
|
||||||
|
|
||||||
// Display a message box to the user
|
|
||||||
vscode.window.showInformationMessage('Hello World!');
|
|
||||||
});
|
|
||||||
|
|
||||||
context.subscriptions.push(disposable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this method is called when your extension is deactivated
|
export function deactivate() {}
|
||||||
export function deactivate() {
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
//
|
|
||||||
// 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 '../extension';
|
|
||||||
|
|
||||||
// Defines a Mocha test suite to group tests of similar kind together
|
|
||||||
suite("Extension Tests", function () {
|
|
||||||
|
|
||||||
// Defines a Mocha unit test
|
|
||||||
test("Something 1", function() {
|
|
||||||
assert.equal(-1, [1, 2, 3].indexOf(5));
|
|
||||||
assert.equal(-1, [1, 2, 3].indexOf(0));
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,22 +0,0 @@
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
|
|
||||||
import * as testRunner from '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;
|
|
1826
angel_vscode/yarn.lock
Normal file
1826
angel_vscode/yarn.lock
Normal file
File diff suppressed because it is too large
Load diff
21
jael_language_server/.gitignore
vendored
Normal file
21
jael_language_server/.gitignore
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# See https://www.dartlang.org/guides/libraries/private-files
|
||||||
|
|
||||||
|
# Files and directories created by pub
|
||||||
|
.dart_tool/
|
||||||
|
.packages
|
||||||
|
build/
|
||||||
|
# If you're building an application, you may want to check-in your pubspec.lock
|
||||||
|
pubspec.lock
|
||||||
|
|
||||||
|
# Directory created by dartdoc
|
||||||
|
# If you don't generate documentation locally you can remove this line.
|
||||||
|
doc/api/
|
||||||
|
|
||||||
|
# Avoid committing generated Javascript files:
|
||||||
|
*.dart.js
|
||||||
|
*.info.json # Produced by the --dump-info flag.
|
||||||
|
*.js # When generated by dart2js. Don't specify *.js if your
|
||||||
|
# project includes source files written in JavaScript.
|
||||||
|
*.js_
|
||||||
|
*.js.deps
|
||||||
|
*.js.map
|
34
jael_language_server/bin/main.dart
Normal file
34
jael_language_server/bin/main.dart
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:args/args.dart';
|
||||||
|
import 'package:io/ansi.dart';
|
||||||
|
import 'package:io/io.dart';
|
||||||
|
import 'package:dart_language_server/dart_language_server.dart';
|
||||||
|
import 'package:jael_language_server/jael_language_server.dart';
|
||||||
|
|
||||||
|
main(List<String> args) async {
|
||||||
|
var argParser = new ArgParser()
|
||||||
|
..addFlag('help',
|
||||||
|
abbr: 'h', negatable: false, help: 'Print this help information.');
|
||||||
|
|
||||||
|
void printUsage() {
|
||||||
|
print('usage: jael_language_server [options...]\n\nOptions:');
|
||||||
|
print(argParser.usage);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
var argResults = argParser.parse(args);
|
||||||
|
|
||||||
|
if (argResults['help'] as bool) {
|
||||||
|
printUsage();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
var jaelServer = new JaelLanguageServer();
|
||||||
|
var stdio = new StdIOLanguageServer.start(jaelServer);
|
||||||
|
await stdio.onDone;
|
||||||
|
}
|
||||||
|
} on ArgParserException catch (e) {
|
||||||
|
print('${red.wrap('error')}: ${e.message}\n');
|
||||||
|
printUsage();
|
||||||
|
exitCode = ExitCode.usage.code;
|
||||||
|
}
|
||||||
|
}
|
1
jael_language_server/lib/jael_language_server.dart
Normal file
1
jael_language_server/lib/jael_language_server.dart
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export 'src/server.dart';
|
139
jael_language_server/lib/src/server.dart
Normal file
139
jael_language_server/lib/src/server.dart
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
import 'dart:async';
|
||||||
|
import 'package:dart_language_server/src/protocol/language_server/interface.dart';
|
||||||
|
import 'package:dart_language_server/src/protocol/language_server/messages.dart';
|
||||||
|
import 'package:file/file.dart';
|
||||||
|
import 'package:file/local.dart';
|
||||||
|
import 'package:file/memory.dart';
|
||||||
|
import 'package:logging/logging.dart';
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
|
|
||||||
|
class JaelLanguageServer extends LanguageServer {
|
||||||
|
var _diagnostics = new StreamController<Diagnostics>();
|
||||||
|
var _done = new Completer();
|
||||||
|
var _memFs = new MemoryFileSystem();
|
||||||
|
var _localFs = const LocalFileSystem();
|
||||||
|
Directory _localRootDir;
|
||||||
|
var _logger = new Logger('jael');
|
||||||
|
var _workspaceEdits = new StreamController<ApplyWorkspaceEditParams>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Stream<Diagnostics> get diagnostics => _diagnostics.stream;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> get onDone => _done.future;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Stream<ApplyWorkspaceEditParams> get workspaceEdits => _workspaceEdits.stream;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> shutdown() {
|
||||||
|
if (!_done.isCompleted) _done.complete();
|
||||||
|
_diagnostics.close();
|
||||||
|
_workspaceEdits.close();
|
||||||
|
return super.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<ServerCapabilities> initialize(int clientPid, String rootUri,
|
||||||
|
ClientCapabilities clientCapabilities, String trace) async {
|
||||||
|
// Find our real root dir.
|
||||||
|
_localRootDir = _localFs.directory(rootUri);
|
||||||
|
|
||||||
|
// Copy all real files that end in *.jael (and *.jl for legacy) into the in-memory filesystem.
|
||||||
|
await for (var entity in _localRootDir.list(recursive: true)) {
|
||||||
|
if (entity is File && p.extension(entity.path) == '.jael') {
|
||||||
|
var relativePath =
|
||||||
|
p.relative(entity.absolute.path, from: _localRootDir.absolute.path);
|
||||||
|
var file = _memFs.file(relativePath);
|
||||||
|
await file.create(recursive: true);
|
||||||
|
await entity.openRead().pipe(file.openWrite(mode: FileMode.write));
|
||||||
|
_logger.info('Found Jael file ${file.path}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ServerCapabilities((b) {
|
||||||
|
b
|
||||||
|
..documentSymbolProvider = true
|
||||||
|
..documentFormattingProvider = true
|
||||||
|
..hoverProvider = true
|
||||||
|
..implementationProvider = true
|
||||||
|
..referencesProvider = true
|
||||||
|
..renameProvider = true
|
||||||
|
..signatureHelpProvider = new SignatureHelpOptions((b) {})
|
||||||
|
..textDocumentSync = new TextDocumentSyncOptions((b) {
|
||||||
|
b
|
||||||
|
..change = TextDocumentSyncKind.incremental
|
||||||
|
..save = new SaveOptions((b) {
|
||||||
|
b..includeText = true;
|
||||||
|
})
|
||||||
|
..willSave = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List> textDocumentCodeAction(TextDocumentIdentifier documentId,
|
||||||
|
Range range, CodeActionContext context) {
|
||||||
|
// TODO: implement textDocumentCodeAction
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<CompletionList> textDocumentCompletion(
|
||||||
|
TextDocumentIdentifier documentId, Position position) {
|
||||||
|
// TODO: implement textDocumentCompletion
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Location> textDocumentDefinition(
|
||||||
|
TextDocumentIdentifier documentId, Position position) {
|
||||||
|
// TODO: implement textDocumentDefinition
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<DocumentHighlight>> textDocumentHighlight(
|
||||||
|
TextDocumentIdentifier documentId, Position position) {
|
||||||
|
// TODO: implement textDocumentHighlight
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future textDocumentHover(
|
||||||
|
TextDocumentIdentifier documentId, Position position) {
|
||||||
|
// TODO: implement textDocumentHover
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<Location>> textDocumentImplementation(
|
||||||
|
TextDocumentIdentifier documentId, Position position) {
|
||||||
|
// TODO: implement textDocumentImplementation
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<Location>> textDocumentReferences(
|
||||||
|
TextDocumentIdentifier documentId,
|
||||||
|
Position position,
|
||||||
|
ReferenceContext context) {
|
||||||
|
// TODO: implement textDocumentReferences
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<WorkspaceEdit> textDocumentRename(
|
||||||
|
TextDocumentIdentifier documentId, Position position, String newName) {
|
||||||
|
// TODO: implement textDocumentRename
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<SymbolInformation>> textDocumentSymbols(
|
||||||
|
TextDocumentIdentifier documentId) {
|
||||||
|
// TODO: implement textDocumentSymbols
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> workspaceExecuteCommand(String command, List arguments) {
|
||||||
|
// TODO: implement workspaceExecuteCommand
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<SymbolInformation>> workspaceSymbol(String query) {
|
||||||
|
// TODO: implement workspaceSymbol
|
||||||
|
}
|
||||||
|
}
|
18
jael_language_server/pubspec.yaml
Normal file
18
jael_language_server/pubspec.yaml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
name: jael_language_server
|
||||||
|
version: 0.0.0
|
||||||
|
description: Language Server Protocol implementation for the Jael templating engine.
|
||||||
|
author: Tobe Osakwe <thosakwe@gmail.com>
|
||||||
|
homepage: https://github.com/angel-dart/vscode
|
||||||
|
environment:
|
||||||
|
sdk: ">=2.0.0-dev <3.0.0"
|
||||||
|
dependencies:
|
||||||
|
args: ^1.0.0
|
||||||
|
dart_language_server: ^0.1.3
|
||||||
|
file: ^5.0.0
|
||||||
|
io: ^0.3.2
|
||||||
|
jael: ^2.0.0
|
||||||
|
jael_preprocessor: ^2.0.0
|
||||||
|
logging: ^0.11.3
|
||||||
|
path: ^1.0.0
|
||||||
|
executables:
|
||||||
|
jael_language_server: main
|
Loading…
Reference in a new issue