Add cdlatex support in latex: +cdlatex

cdlatex has 4 main functionalities:
+ Math and environments snippets: I've disabled these in favor of
  yasnippet when using :editor snippets by just unbinding the TAB in
  cdlatex's keymap
+ Auto insertion of closing delimiters: disabled in favor of smartparens
+ Fast insertion for some macros: `a becomes \alpha. Kept as-is
+ Fast accent insertion: a'~ becomes \tilde{a}. Kept as-is

I also updated the docs, and added a section explaining how to re-enable
cdlatex's snippets despite having yasnippet.
This commit is contained in:
yoavm448 2020-02-07 12:36:07 +02:00
parent 456b501aad
commit 883a326e87
3 changed files with 45 additions and 1 deletions

View file

@ -119,6 +119,30 @@ If no viewers are found, `latex-preview-pane' is used.")
(lambda () (* (/ 10.0 (preview-document-pt)) preview-scale))))
(use-package! cdlatex
:defer t
:when (featurep! +cdlatex)
:hook (LaTeX-mode . cdlatex-mode)
:config
;; Disabling keys that have overlapping functionality with other parts of Doom
;; smartparens takes care of inserting closing delimiters
(define-key cdlatex-mode-map "$" nil)
(define-key cdlatex-mode-map "(" nil)
(define-key cdlatex-mode-map "{" nil)
(define-key cdlatex-mode-map "[" nil)
(define-key cdlatex-mode-map "|" nil)
(define-key cdlatex-mode-map "<" nil)
;; TAB is used for cdlatex's snippets and navigation. But have yasnippet for that.
(when (featurep! :editor snippets)
(define-key cdlatex-mode-map "\t" nil))
;; AUCTeX takes care of auto-inserting {} on _^ if you want, with `TeX-electric-sub-and-superscript'
(define-key cdlatex-mode-map "^" nil)
(define-key cdlatex-mode-map "_" nil)
;; AUCTeX already provides this with `LaTeX-insert-item'
(define-key cdlatex-mode-map [(control return)] nil))
;; Nicely indent lines that have wrapped when visual line mode is activated
(use-package! adaptive-wrap
:hook (LaTeX-mode . adaptive-wrap-prefix-mode)