stan-language-server 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,6 +5,8 @@ import { type StancReturn } from "stanc3";
|
|
|
5
5
|
export interface Settings {
|
|
6
6
|
maxLineLength: number;
|
|
7
7
|
includePaths: string[];
|
|
8
|
+
warnPedantic: boolean;
|
|
8
9
|
}
|
|
9
10
|
export declare const defaultSettings: Settings;
|
|
10
|
-
export
|
|
11
|
+
export type Purpose = "formatting" | "linting";
|
|
12
|
+
export declare function handleCompilation(document: TextDocument, documentManager: TextDocuments<TextDocument>, workspaceFolders: WorkspaceFolder[], settings: Settings, purpose: Purpose, logger: RemoteConsole, reader?: FileSystemReader): Promise<StancReturn>;
|
package/dist/server/index.js
CHANGED
|
@@ -525,7 +525,7 @@ var getTextUpToCursor = (text, position) => {
|
|
|
525
525
|
};
|
|
526
526
|
function handleCompletion(params, documents, supportsSnippets) {
|
|
527
527
|
const document = documents.get(params.textDocument.uri);
|
|
528
|
-
if (!document) {
|
|
528
|
+
if (!document || !document.languageId.startsWith("stan")) {
|
|
529
529
|
return [];
|
|
530
530
|
}
|
|
531
531
|
const textUpToCursor = getTextUpToCursor(document.getText(), params.position);
|
|
@@ -708,32 +708,32 @@ import { URI as URI2 } from "vscode-uri";
|
|
|
708
708
|
import { stanc } from "stanc3";
|
|
709
709
|
var defaultSettings = {
|
|
710
710
|
maxLineLength: 78,
|
|
711
|
-
includePaths: []
|
|
711
|
+
includePaths: [],
|
|
712
|
+
warnPedantic: false
|
|
712
713
|
};
|
|
713
|
-
async function handleCompilation(document, documentManager, workspaceFolders, settings, logger, reader) {
|
|
714
|
+
async function handleCompilation(document, documentManager, workspaceFolders, settings, purpose, logger, reader) {
|
|
714
715
|
const filename = URI2.parse(document.uri).fsPath;
|
|
715
716
|
const code = document.getText();
|
|
716
717
|
const includes = await handleIncludes(document, documentManager, workspaceFolders, settings.includePaths, logger, reader);
|
|
717
|
-
const stanc_args = [
|
|
718
|
-
"auto-format",
|
|
719
|
-
`filename-in-msg=${filename}`,
|
|
720
|
-
`max-line-length=${settings.maxLineLength}`,
|
|
721
|
-
"canonicalze=deprecations",
|
|
722
|
-
"allow-undefined"
|
|
723
|
-
];
|
|
718
|
+
const stanc_args = [`filename-in-msg=${filename}`, "allow-undefined"];
|
|
724
719
|
if (filename.endsWith(".stanfunctions")) {
|
|
725
720
|
stanc_args.push("functions-only");
|
|
726
721
|
}
|
|
722
|
+
if (purpose === "formatting") {
|
|
723
|
+
stanc_args.push("auto-format", `max-line-length=${settings.maxLineLength}`, "canonicalze=deprecations");
|
|
724
|
+
} else if (settings.warnPedantic) {
|
|
725
|
+
stanc_args.push("warn-pedantic");
|
|
726
|
+
}
|
|
727
727
|
return Promise.resolve(stanc(filename, code, stanc_args, includes));
|
|
728
728
|
}
|
|
729
729
|
|
|
730
730
|
// src/handlers/diagnostics.ts
|
|
731
731
|
async function handleDiagnostics(params, documents, workspaceFolders, settings, logger, reader) {
|
|
732
732
|
const document = documents.get(params.textDocument.uri);
|
|
733
|
-
if (!document) {
|
|
733
|
+
if (!document || !document.languageId.startsWith("stan")) {
|
|
734
734
|
return [];
|
|
735
735
|
}
|
|
736
|
-
const compilerResult = await handleCompilation(document, documents, workspaceFolders, settings, logger, reader);
|
|
736
|
+
const compilerResult = await handleCompilation(document, documents, workspaceFolders, settings, "linting", logger, reader);
|
|
737
737
|
const diagnostics = provideDiagnostics(compilerResult).map((diagnostic) => {
|
|
738
738
|
if (diagnostic.severity === "error") {
|
|
739
739
|
return {
|
|
@@ -756,10 +756,10 @@ async function handleDiagnostics(params, documents, workspaceFolders, settings,
|
|
|
756
756
|
// src/handlers/formatting.ts
|
|
757
757
|
async function handleFormatting(params, documents, workspaceFolders, settings, logger, reader) {
|
|
758
758
|
const document = documents.get(params.textDocument.uri);
|
|
759
|
-
if (!document) {
|
|
759
|
+
if (!document || !document.languageId.startsWith("stan")) {
|
|
760
760
|
return [];
|
|
761
761
|
}
|
|
762
|
-
const result = await handleCompilation(document, documents, workspaceFolders, settings, logger, reader);
|
|
762
|
+
const result = await handleCompilation(document, documents, workspaceFolders, settings, "formatting", logger, reader);
|
|
763
763
|
if (result.errors && result.errors.length > 0) {
|
|
764
764
|
return { errors: result.errors };
|
|
765
765
|
} else if (result.result) {
|
|
@@ -889,7 +889,7 @@ var startLanguageServer = (connection, reader) => {
|
|
|
889
889
|
});
|
|
890
890
|
connection.onHover((params) => {
|
|
891
891
|
const document = documents.get(params.textDocument.uri);
|
|
892
|
-
if (!document) {
|
|
892
|
+
if (!document || !document.languageId.startsWith("stan")) {
|
|
893
893
|
return null;
|
|
894
894
|
}
|
|
895
895
|
return hover_default(document, params);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stan-language-server",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "Language Server Protocol implementation for the Stan probabilistic programming language",
|
|
5
5
|
"main": "dist/server/index.js",
|
|
6
6
|
"module": "src/server/index.ts",
|
|
@@ -68,14 +68,14 @@
|
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@types/bun": "latest",
|
|
71
|
-
"@types/node": "25.
|
|
72
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
73
|
-
"@typescript-eslint/parser": "8.
|
|
74
|
-
"eslint": "10.0
|
|
71
|
+
"@types/node": "25.6.0",
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "8.59.1",
|
|
73
|
+
"@typescript-eslint/parser": "8.59.1",
|
|
74
|
+
"eslint": "10.3.0",
|
|
75
75
|
"globals": "^17.3.0",
|
|
76
76
|
"@eslint/js": "^10.0.1",
|
|
77
77
|
"typescript-eslint": "^8.57.0",
|
|
78
|
-
"typescript": "
|
|
78
|
+
"typescript": "6.0.3"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"stanc3": "2.38.0",
|