New layer coffeescript (extracted from javacript layer)
This commit is contained in:
parent
9123ffc986
commit
ca07366f01
|
@ -0,0 +1,53 @@
|
|||
#+TITLE: CoffeeScript layer
|
||||
|
||||
[[file:img/coffee.png]]
|
||||
|
||||
* Table of Contents :TOC_4_gh:noexport:
|
||||
- [[#description][Description]]
|
||||
- [[#features][Features:]]
|
||||
- [[#install][Install]]
|
||||
- [[#configuration][Configuration]]
|
||||
- [[#linting][Linting]]
|
||||
- [[#key-bindings][Key Bindings]]
|
||||
- [[#repl][REPL]]
|
||||
|
||||
* Description
|
||||
This layer adds support for CoffeeScript language using [[https://github.com/defunkt/coffee-mode][coffee-mode]].
|
||||
|
||||
** Features:
|
||||
- Syntax highlighting
|
||||
- Auto-completion with =auto-completion= layer
|
||||
- Syntax checking and linting with =syntax-checking= layer
|
||||
- =Org-Babel= integration
|
||||
- REPL support
|
||||
|
||||
* Install
|
||||
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
|
||||
add =javascript= to the existing =dotspacemacs-configuration-layers= list in
|
||||
this file.
|
||||
|
||||
* Configuration
|
||||
** Linting
|
||||
To enable linting install [http://www.coffeelint.org/][CoffeeLint] with:
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
npm install -g coffeelint
|
||||
#+END_SRC
|
||||
|
||||
* Key Bindings
|
||||
|
||||
| Key Binding | Description |
|
||||
|-------------+----------------------------------------------------|
|
||||
| ~SPC m c c~ | Compile buffer |
|
||||
| ~SPC m c r~ | Compile region |
|
||||
| ~SPC m T c~ | Toggle compile on save |
|
||||
|
||||
** REPL
|
||||
|
||||
| Key Binding | Description |
|
||||
|-------------+----------------------------------------------------|
|
||||
| ~SPC m '~ | Create or go to REPL |
|
||||
| ~SPC m s b~ | Send buffer to REPL |
|
||||
| ~SPC m s i~ | Create or go to REPL |
|
||||
| ~SPC m s l~ | Send line to REPL |
|
||||
| ~SPC m s r~ | send current region to the REPL and stay in buffer |
|
|
@ -0,0 +1,22 @@
|
|||
;;; funcs.el --- CoffeeScript Layer functions File for Spacemacs
|
||||
;;
|
||||
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
||||
;;
|
||||
;; Author: Muneeb Shaikh <muneeb@reversehack.in>
|
||||
;; URL: https://github.com/syl20bnr/spacemacs
|
||||
;;
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
(defun spacemacs//coffeescript-indent-hook ()
|
||||
(setq indent-line-function 'spacemacs//coffeescript-indent
|
||||
evil-shift-width coffee-tab-width))
|
||||
|
||||
(defun spacemacs//coffeescript-indent ()
|
||||
(if (coffee-line-wants-indent)
|
||||
;; We need to insert an additional tab because
|
||||
;; the last line was special.
|
||||
(coffee-insert-spaces (+ (coffee-previous-indent) coffee-tab-width))
|
||||
;; otherwise keep at the same indentation level
|
||||
(coffee-insert-spaces (coffee-previous-indent))))
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1,12 @@
|
|||
;;; layers.el --- CoffeeScript Layer layers File for Spacemacs
|
||||
;;
|
||||
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
||||
;;
|
||||
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
||||
;; URL: https://github.com/syl20bnr/spacemacs
|
||||
;;
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
(configuration-layer/declare-layers '(node))
|
|
@ -0,0 +1,50 @@
|
|||
;;; packages.el --- CoffeeScript Layer packages File for Spacemacs
|
||||
;;
|
||||
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
||||
;;
|
||||
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
||||
;; URL: https://github.com/syl20bnr/spacemacs
|
||||
;;
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
(setq coffeescript-packages
|
||||
'(
|
||||
add-node-modules-path
|
||||
coffee-mode
|
||||
company
|
||||
flycheck
|
||||
))
|
||||
|
||||
(defun coffeescript/post-init-add-node-modules-path ()
|
||||
(add-hook 'coffee-mode-hook #'add-node-modules-path))
|
||||
|
||||
(defun coffeescript/init-coffee-mode ()
|
||||
(use-package coffee-mode
|
||||
:defer t
|
||||
:init
|
||||
(progn
|
||||
(spacemacs/register-repl 'coffee-mode 'coffee-repl "coffeescript")
|
||||
;; keybindings
|
||||
(spacemacs/declare-prefix-for-mode 'coffee-mode "mc" "compile")
|
||||
(spacemacs/declare-prefix-for-mode 'coffee-mode "ms" "REPL")
|
||||
(spacemacs/set-leader-keys-for-major-mode 'coffee-mode
|
||||
"'" 'coffee-repl
|
||||
"cc" 'coffee-compile-buffer
|
||||
"cr" 'coffee-compile-region
|
||||
"sb" 'coffee-send-buffer
|
||||
"si" 'coffee-repl
|
||||
"sl" 'coffee-send-line
|
||||
"sr" 'coffee-send-region
|
||||
"Tc" 'coffee-cos-mode)
|
||||
;; indent to right position after `evil-open-below' and `evil-open-above'
|
||||
(add-hook 'coffee-mode-hook 'spacemacs//coffeescript-indent-hook))))
|
||||
|
||||
(defun coffeescript/post-init-company ()
|
||||
(spacemacs|add-company-backends
|
||||
:backends company-capf
|
||||
:modes coffee-mode))
|
||||
|
||||
(defun coffeescript/post-init-flycheck ()
|
||||
(spacemacs/enable-flycheck 'coffee-mode))
|
|
@ -32,7 +32,7 @@ This layer adds support for the JavaScript language using [[https://github.com/m
|
|||
- Multiple backends support: Tern and LSP
|
||||
- Smart code folding
|
||||
- Refactoring: done using [[https://github.com/magnars/js2-refactor.el][js2-refactor]].
|
||||
- Auto-completion and documentation: provided by [[http://ternjs.net/][tern]]
|
||||
- Auto-completion and documentation
|
||||
- CoffeeScript support
|
||||
- Formatting with [[https://github.com/yasuyk/web-beautify][web-beautify]]
|
||||
- Get the path to a JSON value with [[https://github.com/Sterlingg/json-snatcher][json-snatcher]]
|
||||
|
|
|
@ -113,17 +113,6 @@
|
|||
"Lazy load js2-refactor"
|
||||
(require 'js2-refactor))
|
||||
|
||||
|
||||
;; coffee
|
||||
|
||||
(defun javascript/coffee-indent ()
|
||||
(if (coffee-line-wants-indent)
|
||||
;; We need to insert an additional tab because
|
||||
;; the last line was special.
|
||||
(coffee-insert-spaces (+ (coffee-previous-indent) coffee-tab-width))
|
||||
;; otherwise keep at the same indentation level
|
||||
(coffee-insert-spaces (coffee-previous-indent))))
|
||||
|
||||
|
||||
;; skewer
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
(setq javascript-packages
|
||||
'(
|
||||
add-node-modules-path
|
||||
coffee-mode
|
||||
company
|
||||
(company-tern :requires company)
|
||||
counsel-gtags
|
||||
|
@ -39,34 +38,9 @@
|
|||
(defun javascript/post-init-add-node-modules-path ()
|
||||
(spacemacs/add-to-hooks #'add-node-modules-path
|
||||
'(css-mode-hook
|
||||
coffee-mode-hook
|
||||
js2-mode-hook
|
||||
json-mode-hook)))
|
||||
|
||||
(defun javascript/init-coffee-mode ()
|
||||
(use-package coffee-mode
|
||||
:defer t
|
||||
:init
|
||||
(progn
|
||||
(spacemacs/register-repl 'coffee-mode 'coffee-repl "coffeescript")
|
||||
;; keybindings
|
||||
(spacemacs/declare-prefix-for-mode 'coffee-mode "mc" "compile")
|
||||
(spacemacs/declare-prefix-for-mode 'coffee-mode "ms" "REPL")
|
||||
(spacemacs/set-leader-keys-for-major-mode 'coffee-mode
|
||||
"'" 'coffee-repl
|
||||
"cc" 'coffee-compile-buffer
|
||||
"cr" 'coffee-compile-region
|
||||
"sb" 'coffee-send-buffer
|
||||
"sl" 'coffee-send-line
|
||||
"si" 'coffee-repl
|
||||
"sr" 'coffee-send-region
|
||||
"Tc" 'coffee-cos-mode)
|
||||
;; indent to right position after `evil-open-below' and `evil-open-above'
|
||||
(add-hook 'coffee-mode-hook
|
||||
'(lambda ()
|
||||
(setq indent-line-function 'javascript/coffee-indent
|
||||
evil-shift-width coffee-tab-width))))))
|
||||
|
||||
(defun javascript/post-init-counsel-gtags ()
|
||||
(spacemacs/counsel-gtags-define-keys-for-mode 'js2-mode))
|
||||
|
||||
|
@ -74,18 +48,14 @@
|
|||
(add-hook `js2-mode `turn-on-evil-matchit-mode))
|
||||
|
||||
(defun javascript/post-init-company ()
|
||||
(add-hook 'js2-mode-local-vars-hook #'spacemacs//javascript-setup-company)
|
||||
(when (configuration-layer/package-used-p 'coffee-mode)
|
||||
(spacemacs|add-company-backends
|
||||
:backends company-capf
|
||||
:modes coffee-mode)))
|
||||
(add-hook 'js2-mode-local-vars-hook #'spacemacs//javascript-setup-company))
|
||||
|
||||
(defun javascript/init-company-tern ()
|
||||
(use-package company-tern
|
||||
:defer t))
|
||||
|
||||
(defun javascript/post-init-flycheck ()
|
||||
(dolist (mode '(coffee-mode js2-mode json-mode))
|
||||
(dolist (mode '(js2-mode json-mode))
|
||||
(spacemacs/enable-flycheck mode)))
|
||||
|
||||
(defun javascript/post-init-ggtags ()
|
||||
|
|
Loading…
Reference in New Issue