Set up your environment

The Deno CLI contains a lot of the tools that are commonly needed for developing applications, including a full language server to help power your IDE of choice. Installing is all you need to do to make these tools available to you.

Outside using Deno with your favorite IDE, this section also documents shell completions and environment variables.

Using an editor/IDE

There is broad support for Deno in editors/IDEs. The following sections provide information about how to use Deno with editors. Most editors integrate directly into Deno using the Language Server Protocol and the language server that is integrated into the Deno CLI.

If you are trying to write or support a community integration to the Deno language server, there is some documentation located in the Deno CLI code repository, but also feel free to join the Discord community in the #dev-lsp channel.

Visual Studio Code

There is an official extension for Visual Studio Code called vscode_deno. When installed, it will connect to the language server built into the Deno CLI.

Because most people work in mixed environments, the extension does not enable a workspace as Deno enabled by default, and it requires that the "deno.enable" flag to be set. You can change the settings yourself, or you can choose Deno: Initialize Workspace Configuration from the command palette to enable your project.

More information can be found in the Using Visual Studio Code section of the manual.

JetBrains IDEs

You can get support for Deno in WebStorm and other JetBrains IDEs, including PhpStorm, IntelliJ IDEA Ultimate, and PyCharm Professional. For this, install the official Deno plugin from Preferences / Settings | Plugins - Marketplace.

Check out this blog post to learn more about how to get started with Deno.

vim/Neovim

Deno is well supported on both vim and Neovim via coc.nvim, vim-easycomplete and ALE. coc.nvim offers plugins to integrate to the Deno language server while ALE supports it out of the box. The built-in language server in Neovim also supports Deno. The built-in language server protocol in Neovim also supports Deno.

Neovim 0.6+ and nvim-lspconfig

Neovim has supported Deno’s language server since version 0.5, but recent changes to Deno mean that now Neovim 0.6 or newer is needed.

To use the Deno language server install nvim-lspconfig and follow the instructions to enable the supplied Deno configuration.

Deno’s linting is not supported out of the box, but assuming you are using the on_attach helper function from the basic setup example, the default of lint = false can be overridden as follows:

  1. nvim_lsp.denols.setup {
  2. on_attach = on_attach,
  3. init_options = {
  4. lint = true,
  5. },
  6. }

Note that if you also have tsserver as an LSP client, you may run into having issues where both tsserver and denols are attached to your current buffer. To resolve this, make sure to set some unique root_dir for both tsserver and denols. Here is an example of such a configuration:

  1. nvim_lsp.denols.setup {
  2. on_attach = on_attach,
  3. root_dir = nvim_lsp.util.root_pattern("deno.json"),
  4. init_options = {
  5. lint = true,
  6. },
  7. }
  8. nvim_lsp.tsserver.setup {
  9. on_attach = on_attach,
  10. root_dir = nvim_lsp.util.root_pattern("package.json"),
  11. init_options = {
  12. lint = true,
  13. },
  14. }

Also note here that for a Deno project, the example above assumes that there exists a deno.json file at the root of the project.

coc.nvim

Once you have coc.nvim installed installed, you need to install the required plugin via :CocInstall coc-deno.

Once the plugin is installed and you want to enable Deno for a workspace, run the command :CocCommand deno.initializeWorkspace and you should be able to utilize commands like gd (goto definition) and gr (go/find references).

ALE

ALE supports Deno via the Deno language server out of the box and in many uses cases doesn’t require additional configuration. Once you have ALE installed you can perform the command :help ale-typescript-deno to get information on the configuration options available.

For more information on how to setup ALE (like key bindings) refer to the official documentation.

Vim-EasyComplete

Vim-EasyComplete supports Deno without any other configuration. Once you have vim-easycomplete installed, you need install deno via :InstallLspServer deno if you havn’t installed deno. You can get more information from official documentation.

Emacs

lsp-mode

Emacs supports Deno via the Deno language server using lsp-mode. Once lsp-mode is installed it should support Deno, which can be configured to support various settings.

