Revise flow-type layer

Revise documentation to be spacemacs conform
Reformat code
Make layer correctly declare a dependency on nodejs layer
This commit is contained in:
Maximilian Wolff 2019-12-16 13:23:10 +01:00
parent 06c321d4ac
commit c6d764e041
No known key found for this signature in database
GPG key ID: 2DD07025BFDBD89A
5 changed files with 45 additions and 32 deletions

View file

@ -1,33 +1,50 @@
#+TITLE: flow-type layer
#+TITLE: Flow-type layer
#+TAGS: framework|layer|programming
* Table of Contents
- [[#description][Description]]
- [[#features][Features:]]
- [[#install][Install]]
- [[#key-bindings][Key bindings]]
* Description
This layer adds some [[https://flowtype.org/][flow]] related functionality to Emacs:
- Show the flow-type of the object under the cursor using Eldoc
- Add flow checking to flycheck (based on the flycheck-flow package)
- company-mode completion using company-flow
- "compilation" using =flow status=
This layer adds support for [[https://flowtype.org/][flow]] to spacemacs.
** Features:
- Syntax highlighting
- Linting
- Code-completion
- Eldoc integration for flow-types
- Compilation
* Install
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
add =flow-type= to the existing =dotspacemacs-configuration-layers= list in this
file. Please ensure you already have the flow binary installed, either in
node_modules or in your PATH.
add =flow-type= to the existing =dotspacemacs-configuration-layers= list.
The type under the cursor is shown automatically using eldoc. You may find this
In addition you also need to flow binary installed best with npm like shown below.
#+BEGIN_SRC sh
npm install -g flow
#+END_SRC
The type under the cursor is shown automatically using eldoc. You may find this
a little sluggish, depending on your setup - if so, you can disable it by setting
=flow-type-enable-eldoc-type-info= to =nil=.
#+BEGIN_SRC emacs-lisp
(flow-type :variables flow-type-enable-eldoc-type-info nil)
(flow-type :variables flow-type-enable-eldoc-type-info nil)
#+END_SRC
You can always show types manually using =flow-minor-type-at-pos=,
bound to =,ft= by default.
bound to =SPC m f t= by default.
* flow-minor-mode key bindings
| ,fb | xref-pop-marker-stack | jump back from definition |
| ,fc | flow-minor-status | run `flow status' as a compiler |
| ,fd | flow-minor-jump-to-definition | jump to the definition of the variable under the cursor |
| ,ff | flow-minor-suggest | |
| ,fo | flow-minor-coverage | print coverage information |
| ,ft | flow-minor-type-at-pos | print the type under the cursor to the message line |
* Key bindings
| Key binding | Description |
|-------------+---------------------------------------------------------|
| ~SPC m f b~ | jump back from definition |
| ~SPC m f c~ | run `flow status' as a compiler |
| ~SPC m f d~ | jump to the definition of the variable under the cursor |
| ~SPC m f f~ | show flow suggestions |
| ~SPC m f o~ | print coverage information |

View file

@ -1,6 +1,6 @@
;;; config.el --- flow-type layer configuration file for Spacemacs.
;;
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
;; Copyright (c) 2012-2019 Sylvain Benner & Contributors
;;
;; Author: Mike Holm <coldpour@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs

View file

@ -1,6 +1,6 @@
;;; funcs.el --- flow-type layer functions file for Spacemacs.
;;
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
;; Copyright (c) 2012-2019 Sylvain Benner & Contributors
;;
;; Author: Mike Holm <coldpour@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs

View file

@ -1,6 +1,6 @@
;;; layers.el --- flow-type Layer layers File for Spacemacs
;;
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
;; Copyright (c) 2012-2019 Sylvain Benner & Contributors
;;
;; Author: Holm <holmi09@holmi09mac132>
;; URL: https://github.com/syl20bnr/spacemacs
@ -9,4 +9,4 @@
;;
;;; License: GPLv3
(configuration-layer/declare-layers '(node))
(configuration-layer/declare-layer-dependencies '(node))

View file

@ -1,6 +1,6 @@
;;; packages.el --- flow-type layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;; Copyright (c) 2012-2019 Sylvain Benner & Contributors
;;
;; Author: Mike Holm <coldpour@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
@ -15,8 +15,7 @@
company
(company-flow :toggle (configuration-layer/package-usedp 'company))
(flycheck-flow :toggle (configuration-layer/package-usedp 'flycheck))
eldoc
))
eldoc))
(defun flow-type/init-flow-minor-mode()
(use-package flow-minor-mode
@ -24,8 +23,7 @@
:init
(progn
(add-hook 'js2-mode-hook 'flow-minor-enable-automatically)
(add-hook 'react-mode-hook 'flow-minor-enable-automatically)
)
(add-hook 'react-mode-hook 'flow-minor-enable-automatically))
:config
(progn
;; enable jumping with ,gg
@ -39,8 +37,7 @@
"fc" 'flow-minor-status
"ff" 'flow-minor-suggest
"fo" 'flow-minor-coverage
"ft" 'flow-minor-type-at-pos
))))
"ft" 'flow-minor-type-at-pos))))
(defun flow-type/post-init-eldoc()
(when flow-type-enable-eldoc-type-info
@ -68,5 +65,4 @@
(flycheck-add-mode 'javascript-flow 'react-mode)
;; After running js-flow, run js-eslint
;; doing this in the other order causes a lot of repeated errors!!!
(flycheck-add-next-checker 'javascript-flow 'javascript-eslint)
))))
(flycheck-add-next-checker 'javascript-flow 'javascript-eslint)))))