@@ -13,8 +13,6 @@ import {
1313 useRef ,
1414 useState ,
1515} from "react" ;
16- import { javascript } from "@codemirror/lang-javascript" ;
17- import { python } from "@codemirror/lang-python" ;
1816import ViewLayout from "./layout" ;
1917import { vscodeDark , vscodeLight } from "@uiw/codemirror-theme-vscode" ;
2018import { useTheme } from "next-themes" ;
@@ -38,6 +36,7 @@ import { EditorContext } from "../providers/editor-context-provider";
3836import Loading from "../loading" ;
3937import { ViewTypeEnum } from "@/lib/views/available-views" ;
4038import { View } from "@/lib/views/view" ;
39+ import { getLanguageExtension } from "@/lib/codemirror-extensions/get-language-extension" ;
4140
4241interface CodeEditorViewProps {
4342 width ?: string ;
@@ -427,6 +426,10 @@ const CodeEditorView = forwardRef(
427426 return container ;
428427 }
429428
429+ const cmFileExtension = viewDocument
430+ ? getLanguageExtension ( viewDocument . filePath )
431+ : undefined ;
432+
430433 return (
431434 < ViewLayout width = { width } height = { height } >
432435 < div
@@ -443,14 +446,22 @@ const CodeEditorView = forwardRef(
443446 ref = { cmRef }
444447 value = { viewDocument ?. fileContent }
445448 onChange = { onContentChange }
446- extensions = { [
447- javascript ( { jsx : true } ) ,
448- python ( ) ,
449- codeInlineSuggestionExtension ( {
450- delay : 1000 ,
451- agent : inlineSuggestionAgentRef . current ,
452- } ) ,
453- ] }
449+ extensions = {
450+ cmFileExtension
451+ ? [
452+ cmFileExtension ,
453+ codeInlineSuggestionExtension ( {
454+ delay : 1000 ,
455+ agent : inlineSuggestionAgentRef . current ,
456+ } ) ,
457+ ]
458+ : [
459+ codeInlineSuggestionExtension ( {
460+ delay : 1000 ,
461+ agent : inlineSuggestionAgentRef . current ,
462+ } ) ,
463+ ]
464+ }
454465 theme = { theme }
455466 height = "100%"
456467 style = { {
0 commit comments