2017-12-31 01:00:43 +08:00
|
|
|
---
|
|
|
|
title: "SpaceVim lang#dart layer"
|
2021-06-21 20:39:29 +08:00
|
|
|
description: "This layer is for Dart development, provides autocompletion, syntax checking and code formatting for Dart files."
|
2017-12-31 01:00:43 +08:00
|
|
|
---
|
|
|
|
|
2018-06-23 14:37:41 +08:00
|
|
|
# [Available Layers](../../) >> lang#dart
|
2017-12-31 01:00:43 +08:00
|
|
|
|
|
|
|
<!-- vim-markdown-toc GFM -->
|
|
|
|
|
|
|
|
- [Description](#description)
|
|
|
|
- [Features](#features)
|
2018-06-23 14:37:41 +08:00
|
|
|
- [Install](#install)
|
2017-12-31 01:00:43 +08:00
|
|
|
- [Layer](#layer)
|
|
|
|
- [Syntax checking && Code formatting](#syntax-checking--code-formatting)
|
|
|
|
- [Install dart-repl](#install-dart-repl)
|
2021-04-24 22:12:14 +08:00
|
|
|
- [Layer options](#layer-options)
|
2017-12-31 01:00:43 +08:00
|
|
|
- [Key bindings](#key-bindings)
|
|
|
|
- [Inferior REPL process](#inferior-repl-process)
|
|
|
|
- [Running current script](#running-current-script)
|
|
|
|
- [Code formatting](#code-formatting)
|
2020-10-10 09:51:46 +08:00
|
|
|
- [Flutter integration](#flutter-integration)
|
2017-12-31 01:00:43 +08:00
|
|
|
|
|
|
|
<!-- vim-markdown-toc -->
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
2019-02-03 20:51:01 +08:00
|
|
|
This layer is for Dart development.
|
2017-12-31 01:00:43 +08:00
|
|
|
|
|
|
|
## Features
|
|
|
|
|
|
|
|
- code completion
|
|
|
|
- syntax checking
|
|
|
|
- code formatting
|
|
|
|
- REPL
|
|
|
|
- code runner
|
2020-10-10 09:51:46 +08:00
|
|
|
- flutter integration
|
2017-12-31 01:00:43 +08:00
|
|
|
|
2018-06-23 14:37:41 +08:00
|
|
|
## Install
|
2017-12-31 01:00:43 +08:00
|
|
|
|
|
|
|
### Layer
|
|
|
|
|
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]]
|
|
|
|
name = "lang#dart"
|
|
|
|
```
|
2017-12-31 01:00:43 +08:00
|
|
|
|
|
|
|
### Syntax checking && Code formatting
|
|
|
|
|
2020-10-10 09:51:46 +08:00
|
|
|
To enable syntax checking and code formatting in spacevim,
|
|
|
|
you need to install [dart sdk](https://github.com/dart-lang/sdk).
|
2017-12-31 01:00:43 +08:00
|
|
|
|
|
|
|
### Install dart-repl
|
|
|
|
|
2019-02-03 20:51:01 +08:00
|
|
|
You need to install the dart_repl via pub, pub is a build-in package manager in dart-sdk:
|
2017-12-31 01:00:43 +08:00
|
|
|
|
|
|
|
```sh
|
|
|
|
pub global activate dart_repl
|
|
|
|
```
|
|
|
|
|
2021-04-24 22:12:14 +08:00
|
|
|
## Layer options
|
|
|
|
|
|
|
|
- `dart_sdk_path`: Set the path of dart sdk, by default, it is `''`.
|
|
|
|
|
2017-12-31 01:00:43 +08:00
|
|
|
## Key bindings
|
|
|
|
|
|
|
|
### Inferior REPL process
|
|
|
|
|
2019-01-07 21:15:22 +08:00
|
|
|
Start a `dart.repl` inferior REPL process with `SPC l s i`.
|
2017-12-31 01:00:43 +08:00
|
|
|
|
|
|
|
Send code to inferior process commands:
|
|
|
|
|
2019-02-03 20:51:01 +08:00
|
|
|
| Key Bindings | Descriptions |
|
|
|
|
| ------------ | ------------------------------------------------ |
|
|
|
|
| `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 |
|
2017-12-31 01:00:43 +08:00
|
|
|
|
|
|
|
### Running current script
|
|
|
|
|
2021-06-21 20:39:29 +08:00
|
|
|
To run a ruby script, you can press `SPC l r` to run the current file without losing focus, and the result will be shown in a runner buffer.
|
2017-12-31 01:00:43 +08:00
|
|
|
|
|
|
|
### Code formatting
|
|
|
|
|
2021-06-21 20:39:29 +08:00
|
|
|
The code formatting is provided by the `format` layer, and it will run `dartfmt` asynchronously.
|
2020-10-10 09:51:46 +08:00
|
|
|
|
2019-02-03 20:51:01 +08:00
|
|
|
| Key Bindings | Descriptions |
|
|
|
|
| ------------ | --------------------- |
|
|
|
|
| `SPC b f` | format current buffer |
|
2017-12-31 01:00:43 +08:00
|
|
|
|
2020-10-10 09:51:46 +08:00
|
|
|
### Flutter integration
|
2017-12-31 01:00:43 +08:00
|
|
|
|
2021-06-21 20:39:29 +08:00
|
|
|
When editing a dart file, the following key bindings are available for running flutter commands.
|
2017-12-31 01:00:43 +08:00
|
|
|
|
2020-10-10 09:51:46 +08:00
|
|
|
| Key bindings | Descriptions |
|
|
|
|
| ------------ | -------------------------------- |
|
|
|
|
| `SPC l f D` | Display flutter doctor result |
|
|
|
|
| `SPC l f E` | Launch to a flutter emulators id |
|
|
|
|
| `SPC l f d` | Display flutter devices result |
|
|
|
|
| `SPC l f e` | Display flutter emulators list |
|
|
|
|
| `SPC l f l` | Reload flutter app |
|
|
|
|
| `SPC l f r` | Run `flutter run` command |
|
|
|
|
| `SPC l f s` | Restart flutter app |
|
|
|
|
| `SPC l f q` | Quit current flutter process |
|