2015-06-06 04:46:47 +00:00
|
|
|
;;; packages.el --- Latex Layer packages File for Spacemacs
|
|
|
|
;;
|
2016-01-12 02:40:54 +00:00
|
|
|
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
|
2015-06-06 04:46:47 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
|
|
|
(setq latex-packages
|
2014-12-01 23:20:24 +00:00
|
|
|
'(
|
|
|
|
auctex
|
2016-05-29 16:23:51 +00:00
|
|
|
(auctex-latexmk :toggle (string= "LatexMk" latex-build-command))
|
2015-04-09 04:13:15 +00:00
|
|
|
company
|
2016-05-30 02:39:21 +00:00
|
|
|
(company-auctex :toggle (configuration-layer/package-usedp 'company))
|
2015-04-09 04:13:15 +00:00
|
|
|
evil-matchit
|
2015-12-23 13:46:36 +00:00
|
|
|
(reftex :location built-in)
|
2015-05-03 23:17:41 +00:00
|
|
|
flycheck
|
2015-06-06 04:31:07 +00:00
|
|
|
flyspell
|
|
|
|
smartparens
|
2015-11-25 14:25:04 +00:00
|
|
|
typo
|
2015-06-06 04:31:07 +00:00
|
|
|
yasnippet
|
2015-11-25 14:44:43 +00:00
|
|
|
which-key
|
2014-12-01 23:20:24 +00:00
|
|
|
))
|
|
|
|
|
2015-06-06 04:46:47 +00:00
|
|
|
(defun latex/init-auctex ()
|
2015-01-11 20:33:45 +00:00
|
|
|
(use-package tex
|
|
|
|
:defer t
|
2015-06-06 04:31:07 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2015-06-06 04:46:47 +00:00
|
|
|
(setq TeX-command-default latex-build-command
|
2015-06-06 04:31:07 +00:00
|
|
|
TeX-auto-save t
|
|
|
|
TeX-parse-self t
|
|
|
|
TeX-syntactic-comment t
|
|
|
|
;; Synctex support
|
|
|
|
TeX-source-correlate-start-server nil
|
|
|
|
;; Don't insert line-break at inline math
|
|
|
|
LaTeX-fill-break-at-separators nil)
|
2015-06-06 04:46:47 +00:00
|
|
|
(when latex-enable-auto-fill
|
2015-06-06 09:04:37 +00:00
|
|
|
(add-hook 'LaTeX-mode-hook 'latex/auto-fill-mode))
|
2015-12-23 13:46:36 +00:00
|
|
|
(when latex-enable-folding
|
|
|
|
(add-hook 'LaTeX-mode-hook 'TeX-fold-mode))
|
2015-12-22 15:26:54 +00:00
|
|
|
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
|
|
|
|
(add-hook 'LaTeX-mode-hook 'TeX-source-correlate-mode)
|
|
|
|
(add-hook 'LaTeX-mode-hook 'TeX-PDF-mode))
|
2015-01-11 20:33:45 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2015-05-04 06:29:34 +00:00
|
|
|
;; Key bindings for plain TeX
|
2015-12-23 13:46:36 +00:00
|
|
|
(dolist (mode '(tex-mode latex-mode))
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
2016-02-27 02:30:41 +00:00
|
|
|
"\\" 'TeX-insert-macro ;; C-c C-m
|
|
|
|
"-" 'TeX-recenter-output-buffer ;; C-c C-l
|
|
|
|
"%" 'TeX-comment-or-uncomment-paragraph ;; C-c %
|
|
|
|
";" 'TeX-comment-or-uncomment-region ;; C-c ; or C-c :
|
2016-02-27 06:57:53 +00:00
|
|
|
;; TeX-command-run-all runs compile and open the viewer
|
|
|
|
"a" 'TeX-command-run-all ;; C-c C-a
|
2015-12-23 13:46:36 +00:00
|
|
|
"b" 'latex/build
|
2016-02-27 02:30:41 +00:00
|
|
|
"k" 'TeX-kill-job ;; C-c C-k
|
|
|
|
"l" 'TeX-recenter-output-buffer ;; C-c C-l
|
|
|
|
"m" 'TeX-insert-macro ;; C-c C-m
|
|
|
|
"v" 'TeX-view ;; C-c C-v
|
2015-12-23 13:46:36 +00:00
|
|
|
;; TeX-doc is a very slow function
|
|
|
|
"hd" 'TeX-doc
|
|
|
|
"xb" 'latex/font-bold
|
|
|
|
"xc" 'latex/font-code
|
|
|
|
"xe" 'latex/font-emphasis
|
|
|
|
"xi" 'latex/font-italic
|
|
|
|
"xr" 'latex/font-clear
|
|
|
|
"xo" 'latex/font-oblique
|
|
|
|
"xfc" 'latex/font-small-caps
|
|
|
|
"xff" 'latex/font-sans-serif
|
|
|
|
"xfr" 'latex/font-serif)
|
|
|
|
(when dotspacemacs-major-mode-emacs-leader-key
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
dotspacemacs-major-mode-emacs-leader-key 'TeX-command-master))
|
|
|
|
(when dotspacemacs-major-mode-leader-key
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
dotspacemacs-major-mode-leader-key 'TeX-command-master))
|
|
|
|
(when latex-enable-folding
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
2016-01-04 04:51:19 +00:00
|
|
|
"z=" 'TeX-fold-math
|
|
|
|
"zb" 'TeX-fold-buffer
|
|
|
|
"ze" 'TeX-fold-env
|
|
|
|
"zm" 'TeX-fold-macro
|
|
|
|
"zr" 'TeX-fold-region))
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mx" "text/fonts")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mz" "fold"))
|
2015-11-25 14:44:43 +00:00
|
|
|
|
2015-12-23 13:46:36 +00:00
|
|
|
;; Key bindings specific to LaTeX
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'latex-mode
|
2015-12-23 13:46:36 +00:00
|
|
|
"*" 'LaTeX-mark-section ;; C-c *
|
|
|
|
"." 'LaTeX-mark-environment ;; C-c .
|
|
|
|
"c" 'LaTeX-close-environment ;; C-c ]
|
|
|
|
"e" 'LaTeX-environment ;; C-c C-e
|
2016-03-30 08:44:30 +00:00
|
|
|
"ii" 'LaTeX-insert-item ;; C-c C-j
|
2015-12-23 13:46:36 +00:00
|
|
|
"s" 'LaTeX-section ;; C-c C-s
|
2016-02-27 02:30:41 +00:00
|
|
|
"fe" 'LaTeX-fill-environment ;; C-c C-q C-e
|
|
|
|
"fp" 'LaTeX-fill-paragraph ;; C-c C-q C-p
|
|
|
|
"fr" 'LaTeX-fill-region ;; C-c C-q C-r
|
|
|
|
"fs" 'LaTeX-fill-section ;; C-c C-q C-s
|
2015-12-22 21:18:52 +00:00
|
|
|
"pb" 'preview-buffer
|
|
|
|
"pc" 'preview-clearout
|
|
|
|
"pd" 'preview-document
|
|
|
|
"pe" 'preview-environment
|
|
|
|
"pf" 'preview-cache-preamble
|
|
|
|
"pp" 'preview-at-point
|
|
|
|
"pr" 'preview-region
|
|
|
|
"ps" 'preview-section
|
|
|
|
"xB" 'latex/font-medium
|
|
|
|
"xr" 'latex/font-clear
|
2015-11-25 14:44:43 +00:00
|
|
|
"xfa" 'latex/font-calligraphic
|
|
|
|
"xfn" 'latex/font-normal
|
2016-02-08 20:36:36 +00:00
|
|
|
"xfu" 'latex/font-upright)
|
|
|
|
(spacemacs/declare-prefix-for-mode 'latex-mode "mp" "preview"))))
|
|
|
|
|
2016-05-29 16:23:51 +00:00
|
|
|
(defun latex/init-auctex-latexmk ()
|
|
|
|
(use-package auctex-latexmk
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(setq auctex-latexmk-inherit-TeX-PDF-mode t)
|
|
|
|
(spacemacs|use-package-add-hook tex
|
|
|
|
:post-config
|
|
|
|
(auctex-latexmk-setup)))))
|
2015-05-03 23:17:41 +00:00
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
(defun latex/post-init-company ()
|
|
|
|
(spacemacs|add-company-hook LaTeX-mode))
|
|
|
|
|
|
|
|
(defun latex/init-company-auctex ()
|
|
|
|
(use-package company-auctex
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(push 'company-auctex-labels company-backends-LaTeX-mode)
|
|
|
|
(push 'company-auctex-bibs company-backends-LaTeX-mode)
|
|
|
|
(push '(company-auctex-macros
|
|
|
|
company-auctex-symbols
|
|
|
|
company-auctex-environments) company-backends-LaTeX-mode))))
|
|
|
|
|
|
|
|
(defun latex/post-init-evil-matchit ()
|
|
|
|
(add-hook 'LaTeX-mode-hook 'evil-matchit-mode))
|
|
|
|
|
|
|
|
(defun latex/post-init-flycheck ()
|
|
|
|
(spacemacs/add-flycheck-hook 'LaTeX-mode))
|
|
|
|
|
|
|
|
(defun latex/post-init-flyspell ()
|
|
|
|
(spell-checking/add-flyspell-hook 'LaTeX-mode-hook))
|
|
|
|
|
2015-12-23 13:46:36 +00:00
|
|
|
(defun latex/init-reftex ()
|
|
|
|
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
|
|
|
|
(setq reftex-plug-into-AUCTeX '(nil nil t t t)
|
|
|
|
reftex-use-fonts t)
|
|
|
|
(spacemacs/declare-prefix-for-mode 'latex-mode "mr" "reftex")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'latex-mode
|
|
|
|
"rc" 'reftex-citation
|
|
|
|
"rg" 'reftex-grep-document
|
|
|
|
"ri" 'reftex-index-selection-or-word
|
|
|
|
"rI" 'reftex-display-index
|
|
|
|
"r TAB" 'reftex-index
|
|
|
|
"rl" 'reftex-label
|
|
|
|
"rp" 'reftex-index-phrase-selection-or-word
|
|
|
|
"rP" 'reftex-index-visit-phrases-buffer
|
|
|
|
"rr" 'reftex-reference
|
|
|
|
"rs" 'reftex-search-document
|
|
|
|
"rt" 'reftex-toc
|
|
|
|
"rT" 'reftex-toc-recenter
|
|
|
|
"rv" 'reftex-view-crossref))
|
|
|
|
|
2015-06-06 04:46:47 +00:00
|
|
|
(defun latex/post-init-smartparens ()
|
2015-06-06 04:31:07 +00:00
|
|
|
(add-hook 'LaTeX-mode-hook 'smartparens-mode))
|
|
|
|
|
2015-11-25 14:25:04 +00:00
|
|
|
(defun latex/post-init-typo ()
|
|
|
|
;; Typo mode isn't useful for LaTeX.
|
|
|
|
(defun spacemacs//disable-typo-mode ()
|
|
|
|
(typo-mode -1))
|
|
|
|
(add-hook 'LaTeX-mode-hook 'spacemacs//disable-typo-mode))
|
|
|
|
|
2015-06-06 04:46:47 +00:00
|
|
|
(defun latex/post-init-yasnippet ()
|
2015-06-06 04:31:07 +00:00
|
|
|
(add-hook 'LaTeX-mode-hook 'spacemacs/load-yasnippet))
|
2015-11-25 14:44:43 +00:00
|
|
|
|
|
|
|
(defun latex/post-init-which-key ()
|
|
|
|
(push '("\\`latex/font-\\(.+\\)\\'" . "\\1")
|
|
|
|
which-key-description-replacement-alist))
|