From dc40fa36d3205d2c463661b8c808fae4daaf873c Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Wed, 18 Jul 2018 12:11:53 +0200 Subject: [PATCH] Move referencing setup into different file --- modules/lang/latex/+ref.el | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 modules/lang/latex/+ref.el diff --git a/modules/lang/latex/+ref.el b/modules/lang/latex/+ref.el new file mode 100644 index 000000000..ce47b7f9d --- /dev/null +++ b/modules/lang/latex/+ref.el @@ -0,0 +1,60 @@ +;;; lang/latex/+ref.el -*- lexical-binding: t; -*- + +(defvar +latex-bibtex-file "" + "File AUCTeX (specifically RefTeX) uses to search for citations.") + +(def-package! reftex + :hook ((latex-mode LaTeX-mode) . turn-on-reftex) + :init + (setq reftex-plug-into-AUCTeX t + reftex-toc-split-windows-fraction 0.3) + :config + ;; Get ReTeX working with biblatex + ;; http://tex.stackexchange.com/questions/31966/setting-up-reftex-with-biblatex-citation-commands/31992#31992 + (setq reftex-cite-format + '((?t . "\\textcite[]{%l}") + (?a . "\\autocite[]{%l}") + (?c . "\\cite[]{%l}") + (?s . "\\smartcite[]{%l}") + (?f . "\\footcite[]{%l}") + (?n . "\\nocite{%l}") + (?b . "\\blockcquote[]{%l}{}"))) + (unless (string-empty-p +latex-bibtex-file) + (setq reftex-default-bibliography (list (expand-file-name +latex-bibtex-file)))) + (map! :map reftex-mode-map + :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))) + +(def-package! company-reftex + :when (featurep! :completion company) + :after reftex + :config + (set-company-backend! 'reftex-mode 'company-reftex-labels 'company-reftex-citations)) + +(def-package! bibtex + :defer t + :config + (setq bibtex-dialect 'biblatex + bibtex-align-at-equal-sign t + bibtex-text-indentation 20) + (define-key bibtex-mode-map (kbd "C-c \\") #'bibtex-fill-entry)) + +(def-package! ivy-bibtex + :when (featurep! :completion ivy) + :commands ivy-bibtex) + +(def-package! helm-bibtex + :when (featurep! :completion helm) + :commands helm-bibtex) + +(after! bibtex-completion + (unless (string-empty-p +latex-bibtex-file) + (setq bibtex-completion-bibliography (list (expand-file-name +latex-bibtex-file))))) + +