language server start
This commit is contained in:
@@ -4,6 +4,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NubLang", "NubLang\NubLang.
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NubLang.CLI", "NubLang.CLI\NubLang.CLI.csproj", "{A22F17ED-FA17-45AB-92BA-CD02C28B3524}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NubLang.LSP", "NubLang.LSP\NubLang.LSP.csproj", "{07968F84-0C2E-4D2E-8905-DC8A6140B4C0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -18,5 +20,9 @@ Global
|
||||
{A22F17ED-FA17-45AB-92BA-CD02C28B3524}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A22F17ED-FA17-45AB-92BA-CD02C28B3524}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A22F17ED-FA17-45AB-92BA-CD02C28B3524}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{07968F84-0C2E-4D2E-8905-DC8A6140B4C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{07968F84-0C2E-4D2E-8905-DC8A6140B4C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{07968F84-0C2E-4D2E-8905-DC8A6140B4C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{07968F84-0C2E-4D2E-8905-DC8A6140B4C0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol.Document;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
|
||||
using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range;
|
||||
|
||||
namespace NubLang.LSP;
|
||||
|
||||
@@ -13,12 +15,30 @@ public class DiagnosticsPublisher
|
||||
_server = server;
|
||||
}
|
||||
|
||||
public void Publish(Uri uri, IEnumerable<Diagnostic> diagnostics)
|
||||
public void Publish(DocumentUri uri, IEnumerable<Diagnostics.Diagnostic> diagnostics)
|
||||
{
|
||||
_server.TextDocument.PublishDiagnostics(new PublishDiagnosticsParams
|
||||
{
|
||||
Uri = uri,
|
||||
Diagnostics = new Container<Diagnostic>(diagnostics)
|
||||
Diagnostics = new Container<Diagnostic>(diagnostics.Select(MapDiagnostic))
|
||||
});
|
||||
}
|
||||
|
||||
private static Diagnostic MapDiagnostic(Diagnostics.Diagnostic nubDiagnostic)
|
||||
{
|
||||
return new Diagnostic
|
||||
{
|
||||
Severity = nubDiagnostic.Severity switch
|
||||
{
|
||||
Diagnostics.DiagnosticSeverity.Info => DiagnosticSeverity.Information,
|
||||
Diagnostics.DiagnosticSeverity.Warning => DiagnosticSeverity.Warning,
|
||||
Diagnostics.DiagnosticSeverity.Error => DiagnosticSeverity.Error,
|
||||
_ => null
|
||||
},
|
||||
Message = $"{nubDiagnostic.Message}\nhelp: {nubDiagnostic.Help}",
|
||||
Range = nubDiagnostic.Span.HasValue
|
||||
? new Range(nubDiagnostic.Span.Value.Start.Line, nubDiagnostic.Span.Value.Start.Column, nubDiagnostic.Span.Value.End.Line, nubDiagnostic.Span.Value.Start.Column)
|
||||
: new Range(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,21 @@ internal class HoverHandler : HoverHandlerBase
|
||||
{
|
||||
protected override HoverRegistrationOptions CreateRegistrationOptions(HoverCapability capability, ClientCapabilities clientCapabilities)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return new HoverRegistrationOptions
|
||||
{
|
||||
DocumentSelector = TextDocumentSelector.ForLanguage("nub-lang")
|
||||
};
|
||||
}
|
||||
|
||||
public override Task<Hover?> Handle(HoverParams request, CancellationToken cancellationToken)
|
||||
public override async Task<Hover?> Handle(HoverParams request, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return new Hover
|
||||
{
|
||||
Contents = new MarkedStringsOrMarkupContent(new MarkupContent
|
||||
{
|
||||
Value = "# uwu",
|
||||
Kind = MarkupKind.Markdown,
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
18
compiler/NubLang.LSP/NubLang.LSP.csproj
Normal file
18
compiler/NubLang.LSP/NubLang.LSP.csproj
Normal file
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.19.9" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NubLang\NubLang.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
36
compiler/NubLang.LSP/Program.cs
Normal file
36
compiler/NubLang.LSP/Program.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NubLang.LSP;
|
||||
using OmniSharp.Extensions.LanguageServer.Server;
|
||||
|
||||
var server = await LanguageServer.From(options => options
|
||||
.WithInput(Console.OpenStandardInput())
|
||||
.WithOutput(Console.OpenStandardOutput())
|
||||
.WithServices(services =>
|
||||
{
|
||||
services.AddSingleton<DiagnosticsPublisher>();
|
||||
services.AddSingleton<WorkspaceManager>();
|
||||
})
|
||||
.ConfigureLogging(x => x
|
||||
.AddLanguageProtocolLogging()
|
||||
.SetMinimumLevel(LogLevel.Debug))
|
||||
.WithHandler<TextDocumentSyncHandler>()
|
||||
.WithHandler<HoverHandler>()
|
||||
.OnInitialize((server, request, ct) =>
|
||||
{
|
||||
server.SendNotification("TEST");
|
||||
var workspaceManager = server.GetRequiredService<WorkspaceManager>();
|
||||
|
||||
if (request.RootPath != null)
|
||||
{
|
||||
foreach (var file in Directory.GetFiles(request.RootPath, "*.nub", SearchOption.AllDirectories))
|
||||
{
|
||||
workspaceManager.UpdateFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
})
|
||||
);
|
||||
|
||||
await server.WaitForExit;
|
||||
@@ -3,19 +3,11 @@ using OmniSharp.Extensions.LanguageServer.Protocol;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol.Document;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
|
||||
|
||||
namespace NubLang.LSP;
|
||||
|
||||
internal class TextDocumentSyncHandler : TextDocumentSyncHandlerBase
|
||||
internal class TextDocumentSyncHandler(WorkspaceManager workspaceManager) : TextDocumentSyncHandlerBase
|
||||
{
|
||||
private readonly DiagnosticsPublisher _diagnostics;
|
||||
|
||||
public TextDocumentSyncHandler(DiagnosticsPublisher diagnostics)
|
||||
{
|
||||
_diagnostics = diagnostics;
|
||||
}
|
||||
|
||||
public override TextDocumentAttributes GetTextDocumentAttributes(DocumentUri uri)
|
||||
{
|
||||
return new TextDocumentAttributes(uri, "nub-lang");
|
||||
@@ -23,25 +15,25 @@ internal class TextDocumentSyncHandler : TextDocumentSyncHandlerBase
|
||||
|
||||
public override Task<Unit> Handle(DidOpenTextDocumentParams request, CancellationToken cancellationToken)
|
||||
{
|
||||
workspaceManager.UpdateFile(request.TextDocument.Uri);
|
||||
return Unit.Task;
|
||||
}
|
||||
|
||||
public override Task<Unit> Handle(DidChangeTextDocumentParams request, CancellationToken cancellationToken)
|
||||
{
|
||||
_diagnostics.Publish(new Uri("https://example.com"), [new Diagnostic
|
||||
{
|
||||
Severity = DiagnosticSeverity.Error,
|
||||
}]);
|
||||
workspaceManager.UpdateFile(request.TextDocument.Uri);
|
||||
return Unit.Task;
|
||||
}
|
||||
|
||||
public override Task<Unit> Handle(DidSaveTextDocumentParams request, CancellationToken cancellationToken)
|
||||
{
|
||||
workspaceManager.UpdateFile(request.TextDocument.Uri);
|
||||
return Unit.Task;
|
||||
}
|
||||
|
||||
public override Task<Unit> Handle(DidCloseTextDocumentParams request, CancellationToken cancellationToken)
|
||||
{
|
||||
workspaceManager.UpdateFile(request.TextDocument.Uri);
|
||||
return Unit.Task;
|
||||
}
|
||||
|
||||
@@ -49,23 +41,4 @@ internal class TextDocumentSyncHandler : TextDocumentSyncHandlerBase
|
||||
{
|
||||
return new TextDocumentSyncRegistrationOptions();
|
||||
}
|
||||
}
|
||||
|
||||
public class DiagnosticsPublisher
|
||||
{
|
||||
private readonly ILanguageServerFacade _server;
|
||||
|
||||
public DiagnosticsPublisher(ILanguageServerFacade server)
|
||||
{
|
||||
_server = server;
|
||||
}
|
||||
|
||||
public void Publish(Uri uri, IEnumerable<Diagnostic> diagnostics)
|
||||
{
|
||||
_server.TextDocument.PublishDiagnostics(new PublishDiagnosticsParams
|
||||
{
|
||||
Uri = uri,
|
||||
Diagnostics = new Container<Diagnostic>(diagnostics)
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,29 @@
|
||||
using NubLang.Syntax;
|
||||
using OmniSharp.Extensions.LanguageServer.Protocol;
|
||||
|
||||
namespace NubLang.LSP;
|
||||
|
||||
public class WorkspaceManager
|
||||
public class WorkspaceManager(DiagnosticsPublisher diagnosticsPublisher)
|
||||
{
|
||||
|
||||
private readonly Dictionary<DocumentUri, SyntaxTree> _files = new();
|
||||
|
||||
public void UpdateFile(DocumentUri path)
|
||||
{
|
||||
var text = File.ReadAllText(path.GetFileSystemPath());
|
||||
var tokenizer = new Tokenizer(path.GetFileSystemPath(), text);
|
||||
|
||||
tokenizer.Tokenize();
|
||||
diagnosticsPublisher.Publish(path, tokenizer.Diagnostics);
|
||||
|
||||
var parser = new Parser();
|
||||
var result = parser.Parse(tokenizer.Tokens);
|
||||
diagnosticsPublisher.Publish(path, parser.Diagnostics);
|
||||
|
||||
_files[path] = result;
|
||||
}
|
||||
|
||||
public void RemoveFile(Uri path)
|
||||
{
|
||||
_files.Remove(path);
|
||||
}
|
||||
}
|
||||
1
vscode-lsp/.gitignore
vendored
Normal file
1
vscode-lsp/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
5
vscode-lsp/.vscode-test.mjs
Normal file
5
vscode-lsp/.vscode-test.mjs
Normal file
@@ -0,0 +1,5 @@
|
||||
import { defineConfig } from '@vscode/test-cli';
|
||||
|
||||
export default defineConfig({
|
||||
files: 'out/test/**/*.test.js',
|
||||
});
|
||||
8
vscode-lsp/.vscode/extensions.json
vendored
Normal file
8
vscode-lsp/.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"dbaeumer.vscode-eslint",
|
||||
"ms-vscode.extension-test-runner"
|
||||
]
|
||||
}
|
||||
21
vscode-lsp/.vscode/launch.json
vendored
Normal file
21
vscode-lsp/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
// A launch configuration that compiles the extension and then opens it inside a new window
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Run Extension",
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"--extensionDevelopmentPath=${workspaceFolder}"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/out/**/*.js"
|
||||
],
|
||||
"preLaunchTask": "${defaultBuildTask}"
|
||||
}
|
||||
]
|
||||
}
|
||||
11
vscode-lsp/.vscode/settings.json
vendored
Normal file
11
vscode-lsp/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// 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
|
||||
},
|
||||
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
|
||||
"typescript.tsc.autoDetect": "off"
|
||||
}
|
||||
20
vscode-lsp/.vscode/tasks.json
vendored
Normal file
20
vscode-lsp/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "watch",
|
||||
"problemMatcher": "$tsc-watch",
|
||||
"isBackground": true,
|
||||
"presentation": {
|
||||
"reveal": "never"
|
||||
},
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
11
vscode-lsp/.vscodeignore
Normal file
11
vscode-lsp/.vscodeignore
Normal file
@@ -0,0 +1,11 @@
|
||||
.vscode/**
|
||||
.vscode-test/**
|
||||
src/**
|
||||
.gitignore
|
||||
.yarnrc
|
||||
vsc-extension-quickstart.md
|
||||
**/tsconfig.json
|
||||
**/eslint.config.mjs
|
||||
**/*.map
|
||||
**/*.ts
|
||||
**/.vscode-test.*
|
||||
28
vscode-lsp/eslint.config.mjs
Normal file
28
vscode-lsp/eslint.config.mjs
Normal file
@@ -0,0 +1,28 @@
|
||||
import typescriptEslint from "@typescript-eslint/eslint-plugin";
|
||||
import tsParser from "@typescript-eslint/parser";
|
||||
|
||||
export default [{
|
||||
files: ["**/*.ts"],
|
||||
}, {
|
||||
plugins: {
|
||||
"@typescript-eslint": typescriptEslint,
|
||||
},
|
||||
|
||||
languageOptions: {
|
||||
parser: tsParser,
|
||||
ecmaVersion: 2022,
|
||||
sourceType: "module",
|
||||
},
|
||||
|
||||
rules: {
|
||||
"@typescript-eslint/naming-convention": ["warn", {
|
||||
selector: "import",
|
||||
format: ["camelCase", "PascalCase"],
|
||||
}],
|
||||
|
||||
curly: "warn",
|
||||
eqeqeq: "warn",
|
||||
"no-throw-literal": "warn",
|
||||
semi: "warn",
|
||||
},
|
||||
}];
|
||||
69
vscode-lsp/language-configuration.json
Normal file
69
vscode-lsp/language-configuration.json
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"comments": {
|
||||
"lineComment": {
|
||||
"comment": "//"
|
||||
},
|
||||
"blockComment": [
|
||||
"/*",
|
||||
"*/"
|
||||
]
|
||||
},
|
||||
"brackets": [
|
||||
[
|
||||
"{",
|
||||
"}"
|
||||
],
|
||||
[
|
||||
"[",
|
||||
"]"
|
||||
],
|
||||
[
|
||||
"(",
|
||||
")"
|
||||
]
|
||||
],
|
||||
"autoClosingPairs": [
|
||||
{
|
||||
"open": "{",
|
||||
"close": "}"
|
||||
},
|
||||
{
|
||||
"open": "[",
|
||||
"close": "]"
|
||||
},
|
||||
{
|
||||
"open": "(",
|
||||
"close": ")"
|
||||
},
|
||||
{
|
||||
"open": "\"",
|
||||
"close": "\""
|
||||
},
|
||||
{
|
||||
"open": "'",
|
||||
"close": "'"
|
||||
}
|
||||
],
|
||||
"surroundingPairs": [
|
||||
[
|
||||
"{",
|
||||
"}"
|
||||
],
|
||||
[
|
||||
"[",
|
||||
"]"
|
||||
],
|
||||
[
|
||||
"(",
|
||||
")"
|
||||
],
|
||||
[
|
||||
"\"",
|
||||
"\""
|
||||
],
|
||||
[
|
||||
"'",
|
||||
"'"
|
||||
]
|
||||
]
|
||||
}
|
||||
40
vscode-lsp/out/extension.js
Normal file
40
vscode-lsp/out/extension.js
Normal file
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.activate = activate;
|
||||
exports.deactivate = deactivate;
|
||||
const vscode_1 = require("vscode");
|
||||
const node_1 = require("vscode-languageclient/node");
|
||||
let client;
|
||||
function activate(context) {
|
||||
const outputChannel = vscode_1.window.createOutputChannel('My Language Server');
|
||||
outputChannel.appendLine('Extension activating...');
|
||||
const serverExecutable = '/home/oliste/repos/nub-lang/compiler/NubLang.LSP/bin/Debug/net9.0/NubLang.LSP';
|
||||
outputChannel.appendLine(`Server path: ${serverExecutable}`);
|
||||
client = new node_1.LanguageClient('nub-lang', 'nub lang', {
|
||||
run: {
|
||||
command: serverExecutable,
|
||||
transport: node_1.TransportKind.stdio,
|
||||
},
|
||||
debug: {
|
||||
command: serverExecutable,
|
||||
transport: node_1.TransportKind.stdio,
|
||||
args: ['--debug'],
|
||||
}
|
||||
}, {
|
||||
documentSelector: [
|
||||
{ scheme: 'file', language: 'nub' },
|
||||
{ scheme: 'file', pattern: '**/*.nub' }
|
||||
],
|
||||
synchronize: {
|
||||
fileEvents: vscode_1.workspace.createFileSystemWatcher('**/.clientrc')
|
||||
}
|
||||
});
|
||||
client.start();
|
||||
}
|
||||
function deactivate() {
|
||||
if (!client) {
|
||||
return undefined;
|
||||
}
|
||||
return client.stop();
|
||||
}
|
||||
//# sourceMappingURL=extension.js.map
|
||||
1
vscode-lsp/out/extension.js.map
Normal file
1
vscode-lsp/out/extension.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;AAKA,4BAkCC;AAED,gCAKC;AA9CD,mCAA6D;AAC7D,qDAA2E;AAE3E,IAAI,MAAsB,CAAC;AAE3B,SAAgB,QAAQ,CAAC,OAAyB;IACjD,MAAM,aAAa,GAAG,eAAM,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;IACvE,aAAa,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC;IAEpD,MAAM,gBAAgB,GAAG,+EAA+E,CAAC;IAEzG,aAAa,CAAC,UAAU,CAAC,gBAAgB,gBAAgB,EAAE,CAAC,CAAC;IAE7D,MAAM,GAAG,IAAI,qBAAc,CAC1B,UAAU,EACV,UAAU,EACV;QACC,GAAG,EAAE;YACJ,OAAO,EAAE,gBAAgB;YACzB,SAAS,EAAE,oBAAa,CAAC,KAAK;SAC9B;QACD,KAAK,EAAE;YACN,OAAO,EAAE,gBAAgB;YACzB,SAAS,EAAE,oBAAa,CAAC,KAAK;YAC9B,IAAI,EAAE,CAAC,SAAS,CAAC;SACjB;KACD,EACD;QACC,gBAAgB,EAAE;YACjB,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE;YACnC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE;SACvC;QACD,WAAW,EAAE;YACZ,UAAU,EAAE,kBAAS,CAAC,uBAAuB,CAAC,cAAc,CAAC;SAC7D;KACD,CACD,CAAC;IAEF,MAAM,CAAC,KAAK,EAAE,CAAC;AAChB,CAAC;AAED,SAAgB,UAAU;IACzB,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACtB,CAAC"}
|
||||
48
vscode-lsp/out/test/extension.test.js
Normal file
48
vscode-lsp/out/test/extension.test.js
Normal file
@@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const assert = __importStar(require("assert"));
|
||||
// You can import and use all API from the 'vscode' module
|
||||
// as well as import your extension to test it
|
||||
const vscode = __importStar(require("vscode"));
|
||||
// import * as myExtension from '../../extension';
|
||||
suite('Extension Test Suite', () => {
|
||||
vscode.window.showInformationMessage('Start all tests.');
|
||||
test('Sample test', () => {
|
||||
assert.strictEqual(-1, [1, 2, 3].indexOf(5));
|
||||
assert.strictEqual(-1, [1, 2, 3].indexOf(0));
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=extension.test.js.map
|
||||
1
vscode-lsp/out/test/extension.test.js.map
Normal file
1
vscode-lsp/out/test/extension.test.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"extension.test.js","sourceRoot":"","sources":["../../src/test/extension.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AAEjC,0DAA0D;AAC1D,8CAA8C;AAC9C,+CAAiC;AACjC,kDAAkD;AAElD,KAAK,CAAC,sBAAsB,EAAE,GAAG,EAAE;IAClC,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,kBAAkB,CAAC,CAAC;IAEzD,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE;QACxB,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7C,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
||||
3434
vscode-lsp/package-lock.json
generated
Normal file
3434
vscode-lsp/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
58
vscode-lsp/package.json
Normal file
58
vscode-lsp/package.json
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"name": "nub-lang",
|
||||
"displayName": "Nub Language Support",
|
||||
"description": "Language server client for nub-lang",
|
||||
"version": "0.0.0",
|
||||
"publisher": "nub31",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.oliste.no/nub31/nub-lang"
|
||||
},
|
||||
"engines": {
|
||||
"vscode": "^1.105.0"
|
||||
},
|
||||
"categories": [
|
||||
"Programming Languages"
|
||||
],
|
||||
"main": "./out/extension.js",
|
||||
"contributes": {
|
||||
"languages": [
|
||||
{
|
||||
"id": "nub-lang",
|
||||
"extensions": [
|
||||
".nub"
|
||||
],
|
||||
"configuration": "./language-configuration.json"
|
||||
}
|
||||
],
|
||||
"grammars": [
|
||||
{
|
||||
"language": "nub-lang",
|
||||
"scopeName": "source.nub",
|
||||
"path": "./syntaxes/nub.tmLanguage.json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"vscode:prepublish": "npm run compile",
|
||||
"compile": "tsc -p ./",
|
||||
"watch": "tsc -watch -p ./",
|
||||
"pretest": "npm run compile && npm run lint",
|
||||
"lint": "eslint src",
|
||||
"test": "vscode-test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/mocha": "^10.0.10",
|
||||
"@types/node": "22.x",
|
||||
"@types/vscode": "^1.105.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.45.0",
|
||||
"@typescript-eslint/parser": "^8.45.0",
|
||||
"@vscode/test-cli": "^0.0.11",
|
||||
"@vscode/test-electron": "^2.5.2",
|
||||
"eslint": "^9.36.0",
|
||||
"typescript": "^5.9.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"vscode-languageclient": "^9.0.1"
|
||||
}
|
||||
}
|
||||
47
vscode-lsp/src/extension.ts
Normal file
47
vscode-lsp/src/extension.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { workspace, ExtensionContext, window } from 'vscode';
|
||||
import { LanguageClient, TransportKind } from 'vscode-languageclient/node';
|
||||
|
||||
let client: LanguageClient;
|
||||
|
||||
export function activate(context: ExtensionContext) {
|
||||
const outputChannel = window.createOutputChannel('My Language Server');
|
||||
outputChannel.appendLine('Extension activating...');
|
||||
|
||||
const serverExecutable = '/home/oliste/repos/nub-lang/compiler/NubLang.LSP/bin/Debug/net9.0/NubLang.LSP';
|
||||
|
||||
outputChannel.appendLine(`Server path: ${serverExecutable}`);
|
||||
|
||||
client = new LanguageClient(
|
||||
'nub-lang',
|
||||
'nub lang',
|
||||
{
|
||||
run: {
|
||||
command: serverExecutable,
|
||||
transport: TransportKind.stdio,
|
||||
},
|
||||
debug: {
|
||||
command: serverExecutable,
|
||||
transport: TransportKind.stdio,
|
||||
args: ['--debug'],
|
||||
}
|
||||
},
|
||||
{
|
||||
documentSelector: [
|
||||
{ scheme: 'file', language: 'nub' },
|
||||
{ scheme: 'file', pattern: '**/*.nub' }
|
||||
],
|
||||
synchronize: {
|
||||
fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
client.start();
|
||||
}
|
||||
|
||||
export function deactivate(): Thenable<void> | undefined {
|
||||
if (!client) {
|
||||
return undefined;
|
||||
}
|
||||
return client.stop();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
||||
"name": "Nub",
|
||||
"name": "nub-lang",
|
||||
"scopeName": "source.nub",
|
||||
"patterns": [
|
||||
{
|
||||
15
vscode-lsp/tsconfig.json
Normal file
15
vscode-lsp/tsconfig.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "Node16",
|
||||
"target": "ES2022",
|
||||
"outDir": "out",
|
||||
"lib": [
|
||||
"ES2022"
|
||||
],
|
||||
"sourceMap": true,
|
||||
"rootDir": "src",
|
||||
"strict": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
}
|
||||
}
|
||||
1
vscode/.gitignore
vendored
1
vscode/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
out
|
||||
@@ -1,9 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 nub31
|
||||
|
||||
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.
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"comments": {
|
||||
"lineComment": "//",
|
||||
"blockComment": ["/*", "*/"]
|
||||
},
|
||||
"brackets": [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"]
|
||||
],
|
||||
"autoClosingPairs": [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"],
|
||||
["\"", "\""],
|
||||
["'", "'"]
|
||||
],
|
||||
"surroundingPairs": [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"],
|
||||
["\"", "\""],
|
||||
["'", "'"]
|
||||
],
|
||||
"indentationRules": {
|
||||
"increaseIndentPattern": "^((?!\\/\\*).)*(\\{[^}\"'`]*|\\([^)\"'`]*|\\[[^\\]\"'`]*)$",
|
||||
"decreaseIndentPattern": "^((?!.*?\\/\\*).*\\*/)?\\s*[\\}\\]\\)].*$"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
vscode:
|
||||
mkdir -p out
|
||||
npx vsce package -o out/nub-lang.vsix
|
||||
|
||||
clean:
|
||||
rm -r out
|
||||
@@ -1,40 +0,0 @@
|
||||
{
|
||||
"name": "nub-lang",
|
||||
"displayName": "Nub Language Support",
|
||||
"description": "Syntax highlighting for Nub programming language",
|
||||
"version": "0.0.0",
|
||||
"publisher": "nub31",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://git.oliste.no/nub31/nub-lang"
|
||||
},
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"vscode": "^1.74.0"
|
||||
},
|
||||
"categories": [
|
||||
"Programming Languages"
|
||||
],
|
||||
"contributes": {
|
||||
"languages": [
|
||||
{
|
||||
"id": "nub",
|
||||
"aliases": [
|
||||
"Nub",
|
||||
"nub"
|
||||
],
|
||||
"extensions": [
|
||||
".nub"
|
||||
],
|
||||
"configuration": "./language-configuration.json"
|
||||
}
|
||||
],
|
||||
"grammars": [
|
||||
{
|
||||
"language": "nub",
|
||||
"scopeName": "source.nub",
|
||||
"path": "./syntaxes/nub.tmLanguage.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user