stan-language-server 0.4.7 → 0.4.9

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.
@@ -6,7 +6,8 @@ import {
6
6
  DocumentDiagnosticRequest,
7
7
  MessageType,
8
8
  TextDocumentSyncKind,
9
- TextDocuments as TextDocuments3
9
+ TextDocuments as TextDocuments3,
10
+ CompletionItemKind as CompletionItemKind8
10
11
  } from "vscode-languageserver/node";
11
12
 
12
13
  // src/handlers/completion.ts
@@ -38,6 +39,8 @@ var DATATYPES = [
38
39
  "int",
39
40
  "real",
40
41
  "complex",
42
+ "array",
43
+ "tuple",
41
44
  "vector",
42
45
  "row_vector",
43
46
  "matrix",
@@ -53,8 +56,9 @@ var DATATYPES = [
53
56
  "cholesky_factor_cov",
54
57
  "corr_matrix",
55
58
  "cov_matrix",
56
- "stochastic_column_matrix",
57
- "stochastic_row_matrix"
59
+ "row_stochastic_matrix",
60
+ "column_stochastic_matrix",
61
+ "sum_to_zero_matrix"
58
62
  ].map(datatypeToCompletionItem);
59
63
 
60
64
  // src/handlers/completion/keywords.ts
@@ -69,17 +73,12 @@ var KEYWORDS = [
69
73
  "for",
70
74
  "in",
71
75
  "while",
72
- "repeat",
73
- "until",
74
76
  "if",
75
77
  "then",
76
78
  "else",
77
79
  "break",
78
80
  "continue",
79
81
  "return",
80
- "true",
81
- "false",
82
- "target",
83
82
  "functions",
84
83
  "data",
85
84
  "transformed",
@@ -91,21 +90,11 @@ var KEYWORDS = [
91
90
  "reject",
92
91
  "fatal_error",
93
92
  "profile",
94
- "get_lp",
95
- "struct",
96
- "typedef",
97
- "export",
98
- "auto",
99
- "extern",
100
- "var",
101
- "static",
102
- "array",
103
93
  "lower",
104
94
  "upper",
105
95
  "offset",
106
96
  "multiplier",
107
- "tuple",
108
- "truncate",
97
+ "target",
109
98
  "jacobian"
110
99
  ].map(keywordToCompletionItem);
111
100
 
@@ -475,6 +464,12 @@ var getFunctions = () => {
475
464
  var FUNCTIONS = getFunctions();
476
465
 
477
466
  // src/handlers/completion.ts
467
+ var addTextEdit = (item, position, prefix_length) => {
468
+ const start = { line: position.line, character: position.character - prefix_length };
469
+ const end = position;
470
+ const textEdit = { range: { start, end }, newText: item.insertText || item.label };
471
+ return { ...item, textEdit };
472
+ };
478
473
  var COMPLETION_TRIE = new TrieSearch("label", {
479
474
  splitOnRegEx: /[\s_]/g,
480
475
  min: 0
@@ -486,7 +481,7 @@ COMPLETION_TRIE.addAll([
486
481
  ...FUNCTIONS,
487
482
  ...SNIPPETS
488
483
  ]);
489
- var searchWords = (textUpToCursor, supportsSnippets) => {
484
+ var searchWords = (position, textUpToCursor, supportsSnippets) => {
490
485
  const match = textUpToCursor.match(/(?:^|\s)([\w_]+)$/);
491
486
  if (match) {
492
487
  const word = match[1] || "";
@@ -494,7 +489,7 @@ var searchWords = (textUpToCursor, supportsSnippets) => {
494
489
  if (!supportsSnippets) {
495
490
  return completionProposals.filter((item) => item.kind !== CompletionItemKind7.Snippet);
496
491
  }
497
- return completionProposals;
492
+ return completionProposals.map((item) => addTextEdit(item, position, word.length));
498
493
  }
499
494
  return [];
500
495
  };
@@ -503,7 +498,7 @@ var DISTRIBUTION_TRIE = new TrieSearch("label", {
503
498
  min: 0
504
499
  });
505
500
  DISTRIBUTION_TRIE.addAll(DISTRIBUTIONS);
506
- var searchDistributions = (textUpToCursor) => {
501
+ var searchDistributions = (position, textUpToCursor) => {
507
502
  const match = textUpToCursor.match(/.*~\s*([\w_]*)$/);
508
503
  if (match) {
509
504
  const distName = match[1] || "";
@@ -513,7 +508,7 @@ var searchDistributions = (textUpToCursor) => {
513
508
  } else {
514
509
  completionProposals = DISTRIBUTION_TRIE.search(distName);
515
510
  }
516
- return completionProposals;
511
+ return completionProposals.map((item) => addTextEdit(item, position, distName.length));
517
512
  }
518
513
  return [];
519
514
  };
@@ -523,15 +518,15 @@ var getTextUpToCursor = (text, position) => {
523
518
  const currentLine = lines[position.line] || "";
524
519
  return currentLine.substring(0, position.character);
525
520
  };
526
- function handleCompletion(params, documents, supportsSnippets) {
527
- const document = documents.get(params.textDocument.uri);
521
+ function handleCompletion({ position, textDocument }, documents, supportsSnippets) {
522
+ const document = documents.get(textDocument.uri);
528
523
  if (!document || !document.languageId.startsWith("stan")) {
529
524
  return [];
530
525
  }
531
- const textUpToCursor = getTextUpToCursor(document.getText(), params.position);
526
+ const textUpToCursor = getTextUpToCursor(document.getText(), position);
532
527
  return [
533
- ...searchDistributions(textUpToCursor),
534
- ...searchWords(textUpToCursor, supportsSnippets)
528
+ ...searchDistributions(position, textUpToCursor),
529
+ ...searchWords(position, textUpToCursor, supportsSnippets)
535
530
  ];
536
531
  }
537
532
  // src/handlers/diagnostics.ts
@@ -572,7 +567,7 @@ function getRangeFromMessage(message) {
572
567
  }
573
568
  function getWarningMessage(message) {
574
569
  const msg = String(message);
575
- let warning = msg.replace(/Warning.*column \d+: /s, "");
570
+ let warning = msg.replace(/Warning.*column \d+:/s, "");
576
571
  warning = warning.replace(/\s+/gs, " ");
577
572
  warning = warning.trim();
578
573
  warning = msg.includes("included from") ? `Warning in included file:
@@ -791,7 +786,7 @@ var startLanguageServer = (connection, reader) => {
791
786
  hasConfigurationCapability = Boolean(capabilities.workspace?.configuration);
792
787
  hasDynamicConfigurationRequestCapability = Boolean(capabilities.workspace?.configuration && capabilities.workspace?.didChangeConfiguration?.dynamicRegistration);
793
788
  hasWorkspaceFolderCapability = Boolean(capabilities.workspace?.workspaceFolders);
794
- hasSnippetSupport = Boolean(capabilities.textDocument?.completion?.completionItem?.snippetSupport);
789
+ hasSnippetSupport = Boolean(capabilities.textDocument?.completion?.completionItem?.snippetSupport || capabilities.textDocument?.completion?.completionItemKind?.valueSet?.some((kind) => kind === CompletionItemKind8.Snippet));
795
790
  return {
796
791
  capabilities: {
797
792
  textDocumentSync: TextDocumentSyncKind.Incremental,
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "stan-language-server",
3
- "version": "0.4.7",
3
+ "version": "0.4.9",
4
+ "packageManager": "bun@1.3.13",
4
5
  "description": "Language Server Protocol implementation for the Stan probabilistic programming language",
5
6
  "main": "dist/server/index.js",
6
7
  "module": "src/server/index.ts",
@@ -46,8 +47,9 @@
46
47
  "node": ">=18.0.0"
47
48
  },
48
49
  "scripts": {
49
- "build": "bun build src/server/index.ts --outdir dist/server --packages external --target browser --format esm && tsc --emitDeclarationOnly --outDir dist",
50
- "build:binary": "bun build src/server/cli.ts --compile --outfile bin/stan-language-server",
50
+ "generate:wasm": "bun run scripts/generate-wasm-data.ts",
51
+ "build": "bun run generate:wasm && bun build src/server/index.ts --outdir dist/server --packages external --target browser --format esm && tsc -p ./tsconfig.src.json",
52
+ "build:binary": "bun run generate:wasm && bun build src/server/cli.ts --compile --outfile bin/stan-language-server",
51
53
  "build:bin-package": "bun run scripts/build-bin-package.ts",
52
54
  "prepublishOnly": "bun run build",
53
55
  "version:set": "bun run scripts/set-version.ts",
@@ -58,7 +60,8 @@
58
60
  "publish:rc": "bun run build && npm publish --access public --tag rc",
59
61
  "lint": "eslint src --ext .ts",
60
62
  "lint:fix": "eslint src --ext .ts --fix",
61
- "typecheck": "tsc --noEmit",
63
+ "deps:check": "bun run scripts/check-dependency-policy.ts",
64
+ "typecheck": "bun run generate:wasm && tsc --noEmit",
62
65
  "check": "bun run lint && bun run typecheck",
63
66
  "test": "bun test",
64
67
  "test:unit": "bun test src/__tests__/handlers src/__tests__/language",
@@ -67,21 +70,26 @@
67
70
  "dev": "bun run src/server/cli.ts"
68
71
  },
69
72
  "devDependencies": {
70
- "@types/bun": "latest",
71
- "@types/node": "25.6.0",
72
- "@typescript-eslint/eslint-plugin": "8.59.1",
73
- "@typescript-eslint/parser": "8.59.1",
73
+ "@eslint/js": "10.0.1",
74
+ "@types/bun": "1.3.14",
75
+ "@types/node": "25.7.0",
76
+ "@typescript-eslint/eslint-plugin": "8.59.3",
77
+ "@typescript-eslint/parser": "8.59.3",
78
+ "@wardbrian/tree-sitter-stan": "0.3.1",
74
79
  "eslint": "10.3.0",
75
- "globals": "^17.3.0",
76
- "@eslint/js": "^10.0.1",
77
- "typescript-eslint": "^8.57.0",
78
- "typescript": "6.0.3"
80
+ "globals": "17.6.0",
81
+ "typescript": "6.0.3",
82
+ "typescript-eslint": "8.59.3",
83
+ "web-tree-sitter": "0.26.8"
79
84
  },
80
85
  "dependencies": {
81
- "stanc3": "2.38.0",
86
+ "stanc3": "2.39.0",
82
87
  "trie-search": "2.2.1",
83
88
  "vscode-languageserver": "9.0.1",
84
89
  "vscode-languageserver-textdocument": "1.0.12",
85
90
  "vscode-uri": "3.1.0"
91
+ },
92
+ "overrides": {
93
+ "@types/node": "25.7.0"
86
94
  }
87
95
  }