add JavaScript as language info

This commit is contained in:
Jacob Kim 2025-06-26 16:55:32 -07:00
parent b4e8431d4d
commit cc3b8d9008

View file

@ -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,