Grammarly in Code

NOTE:
Code samples on medium does not work well, so I have have included screenshots. I recommend reading this article on my website: https://znck.dev/blog/2019-grammarly-in-code

Hunt for Grammarly API

No API — yet! We’ll keep you posted! — Grammarly
Screenshot of Google search results for query “Grammarly API Github”

Building the Extension

Screenshot of Yeoman Visual Studio Code Generator running in iTerm2 zsh shell
A naive language server implementation to provide grammar diagnostics using Grammarly API
Screenshot of VS Code editor highlighting grammar issues and displaying Grammarly diagnostics

Peeking into Grammarly API

Screenshot of Chrome DevTools Network tab showing web socket connection to Grammarly API
The first message sent to Grammarly WebSocket server
Ack from Grammarly server for the start message
Initial message sent to Grammarly server for grammar anaylsis
Example insertion and deletion messages from Grammarly Operation Transformation messages

Generationg Operational Transformations

Example implementation of incremental document sync using content change events
Code displaying same message as VS Code change event and Grammarly OT
Code displaying same message as VS Code change event and Grammarly OT
Code displaying same message as VS Code change event and Grammarly OT

Shipping the extension

Screenshot of Grammarly extension on VS Code marketplace

Markdown. Code. Grammarly.

Now, hear me ~~roar~~ write.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store