spacemacs/layers/+lang/dart/README.org
smile13241324 58e342f242 [dart] Explain LSP dependency and make layer require LSP layer
The dart layer requires the official LSP server as the
emacs mode alternative is not longer properly maintained.
Therefore I have added some more description of how to
install the server properly and let the layer load
the LSP layer automatically.

In addition I have removed the unsupported variable
`dart-server-enable-analysis-server` from the
documentation.

See https://github.com/bradyt/dart-mode/wiki/LSP for
details.
2019-09-28 23:01:49 +02:00

103 lines
3.5 KiB
Org Mode

#+TITLE: dart layer
#+TAGS: general|layer|multi-paradigm|programming
[[file:img/dart.png]]
* Table of Contents :TOC_5_gh:noexport:
- [[#description][Description]]
- [[#features][Features:]]
- [[#install][Install]]
- [[#layer][Layer]]
- [[#dart-sdk-location][Dart SDK location]]
- [[#flutter-integration][Flutter integration]]
- [[#lsp][LSP]]
- [[#configuration][Configuration]]
- [[#format-on-save][Format on save]]
- [[#key-bindings][Key bindings]]
- [[#normal-mode][Normal mode]]
- [[#insert-mode][Insert mode]]
- [[#popup-screens][Popup screens]]
* 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 =/=.
#+BEGIN_SRC elisp
(dart :variables dart-server-sdk-path "~/path/to/dart-sdk/")
#+END_SRC
*** Flutter integration
Flutter comes with a internal Dart SDK, which can be used to provide all the
integration tools.
#+BEGIN_SRC elisp
(dart :variables dart-server-sdk-path "<flutter-path>/bin/cache/dart-sdk/")
#+END_SRC
** 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=.
#+BEGIN_SRC shell
pub global activate dart_language_server
#+END_SRC
* Configuration
For additional variables check the [[https://github.com/bradyt/dart-server][dart-server]] documentation.
** Format on save
#+BEGIN_SRC elisp
(dart :variables dart-server-format-on-save t)
#+END_SRC
* 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-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 |
** 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 |