Table of Contents

dart layer

Table of ContentsClose

dart.png

1 Description

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

1.1 Features:

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

2 Install

2.1 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.

2.2 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-server-sdk-path "~/path/to/dart-sdk/")

2.2.1 Flutter integration

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

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

2.3 LSP

This layer requires an instance of a dart lsp server to work properly. You can execute below command to install the official dart lsp server. Make sure that the executable is available on your path.

pub global activate dart_language_server

3 Configuration

For additional variables check the dart-server documentation.

3.1 Format on save

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

4 Key bindings

4.1 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-server-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 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

4.2 Insert mode

Key binding Description
<tab> Expand previous word using Analyzer if available
C-<tab> Expand including parameters
Key binding Description
q Close popup
gr Execute last command to repopulate buffer

Author: root

Created: 2019-11-10 Sun 14:17

Validate