2017-09-22 20:59:38 +08:00
|
|
|
---
|
|
|
|
title: "SpaceVim lang#javascript layer"
|
2019-07-25 22:04:28 +08:00
|
|
|
description: "This layer provides JavaScript development support for SpaceVim, including code completion, syntax highlighting and syntax checking"
|
2017-09-22 20:59:38 +08:00
|
|
|
---
|
|
|
|
|
2018-06-23 14:37:41 +08:00
|
|
|
# [Available Layers](../../) >> lang#javascript
|
2017-09-22 20:59:38 +08:00
|
|
|
|
|
|
|
<!-- vim-markdown-toc GFM -->
|
|
|
|
|
2017-12-23 14:56:31 +08:00
|
|
|
- [Description](#description)
|
2018-01-03 22:56:15 +08:00
|
|
|
- [Install](#install)
|
2017-12-23 14:56:31 +08:00
|
|
|
- [Features](#features)
|
|
|
|
- [Layer configuration](#layer-configuration)
|
2018-01-13 12:45:21 +08:00
|
|
|
- [Key bindings](#key-bindings)
|
|
|
|
- [Import key bindings](#import-key-bindings)
|
|
|
|
- [Generate key bindings](#generate-key-bindings)
|
2019-02-01 00:00:16 +08:00
|
|
|
- [Code runner](#code-runner)
|
2019-01-30 22:20:22 +08:00
|
|
|
- [Inferior REPL process](#inferior-repl-process)
|
2017-09-22 20:59:38 +08:00
|
|
|
|
|
|
|
<!-- vim-markdown-toc -->
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
|
|
|
This layer is for JavaScript development.
|
|
|
|
|
2018-01-03 22:56:15 +08:00
|
|
|
## Install
|
2017-09-22 20:59:38 +08:00
|
|
|
|
2021-06-21 20:39:29 +08:00
|
|
|
To use this configuration layer, update your custom configuration file with:
|
2018-06-23 14:37:41 +08:00
|
|
|
|
|
|
|
```toml
|
|
|
|
[[layers]]
|
2018-06-27 18:18:11 +08:00
|
|
|
name = "lang#javascript"
|
2018-06-23 14:37:41 +08:00
|
|
|
```
|
2017-09-22 20:59:38 +08:00
|
|
|
|
|
|
|
## Features
|
|
|
|
|
|
|
|
- auto-completion
|
|
|
|
- syntax checking
|
|
|
|
- goto definition
|
2019-02-01 12:37:49 +08:00
|
|
|
- reference finder
|
2017-09-22 20:59:38 +08:00
|
|
|
|
|
|
|
## Layer configuration
|
|
|
|
|
2018-06-27 18:18:11 +08:00
|
|
|
`auto_fix`: auto fix problems when saving files, disabled by default.
|
2017-09-22 20:59:38 +08:00
|
|
|
|
2018-06-27 18:18:11 +08:00
|
|
|
`enable_flow_syntax`: Enable configuration for [flow](https://flow.org/), disabled by default.
|
2018-06-02 09:04:38 +08:00
|
|
|
|
2018-06-27 18:18:11 +08:00
|
|
|
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
|
2018-06-02 09:04:38 +08:00
|
|
|
```
|
|
|
|
|
2021-04-10 19:40:18 +08:00
|
|
|
`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
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2018-01-13 12:45:21 +08:00
|
|
|
## Key bindings
|
|
|
|
|
|
|
|
### Import key bindings
|
|
|
|
|
2019-02-03 20:51:01 +08:00
|
|
|
| Key Bindings | Descriptions |
|
2018-01-13 12:45:21 +08:00
|
|
|
| -------------------- | ------------------------------- |
|
2019-02-19 21:54:05 +08:00
|
|
|
| `<F4>` (Insert/Normal) | Import symbol under cursor |
|
2018-01-13 12:45:21 +08:00
|
|
|
| `SPC j i` | Import symbol under cursor |
|
|
|
|
| `SPC j f` | Import missing symbols |
|
|
|
|
| `SPC j g` | Jump to module under cursor |
|
2019-02-19 21:54:05 +08:00
|
|
|
| `Ctrl-j i` (Insert) | Import symbol under cursor |
|
|
|
|
| `Ctrl-j f` (Insert) | Import missing symbols |
|
|
|
|
| `Ctrl-j g` (Insert) | Jump to module under cursor |
|
2018-01-13 12:45:21 +08:00
|
|
|
|
|
|
|
### Generate key bindings
|
|
|
|
|
|
|
|
| Mode | Key Binding | Description |
|
|
|
|
| ------------- | ----------- | ------------------------------------- |
|
2019-02-19 21:54:05 +08:00
|
|
|
| Normal | `SPC l g d` | Generate JSDoc |
|
2019-01-30 22:20:22 +08:00
|
|
|
|
2019-02-01 00:00:16 +08:00
|
|
|
### Code runner
|
|
|
|
|
2021-06-21 20:39:29 +08:00
|
|
|
To run JavaScript code in current buffer, you can press `SPC l r`. It will run without losing focus,
|
2019-02-01 00:00:16 +08:00
|
|
|
and the result will be shown in a runner buffer.
|
|
|
|
|
2019-01-30 22:20:22 +08:00
|
|
|
### Inferior REPL process
|
|
|
|
|
|
|
|
Start a `node -i` inferior REPL process with `SPC l s i`.
|
|
|
|
|
|
|
|
Send code to inferior process commands:
|
|
|
|
|
2019-02-03 20:51:01 +08:00
|
|
|
| Key Bindings | Descriptions |
|
2019-02-19 21:54:05 +08:00
|
|
|
| ------------ | ------------------------------------------------ |
|
2019-02-03 20:51:01 +08:00
|
|
|
| `SPC l s b` | send buffer and keep code buffer focused |
|
|
|
|
| `SPC l s l` | send line and keep code buffer focused |
|
|
|
|
| `SPC l s s` | send selection text and keep code buffer focused |
|
2019-01-30 22:20:22 +08:00
|
|
|
|