2015-08-01 14:58:51 +00:00
|
|
|
;;; packages.el --- Markdown Layer packages File for Spacemacs
|
2015-02-10 03:13:09 +00:00
|
|
|
;;
|
|
|
|
;; Copyright (c) 2012-2014 Sylvain Benner
|
|
|
|
;; Copyright (c) 2014-2015 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
|
|
|
|
|
2015-04-19 03:40:24 +00:00
|
|
|
(setq markdown-packages
|
2015-02-10 03:13:09 +00:00
|
|
|
'(
|
2015-08-27 01:55:28 +00:00
|
|
|
emoji-cheat-sheet-plus
|
2015-02-10 03:13:09 +00:00
|
|
|
markdown-mode
|
|
|
|
markdown-toc
|
2015-05-06 23:28:17 +00:00
|
|
|
mmm-mode
|
2015-08-18 22:27:49 +00:00
|
|
|
company
|
|
|
|
company-emoji
|
2015-04-19 03:40:24 +00:00
|
|
|
))
|
2015-02-10 03:13:09 +00:00
|
|
|
|
2015-08-27 01:55:28 +00:00
|
|
|
(defun markdown/post-init-emoji-cheat-sheet-plus ()
|
|
|
|
(add-hook 'markdown-mode-hook 'emoji-cheat-sheet-plus-display-mode))
|
|
|
|
|
2015-02-10 03:13:09 +00:00
|
|
|
(defun markdown/init-markdown-mode ()
|
|
|
|
(use-package markdown-mode
|
2015-04-03 22:55:47 +00:00
|
|
|
:mode ("\\.m[k]d" . markdown-mode)
|
2015-02-10 03:13:09 +00:00
|
|
|
:defer t
|
2015-04-03 04:28:13 +00:00
|
|
|
:init (add-hook 'markdown-mode-hook 'smartparens-mode)
|
2015-02-10 03:13:09 +00:00
|
|
|
:config
|
2015-02-16 22:05:19 +00:00
|
|
|
(progn
|
2015-05-13 17:15:14 +00:00
|
|
|
;; Insert key for org-mode and markdown a la C-h k
|
|
|
|
;; from SE endless http://emacs.stackexchange.com/questions/2206/i-want-to-have-the-kbd-tags-for-my-blog-written-in-org-mode/2208#2208
|
|
|
|
(defun spacemacs/insert-keybinding-markdown (key)
|
|
|
|
"Ask for a key then insert its description.
|
|
|
|
Will work on both org-mode and any mode that accepts plain html."
|
|
|
|
(interactive "kType key sequence: ")
|
2015-06-10 16:44:30 +00:00
|
|
|
(let* ((tag "~%s~"))
|
2015-05-13 17:15:14 +00:00
|
|
|
(if (null (equal key "\r"))
|
|
|
|
(insert
|
|
|
|
(format tag (help-key-description key nil)))
|
|
|
|
(insert (format tag ""))
|
|
|
|
(forward-char -6))))
|
2015-02-16 22:05:19 +00:00
|
|
|
(evil-leader/set-key-for-mode 'markdown-mode
|
2015-05-08 03:06:38 +00:00
|
|
|
;; Movement
|
|
|
|
"m{" 'markdown-backward-paragraph
|
|
|
|
"m}" 'markdown-forward-paragraph
|
2015-04-14 20:36:02 +00:00
|
|
|
;; Completion, and Cycling
|
2015-05-08 03:06:38 +00:00
|
|
|
"m]" 'markdown-complete
|
2015-02-16 22:05:19 +00:00
|
|
|
;; Indentation
|
|
|
|
"m>" 'markdown-indent-region
|
|
|
|
"m<" 'markdown-exdent-region
|
|
|
|
;; Buffer-wide commands
|
2015-02-20 04:04:03 +00:00
|
|
|
"mc]" 'markdown-complete-buffer
|
2015-02-16 22:05:19 +00:00
|
|
|
"mcm" 'markdown-other-window
|
|
|
|
"mcp" 'markdown-preview
|
|
|
|
"mce" 'markdown-export
|
|
|
|
"mcv" 'markdown-export-and-preview
|
|
|
|
"mco" 'markdown-open
|
|
|
|
"mcw" 'markdown-kill-ring-save
|
|
|
|
"mcc" 'markdown-check-refs
|
|
|
|
"mcn" 'markdown-cleanup-list-numbers
|
2015-04-23 08:31:54 +00:00
|
|
|
"mcr" 'gh-md-render-buffer
|
2015-05-08 03:06:38 +00:00
|
|
|
;; headings
|
|
|
|
"mhi" 'markdown-insert-header-dwim
|
|
|
|
"mhI" 'markdown-insert-header-setext-dwim
|
|
|
|
"mh1" 'markdown-insert-header-atx-1
|
|
|
|
"mh2" 'markdown-insert-header-atx-2
|
|
|
|
"mh3" 'markdown-insert-header-atx-3
|
|
|
|
"mh4" 'markdown-insert-header-atx-4
|
|
|
|
"mh5" 'markdown-insert-header-atx-5
|
|
|
|
"mh6" 'markdown-insert-header-atx-6
|
|
|
|
"mh!" 'markdown-insert-header-setext-1
|
|
|
|
"mh@" 'markdown-insert-header-setext-2
|
|
|
|
;; Insertion of common elements
|
|
|
|
"m-" 'markdown-insert-hr
|
|
|
|
"mif" 'markdown-insert-footnote
|
|
|
|
"mii" 'markdown-insert-image
|
2015-05-13 17:15:14 +00:00
|
|
|
"mik" 'spacemacs/insert-keybinding-markdown
|
2015-05-08 03:06:38 +00:00
|
|
|
"miI" 'markdown-insert-reference-image
|
|
|
|
"mil" 'markdown-insert-link
|
|
|
|
"miL" 'markdown-insert-reference-link-dwim
|
|
|
|
"miw" 'markdown-insert-wiki-link
|
|
|
|
"miu" 'markdown-insert-uri
|
|
|
|
;; Element removal
|
|
|
|
"mk" 'markdown-kill-thing-at-point
|
2015-02-16 22:05:19 +00:00
|
|
|
;; List editing
|
|
|
|
"mli" 'markdown-insert-list-item
|
2015-05-08 03:06:38 +00:00
|
|
|
;; region manipulation
|
|
|
|
"mxb" 'markdown-insert-bold
|
|
|
|
"mxi" 'markdown-insert-italic
|
|
|
|
"mxc" 'markdown-insert-code
|
|
|
|
"mxq" 'markdown-insert-blockquote
|
|
|
|
"mxQ" 'markdown-blockquote-region
|
|
|
|
"mxp" 'markdown-insert-pre
|
|
|
|
"mxP" 'markdown-pre-region
|
|
|
|
;; Following and Jumping
|
2015-02-16 22:05:19 +00:00
|
|
|
"mN" 'markdown-next-link
|
2015-08-17 18:25:48 +00:00
|
|
|
"mf" 'markdown-follow-thing-at-point
|
2015-05-08 03:06:38 +00:00
|
|
|
"mP" 'markdown-previous-link
|
|
|
|
"m <RET>" 'markdown-jump)
|
2015-04-13 08:09:50 +00:00
|
|
|
|
2015-04-14 20:36:02 +00:00
|
|
|
;; Header navigation in normal state movements
|
2015-04-13 08:09:50 +00:00
|
|
|
(evil-define-key 'normal markdown-mode-map
|
|
|
|
"gj" 'outline-forward-same-level
|
|
|
|
"gk" 'outline-backward-same-level
|
|
|
|
"gh" 'outline-up-heading
|
|
|
|
;; next visible heading is not exactly what we want but close enough
|
2015-05-08 03:06:38 +00:00
|
|
|
"gl" 'outline-next-visible-heading)
|
2015-04-14 20:36:02 +00:00
|
|
|
|
|
|
|
;; Promotion, Demotion
|
2015-04-13 08:09:50 +00:00
|
|
|
(define-key markdown-mode-map (kbd "M-h") 'markdown-promote)
|
2015-05-08 03:06:38 +00:00
|
|
|
(define-key markdown-mode-map (kbd "M-j") 'markdown-move-down)
|
|
|
|
(define-key markdown-mode-map (kbd "M-k") 'markdown-move-up)
|
2015-04-13 08:09:50 +00:00
|
|
|
(define-key markdown-mode-map (kbd "M-l") 'markdown-demote))))
|
2015-02-10 03:13:09 +00:00
|
|
|
|
|
|
|
(defun markdown/init-markdown-toc ()
|
|
|
|
(use-package markdown-toc
|
|
|
|
:defer t))
|
2015-05-06 23:28:17 +00:00
|
|
|
|
|
|
|
(defun markdown/init-mmm-mode ()
|
|
|
|
(use-package mmm-mode
|
|
|
|
:commands mmm-parse-buffer
|
|
|
|
:init
|
|
|
|
(evil-leader/set-key-for-mode 'markdown-mode
|
|
|
|
;; Highlight code blocks
|
|
|
|
"mcs" 'mmm-parse-buffer)
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(mmm-add-classes '((markdown-python
|
|
|
|
:submode python-mode
|
|
|
|
:face mmm-declaration-submode-face
|
|
|
|
:front "^```python[\n\r]+"
|
|
|
|
:back "^```$")))
|
|
|
|
(mmm-add-classes '((markdown-html
|
|
|
|
:submode web-mode
|
|
|
|
:face mmm-declaration-submode-face
|
|
|
|
:front "^```html[\n\r]+"
|
|
|
|
:back "^```$")))
|
2015-06-15 07:07:30 +00:00
|
|
|
(mmm-add-classes '((markdown-java
|
|
|
|
:submode java-mode
|
|
|
|
:face mmm-declaration-submode-face
|
|
|
|
:front "^```java[\n\r]+"
|
|
|
|
:back "^```$")))
|
|
|
|
(mmm-add-classes '((markdown-ruby
|
|
|
|
:submode ruby-mode
|
|
|
|
:face mmm-declaration-submode-face
|
|
|
|
:front "^```ruby[\n\r]+"
|
|
|
|
:back "^```$")))
|
|
|
|
(mmm-add-classes '((markdown-c
|
|
|
|
:submode c-mode
|
|
|
|
:face mmm-declaration-submode-face
|
|
|
|
:front "^```c[\n\r]+"
|
|
|
|
:back "^```$")))
|
|
|
|
(mmm-add-classes '((markdown-c++
|
|
|
|
:submode c++-mode
|
|
|
|
:face mmm-declaration-submode-face
|
|
|
|
:front "^```c\+\+[\n\r]+"
|
|
|
|
:back "^```$")))
|
|
|
|
(mmm-add-classes '((markdown-elisp
|
|
|
|
:submode emacs-lisp-mode
|
|
|
|
:face mmm-declaration-submode-face
|
|
|
|
:front "^```elisp[\n\r]+"
|
|
|
|
:back "^```$")))
|
2015-05-06 23:28:17 +00:00
|
|
|
(setq mmm-global-mode t)
|
|
|
|
(mmm-add-mode-ext-class 'markdown-mode nil 'markdown-python)
|
2015-06-15 07:07:30 +00:00
|
|
|
(mmm-add-mode-ext-class 'markdown-mode nil 'markdown-java)
|
|
|
|
(mmm-add-mode-ext-class 'markdown-mode nil 'markdown-ruby)
|
|
|
|
(mmm-add-mode-ext-class 'markdown-mode nil 'markdown-c)
|
|
|
|
(mmm-add-mode-ext-class 'markdown-mode nil 'markdown-c++)
|
|
|
|
(mmm-add-mode-ext-class 'markdown-mode nil 'markdown-elisp)
|
2015-05-06 23:28:17 +00:00
|
|
|
(mmm-add-mode-ext-class 'markdown-mode nil 'markdown-html))))
|
2015-08-18 22:27:49 +00:00
|
|
|
|
|
|
|
(when (configuration-layer/layer-usedp 'auto-completion)
|
|
|
|
(defun markdown/post-init-company ()
|
|
|
|
(spacemacs|add-company-hook markdown-mode)
|
|
|
|
(push 'company-capf company-backends-markdown-mode))
|
|
|
|
(defun markdown/post-init-company-emoji ()
|
|
|
|
(push 'company-emoji company-backends-markdown-mode)))
|