Skip to content

Port clangd language server to WASM, and run it in your browser.

License

Notifications You must be signed in to change notification settings

TypeFox/clangd-in-browser

 
 

Repository files navigation

Clangd in Browser

Finally, I made clangd work in browser. You can now get C++ IntelliSense directly without installing any native compiler or relying on a remote server.

This repo contains a build script for clangd on WebAssembly (TBD), and an example of using clangd WASM module together with Monaco Editor powered by it's Language Client port (thanks TypeFox/monaco-languageclient).

How to build

You can take a look at build.sh for how to build clangd to WASM. Once clangd.wasm generated at public/wasm, you can build those frontend code using pnpm install and pnpm build.

About the example page

I've publish a GitHub Page for demonstrating how clangd works in your browser.

Notice that clangd is a multi-thread program, so we need SharedArrayBuffer -- and more over, a strict context called crossOriginIsolated. GitHub Pages do not send COOP/COEP headers for us to enabling that context, so I served this site through CloudFlare with a custom rule adding those headers. If you want to deploy this project by yourself, make sure correct COOP/COEP header is set on the server side, or you can use coi-serviceworker.

You can pass URL search parameters to control the initial state of this page (see here), or embed it in your website (see here, your website needs to be cross-origin-isolated too)

Acknowledgement

About

Port clangd language server to WASM, and run it in your browser.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages

  • TypeScript 53.7%
  • CSS 29.3%
  • Shell 8.1%
  • HTML 4.8%
  • JavaScript 4.1%