doomemacs/modules/lang/latex/config.el

97 lines
2.6 KiB
EmacsLisp
Raw Normal View History

;;; lang/latex/config.el -*- lexical-binding: t; -*-
2016-05-08 18:27:28 -04:00
2017-02-19 18:57:16 -05:00
(defvar +latex-bibtex-dir "~/work/writing/biblio/"
"Where bibtex files are kept.")
(defvar +latex-bibtex-default-file "default.bib"
"TODO")
2016-05-08 18:27:28 -04:00
2017-02-19 18:57:16 -05:00
;;
2018-01-04 14:50:59 -05:00
;; AucTex/LaTeX bootstrap
2017-02-19 18:57:16 -05:00
;;
;; Because tex-mode is built-in and AucTex has conflicting components, we need
;; to ensure that auctex gets loaded instead of tex-mode.
2017-03-08 21:36:57 -05:00
(load "auctex" nil t)
(load "auctex-autoloads" nil t)
(push '("\\.[tT]e[xX]\\'" . TeX-latex-mode) auto-mode-alist)
2018-01-04 14:50:59 -05:00
(add-hook! (latex-mode LaTeX-mode) #'turn-on-auto-fill)
(add-hook! 'LaTeX-mode-hook #'(LaTeX-math-mode TeX-source-correlate-mode))
(add-transient-hook! 'LaTeX-mode-hook
2016-05-08 18:27:28 -04:00
(setq TeX-auto-save t
TeX-parse-self t
TeX-save-query nil
2017-02-19 18:57:16 -05:00
TeX-source-correlate-start-server nil
LaTeX-fill-break-at-separators nil
LaTeX-section-hook
'(LaTeX-section-heading
LaTeX-section-title
LaTeX-section-toc
LaTeX-section-section
LaTeX-section-label))
(set! :popup " output\\*$" '((size . 15)))
2018-01-04 14:50:59 -05:00
(map! :map LaTeX-mode-map "C-j" nil))
2018-01-04 14:50:59 -05:00
;;
;; Plugins
;;
(def-package! reftex ; built-in
:commands (turn-on-reftex reftex-mode)
:init
(setq reftex-plug-into-AUCTeX t
reftex-default-bibliography (list +latex-bibtex-default-file)
reftex-toc-split-windows-fraction 0.2)
2017-02-19 18:57:16 -05:00
(add-hook! (latex-mode LaTeX-mode) #'turn-on-reftex)
:config
(map! :map reftex-mode-map
2017-06-19 00:30:41 +02:00
:localleader :n ";" 'reftex-toc)
(add-hook! 'reftex-toc-mode-hook
(reftex-toc-rescan)
(map! :local
:e "j" #'next-line
:e "k" #'previous-line
:e "q" #'kill-buffer-and-window
:e "ESC" #'kill-buffer-and-window)))
2017-02-19 18:57:16 -05:00
(def-package! bibtex ; built-in
:defer t
2017-02-19 18:57:16 -05:00
:config
(setq bibtex-dialect 'biblatex
2016-05-08 18:27:28 -04:00
bibtex-align-at-equal-sign t
2017-02-19 18:57:16 -05:00
bibtex-text-indentation 20
bibtex-completion-bibliography (list +latex-bibtex-default-file))
(map! :map bibtex-mode-map "C-c \\" #'bibtex-fill-entry))
2017-02-19 18:57:16 -05:00
2017-06-11 00:59:02 +02:00
(def-package! ivy-bibtex
:when (featurep! :completion ivy)
2017-02-19 18:57:16 -05:00
:commands ivy-bibtex)
2016-05-08 18:27:28 -04:00
2017-06-11 00:59:02 +02:00
(def-package! helm-bibtex
:when (featurep! :completion helm)
2017-02-19 18:57:16 -05:00
:commands helm-bibtex)
2016-05-08 18:27:28 -04:00
2018-01-04 14:50:59 -05:00
(def-package! company-auctex
:when (featurep! :completion company)
:commands company-auctex-init
:init
;; We can't use the (set! :company-backend ...) because Auctex reports its
;; major-mode as `latex-mode', but uses LaTeX-mode-hook for its mode, which is
;; :company-backend doesn't anticipate (and shouldn't have to!)
(add-hook! LaTeX-mode
(make-variable-buffer-local 'company-backends)
(company-auctex-init)))