From cc3b8d9008c163e55ac2c443fa5fc8f00ae9760b Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Thu, 26 Jun 2025 16:55:32 -0700 Subject: [PATCH] add JavaScript as language info --- .../constants/AutocompleteLanguageInfo.ts | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/core/autocomplete/constants/AutocompleteLanguageInfo.ts b/core/autocomplete/constants/AutocompleteLanguageInfo.ts index 82b169677..1fdbd3e86 100644 --- a/core/autocomplete/constants/AutocompleteLanguageInfo.ts +++ b/core/autocomplete/constants/AutocompleteLanguageInfo.ts @@ -6,12 +6,36 @@ import { } from "../filtering/streamTransforms/lineStream"; export interface AutocompleteLanguageInfo { + /** + * The display name of the language + */ name: string; + /** + * Keywords that show up at the top-level of files. We often use these as stop words or soft breaks + */ topLevelKeywords: string[]; + /** + * The character that prefixes a single line comment + * We use this to format snippets from other files as large comment blocks + */ singleLineComment?: string; + /** + * Semi-colon or other end of line indicator that may be used as a stop char + * or other parsing + */ endOfLine: string[]; + /** + * Strings that indicate we should filter out a line from completion + * Primarily currently used for .ipynb files + */ lineFilters?: LineFilter[]; + /** + * Similar to line filters, but characters. I think. + */ charFilters?: CharacterFilter[]; + /** + * Function that allows cusotmization of whether to use a multi-line completion on a per-language and completion basis + */ useMultiline?: (args: { prefix: string; suffix: string }) => boolean; } @@ -23,6 +47,14 @@ export const Typescript = { endOfLine: [";"], }; +// JavaScript +export const JavaScript = { + name: "JavaScript", + topLevelKeywords: ["function", "class", "module", "export", "import"], + singleLineComment: "//", + endOfLine: [";"], +}; + // Python export const Python = { name: "Python", @@ -336,7 +368,7 @@ export const Markdown: AutocompleteLanguageInfo = { export const LANGUAGES: { [extension: string]: AutocompleteLanguageInfo } = { ts: Typescript, - js: Typescript, + js: JavaScript, tsx: Typescript, json: Json, jsx: Typescript,