Back to Spacevim

SpaceVim lang#javascript layer

docs/layers/lang/javascript.md

2.4.02.7 KB
Original Source

Available Layers >> lang#javascript

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

Description

This layer is for JavaScript development.

Install

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

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

Features

  • auto-completion
  • syntax checking
  • goto definition
  • reference finder

Layer configuration

auto_fix: auto fix problems when saving files, disabled by default.

enable_flow_syntax: Enable configuration for flow, disabled by default.

If you need these features, you can enable them in the layer config:

toml
[[layers]]
name = "lang#javascript"
auto_fix = true
enable_flow_syntax = true

format_on_save: Enable/disable file formatting when saving current javascript file. By default, it is disabled, to enable it:

toml
[[layers]]
    name = 'lang#javascript'
    format_on_save = true

Key bindings

Import key bindings

Key BindingsDescriptions
<F4> (Insert/Normal)Import symbol under cursor
SPC j iImport symbol under cursor
SPC j fImport missing symbols
SPC j gJump to module under cursor
Ctrl-j i (Insert)Import symbol under cursor
Ctrl-j f (Insert)Import missing symbols
Ctrl-j g (Insert)Jump to module under cursor

Generate key bindings

ModeKey BindingDescription
NormalSPC l g dGenerate JSDoc

Code runner

To run JavaScript 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 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