spacemacs/layers/+lang/dart/README.org
Bruno Tavares 7841d3ba6a Introduces Dart layer
This is a initial implementation of a Dart later.
A [previous implementation] has been deprecated, using a forked version of `dart-mode`.

This layer uses the [dart-mode] linked on the [Dart tools] page.
The layer works with a Flutter installation as well.

Ideally, we would be able to offer a `lsp` backend as an option to use, instead
of using the Dart Analyzer, but I'm still figuring out how to implement and
integrate this.

This layer has [some] [fixes] to make it work, and it is waiting for upstream to
take patches.

- Resolves https://github.com/syl20bnr/spacemacs/issues/8333
- Resolves https://github.com/syl20bnr/spacemacs/issues/8395
- Resolves https://github.com/syl20bnr/spacemacs/issues/10452

---
[previous implementation]: https://github.com/syl20bnr/spacemacs/pull/8406
[dart-mode]: https://github.com/bradyt/dart-mode
[Dart tools]: https://www.dartlang.org/tools
[some]: https://github.com/bradyt/dart-mode/pull/67
[fixes]: https://github.com/bradyt/dart-mode/pull/66
2019-04-12 18:00:00 +02:00

3.5 KiB

dart layer

/TakeV/spacemacs/media/commit/7841d3ba6a23b71ca0d596c80faacd0d1ef342a8/layers/+lang/dart/img/dart.png

Description

This layer adds support for Dart language, and could be optionally used for Flutter development as well.

Features:

  • Syntax Highlight
  • Error checking with flycheck
  • Go to Definition
  • Dart Analyzer integration
  • Key bindings

Install

Layer

To use this configuration layer, add it to your ~/.spacemacs. You will need to add dart to the existing dotspacemacs-configuration-layers list in this file.

Dart SDK location

The layer itself will use the `dart` executable location if available on the execution path, but it is possible to define the location manually. It should point to the folder, and end with `/`.

  (dart :variables dart-sdk-path "~/path/to/dart-sdk/")

Flutter integration

Flutter comes with a internal Dart SDK, which can be used to provide all the integration tools.

  (dart :variables dart-sdk-path "<flutter-location>/bin/cache/dart-sdk/")

Configuration

For more available variables check dart-mode documentation.

Use analysis server

  (dart :variables dart-enable-analysis-server t)

Format on save

  (dart :variables dart-format-on-save t)

Key bindings

Normal mode

Some of the commands will instantiate a new Dart Analyzer server if necessary, while others work without using a Dart Analyzer connection.

When dart-enable-analysis-server is enabled, most of the commands become Async, and there might be a delay when executing them.

Key Binding Description
SPC m h h, SPC m ? Displays hover information for the current point.
SPC m h b Displays information at point on a new buffer.
gd, SPC m g Go to definition.
SPC m f f Find reference at point.
SPC m f d Find members declarations by name.
SPC m f r Find members references by name.
SPC m f d Find top-level declarations by name.
SPC m = Format buffer

Insert mode

Key Binding Description
<tab> Expand previous word using Analyzer if available
C-<tab> Expand including parameters

Popup screens

Key Binding Description
q Close popup
gr Execute last command to repopulate buffer