react: fix tern and docs
This commit is contained in:
parent
f88a7889a4
commit
cb55e3da3c
|
@ -8,13 +8,9 @@
|
|||
- [[#install][Install]]
|
||||
- [[#optional-configuration][Optional Configuration]]
|
||||
- [[#key-bindings][Key Bindings]]
|
||||
- [[#js2-mode][js2-mode]]
|
||||
- [[#folding-js2-mode][Folding (js2-mode)]]
|
||||
- [[#refactoring-js2-refactor][Refactoring (js2-refactor)]]
|
||||
- [[#formatting-web-beautify][Formatting (web-beautify)]]
|
||||
- [[#documentation-js-doc][Documentation (js-doc)]]
|
||||
- [[#auto-complete-and-documentation-tern][Auto-complete and documentation (tern)]]
|
||||
- [[#json][JSON]]
|
||||
|
||||
* Description
|
||||
|
||||
|
@ -110,60 +106,6 @@ And if you want to have 2 space indent also for element's attributes, concatenat
|
|||
|
||||
* Key Bindings
|
||||
|
||||
** js2-mode
|
||||
|
||||
| Key Binding | Description |
|
||||
|-------------+-------------------------------------|
|
||||
| ~SPC m w~ | toggle js2-mode warnings and errors |
|
||||
|
||||
** Folding (js2-mode)
|
||||
|
||||
| Key Binding | Description |
|
||||
|-------------+--------------------------|
|
||||
| ~SPC m z c~ | hide element |
|
||||
| ~SPC m z o~ | show element |
|
||||
| ~SPC m z r~ | show all element |
|
||||
| ~SPC m z e~ | toggle hide/show element |
|
||||
| ~SPC m z F~ | toggle hide functions |
|
||||
| ~SPC m z C~ | toggle hide comments |
|
||||
|
||||
** Refactoring (js2-refactor)
|
||||
|
||||
Bindings should match the plain emacs assignments.
|
||||
|
||||
| Key Binding | Description |
|
||||
|---------------+----------------------------------------------------------------------------------------------------------------|
|
||||
| ~SPC x m j~ | move line down, while keeping commas correctly placed |
|
||||
| ~SPC x m k~ | move line up, while keeping commas correctly placed |
|
||||
| ~SPC m k~ | deletes to the end of the line, but does not cross semantic boundaries |
|
||||
| ~SPC m r 3 i~ | converts ternary operator to if-statement |
|
||||
| ~SPC m r a g~ | creates a =/* global */= annotation if it is missing, and adds var to point to it |
|
||||
| ~SPC m r a o~ | replaces arguments to a function call with an object literal of named arguments |
|
||||
| ~SPC m r b a~ | moves the last child out of current function, if-statement, for-loop or while-loop |
|
||||
| ~SPC m r c a~ | converts a multiline array to one line |
|
||||
| ~SPC m r c o~ | converts a multiline object literal to one line |
|
||||
| ~SPC m r c u~ | converts a multiline function to one line (expecting semicolons as statement delimiters) |
|
||||
| ~SPC m r e a~ | converts a one line array to multiline |
|
||||
| ~SPC m r e f~ | extracts the marked expressions into a new named function |
|
||||
| ~SPC m r e m~ | extracts the marked expressions out into a new method in an object literal |
|
||||
| ~SPC m r e o~ | converts a one line object literal to multiline |
|
||||
| ~SPC m r e u~ | converts a one line function to multiline (expecting semicolons as statement delimiters) |
|
||||
| ~SPC m r e v~ | takes a marked expression and replaces it with a var |
|
||||
| ~SPC m r i g~ | creates a shortcut for a marked global by injecting it in the wrapping immediately invoked function expression |
|
||||
| ~SPC m r i p~ | changes the marked expression to a parameter in a local function |
|
||||
| ~SPC m r i v~ | replaces all instances of a variable with its initial value |
|
||||
| ~SPC m r l p~ | changes a parameter to a local var in a local function |
|
||||
| ~SPC m r l t~ | adds a console.log statement for what is at point (or region) |
|
||||
| ~SPC m r r v~ | renames the variable on point and all occurrences in its lexical scope |
|
||||
| ~SPC m r s l~ | moves the next statement into current function, if-statement, for-loop, while-loop |
|
||||
| ~SPC m r s s~ | splits a =String= |
|
||||
| ~SPC m r s v~ | splits a =var= with multiple vars declared into several =var= statements |
|
||||
| ~SPC m r t f~ | toggle between function declaration and function expression |
|
||||
| ~SPC m r u w~ | replaces the parent statement with the selected region |
|
||||
| ~SPC m r v t~ | changes local =var a= to be =this.a= instead |
|
||||
| ~SPC m r w i~ | wraps the entire buffer in an immediately invoked function expression |
|
||||
| ~SPC m r w l~ | wraps the region in a for-loop |
|
||||
|
||||
** Formatting (web-beautify)
|
||||
|
||||
| Key Binding | Description |
|
||||
|
@ -192,8 +134,3 @@ You can check more [[https://github.com/mooz/js-doc/][here]]
|
|||
| ~SPC m h t~ | find the type of the thing under the cursor |
|
||||
| ~SPC m r r V~ | rename variable under the cursor using tern |
|
||||
|
||||
** JSON
|
||||
|
||||
| Key Binding | Description |
|
||||
|-------------+------------------------------------|
|
||||
| ~SPC m h p~ | Get the path of the value at point |
|
||||
|
|
|
@ -63,7 +63,28 @@
|
|||
(add-hook 'react-mode-hook #'smartparens-strict-mode)
|
||||
(add-hook 'react-mode-hook #'smartparens-mode)))
|
||||
|
||||
(defun react/post-init-tern ()
|
||||
(defun react/init-tern ()
|
||||
(defun react//tern-detect ()
|
||||
"Detect tern binary and warn if not found."
|
||||
(let ((found (executable-find "tern")))
|
||||
(unless found
|
||||
(spacemacs-buffer/warning "tern binary not found!"))
|
||||
found))
|
||||
(use-package tern
|
||||
:defer t
|
||||
:if (react//tern-detect)
|
||||
:init (add-hook 'react-mode-hook 'tern-mode)
|
||||
:config
|
||||
(progn
|
||||
(when javascript-disable-tern-port-files
|
||||
(add-to-list 'tern-command "--no-port-file" 'append))
|
||||
(spacemacs/set-leader-keys-for-major-mode 'react-mode "rrV" 'tern-rename-variable)
|
||||
(spacemacs/set-leader-keys-for-major-mode 'react-mode "hd" 'tern-get-docs)
|
||||
(spacemacs/set-leader-keys-for-major-mode 'react-mode "ht" 'tern-get-type)
|
||||
(spacemacs/set-leader-keys-for-major-mode 'react-mode "gg" 'tern-find-definition)
|
||||
(spacemacs/set-leader-keys-for-major-mode 'react-mode "gG" 'tern-find-definition-by-name)
|
||||
(spacemacs/set-leader-keys-for-major-mode 'react-mode (kbd " C-g") 'tern-pop-find-definition)
|
||||
(spacemacs/set-leader-keys-for-major-mode 'react-mode "ht" 'tern-get-type)))
|
||||
(add-hook 'react-mode-hook 'tern-mode))
|
||||
|
||||
(defun react/post-init-web-beautify ()
|
||||
|
|
Loading…
Reference in New Issue