pr 08 lsp

This commit is contained in:
bQUARKz 2026-02-06 16:06:00 +00:00
parent 06b49cf433
commit 5cf77359fb
Signed by: bquarkz
SSH Key Fingerprint: SHA256:Z7dgqoglWwoK6j6u4QC87OveEq74WOhFN+gitsxtkf8
9 changed files with 7570 additions and 0 deletions

View File

@ -0,0 +1,33 @@
use prometeu_analysis::TextIndex;
#[test]
fn span_to_range_uses_utf16() {
// "ação" has: a (1), ç (1 utf16, BMP), ã (1 utf16, BMP), o (1) → total 4 utf16 units
let s = "ação\n"; // newline to ensure line indexing works
let idx = TextIndex::new(s);
// Byte offsets for each char boundary
let bytes: Vec<u32> = s.char_indices().map(|(i, _)| i as u32).collect();
// last boundary is newline; the previous is end of line content
let end_of_line = bytes[bytes.len() - 1];
let (line, col) = idx.byte_to_lsp(end_of_line);
assert_eq!(line, 0);
assert_eq!(col, 4, "UTF-16 column should be 4 for 'ação'");
}
#[test]
fn position_to_byte_roundtrip() {
let s = "😀a\n"; // emoji is surrogate pair in UTF-16
let idx = TextIndex::new(s);
// emoji (😀) occupies 2 utf16 code units; 'a' adds 1
let emoji_end_byte = "😀".len() as u32; // byte length of emoji
// From bytes→(line,col)
let (line, col) = idx.byte_to_lsp(emoji_end_byte);
assert_eq!(line, 0);
assert_eq!(col, 2, "emoji should count as 2 UTF-16 units");
// Back from (line,col)→bytes should land at the same boundary
let back = idx.lsp_to_byte(line, col);
assert_eq!(back, emoji_end_byte);
}

View File

@ -0,0 +1,19 @@
{
"comments": {
"lineComment": "//",
"blockComment": ["/*", "*/"]
},
"brackets": [
["{", "}"],
["[", "]"],
["[[", "]]"],
["(", ")"]
],
"autoClosingPairs": [
{ "open": "{", "close": "}" },
{ "open": "[", "close": "]" },
{ "open": "[[", "close": "]]" },
{ "open": "(", "close": ")" },
{ "open": "\"", "close": "\"" }
]
}

View File

@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.activate = activate;
exports.deactivate = deactivate;
const vscode = require("vscode");
const node_1 = require("vscode-languageclient/node");
let client;
function activate(context) {
const cfg = vscode.workspace.getConfiguration("prometeuPbs");
const serverPath = cfg.get("serverPath");
if (!serverPath) {
vscode.window.showErrorMessage("Prometeu PBS: configure 'prometeuPbs.serverPath' com o caminho do bin prometeu-lsp.");
return;
}
const serverOptions = {
command: serverPath,
args: []
};
const clientOptions = {
documentSelector: [{ scheme: "file", language: "pbs" }]
};
client = new node_1.LanguageClient("prometeuPbsLsp", "Prometeu PBS LSP", serverOptions, clientOptions);
// ✅ O client é “parável” no deactivate, não o start() Promise
context.subscriptions.push({
dispose: () => {
void client?.stop();
}
});
void client.start();
}
function deactivate() {
return client?.stop();
}
//# sourceMappingURL=extension.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;AAKA,4BA8BC;AAED,gCAEC;AAvCD,iCAAiC;AACjC,qDAAkG;AAElG,IAAI,MAAkC,CAAC;AAEvC,SAAgB,QAAQ,CAAC,OAAgC;IACrD,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAC7D,MAAM,UAAU,GAAG,GAAG,CAAC,GAAG,CAAS,YAAY,CAAC,CAAC;IAEjD,IAAI,CAAC,UAAU,EAAE,CAAC;QACd,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAC1B,qFAAqF,CACxF,CAAC;QACF,OAAO;IACX,CAAC;IAED,MAAM,aAAa,GAAkB;QACjC,OAAO,EAAE,UAAU;QACnB,IAAI,EAAE,EAAE;KACX,CAAC;IAEF,MAAM,aAAa,GAA0B;QACzC,gBAAgB,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;KAC1D,CAAC;IAEF,MAAM,GAAG,IAAI,qBAAc,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;IAEhG,8DAA8D;IAC9D,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC;QACvB,OAAO,EAAE,GAAG,EAAE;YACV,KAAK,MAAM,EAAE,IAAI,EAAE,CAAC;QACxB,CAAC;KACJ,CAAC,CAAC;IAEH,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC;AACxB,CAAC;AAED,SAAgB,UAAU;IACtB,OAAO,MAAM,EAAE,IAAI,EAAE,CAAC;AAC1B,CAAC"}

7378
prometeu-vscode/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,50 @@
{
"name": "prometeu-pbs",
"displayName": "Prometeu PBS",
"version": "0.0.1",
"publisher": "local",
"engines": {
"vscode": "^1.85.0"
},
"main": "./out/extension.js",
"contributes": {
"languages": [
{
"id": "pbs",
"aliases": [
"PBS",
"Prometeu Base Script"
],
"extensions": [
".pbs"
],
"configuration": "./language-configuration.json"
}
],
"configuration": {
"type": "object",
"title": "Prometeu PBS",
"properties": {
"prometeuPbs.serverPath": {
"type": "string",
"default": "",
"description": "/Users/niltonconstantino/personal/workspace.personal/intrepid/prometeu/runtime/target/debug/prometeu-lsp --stdio"
}
}
}
},
"dependencies": {
"vscode-languageclient": "^9.0.1"
},
"devDependencies": {
"@types/node": "^20.0.0",
"@types/vscode": "^1.85.0",
"generator-code": "^1.11.17",
"typescript": "^5.0.0",
"yo": "^6.0.0"
},
"scripts": {
"compile": "tsc -p .",
"watch": "tsc -watch -p ."
}
}

View File

@ -0,0 +1,3 @@
{
"prometeuPbs.serverPath": "/Users/niltonconstantino/personal/workspace.personal/intrepid/prometeu/runtime/target/debug/prometeu-lsp"
}

View File

@ -0,0 +1,40 @@
import * as vscode from "vscode";
import { LanguageClient, LanguageClientOptions, ServerOptions } from "vscode-languageclient/node";
let client: LanguageClient | undefined;
export function activate(context: vscode.ExtensionContext) {
const cfg = vscode.workspace.getConfiguration("prometeuPbs");
const serverPath = cfg.get<string>("serverPath");
if (!serverPath) {
vscode.window.showErrorMessage(
"Prometeu PBS: configure 'prometeuPbs.serverPath' com o caminho do bin prometeu-lsp."
);
return;
}
const serverOptions: ServerOptions = {
command: serverPath,
args: []
};
const clientOptions: LanguageClientOptions = {
documentSelector: [{ scheme: "file", language: "pbs" }]
};
client = new LanguageClient("prometeuPbsLsp", "Prometeu PBS LSP", serverOptions, clientOptions);
// ✅ O client é “parável” no deactivate, não o start() Promise
context.subscriptions.push({
dispose: () => {
void client?.stop();
}
});
void client.start();
}
export function deactivate(): Thenable<void> | undefined {
return client?.stop();
}

View File

@ -0,0 +1,12 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "ES2020",
"outDir": "out",
"rootDir": "src",
"lib": ["ES2020"],
"sourceMap": true,
"strict": true
},
"exclude": ["node_modules", ".vscode-test"]
}