2017-06-08 11:47:56 +02:00
|
|
|
;;; lang/latex/config.el -*- lexical-binding: t; -*-
|
2016-05-08 18:27:28 -04:00
|
|
|
|
2018-06-08 16:10:00 +02:00
|
|
|
(defvar +latex-indent-level-item-continuation 4
|
2018-01-01 20:48:23 +01:00
|
|
|
"Custom indentation level for items in enumeration-type environments")
|
2016-05-08 18:27:28 -04:00
|
|
|
|
2018-07-18 13:38:02 +02:00
|
|
|
(defvar +latex-bibtex-file ""
|
|
|
|
"File AUCTeX (specifically RefTeX) uses to search for citations.")
|
|
|
|
|
2018-07-29 21:57:56 +02:00
|
|
|
(defvar +latex-enable-unicode-math nil
|
|
|
|
"If non-nil, use `company-math-symbols-unicode' backend in LaTeX-mode,
|
|
|
|
enabling unicode symbols in math regions. This requires the unicode-math latex
|
|
|
|
package to be installed.")
|
|
|
|
|
|
|
|
;;
|
|
|
|
(defvar +latex--company-backends nil)
|
|
|
|
|
|
|
|
|
2018-07-18 13:38:02 +02:00
|
|
|
;;
|
|
|
|
;; Plugins
|
|
|
|
;;
|
|
|
|
|
2018-07-13 10:07:02 +02:00
|
|
|
;; sp's default rules are obnoxious, so disable them
|
|
|
|
(provide 'smartparens-latex)
|
|
|
|
|
2018-07-18 13:38:02 +02:00
|
|
|
(def-package! tex
|
|
|
|
:mode ("\\.tex\\'" . TeX-latex-mode)
|
|
|
|
:hook (TeX-mode . visual-line-mode)
|
|
|
|
:config
|
|
|
|
;; fontify common latex commands
|
2018-05-27 12:44:22 +02:00
|
|
|
(load! "+fontification")
|
2018-07-18 13:38:02 +02:00
|
|
|
;; select viewer
|
2018-07-18 12:15:55 +02:00
|
|
|
(load! "+viewers")
|
2018-07-18 13:38:02 +02:00
|
|
|
(setq TeX-parse-self t ;; parse on load
|
|
|
|
TeX-auto-save t ;; parse on save
|
|
|
|
;; use hidden dirs for auctex files
|
2018-01-01 20:48:23 +01:00
|
|
|
TeX-auto-local ".auctex-auto"
|
|
|
|
TeX-style-local ".auctex-style"
|
|
|
|
TeX-source-correlate-mode t
|
|
|
|
TeX-source-correlate-method 'synctex
|
2018-07-18 13:38:02 +02:00
|
|
|
;; don't start the emacs server when correlating sources
|
|
|
|
TeX-source-correlate-start-server nil
|
|
|
|
;; automatically insert braces after sub/superscript in math mode
|
|
|
|
TeX-electric-sub-and-superscript t)
|
|
|
|
;; prompt for master
|
2018-01-01 20:48:23 +01:00
|
|
|
(setq-default TeX-master nil)
|
2018-07-18 13:38:02 +02:00
|
|
|
;; set-up chktex
|
2018-07-18 14:03:31 +02:00
|
|
|
(setcar (cdr (assoc "Check" TeX-command-list)) "chktex -v6 -H %s")
|
2018-07-18 14:04:23 +02:00
|
|
|
;; tell emacs how to parse tex files
|
2018-07-18 15:31:35 +02:00
|
|
|
(add-hook! 'tex-mode-hook (setq ispell-parser 'tex))
|
2018-07-18 13:38:02 +02:00
|
|
|
;; display output of latex commands in popup
|
2018-06-18 02:26:05 +02:00
|
|
|
(set-popup-rule! " output\\*$" :size 15)
|
2018-07-18 13:38:02 +02:00
|
|
|
;; Do not prompt for Master files, this allows auto-insert to add templates to
|
|
|
|
;; .tex files
|
|
|
|
(add-hook! 'TeX-mode-hook (remove-hook 'find-file-hook
|
|
|
|
(cl-find-if #'byte-code-function-p find-file-hook)
|
|
|
|
'local))
|
|
|
|
;; Enable rainbow mode after applying styles to the buffer
|
2018-07-18 15:31:35 +02:00
|
|
|
(add-hook 'TeX-update-style-hook #'rainbow-delimiters-mode)
|
|
|
|
(add-hook 'TeX-mode-hook #'visual-line-mode)
|
2018-07-18 13:38:02 +02:00
|
|
|
(when (featurep! :feature spellcheck)
|
|
|
|
(add-hook 'TeX-mode-hook #'flyspell-mode :append)))
|
|
|
|
|
|
|
|
; Fold TeX macros
|
|
|
|
(def-package! tex-fold
|
|
|
|
:hook (TeX-mode . TeX-fold-mode))
|
2018-05-29 12:46:13 +02:00
|
|
|
|
2018-07-18 15:31:35 +02:00
|
|
|
(after! latex
|
2018-05-29 12:46:13 +02:00
|
|
|
(setq LaTeX-section-hook ; Add the toc entry to the sectioning hooks.
|
|
|
|
'(LaTeX-section-heading
|
|
|
|
LaTeX-section-title
|
|
|
|
LaTeX-section-toc
|
|
|
|
LaTeX-section-section
|
|
|
|
LaTeX-section-label)
|
|
|
|
LaTeX-fill-break-at-separators nil
|
2018-07-18 13:38:02 +02:00
|
|
|
LaTeX-item-indent 0)
|
2018-07-29 21:57:56 +02:00
|
|
|
(when +latex--company-backends
|
|
|
|
(set-company-backend! 'latex-mode +latex--company-backends))
|
2018-07-18 13:38:02 +02:00
|
|
|
;; Set custom item indentation
|
2018-05-29 12:46:13 +02:00
|
|
|
(dolist (env '("itemize" "enumerate" "description"))
|
2018-07-18 12:15:55 +02:00
|
|
|
(add-to-list 'LaTeX-indent-environment-list `(,env +latex/LaTeX-indent-item))))
|
2018-05-29 12:46:13 +02:00
|
|
|
|
2018-07-18 13:38:02 +02:00
|
|
|
;; set-up preview package
|
2018-01-01 20:48:23 +01:00
|
|
|
(def-package! preview
|
2018-05-29 12:46:13 +02:00
|
|
|
:hook (LaTeX-mode . LaTeX-preview-setup)
|
|
|
|
:config
|
2018-03-07 21:21:17 -05:00
|
|
|
(setq-default preview-scale 1.4
|
2018-05-09 12:31:24 +02:00
|
|
|
preview-scale-function
|
2018-05-29 12:46:13 +02:00
|
|
|
(lambda () (* (/ 10.0 (preview-document-pt)) preview-scale))))
|
2018-05-09 12:31:24 +02:00
|
|
|
|
2018-01-04 14:50:59 -05:00
|
|
|
(def-package! company-auctex
|
|
|
|
:when (featurep! :completion company)
|
2018-07-18 16:22:47 +02:00
|
|
|
:defer t
|
|
|
|
:init
|
2018-07-29 21:57:56 +02:00
|
|
|
(add-to-list '+latex--company-backends #'company-auctex-environments nil #'eq)
|
|
|
|
(add-to-list '+latex--company-backends #'company-auctex-macros nil #'eq))
|
2018-07-18 16:22:47 +02:00
|
|
|
|
|
|
|
(def-package! company-math
|
|
|
|
:when (featurep! :completion company)
|
|
|
|
:defer t
|
|
|
|
:init
|
2018-07-29 21:57:56 +02:00
|
|
|
(add-to-list '+latex--company-backends #'+latex-symbols-company-backend nil #'eq))
|
2018-05-09 12:31:24 +02:00
|
|
|
|
2018-01-01 20:48:23 +01:00
|
|
|
;; Nicely indent lines that have wrapped when visual line mode is activated
|
|
|
|
(def-package! adaptive-wrap
|
2018-05-29 12:46:13 +02:00
|
|
|
:hook (LaTeX-mode . adaptive-wrap-prefix-mode)
|
|
|
|
:init (setq-default adaptive-wrap-extra-indent 0))
|
2018-07-18 12:12:15 +02:00
|
|
|
|
|
|
|
;; referencing + bibtex setup
|
|
|
|
(load! "+ref")
|
|
|
|
|
|
|
|
;;
|
|
|
|
;; Sub-modules
|
|
|
|
;;
|
|
|
|
|
|
|
|
(if (featurep! +latexmk) (load! "+latexmk"))
|
|
|
|
(if (featurep! +preview-pane) (load! "+preview-pane"))
|