lang/latex: general refactor
This commit is contained in:
parent
2e6c362df9
commit
14f4e4384a
4 changed files with 42 additions and 49 deletions
|
@ -2,8 +2,7 @@
|
||||||
|
|
||||||
;; Fontification taken from https://tex.stackexchange.com/a/86119/81279
|
;; Fontification taken from https://tex.stackexchange.com/a/86119/81279
|
||||||
(setq font-latex-match-reference-keywords
|
(setq font-latex-match-reference-keywords
|
||||||
'(
|
'(;; biblatex
|
||||||
;; biblatex
|
|
||||||
("printbibliography" "[{")
|
("printbibliography" "[{")
|
||||||
("addbibresource" "[{")
|
("addbibresource" "[{")
|
||||||
;; Standard commands
|
;; Standard commands
|
||||||
|
@ -64,8 +63,7 @@
|
||||||
("labelcref" "{")))
|
("labelcref" "{")))
|
||||||
|
|
||||||
(setq font-latex-match-textual-keywords
|
(setq font-latex-match-textual-keywords
|
||||||
'(
|
'(;; biblatex brackets
|
||||||
;; biblatex brackets
|
|
||||||
("parentext" "{")
|
("parentext" "{")
|
||||||
("brackettext" "{")
|
("brackettext" "{")
|
||||||
("hybridblockquote" "[{")
|
("hybridblockquote" "[{")
|
||||||
|
@ -78,8 +76,7 @@
|
||||||
("subcaption" "[{")))
|
("subcaption" "[{")))
|
||||||
|
|
||||||
(setq font-latex-match-variable-keywords
|
(setq font-latex-match-variable-keywords
|
||||||
'(
|
'(;; amsmath
|
||||||
;; amsmath
|
|
||||||
("numberwithin" "{")
|
("numberwithin" "{")
|
||||||
;; enumitem
|
;; enumitem
|
||||||
("setlist" "[{")
|
("setlist" "[{")
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
;;; lang/latex/+latexmk.el -*- lexical-binding: t; -*-
|
|
||||||
;;;###if (featurep! +latexmk)
|
|
||||||
|
|
||||||
(def-package! auctex-latexmk
|
|
||||||
:after latex
|
|
||||||
:init
|
|
||||||
;; Pass the -pdf flag when TeX-PDF-mode is active
|
|
||||||
(setq auctex-latexmk-inherit-TeX-PDF-mode t)
|
|
||||||
;; Set LatexMk as the default
|
|
||||||
(setq-hook! LaTeX-mode TeX-command-default "LatexMk")
|
|
||||||
:config
|
|
||||||
;; Add latexmk as a TeX target
|
|
||||||
(auctex-latexmk-setup))
|
|
|
@ -18,7 +18,7 @@
|
||||||
(?t . "\\textcite[]{%l}"))
|
(?t . "\\textcite[]{%l}"))
|
||||||
reftex-plug-into-AUCTeX t
|
reftex-plug-into-AUCTeX t
|
||||||
reftex-toc-split-windows-fraction 0.3)
|
reftex-toc-split-windows-fraction 0.3)
|
||||||
(unless (string-empty-p +latex-bibtex-file)
|
(unless +latex-bibtex-file
|
||||||
(setq reftex-default-bibliography (list (expand-file-name +latex-bibtex-file))))
|
(setq reftex-default-bibliography (list (expand-file-name +latex-bibtex-file))))
|
||||||
(map! :map reftex-mode-map
|
(map! :map reftex-mode-map
|
||||||
:localleader :n ";" 'reftex-toc)
|
:localleader :n ";" 'reftex-toc)
|
||||||
|
@ -38,7 +38,5 @@
|
||||||
(define-key bibtex-mode-map (kbd "C-c \\") #'bibtex-fill-entry))
|
(define-key bibtex-mode-map (kbd "C-c \\") #'bibtex-fill-entry))
|
||||||
|
|
||||||
(after! bibtex-completion
|
(after! bibtex-completion
|
||||||
(unless (string-empty-p +latex-bibtex-file)
|
(unless +latex-bibtex-file
|
||||||
(setq bibtex-completion-bibliography (list (expand-file-name +latex-bibtex-file)))))
|
(setq bibtex-completion-bibliography (list (expand-file-name +latex-bibtex-file)))))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
(defvar +latex-indent-level-item-continuation 4
|
(defvar +latex-indent-level-item-continuation 4
|
||||||
"Custom indentation level for items in enumeration-type environments")
|
"Custom indentation level for items in enumeration-type environments")
|
||||||
|
|
||||||
(defvar +latex-bibtex-file ""
|
(defvar +latex-bibtex-file nil
|
||||||
"File AUCTeX (specifically RefTeX) uses to search for citations.")
|
"File AUCTeX (specifically RefTeX) uses to search for citations.")
|
||||||
|
|
||||||
(defvar +latex-enable-unicode-math nil
|
(defvar +latex-enable-unicode-math nil
|
||||||
|
@ -33,10 +33,6 @@ If no viewers are found, `latex-preview-pane' is used.")
|
||||||
:mode ("\\.tex\\'" . TeX-latex-mode)
|
:mode ("\\.tex\\'" . TeX-latex-mode)
|
||||||
:hook (TeX-mode . visual-line-mode)
|
:hook (TeX-mode . visual-line-mode)
|
||||||
:config
|
:config
|
||||||
;; fontify common latex commands
|
|
||||||
(load! "+fontification")
|
|
||||||
;; select viewer
|
|
||||||
(load! "+viewers")
|
|
||||||
(setq TeX-parse-self t ;; parse on load
|
(setq TeX-parse-self t ;; parse on load
|
||||||
TeX-auto-save t ;; parse on save
|
TeX-auto-save t ;; parse on save
|
||||||
;; use hidden dirs for auctex files
|
;; use hidden dirs for auctex files
|
||||||
|
@ -48,28 +44,34 @@ If no viewers are found, `latex-preview-pane' is used.")
|
||||||
TeX-source-correlate-start-server nil
|
TeX-source-correlate-start-server nil
|
||||||
;; automatically insert braces after sub/superscript in math mode
|
;; automatically insert braces after sub/superscript in math mode
|
||||||
TeX-electric-sub-and-superscript t)
|
TeX-electric-sub-and-superscript t)
|
||||||
|
;; fontify common latex commands
|
||||||
|
(load! "+fontification")
|
||||||
|
;; select viewer
|
||||||
|
(load! "+viewers")
|
||||||
;; prompt for master
|
;; prompt for master
|
||||||
(setq-default TeX-master nil)
|
(setq-default TeX-master nil)
|
||||||
;; set-up chktex
|
;; set-up chktex
|
||||||
(setcar (cdr (assoc "Check" TeX-command-list)) "chktex -v6 -H %s")
|
(setcar (cdr (assoc "Check" TeX-command-list)) "chktex -v6 -H %s")
|
||||||
;; tell emacs how to parse tex files
|
;; tell emacs how to parse tex files
|
||||||
(add-hook! 'tex-mode-hook (setq ispell-parser 'tex))
|
(setq-hook! 'TeX-mode-hook ispell-parser 'tex)
|
||||||
|
;; Enable word wrapping
|
||||||
|
(add-hook 'TeX-mode-hook #'visual-line-mode)
|
||||||
|
;; Fold TeX macros
|
||||||
|
(add-hook 'TeX-mode-hook #'TeX-fold-mode)
|
||||||
;; display output of latex commands in popup
|
;; display output of latex commands in popup
|
||||||
(set-popup-rule! " output\\*$" :size 15)
|
(set-popup-rule! " output\\*$" :size 15)
|
||||||
;; Do not prompt for Master files, this allows auto-insert to add templates to
|
;; Do not prompt for Master files, this allows auto-insert to add templates to
|
||||||
;; .tex files
|
;; .tex files
|
||||||
(add-hook! 'TeX-mode-hook (remove-hook 'find-file-hook
|
(add-hook! 'TeX-mode-hook
|
||||||
(cl-find-if #'byte-code-function-p find-file-hook)
|
;; Necessary because it is added as an anonymous, byte-compiled function
|
||||||
'local))
|
(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
|
;; Enable rainbow mode after applying styles to the buffer
|
||||||
(add-hook 'TeX-update-style-hook #'rainbow-delimiters-mode)
|
(add-hook 'TeX-update-style-hook #'rainbow-delimiters-mode)
|
||||||
(add-hook 'TeX-mode-hook #'visual-line-mode)
|
|
||||||
(when (featurep! :feature spellcheck)
|
(when (featurep! :feature spellcheck)
|
||||||
(add-hook 'TeX-mode-hook #'flyspell-mode :append)))
|
(add-hook 'TeX-mode-hook #'flyspell-mode :append)))
|
||||||
|
|
||||||
; Fold TeX macros
|
|
||||||
(def-package! tex-fold
|
|
||||||
:hook (TeX-mode . TeX-fold-mode))
|
|
||||||
|
|
||||||
(after! latex
|
(after! latex
|
||||||
(setq LaTeX-section-hook ; Add the toc entry to the sectioning hooks.
|
(setq LaTeX-section-hook ; Add the toc entry to the sectioning hooks.
|
||||||
|
@ -86,7 +88,7 @@ If no viewers are found, `latex-preview-pane' is used.")
|
||||||
(dolist (env '("itemize" "enumerate" "description"))
|
(dolist (env '("itemize" "enumerate" "description"))
|
||||||
(add-to-list 'LaTeX-indent-environment-list `(,env +latex/LaTeX-indent-item))))
|
(add-to-list 'LaTeX-indent-environment-list `(,env +latex/LaTeX-indent-item))))
|
||||||
|
|
||||||
;; set-up preview package
|
|
||||||
(def-package! preview
|
(def-package! preview
|
||||||
:hook (LaTeX-mode . LaTeX-preview-setup)
|
:hook (LaTeX-mode . LaTeX-preview-setup)
|
||||||
:config
|
:config
|
||||||
|
@ -94,6 +96,26 @@ If no viewers are found, `latex-preview-pane' is used.")
|
||||||
preview-scale-function
|
preview-scale-function
|
||||||
(lambda () (* (/ 10.0 (preview-document-pt)) preview-scale))))
|
(lambda () (* (/ 10.0 (preview-document-pt)) preview-scale))))
|
||||||
|
|
||||||
|
|
||||||
|
;; Nicely indent lines that have wrapped when visual line mode is activated
|
||||||
|
(def-package! adaptive-wrap
|
||||||
|
:hook (LaTeX-mode . adaptive-wrap-prefix-mode)
|
||||||
|
:init (setq-default adaptive-wrap-extra-indent 0))
|
||||||
|
|
||||||
|
|
||||||
|
(def-package! auctex-latexmk
|
||||||
|
:when (featurep! +latexmk)
|
||||||
|
:after latex
|
||||||
|
:init
|
||||||
|
;; Pass the -pdf flag when TeX-PDF-mode is active
|
||||||
|
(setq auctex-latexmk-inherit-TeX-PDF-mode t)
|
||||||
|
;; Set LatexMk as the default
|
||||||
|
(setq-hook! LaTeX-mode TeX-command-default "LatexMk")
|
||||||
|
:config
|
||||||
|
;; Add latexmk as a TeX target
|
||||||
|
(auctex-latexmk-setup))
|
||||||
|
|
||||||
|
|
||||||
(def-package! company-auctex
|
(def-package! company-auctex
|
||||||
:when (featurep! :completion company)
|
:when (featurep! :completion company)
|
||||||
:defer t
|
:defer t
|
||||||
|
@ -107,17 +129,6 @@ If no viewers are found, `latex-preview-pane' is used.")
|
||||||
:init
|
:init
|
||||||
(add-to-list '+latex--company-backends #'+latex-symbols-company-backend nil #'eq))
|
(add-to-list '+latex--company-backends #'+latex-symbols-company-backend nil #'eq))
|
||||||
|
|
||||||
;; Nicely indent lines that have wrapped when visual line mode is activated
|
|
||||||
(def-package! adaptive-wrap
|
|
||||||
:hook (LaTeX-mode . adaptive-wrap-prefix-mode)
|
|
||||||
:init (setq-default adaptive-wrap-extra-indent 0))
|
|
||||||
|
|
||||||
;; referencing + bibtex setup
|
;; bibtex + reftex
|
||||||
(load! "+ref")
|
(load! "+ref")
|
||||||
|
|
||||||
;;
|
|
||||||
;; Sub-modules
|
|
||||||
;;
|
|
||||||
|
|
||||||
(if (featurep! +latexmk) (load! "+latexmk"))
|
|
||||||
(if (featurep! +preview-pane) (load! "+preview-pane"))
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue