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-13 10:07:02 +02:00
|
|
|
;; sp's default rules are obnoxious, so disable them
|
|
|
|
(provide 'smartparens-latex)
|
|
|
|
|
2018-05-29 12:46:13 +02:00
|
|
|
(after! tex
|
2018-01-01 20:48:23 +01:00
|
|
|
;; Set some varibles to fontify common LaTeX commands.
|
2018-05-27 12:44:22 +02:00
|
|
|
(load! "+fontification")
|
2018-07-18 12:15:55 +02:00
|
|
|
;; Set-up viewers
|
|
|
|
(load! "+viewers")
|
2018-05-29 12:46:13 +02:00
|
|
|
|
|
|
|
(setq TeX-parse-self t ; Enable parse on load.
|
|
|
|
TeX-save-query nil ; just save, don't ask
|
|
|
|
TeX-auto-save t ; Enable parse on save.
|
2018-01-01 20:48:23 +01:00
|
|
|
;; Use hidden directories for AUCTeX files.
|
|
|
|
TeX-auto-local ".auctex-auto"
|
|
|
|
TeX-style-local ".auctex-style"
|
2018-02-14 07:42:22 -05:00
|
|
|
;; When correlating sources to rendered PDFs, don't start the emacs
|
|
|
|
;; server
|
2017-02-19 18:57:16 -05:00
|
|
|
TeX-source-correlate-start-server nil
|
2018-01-01 20:48:23 +01:00
|
|
|
TeX-source-correlate-mode t
|
|
|
|
TeX-source-correlate-method 'synctex
|
|
|
|
;; Fonts for section, subsection, etc
|
|
|
|
font-latex-fontify-sectioning 1.15)
|
|
|
|
(setq-default TeX-master nil)
|
|
|
|
;; Display the output of the latex commands in a popup.
|
2018-06-18 02:26:05 +02:00
|
|
|
(set-popup-rule! " output\\*$" :size 15)
|
2018-01-01 20:48:23 +01:00
|
|
|
;; TeX Folding
|
2018-05-29 12:46:13 +02:00
|
|
|
(add-hook 'TeX-mode-hook #'TeX-fold-mode))
|
|
|
|
|
|
|
|
(after! latex
|
|
|
|
(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
|
|
|
|
LaTeX-item-indent 0) ; item indentation.
|
|
|
|
|
2018-06-15 21:16:37 +02:00
|
|
|
;; Do not prompt for Master files, this allows auto-insert to add templates to
|
|
|
|
;; .tex files
|
|
|
|
(add-hook! '(LaTeX-mode-hook TeX-mode-hook)
|
|
|
|
(remove-hook 'find-file-hook
|
|
|
|
(cl-find-if #'byte-code-function-p find-file-hook)
|
|
|
|
'local))
|
2018-05-29 12:46:13 +02:00
|
|
|
;; Adding useful things for latex
|
|
|
|
(add-hook! 'LaTeX-mode-hook
|
2018-07-13 18:45:59 +02:00
|
|
|
#'(TeX-source-correlate-mode
|
2018-06-02 13:58:04 +02:00
|
|
|
visual-line-mode))
|
2018-05-29 12:46:13 +02:00
|
|
|
;; Enable rainbow mode after applying styles to the buffer
|
|
|
|
(add-hook 'TeX-update-style-hook #'rainbow-delimiters-mode)
|
|
|
|
(when (featurep! :feature spellcheck)
|
2018-06-15 21:00:38 +02:00
|
|
|
(add-hook 'LaTeX-mode-hook #'flyspell-mode :append))
|
2018-05-29 12:46:13 +02:00
|
|
|
;; Use chktex to search for errors in a latex file.
|
|
|
|
(setcar (cdr (assoc "Check" TeX-command-list)) "chktex -v6 %s")
|
|
|
|
;; Set a custom item indentation
|
|
|
|
(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-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-12 19:52:54 +02:00
|
|
|
:after latex
|
|
|
|
:config
|
2018-07-13 18:01:22 +02:00
|
|
|
(def-package! company-math
|
|
|
|
:defer t
|
2018-07-18 11:10:55 +02:00
|
|
|
;; 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
|
|
|
|
;; not something `set-company-backend!' anticipates (and shouldn't have to!)
|
2018-07-13 18:01:22 +02:00
|
|
|
:init
|
|
|
|
(add-hook! LaTeX-mode
|
|
|
|
(setq-local company-backends
|
|
|
|
(append '((company-math-symbols-latex
|
|
|
|
company-auctex-macros
|
|
|
|
company-auctex-environments))
|
|
|
|
company-backends)))))
|
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"))
|