Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Troubles with python/websocket & theme #810

Open
Koxx3 opened this issue Dec 24, 2024 · 4 comments
Open

Troubles with python/websocket & theme #810

Koxx3 opened this issue Dec 24, 2024 · 4 comments

Comments

@Koxx3
Copy link

Koxx3 commented Dec 24, 2024

Hello,

I followed the README for the project initialization (this one : https://github.com/CodinGame/monaco-vscode-api/wiki/Getting-started-guide)

I have been trying for hours to get the react/python working with lsp.

when I run it from your code examples, no problem. I can see exchanges on the websocket.
with the same server, but the code I initialized, after the websocket initialization, I don't see any exchange when I type.

also, impossible to load the theme & get highlight, even after configuring getThemeServiceOverride & getTextmateServiceOverride.

I place my 'refactored' version of your example in this repo :
https://github.com/Koxx3/sdx-front3/tree/with_react_compo

To run :
yarn install; yarn dev

Logs :

Monaco Editor has been mounted.
main.tsx:40 Monaco Editor has been mounted.
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Initializing vscode services. Caller: monaco-editor (93)
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: fileService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: textFileService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: filesConfigurationService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: elevatedFileService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: languageService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: ILanguageStatusService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: environmentService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: loggerService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: logService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: IDefaultLogLevelsService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: textModelService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: keybindingService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: keyboardLayoutService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: commandService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: themeService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: textMateTokenizationFeature
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: configurationService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: contextService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: textResourceConfigurationService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: workspaceEditingService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: workspacesService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: textResourcePropertiesService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: configurationResolverService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: codeEditorService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: editorService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: textEditorService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Loading service: editorGroupsService
chunk-HUJS4XXM.js?v=6f7a96d5:1952 DEBUG Initialization of vscode services completed successfully.
chunk-HUJS4XXM.js?v=6f7a96d5:1961  INFO Init of EditorApp was completed.
chunk-HUJS4XXM.js?v=6f7a96d5:1961  INFO Starting monaco-editor (93)
main.tsx:23 Dirty? false
text: print('Hello World');
t5sdf12$sf
textOriginal: 
chunk-KTKQVFSZ.js?v=6f7a96d5:6148 
        
        
       GET http://localhost:5173/@fs/C:/Users/koxx3/Documents/Coding/node_modules/@codingame/monaco-vscode-theme-defaults-default-extension/resources/package.nls.json 403 (Forbidden)
fetch @ chunk-KTKQVFSZ.js?v=6f7a96d5:6148
read @ chunk-KTKQVFSZ.js?v=6f7a96d5:6163
readFile @ chunk-KTKQVFSZ.js?v=6f7a96d5:6332
(anonymous) @ chunk-KTKQVFSZ.js?v=6f7a96d5:943
readFileUnbuffered @ chunk-KTKQVFSZ.js?v=6f7a96d5:957
doReadFileStream @ chunk-KTKQVFSZ.js?v=6f7a96d5:884
doReadFile @ chunk-KTKQVFSZ.js?v=6f7a96d5:854
readFile @ chunk-KTKQVFSZ.js?v=6f7a96d5:839
await in readFile
getLocalizedMessages @ chunk-YYXAS5XO.js?v=6f7a96d5:7720
await in getLocalizedMessages
translateManifest @ chunk-YYXAS5XO.js?v=6f7a96d5:7738
(anonymous) @ chunk-YYXAS5XO.js?v=6f7a96d5:8201
await in (anonymous)
registerExtension @ chunk-YYXAS5XO.js?v=6f7a96d5:8226
(anonymous) @ monaco-vscode-theme-defaults-default-extension-E3RHADR5.js?v=6f7a96d5:17Understand this errorAI
chunk-KTKQVFSZ.js?v=6f7a96d5:6148 
        
        
       GET http://localhost:5173/@fs/C:/Users/koxx3/Documents/Coding/node_modules/@codingame/monaco-vscode-theme-defaults-default-extension/resources/dark_modern.json 403 (Forbidden)
fetch @ chunk-KTKQVFSZ.js?v=6f7a96d5:6148
read @ chunk-KTKQVFSZ.js?v=6f7a96d5:6163
readFile @ chunk-KTKQVFSZ.js?v=6f7a96d5:6332
(anonymous) @ chunk-KTKQVFSZ.js?v=6f7a96d5:943
readFileUnbuffered @ chunk-KTKQVFSZ.js?v=6f7a96d5:957
doReadFileStream @ chunk-KTKQVFSZ.js?v=6f7a96d5:884
doReadFile @ chunk-KTKQVFSZ.js?v=6f7a96d5:854
readFile @ chunk-KTKQVFSZ.js?v=6f7a96d5:839
await in readFile
readExtensionResource @ chunk-2MOIIFEY.js?v=6f7a96d5:93314
_loadColorTheme @ monaco-vscode-theme-service-override-6ZPH2TZP.js?v=6f7a96d5:1438
load @ monaco-vscode-theme-service-override-6ZPH2TZP.js?v=6f7a96d5:1284
ensureLoaded @ monaco-vscode-theme-service-override-6ZPH2TZP.js?v=6f7a96d5:1267
internalSetColorTheme @ monaco-vscode-theme-service-override-6ZPH2TZP.js?v=6f7a96d5:3997
(anonymous) @ monaco-vscode-theme-service-override-6ZPH2TZP.js?v=6f7a96d5:4028
(anonymous) @ chunk-T3WN2T5T.js?v=6f7a96d5:6989
Promise.then
queue @ chunk-T3WN2T5T.js?v=6f7a96d5:6989
restoreColorTheme @ monaco-vscode-theme-service-override-6ZPH2TZP.js?v=6f7a96d5:4023
(anonymous) @ monaco-vscode-theme-service-override-6ZPH2TZP.js?v=6f7a96d5:3887
_deliver @ chunk-T3WN2T5T.js?v=6f7a96d5:3151
fire @ chunk-T3WN2T5T.js?v=6f7a96d5:3172
(anonymous) @ monaco-vscode-theme-service-override-6ZPH2TZP.js?v=6f7a96d5:2963
_handle @ chunk-D43IWEDJ.js?v=6f7a96d5:173
acceptUsers @ chunk-D43IWEDJ.js?v=6f7a96d5:166
_handleExtensionPoint @ chunk-2MOIIFEY.js?v=6f7a96d5:18796
_doHandleExtensionPoints @ chunk-2MOIIFEY.js?v=6f7a96d5:18745
_deltaExtensions @ chunk-2MOIIFEY.js?v=6f7a96d5:18153
_handleDeltaExtensions @ chunk-2MOIIFEY.js?v=6f7a96d5:18096
await in _handleDeltaExtensions
deltaExtensions @ chunk-2MOIIFEY.js?v=6f7a96d5:93284
throttle.toAdd @ chunk-YYXAS5XO.js?v=6f7a96d5:8176
await in throttle.toAdd
(anonymous) @ chunk-YYXAS5XO.js?v=6f7a96d5:8138
Promise.then
(anonymous) @ chunk-YYXAS5XO.js?v=6f7a96d5:8135
(anonymous) @ chunk-YYXAS5XO.js?v=6f7a96d5:8223
await in (anonymous)
registerExtension @ chunk-YYXAS5XO.js?v=6f7a96d5:8226
(anonymous) @ monaco-vscode-theme-defaults-default-extension-E3RHADR5.js?v=6f7a96d5:17Understand this errorAI
config.ts:50 MonacoLanguageClient {_traceFormat: 'text', _diagnosticQueue: Map(0), _diagnosticQueueState: {…}, _features: Array(46), _dynamicFeatures: Map(44), …}
chunk-HUJS4XXM.js?v=6f7a96d5:1961  INFO languageClientWrapper (Python Language Server Example): Started successfully.
main.tsx:50 Loaded Wrapper status:
Editor: vs.editor.ICodeEditor:1
DiffEditor: undefined
monaco-vscode-theme-service-override-6ZPH2TZP.js?v=6f7a96d5:4001 Uncaught (in promise) Error: Unable to load extension-file://vscode.theme-defaults/extension/themes/dark_modern.json: Forbidden
    at StandaloneWorkbenchThemeService.internalSetColorTheme (monaco-vscode-theme-service-override-6ZPH2TZP.js?v=6f7a96d5:4001:13)
    at async monaco-vscode-theme-service-override-6ZPH2TZP.js?v=6f7a96d5:4028:11
    at async UniqueContainer.value (monaco-vscode-theme-service-override-6ZPH2TZP.js?v=6f7a96d5:3887:11)
internalSetColorTheme @ monaco-vscode-theme-service-override-6ZPH2TZP.js?v=6f7a96d5:4001
await in internalSetColorTheme
(anonymous) @ monaco-vscode-theme-service-override-6ZPH2TZP.js?v=6f7a96d5:4028
(anonymous) @ chunk-T3WN2T5T.js?v=6f7a96d5:6989
Promise.then
queue @ chunk-T3WN2T5T.js?v=6f7a96d5:6989
restoreColorTheme @ monaco-vscode-theme-service-override-6ZPH2TZP.js?v=6f7a96d5:4023
(anonymous) @ monaco-vscode-theme-service-override-6ZPH2TZP.js?v=6f7a96d5:3887
_deliver @ chunk-T3WN2T5T.js?v=6f7a96d5:3151
fire @ chunk-T3WN2T5T.js?v=6f7a96d5:3172
(anonymous) @ monaco-vscode-theme-service-override-6ZPH2TZP.js?v=6f7a96d5:2963
_handle @ chunk-D43IWEDJ.js?v=6f7a96d5:173
acceptUsers @ chunk-D43IWEDJ.js?v=6f7a96d5:166
_handleExtensionPoint @ chunk-2MOIIFEY.js?v=6f7a96d5:18796
_doHandleExtensionPoints @ chunk-2MOIIFEY.js?v=6f7a96d5:18745
_deltaExtensions @ chunk-2MOIIFEY.js?v=6f7a96d5:18153
_handleDeltaExtensions @ chunk-2MOIIFEY.js?v=6f7a96d5:18096
await in _handleDeltaExtensions
deltaExtensions @ chunk-2MOIIFEY.js?v=6f7a96d5:93284
throttle.toAdd @ chunk-YYXAS5XO.js?v=6f7a96d5:8176
await in throttle.toAdd
(anonymous) @ chunk-YYXAS5XO.js?v=6f7a96d5:8138
Promise.then
(anonymous) @ chunk-YYXAS5XO.js?v=6f7a96d5:8135
(anonymous) @ chunk-YYXAS5XO.js?v=6f7a96d5:8223
await in (anonymous)
registerExtension @ chunk-YYXAS5XO.js?v=6f7a96d5:8226
(anonymous) @ monaco-vscode-theme-defaults-default-extension-E3RHADR5.js?v=6f7a96d5:17Understand this errorAI
chunk-HUJS4XXM.js?v=6f7a96d5:1961  INFO getWorker: moduleId: workerMain.js label: TextEditorWorker

Can anybody help please ?

@Koxx3 Koxx3 changed the title Troubles with python/websocket & Troubles with python/websocket & theme Dec 24, 2024
@Koxx3
Copy link
Author

Koxx3 commented Dec 24, 2024

also, if I place a function on websocket "onCall" (https://github.com/Koxx3/sdx-front3/blob/with_react_compo/src/config.ts#L50)

like this :

                            onCall: (languageClient?: MonacoLanguageClient) => {
                                setTimeout(() => {
                                    ['pyright.restartserver', 'pyright.organizeimports'].forEach((cmdName) => {
                                        vscode.commands.registerCommand(cmdName, (...args: unknown[]) => {
                                            languageClient?.sendRequest('workspace/executeCommand', { command: cmdName, arguments: args });
                                        });
                                    });
                                }, 250);
                            },

it fails with this error :

Uncaught Error: Default api is not ready yet, do not forget to import 'vscode/localExtensionHost' and wait for services initialization
    at Object.get (chunk-XCOK4JX4.js?v=6f7a96d5:4707:15)
    at config.ts:46:57
    at Array.forEach (<anonymous>)
    at config.ts:45:90

@Koxx3
Copy link
Author

Koxx3 commented Dec 24, 2024

I managed to get the websocket & highlight working ... but now, I can't edit the text in the editor, and the theme isn't loading.

nota : repo updated

@Koxx3
Copy link
Author

Koxx3 commented Dec 24, 2024

one more step !
editor now works, and I can load content dynamically. great !

1/ when loading the content, it "blinks" because it seem to reload with the white theme

2/ still have this erroor :

textMateWorkerTokenizer.js?v=cd95722d:81 Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'onig')
    at main.js?v=cd95722d:1:184
    at main.js?v=cd95722d:1:189

3/ when I try to format the text, it says :
image

I know pyright support formatting. how to enable it ?

4/ how to add a "save" hotkey action with a callback to do what ever we want ?

@kaisalmen
Copy link
Collaborator

Hi @Koxx3 regarding the formatter you can try this one:
https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter

and use the vsix loading plugin demonstrated here: https://github.com/TypeFox/monaco-languageclient/blob/main/packages/examples/src/appPlayground/main.ts#L25

You have to install the package: https://github.com/TypeFox/monaco-languageclient/blob/main/package.json#L16

Regarding the textmate worker issue try setting this: https://github.com/TypeFox/monaco-languageclient/blob/main/packages/examples/src/python/client/config.ts#L76 to false.

4/ how to add a "save" hotkey action with a callback to do what ever we want ?

Just do it on the client side with the editor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants