Back to Spacevim

SpaceVim lang#typescript layer

docs/layers/lang/typescript.md

2.4.02.1 KB
Original Source

Available Layers >> lang#typescript

<!-- vim-markdown-toc GFM --> <!-- vim-markdown-toc -->

Description

This layer is for TypeScript development, including code completion, syntax lint and doc generation.

Installation

To use this configuration layer, update your custom configuration file with:

toml
[[layers]]
  name = "lang#typescript"

If you are using neovim instead of vim, please use npm to install neovim lib:

bash
npm install -g neovim

then in SpaceVim run :UpdateRemotePlugin

To generate doc of typescript file, you need to install lehre

yarn add -D lehre

Install eslint for syntax checking:

npm install -g eslint

Layer options

  • typescript_server_path: set the path of the tsserver.
  • lehre_path: set the path of lehre

Key bindings

Key BindingsDescriptions
SPC l d / Kshow documentation
SPC l erename symbol
SPC l fcode fix
SPC l gdefinition
SPC l iimport
SPC l ttype
SPC l g dgenerate doc
g ddefintion preview
g Dtype definition

Code runner

To run TypeScript code in current buffer, you can press SPC l r. It will run without losing focus, and the result will be shown in a runner buffer.

Inferior REPL process

Start a ts-node -i inferior REPL process with SPC l s i.

Send code to inferior process commands:

Key BindingsDescriptions
SPC l s bsend buffer and keep code buffer focused
SPC l s lsend line and keep code buffer focused
SPC l s ssend selection text and keep code buffer focused