I’ve been doing a lot of JavaScript development lately (yes, vanilla Javascript, pure and simple) and thought that it’s a good opportunity to explore LSP modes on (Doom) Emacs a bit, and I must say that I’m impressed by how smooth the experience is!

Thus, I’ve decided to write a quick “how to” guide (of sorts) detailing my current setup.

Before we get started, make sure you’ve got Node.js, npm, and a JavaScript/TypeScript language server installed on your system. If not, check out JS / TS language server.

  1. Enable LSP in Doom Emacs: First up, open your init.el file (probably located in $DOOM_HOME/doom/init.el) and add (or uncomment) these lines to turn on LSP mode:
(doom!
    :tools
    (lsp +peek)
    (debugger +lsp)
)

I’ve also turned on debugging mode for LSP, just in case.

  1. Enable JavaScript Mode: Next, enable javascript mode with LSP (also in your init.el):
(doom!
    :lang
    (javascript +lsp)
)
  1. Synchronize Doom: Close Doom Emacs and run doom sync to apply your new settings. This step isn’t strictly necessary, but it helps ensure a smooth transition.

  2. Time to Test: Open up Doom Emacs, fire up a JS file, and start coding away with the full-on JavaScript IDE experience powered by Doom and LSP mode!

And there we have it - our very own customizable, feature-packed JavaScript development environment in (Doom) Emacs no less - best of both worlds, so to speak.

Happy coding :)