-
Hello again, I'm trying to work with an extension which provides syntax highlight and lsp for terraform files: I've downloaded it like in the github theme example and able to import it and even get part of it working: But the lsp does not start, or at least not working and I'm not seeing in the htop like I see it when it runs from vscode. I think I'm doing something wrong in this part: I configure the editor the same like in the python example: export const runTerraformWrapper = async () => {
const mainTfUri = vscode.Uri.file('/workspace/main.tf');
const resourcesTfUri = vscode.Uri.file('/workspace/resources.tf');
const fileSystemProvider = new RegisteredFileSystemProvider(false);
fileSystemProvider.registerFile(
new RegisteredMemoryFile(mainTfUri, mainTfCode),
);
fileSystemProvider.registerFile(
new RegisteredMemoryFile(resourcesTfUri, resourcesTfCode),
);
registerFileSystemOverlay(1, fileSystemProvider);
const userConfig = createUserConfig(
'/workspace',
resourcesTfCode,
resourcesTfUri.toString(),
);
const htmlElement = document.getElementById('monaco-editor-root');
const wrapper = new MonacoEditorLanguageClientWrapper();
try {
document
.querySelector('#button-start')
?.addEventListener('click', async () => {
if (wrapper.isStarted()) {
console.warn('Editor was already started!');
} else {
await wrapper.init(userConfig);
// open files, so the LS can pick it up
await vscode.workspace.openTextDocument(resourcesTfUri);
await vscode.workspace.openTextDocument(mainTfUri);
await wrapper.start(htmlElement);
}
});
document
.querySelector('#button-dispose')
?.addEventListener('click', async () => {
await wrapper.dispose();
});
} catch (e) {
console.error(e);
}
}; Would appreciate any help on making the lsp work. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Did you manage to make it work in vscode.dev?
You're in the browser, it's not able to start new process. The extension needs to be browser-compatible. It seems it is (I was able to install it in vscode.dev) but I don't know how it impacts features. I wasn't able to display any intellisense but I don't know what can be expected. |
Beta Was this translation helpful? Give feedback.
-
Thank you for that clarification, my required functionality does not work in vscode.dev in that extension, only syntax highlight. I want to use this package in a desktop app, with similar functionality to vscode, I initially wanted to use monaco-vscode-api but cannot download that extension there. How would one create a desktop app with this package? Maybe you're familiar with what gives vscode the ability to open processes? |
Beta Was this translation helpful? Give feedback.
Unfortunately, the code bundled by monaco-vscode-api (used by monaco-languageclient) is the one designed for the web version of VSCode, so it doesn't include the node extension host. It would be a nice feature to be able to use the code designed for the native version, but it's not done yet. And since I don't have that needs, it's not really planned short-term
What you can probably do is using the server extension host. You have to run the VSCode server, and connect to it. You can have a look at https://github.com/CodinGame/monaco-vscode-api/blob/main/docs/vscode_server.md