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
This commit is contained in:
parent
12defb470e
commit
7841d3ba6a
|
@ -0,0 +1,94 @@
|
|||
#+TITLE: dart layer
|
||||
|
||||
[[file:img/dart.png]]
|
||||
|
||||
* Table of Contents :TOC_4_gh:noexport:
|
||||
- [[#description][Description]]
|
||||
- [[#features][Features:]]
|
||||
- [[#install][Install]]
|
||||
- [[#layer][Layer]]
|
||||
- [[#dart-sdk-location][Dart SDK location]]
|
||||
- [[#flutter-integration][Flutter integration]]
|
||||
- [[#configuration][Configuration]]
|
||||
- [[#use-analysis-server][Use analysis server]]
|
||||
- [[#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-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-sdk-path "<flutter-location>/bin/cache/dart-sdk/")
|
||||
#+END_SRC
|
||||
|
||||
* Configuration
|
||||
For more available variables check [[https://github.com/bradyt/dart-mode][dart-mode]] documentation.
|
||||
|
||||
** Use analysis server
|
||||
#+BEGIN_SRC elisp
|
||||
(dart :variables dart-enable-analysis-server t)
|
||||
#+END_SRC
|
||||
|
||||
** Format on save
|
||||
#+BEGIN_SRC elisp
|
||||
(dart :variables dart-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-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 |
|
|
@ -0,0 +1,14 @@
|
|||
;;; config.el --- dart Layer configuration File for Spacemacs
|
||||
;;
|
||||
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
||||
;;
|
||||
;; Author: Bruno Tavares <connect+spacemacs@bltavares.com>
|
||||
;; URL: https://github.com/syl20bnr/spacemacs
|
||||
;;
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
;; Variables
|
||||
|
||||
(spacemacs|define-jump-handlers dart-mode)
|
Binary file not shown.
After Width: | Height: | Size: 9.9 KiB |
|
@ -0,0 +1,76 @@
|
|||
;;; packages.el --- dart layer packages file for Spacemacs.
|
||||
;;
|
||||
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
||||
;;
|
||||
;; Author: Bruno Tavares <connect+spacemacs@bltavares.com>
|
||||
;; URL: https://github.com/syl20bnr/spacemacs
|
||||
;;
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; TODO: offer lsp integration
|
||||
(defconst dart-packages
|
||||
'(dart-mode
|
||||
flycheck))
|
||||
|
||||
;; TODO: Remove when https://github.com/bradyt/dart-mode/pull/67
|
||||
(defun dart/trigger-hooks ()
|
||||
(run-hooks 'change-major-mode-after-body-hook))
|
||||
|
||||
(defun dart/show-buffer ()
|
||||
"Shows information at point on a new buffer"
|
||||
(interactive)
|
||||
(dart-show-hover 't))
|
||||
|
||||
(defun dart/init-dart-mode ()
|
||||
(use-package dart-mode
|
||||
:defer t
|
||||
:mode "\\.dart\\'"
|
||||
:init
|
||||
(progn
|
||||
(spacemacs/declare-prefix-for-mode 'dart-mode "mf" "find")
|
||||
(spacemacs/declare-prefix-for-mode 'dart-mode "mh" "help")
|
||||
(spacemacs/set-leader-keys-for-major-mode 'dart-mode
|
||||
"=" 'dart-format
|
||||
"?" 'dart-show-hover
|
||||
"g" 'dart-goto
|
||||
"hh" 'dart-show-hover
|
||||
"hb" 'dart/show-buffer
|
||||
"ff" 'dart-find-refs
|
||||
"fe" 'dart-find-member-decls
|
||||
"fr" 'dart-find-member-refs
|
||||
"fd" 'dart-find-top-level-decls)
|
||||
|
||||
(add-to-list 'spacemacs-jump-handlers-dart-mode '(dart-goto :async t))
|
||||
|
||||
(evil-define-key 'insert dart-mode-map
|
||||
(kbd "<tab>") 'dart-expand
|
||||
(kbd "C-<tab>") 'dart-expand-parameters)
|
||||
|
||||
(evil-set-initial-state 'dart-popup-mode 'motion)
|
||||
(evil-define-key 'motion dart-popup-mode-map
|
||||
(kbd "gr") 'dart-do-it-again)
|
||||
|
||||
(add-hook 'dart-mode-hook #'dart/trigger-hooks))
|
||||
|
||||
:config
|
||||
;; TODO: Remove when fix lands
|
||||
;; https://github.com/bradyt/dart-mode/pull/66
|
||||
(defun dart-formatter-command ()
|
||||
"The command for running the Dart formatter.
|
||||
This can be customized by setting `dart-formatter-command-override'."
|
||||
(or dart-formatter-command-override
|
||||
(when dart-sdk-path
|
||||
(concat dart-sdk-path
|
||||
(file-name-as-directory "bin")
|
||||
(if (memq system-type '(ms-dos windows-nt))
|
||||
"dartfmt.exe"
|
||||
"dartfmt"))))))
|
||||
|
||||
(defun dart/post-init-flycheck ()
|
||||
(spacemacs/add-flycheck-mode 'dart-mode)))
|
||||
|
||||
;;; packages.el ends here
|
Loading…
Reference in New Issue