Using code editors with devbox

A code editor is a piece of software designed specifically for editing source code of computer programs. It may be a standalone application or it may be built into an IDE. There are two main approaches an editor may take to implement language specific functionality:

  • Build everything from scratch except the compiler/interpreter, for example, JetBrain IDEs do this
  • Integrate tooling written by the language authors over LSP and DAP protocols, for example, VS Code does this

Regardless of the approach chosen, an editor has to at least download a compiler/interpreter and thus must include a downloader. Most downloaders have 2 major flaws: not allowing to specify versions and installing everything user-wide and thus forcing all projects to use the exact same versions of language and its tooling.

Successful download means that software is put on PATH and does not have to be downloaded again, which means that if devbox had placed it in advance, the downloader would have never been triggered. For example, each project that uses Go can specify versions of Go tooling just by going to that project's directory and executing:

devbox add [email protected] [email protected] [email protected]

In order for an editor to use dependencies specified in devbox, it needs to automatically enter the development shell upon opening the project. This can be done by installing direnv and executing the following command to enable it for the project:

devbox generate direnv

Depending on the editor, a direnv plugin may be needed as well.