stan-language-server-bin 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.
Files changed (2) hide show
  1. package/bin/cli.js +15 -15
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -30324,7 +30324,7 @@ var getTextUpToCursor = (text, position) => {
30324
30324
  };
30325
30325
  function handleCompletion(params, documents, supportsSnippets) {
30326
30326
  const document = documents.get(params.textDocument.uri);
30327
- if (!document) {
30327
+ if (!document || !document.languageId.startsWith("stan")) {
30328
30328
  return [];
30329
30329
  }
30330
30330
  const textUpToCursor = getTextUpToCursor(document.getText(), params.position);
@@ -30880,32 +30880,32 @@ var readIncludedFileFromFileSystem = async (filename, dirs, fileSystemReader) =>
30880
30880
  // src/handlers/compilation/compilation.ts
30881
30881
  var defaultSettings = {
30882
30882
  maxLineLength: 78,
30883
- includePaths: []
30883
+ includePaths: [],
30884
+ warnPedantic: false
30884
30885
  };
30885
- async function handleCompilation(document, documentManager, workspaceFolders, settings, logger, reader) {
30886
+ async function handleCompilation(document, documentManager, workspaceFolders, settings, purpose, logger, reader) {
30886
30887
  const filename = URI.parse(document.uri).fsPath;
30887
30888
  const code = document.getText();
30888
30889
  const includes = await handleIncludes(document, documentManager, workspaceFolders, settings.includePaths, logger, reader);
30889
- const stanc_args = [
30890
- "auto-format",
30891
- `filename-in-msg=${filename}`,
30892
- `max-line-length=${settings.maxLineLength}`,
30893
- "canonicalze=deprecations",
30894
- "allow-undefined"
30895
- ];
30890
+ const stanc_args = [`filename-in-msg=${filename}`, "allow-undefined"];
30896
30891
  if (filename.endsWith(".stanfunctions")) {
30897
30892
  stanc_args.push("functions-only");
30898
30893
  }
30894
+ if (purpose === "formatting") {
30895
+ stanc_args.push("auto-format", `max-line-length=${settings.maxLineLength}`, "canonicalze=deprecations");
30896
+ } else if (settings.warnPedantic) {
30897
+ stanc_args.push("warn-pedantic");
30898
+ }
30899
30899
  return Promise.resolve(stanc(filename, code, stanc_args, includes));
30900
30900
  }
30901
30901
 
30902
30902
  // src/handlers/diagnostics.ts
30903
30903
  async function handleDiagnostics(params, documents, workspaceFolders, settings, logger, reader) {
30904
30904
  const document = documents.get(params.textDocument.uri);
30905
- if (!document) {
30905
+ if (!document || !document.languageId.startsWith("stan")) {
30906
30906
  return [];
30907
30907
  }
30908
- const compilerResult = await handleCompilation(document, documents, workspaceFolders, settings, logger, reader);
30908
+ const compilerResult = await handleCompilation(document, documents, workspaceFolders, settings, "linting", logger, reader);
30909
30909
  const diagnostics = provideDiagnostics(compilerResult).map((diagnostic) => {
30910
30910
  if (diagnostic.severity === "error") {
30911
30911
  return {
@@ -30928,10 +30928,10 @@ async function handleDiagnostics(params, documents, workspaceFolders, settings,
30928
30928
  // src/handlers/formatting.ts
30929
30929
  async function handleFormatting(params, documents, workspaceFolders, settings, logger, reader) {
30930
30930
  const document = documents.get(params.textDocument.uri);
30931
- if (!document) {
30931
+ if (!document || !document.languageId.startsWith("stan")) {
30932
30932
  return [];
30933
30933
  }
30934
- const result = await handleCompilation(document, documents, workspaceFolders, settings, logger, reader);
30934
+ const result = await handleCompilation(document, documents, workspaceFolders, settings, "formatting", logger, reader);
30935
30935
  if (result.errors && result.errors.length > 0) {
30936
30936
  return { errors: result.errors };
30937
30937
  } else if (result.result) {
@@ -31061,7 +31061,7 @@ var startLanguageServer = (connection, reader) => {
31061
31061
  });
31062
31062
  connection.onHover((params) => {
31063
31063
  const document = documents.get(params.textDocument.uri);
31064
- if (!document) {
31064
+ if (!document || !document.languageId.startsWith("stan")) {
31065
31065
  return null;
31066
31066
  }
31067
31067
  return hover_default(document, params);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stan-language-server-bin",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
4
4
  "description": "CLI distribution of the Stan language server",
5
5
  "bin": {
6
6
  "stan-language-server": "bin/cli.js"