2015-06-06 04:46:47 +00:00
|
|
|
;;; packages.el --- Latex Layer packages File for Spacemacs
|
|
|
|
;;
|
2021-03-22 20:11:29 +00:00
|
|
|
;; Copyright (c) 2012-2021 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.
|
|
|
|
;;
|
2021-03-24 03:31:44 +00:00
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
;;
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
;;
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2015-06-06 04:46:47 +00:00
|
|
|
|
2020-10-27 21:48:22 +00:00
|
|
|
(defconst latex-packages
|
|
|
|
'(
|
|
|
|
auctex
|
|
|
|
(auctex-latexmk :toggle (string= "LatexMk" latex-build-command))
|
|
|
|
company
|
2020-12-23 12:52:32 +00:00
|
|
|
math-symbol-lists
|
|
|
|
(company-math :requires company math-symbol-lists)
|
2020-10-27 21:48:22 +00:00
|
|
|
(company-auctex :requires company)
|
|
|
|
(company-reftex :requires company)
|
|
|
|
counsel-gtags
|
|
|
|
evil-matchit
|
|
|
|
flycheck
|
|
|
|
flyspell
|
|
|
|
ggtags
|
|
|
|
helm-gtags
|
|
|
|
(lsp-latex :requires lsp-mode)
|
|
|
|
(magic-latex-buffer :toggle latex-enable-magic)
|
|
|
|
smartparens
|
|
|
|
(reftex :location built-in)
|
|
|
|
typo
|
|
|
|
which-key
|
|
|
|
yasnippet))
|
|
|
|
|
|
|
|
(defun latex/post-init-company ()
|
|
|
|
(spacemacs//latex-setup-company))
|
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
|
2018-03-04 04:37:53 +00:00
|
|
|
: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
|
2020-12-13 09:33:04 +00:00
|
|
|
TeX-engine latex-build-engine
|
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)
|
2020-10-27 21:48:22 +00:00
|
|
|
(add-hook 'LaTeX-mode-hook 'TeX-PDF-mode)
|
2020-12-13 09:33:04 +00:00
|
|
|
(add-hook 'LaTeX-mode-hook #'spacemacs//latex-setup-backend)
|
|
|
|
(when latex-refresh-preview
|
|
|
|
(add-hook 'doc-view-mode-hook 'auto-revert-mode)))
|
2015-01-11 20:33:45 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2015-05-04 06:29:34 +00:00
|
|
|
;; Key bindings for plain TeX
|
2019-09-24 05:22:57 +00:00
|
|
|
(dolist (mode '(tex-mode latex-mode context-mode))
|
2015-12-23 13:46:36 +00:00
|
|
|
(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 %
|
2020-01-19 00:05:22 +00:00
|
|
|
";" '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
|
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
|
2017-09-18 07:29:20 +00:00
|
|
|
"n" 'TeX-next-error ;; C-c `
|
|
|
|
"N" 'TeX-previous-error ;; M-g p
|
2016-02-27 02:30:41 +00:00
|
|
|
"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)
|
2020-10-27 21:48:22 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mxf" "fonts")
|
2021-03-18 04:31:59 +00:00
|
|
|
(unless (and (eq latex-backend 'lsp)
|
2020-10-27 21:48:22 +00:00
|
|
|
(eq mode 'latex-mode))
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mh" "help")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mx" "text/fonts")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"a" 'TeX-command-run-all ;; C-c C-a
|
|
|
|
"b" 'latex/build))
|
2015-12-23 13:46:36 +00:00
|
|
|
(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
|
2017-03-06 13:58:26 +00:00
|
|
|
;; the following commands are mostly not autoloaded, but that's fine
|
|
|
|
;; because `TeX-fold-mode' is added to `LaTeX-mode-hook'
|
2016-01-04 04:51:19 +00:00
|
|
|
"z=" 'TeX-fold-math
|
|
|
|
"zb" 'TeX-fold-buffer
|
2017-02-12 21:01:45 +00:00
|
|
|
"zB" 'TeX-fold-clearout-buffer
|
2016-01-04 04:51:19 +00:00
|
|
|
"ze" 'TeX-fold-env
|
2017-02-12 21:01:45 +00:00
|
|
|
"zI" 'TeX-fold-clearout-item
|
2016-01-04 04:51:19 +00:00
|
|
|
"zm" 'TeX-fold-macro
|
2017-02-12 21:01:45 +00:00
|
|
|
"zp" 'TeX-fold-paragraph
|
|
|
|
"zP" 'TeX-fold-clearout-paragraph
|
|
|
|
"zr" 'TeX-fold-region
|
|
|
|
"zR" 'TeX-fold-clearout-region
|
2020-10-27 21:48:22 +00:00
|
|
|
"zz" 'TeX-fold-dwim)
|
|
|
|
(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 .
|
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)
|
2020-10-27 21:48:22 +00:00
|
|
|
|
|
|
|
;; Rebind latex keys to avoid conflicts with lsp mode
|
2021-03-18 04:31:59 +00:00
|
|
|
(if (eq latex-backend 'lsp)
|
2020-10-27 21:48:22 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'latex-mode
|
|
|
|
"au" 'TeX-command-run-all
|
|
|
|
"c" 'latex/build
|
|
|
|
"ic" 'LaTeX-close-environment ;; C-c ]
|
|
|
|
"ie" 'LaTeX-environment) ;; C-c C-e
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'latex-mode
|
|
|
|
"c" 'LaTeX-close-environment ;; C-c ]
|
|
|
|
"e" 'LaTeX-environment)) ;; C-c C-e
|
|
|
|
|
|
|
|
;; Declare prefixes
|
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
|
|
|
|
2018-01-11 04:57:18 +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
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2018-01-11 04:57:18 +00:00
|
|
|
:init (setq auctex-latexmk-inherit-TeX-PDF-mode t)))
|
2015-05-03 23:17:41 +00:00
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
(defun latex/post-init-evil-matchit ()
|
|
|
|
(add-hook 'LaTeX-mode-hook 'evil-matchit-mode))
|
|
|
|
|
|
|
|
(defun latex/post-init-flycheck ()
|
2020-10-27 21:48:22 +00:00
|
|
|
(spacemacs/enable-flycheck 'latex-mode))
|
2016-05-30 02:39:21 +00:00
|
|
|
|
|
|
|
(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)
|
2021-03-18 04:31:59 +00:00
|
|
|
(let ((prefix (if (eq latex-backend 'lsp) "R" "r")))
|
2020-10-27 21:48:22 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'latex-mode (concat "m" prefix) "reftex")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'latex-mode
|
|
|
|
(concat prefix "c") 'reftex-citation
|
|
|
|
(concat prefix "g") 'reftex-grep-document
|
2020-11-12 21:03:47 +00:00
|
|
|
(concat prefix "i") 'reftex-index-selection-or-word
|
2020-10-27 21:48:22 +00:00
|
|
|
(concat prefix "I") 'reftex-display-index
|
2020-11-12 21:03:47 +00:00
|
|
|
(concat prefix " " "TAB") 'reftex-index
|
2020-10-27 21:48:22 +00:00
|
|
|
(concat prefix "l") 'reftex-label
|
|
|
|
(concat prefix "p") 'reftex-index-phrase-selection-or-word
|
|
|
|
(concat prefix "P") 'reftex-index-visit-phrases-buffer
|
|
|
|
(concat prefix "r") 'reftex-reference
|
|
|
|
(concat prefix "s") 'reftex-search-document
|
|
|
|
(concat prefix "t") 'reftex-toc
|
|
|
|
(concat prefix "T") 'reftex-toc-recenter
|
|
|
|
(concat prefix "v") 'reftex-view-crossref)))
|
2015-12-23 13:46:36 +00:00
|
|
|
|
2017-08-26 21:18:09 +00:00
|
|
|
(defun latex/post-init-counsel-gtags ()
|
|
|
|
(spacemacs/counsel-gtags-define-keys-for-mode 'latex-mode))
|
|
|
|
|
2016-04-05 04:08:34 +00:00
|
|
|
(defun latex/post-init-helm-gtags ()
|
|
|
|
(spacemacs/helm-gtags-define-keys-for-mode 'latex-mode))
|
|
|
|
|
|
|
|
(defun latex/post-init-ggtags ()
|
2016-08-15 19:24:44 +00:00
|
|
|
(add-hook 'latex-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
|
2016-04-05 04:08:34 +00:00
|
|
|
|
2015-06-06 04:46:47 +00:00
|
|
|
(defun latex/post-init-smartparens ()
|
2021-03-16 17:47:15 +00:00
|
|
|
(add-hook 'LaTeX-mode-hook #'spacemacs//activate-smartparens))
|
2015-06-06 04:31:07 +00:00
|
|
|
|
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 ()
|
2016-11-22 18:34:22 +00:00
|
|
|
(push '((nil . "\\`latex/font-\\(.+\\)\\'") . (nil . "\\1"))
|
|
|
|
which-key-replacement-alist))
|
2015-12-11 22:14:56 +00:00
|
|
|
|
|
|
|
(defun latex/init-magic-latex-buffer ()
|
|
|
|
(use-package magic-latex-buffer
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-12-11 22:14:56 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2018-09-26 03:39:03 +00:00
|
|
|
(add-hook 'TeX-update-style-hook 'magic-latex-buffer)
|
2015-12-11 22:14:56 +00:00
|
|
|
(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))))
|
2020-10-27 21:48:22 +00:00
|
|
|
|
|
|
|
(defun latex/init-lsp-latex ()
|
|
|
|
(use-package lsp-latex
|
|
|
|
:defer t))
|
|
|
|
|
2021-02-10 07:51:55 +00:00
|
|
|
(defun latex/init-math-symbol-lists ()
|
2020-12-23 12:52:32 +00:00
|
|
|
(use-package math-symbol-lists
|
|
|
|
:defer t))
|
|
|
|
|
|
|
|
(defun latex/init-company-math ()
|
|
|
|
(use-package company-math
|
|
|
|
:defer t))
|
|
|
|
|
2020-10-27 21:48:22 +00:00
|
|
|
(defun latex/init-company-auctex ()
|
|
|
|
(use-package company-auctex
|
|
|
|
:defer t))
|
|
|
|
|
|
|
|
(defun latex/init-company-reftex ()
|
|
|
|
(use-package company-reftex
|
|
|
|
:defer t))
|