This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+lang/latex/packages.el

229 lines
8.2 KiB
EmacsLisp
Raw Normal View History

;;; packages.el --- Latex Layer packages File for Spacemacs
;;
2018-01-04 07:00:25 +00:00
;; 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 latex-packages
'(
auctex
(auctex-latexmk :toggle (string= "LatexMk" latex-build-command))
2017-07-03 07:52:54 +00:00
(company-auctex :requires company)
2018-04-25 13:26:58 +00:00
(company-reftex :requires company)
evil-matchit
(reftex :location built-in)
flycheck
flyspell
ggtags
counsel-gtags
helm-gtags
(magic-latex-buffer :toggle latex-enable-magic)
smartparens
typo
yasnippet
which-key
))
2014-12-01 23:20:24 +00:00
(defun latex/init-auctex ()
2015-01-11 20:33:45 +00:00
(use-package tex
:defer t
:init
(progn
(setq TeX-command-default latex-build-command
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)
(when latex-enable-auto-fill
(add-hook 'LaTeX-mode-hook 'latex/auto-fill-mode))
(when latex-enable-folding
(add-hook 'LaTeX-mode-hook 'TeX-fold-mode))
(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
;; Key bindings for plain TeX
(dolist (mode '(tex-mode latex-mode))
(spacemacs/set-leader-keys-for-major-mode mode
"\\" '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
"b" 'latex/build
"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
"n" 'TeX-next-error ;; C-c `
"N" 'TeX-previous-error ;; M-g p
"v" 'TeX-view ;; C-c C-v
;; 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
;; the following commands are mostly not autoloaded, but that's fine
;; because `TeX-fold-mode' is added to `LaTeX-mode-hook'
"z=" 'TeX-fold-math
"zb" 'TeX-fold-buffer
"zB" 'TeX-fold-clearout-buffer
"ze" 'TeX-fold-env
"zI" 'TeX-fold-clearout-item
"zm" 'TeX-fold-macro
"zp" 'TeX-fold-paragraph
"zP" 'TeX-fold-clearout-paragraph
"zr" 'TeX-fold-region
"zR" 'TeX-fold-clearout-region
"zz" 'TeX-fold-dwim))
2016-06-12 18:54:45 +00:00
(spacemacs/declare-prefix-for-mode mode "mh" "help")
(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
;; Key bindings specific to LaTeX
(spacemacs/set-leader-keys-for-major-mode 'latex-mode
"*" 'LaTeX-mark-section ;; C-c *
"." 'LaTeX-mark-environment ;; C-c .
"c" 'LaTeX-close-environment ;; C-c ]
"e" 'LaTeX-environment ;; C-c C-e
"ii" 'LaTeX-insert-item ;; C-c C-j
"s" 'LaTeX-section ;; C-c C-s
"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
"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)
2016-06-12 18:54:45 +00:00
(spacemacs/declare-prefix-for-mode 'latex-mode "mi" "insert")
(spacemacs/declare-prefix-for-mode 'latex-mode "mp" "preview")
(spacemacs/declare-prefix-for-mode 'latex-mode "mf" "fill"))))
2016-02-08 20:36:36 +00:00
(defun latex/pre-init-auctex-latexmk ()
(spacemacs|use-package-add-hook tex
:post-config
(auctex-latexmk-setup)))
2016-05-29 16:23:51 +00:00
(defun latex/init-auctex-latexmk ()
(use-package auctex-latexmk
:defer t
:init (setq auctex-latexmk-inherit-TeX-PDF-mode t)))
(defun latex/init-company-auctex ()
(use-package company-auctex
:defer t
Refactor and simplify company backends declaration Enabling a company backend for a specific mode was a tedious tasks with code scattered at different locations, one for local variable definitions, one for company hook function definitions and another where the backends were pushed to the local variables (which was problematic, since we ended up pushing the same backends over and over again with `SPC f e R`, pushes have been replaced by add-to-list calls in the new macro). All these steps are now put together at one place with the new macro spacemacs|add-company-backends, check its docstring for more info on its arguments. This macro also allows to define arbitrary buffer local variables to tune company for specific modes (similar to layer variables via a keyword :variables) The code related to company backends management has been moved to the auto-completion layer in the funcs.el file. A nice side effect of this move is that it enforces correct encapsulation of company backends related code. We can now easily detect if there is some configuration leakage when the auto-completion layer is not used. But we loose macro expansion at file loading time (not sue it is a big concern though). The function spacemacs|enable-auto-complete was never used so it has been deleted which led to the deletion of the now empty file core-auto-completion.el. The example in LAYERS.org regarding auto-completion is now out of date and has been deleted. An example to setup auto-completion is provided in the README.org file of the auto-completion layer.
2017-01-02 05:39:04 +00:00
:init (spacemacs|add-company-backends
:backends
(company-auctex-macros
company-auctex-symbols
company-auctex-environments)
:modes LaTeX-mode)))
2018-04-25 13:26:58 +00:00
(defun latex/init-company-reftex ()
(use-package company-reftex
:defer t
:init (spacemacs|add-company-backends
:backends
company-reftex-labels
company-reftex-citations
:modes LaTeX-mode)))
(defun latex/post-init-evil-matchit ()
(add-hook 'LaTeX-mode-hook 'evil-matchit-mode))
(defun latex/post-init-flycheck ()
(spacemacs/enable-flycheck 'LaTeX-mode))
(defun latex/post-init-flyspell ()
(spell-checking/add-flyspell-hook 'LaTeX-mode-hook))
(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)
2016-06-12 18:54:45 +00:00
(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))
(defun latex/post-init-counsel-gtags ()
(spacemacs/counsel-gtags-define-keys-for-mode 'latex-mode))
(defun latex/post-init-helm-gtags ()
(spacemacs/helm-gtags-define-keys-for-mode 'latex-mode))
(defun latex/post-init-ggtags ()
(add-hook 'latex-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
(defun latex/post-init-smartparens ()
(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))
(defun latex/post-init-yasnippet ()
(add-hook 'LaTeX-mode-hook 'spacemacs/load-yasnippet))
2015-11-25 14:44:43 +00:00
(defun latex/post-init-which-key ()
(push '((nil . "\\`latex/font-\\(.+\\)\\'") . (nil . "\\1"))
which-key-replacement-alist))
(defun latex/init-magic-latex-buffer ()
(use-package magic-latex-buffer
:defer t
:init
(progn
(add-hook 'TeX-update-style-hook 'magic-latex-buffer)
(setq magic-latex-enable-block-highlight t
magic-latex-enable-suscript t
magic-latex-enable-pretty-symbols t
magic-latex-enable-block-align nil
magic-latex-enable-inline-image nil))))