eglot

You can also use built-in Deno language server by using eglot.

An example configuration for Deno via eglot:

  1. (add-to-list 'eglot-server-programs '((js-mode typescript-mode) . (eglot-deno "deno" "lsp")))
  2. (defclass eglot-deno (eglot-lsp-server) ()
  3. :documentation "A custom class for deno lsp.")
  4. (cl-defmethod eglot-initialization-options ((server eglot-deno))
  5. "Passes through required deno initialization options"
  6. (list :enable t
  7. :lint t))

Atom

The Atom editor supports integrating with the Deno language server via the atom-ide-deno package. atom-ide-deno requires that the Deno CLI be installed and the atom-ide-base package to be installed as well.

Sublime Text

Sublime Text supports connecting to the Deno language server via the LSP package. You may also want to install the TypeScript package to get full syntax highlighting.

Once you have the LSP package installed, you will want to add configuration to your .sublime-project configuration like the below:

  1. {
  2. "settings": {
  3. "LSP": {
  4. "deno": {
  5. "command": [
  6. "deno",
  7. "lsp"
  8. ],
  9. "initializationOptions": {
  10. // "config": "", // Sets the path for the config file in your project
  11. "enable": true,
  12. // "importMap": "", // Sets the path for the import-map in your project
  13. "lint": true,
  14. "unstable": false
  15. },
  16. "enabled": true,
  17. "languages": [
  18. {
  19. "languageId": "javascript",
  20. "scopes": ["source.js"],
  21. "syntaxes": [
  22. "Packages/Babel/JavaScript (Babel).sublime-syntax",
  23. "Packages/JavaScript/JavaScript.sublime-syntax"
  24. ]
  25. },
  26. {
  27. "languageId": "javascriptreact",
  28. "scopes": ["source.jsx"],
  29. "syntaxes": [
  30. "Packages/Babel/JavaScript (Babel).sublime-syntax",
  31. "Packages/JavaScript/JavaScript.sublime-syntax"
  32. ]
  33. },
  34. {
  35. "languageId": "typescript",
  36. "scopes": ["source.ts"],
  37. "syntaxes": [
  38. "Packages/TypeScript-TmLanguage/TypeScript.tmLanguage",
  39. "Packages/TypeScript Syntax/TypeScript.tmLanguage"
  40. ]
  41. },
  42. {
  43. "languageId": "typescriptreact",
  44. "scopes": ["source.tsx"],
  45. "syntaxes": [
  46. "Packages/TypeScript-TmLanguage/TypeScriptReact.tmLanguage",
  47. "Packages/TypeScript Syntax/TypeScriptReact.tmLanguage"
  48. ]
  49. }
  50. ]
  51. }
  52. }
  53. }
  54. }

Nova

The Nova editor can integrate the Deno language server via the Deno extension.

GitHub Codespaces

GitHub Codespaces allows you develop fully online or remotely on your local machine without needing to configure or install Deno. It is currently in early access.

If a project is a Deno enabled project and contains the .devcontainer configuration as part of the repository, opening the project in GitHub Codespaces should just “work”. If you are starting a new project, or you want to add Deno support to an existing code space, it can be added by selecting the Codespaces: Add Development Container Configuration Files... from the command pallet and then selecting Show All Definitions... and then searching for the Deno definition.

Once selected, you will need to rebuild your container so that the Deno CLI is added to the container. After the container is rebuilt, the code space will support Deno.

Kakoune

Kakoune supports connecting to the Deno language server via the kak-lsp client. Once kak-lsp is installed an example of configuring it up to connect to the Deno language server is by adding the following to your kak-lsp.toml:

  1. [language.typescript]
  2. filetypes = ["typescript", "javascript"]
  3. roots = [".git"]
  4. command = "deno"
  5. args = ["lsp"]
  6. [language.typescript.settings.deno]
  7. enable = true
  8. lint = true

Shell completions

Built into the Deno CLI is support to generate shell completion information for the CLI itself. By using deno completions <shell>, the Deno CLI will output to stdout the completions. Current shells that are supported:

  • bash
  • elvish
  • fish
  • powershell
  • zsh

bash example

Output the completions and add them to the environment:

  1. > deno completions bash > /usr/local/etc/bash_completion.d/deno.bash
  2. > source /usr/local/etc/bash_completion.d/deno.bash

PowerShell example

Output the completions:

  1. > deno completions powershell >> $profile
  2. > .$profile

This will be create a Powershell profile at $HOME\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1, and it will be run whenever you launch the PowerShell.

zsh example

You should have a directory where the completions can be saved:

  1. > mkdir ~/.zsh

Then output the completions:

  1. > deno completions zsh > ~/.zsh/_deno

And ensure the completions get loaded in your ~/.zshrc:

  1. fpath=(~/.zsh $fpath)
  2. autoload -Uz compinit
  3. compinit -u

If after reloading your shell and completions are still not loading, you may need to remove ~/.zcompdump/ to remove previously generated completions and then compinit to generate them again.

zsh example with ohmyzsh and antigen

ohmyzsh is a configuration framework for zsh and can make it easier to manage your shell configuration. antigen is a plugin manager for zsh.

Create the directory to store the completions and output the completions:

  1. > mkdir ~/.oh-my-zsh/custom/plugins/deno
  2. > deno completions zsh > ~/.oh-my-zsh/custom/plugins/deno/_deno

Then your .zshrc might look something like this:

  1. source /path-to-antigen/antigen.zsh
  2. # Load the oh-my-zsh's library.
  3. antigen use oh-my-zsh
  4. antigen bundle deno

fish example

Output the completions to a deno.fish file into the completions directory in the fish config folder:

  1. deno completions fish > ~/.config/fish/completions/deno.fish

Environment variables

There are several environment variables which can impact the behavior of Deno:

  • DENO_AUTH_TOKENS - a list of authorization tokens which can be used to allow Deno to access remote private code. See the Private modules and repositories section for more details.
  • DENO_TLS_CA_STORE - a list of certificate stores which will be used when establishing TLS connections. The available stores are mozilla and system. You can specify one, both or none. The order you specify the store determines the order in which certificate chains will be attempted to resolved. The default value is mozilla. The mozilla store will use the bundled mozilla certs provided by webpki-roots. The system store will use your platforms native certificate store. The exact set of mozilla certs will depend the version of Deno you are using. If you specify no certificate stores, then no trust will be given to any TLS connection without also specifying DENO_CERT or --cert or specifying a specific certificate per TLS connection.
  • DENO_CERT - load a certificate authority from a PEM encoded file. This “overrides” the --cert option. See the Proxies section for more information.
  • DENO_DIR - this will set the directory where cached information from the CLI is stored. This includes items like cached remote modules, cached transpiled modules, language server cache information and persisted data from local storage. This defaults to the operating systems default cache location and then under the deno path.
  • DENO_INSTALL_ROOT - When using deno install where the installed scripts are stored. This defaults to $HOME/.deno/bin.
  • DENO_FUTURE_CHECK - Opt-in to the upcoming behavior of the deno run subcommand that doesn’t perform type-checking by default.
  • DENO_WEBGPU_TRACE - The directory to use for WebGPU traces.
  • HTTP_PROXY - The proxy address to use for HTTP requests. See the Proxies section for more information.
  • HTTPS_PROXY - The proxy address to use for HTTPS requests. See the Proxies section for more information.
  • NO_COLOR - If set, this will cause the Deno CLI to not send ANSI color codes when writing to stdout and stderr. See the website https://no-color.org/ for more information on this de facto standard. The value of this flag can be accessed at runtime without permission to read the environment variables by checking the value of Deno.noColor.
  • NO_PROXY - Indicates hosts which should bypass the proxy set in the other environment variables. See the Proxies section for more information.