cdominik / cdlatex

Fast input methods to enter LaTeX environments and math with GNU Emacs
231 stars 48 forks source link

How to properly configure cdlatex to work with doom emacs? #26

Closed roiholtzman closed 3 years ago

roiholtzman commented 3 years ago

I am using doom emacs, and I for some time now I cannot configure correctly cdlatex to work properly. It seems that every time I upgrade doom, cdlatex operates differently and I am not sure why. The main problem is that the snippets do not work properly, namely equ-TAB does not insert an equation environment, and fr-TAB does not put in \frac{}{} etc.

It seems to me that my problem is company mode which overrides the cdlatex. Is there a way to make cdlatex override the company mode? One way is to disable company mode for org mode documents, but I am not sure how to do that.

At the moment my configuration is this:

init.el

:lang       
    (latex
        +latexmk
        +cdlatex)
   (org +roam)

config.el

(after! org (add-hook 'org-mode-hook 'turn-on-org-cdlatex))
(map! :after org
      :map org-cdlatex-mode
      "TAB" #'cdlatex-tab)
(after! cdlatex
  (setq cdlatex-use-dollar-to-ensure-math t)
  (map! :map cdlatex-mode-map
        :i "TAB" #'cdlatex-tab))

I would love to finally understand how this should be set.

roiholtzman commented 3 years ago

I have disabled company mode for org files which solves the problem.

(defun zz/adjust-org-company-backends ()
  (remove-hook 'after-change-major-mode-hook '+company-init-backends-h)
  (setq-local company-backends nil))
(add-hook! org-mode (zz/adjust-org-company-backends))

However, I still see that there are bugs with org mode when inserting parenthesis (inserting ( in math inline mode does not give a closing parenthesis, deleting $ does not delete the closing $ etc.). Probably there are some clashes with smartparnes, but I don't know how to solve them...

ymarco commented 3 years ago

Have you looked at Doom's configuration for cdlatex? Some parts are disabled due to conflict with other packages. It might provide some insight.

https://github.com/hlissner/doom-emacs/blob/develop/modules/lang/latex/config.el#L184-L210 EDIT: fixed link

roiholtzman commented 3 years ago

Have you looked at Doom's configuration for cdlatex? Some parts are disabled due to conflict with other packages. It might provide some insight.

https://github.com/hlissner/doom-emacs/blob/develop/modules/lang/latex/config.el#L184-L210 EDIT: fixed link

Thanks for the link, it seems very useful indeed. My elementary knowledge on lisp is not enough to fully understand everything. However, I do not understand why cdlatex works well with latex mode, but not with org mode. Doesn't the linked configuration apply to both latex and org modes?

I usually use $ ... $ to write inline math equations. How would one properly configure this to work well in org mode? (i.e. as it works in latex mode)

ymarco commented 3 years ago

roiholtzman @.***> writes:

My elementary knowledge on lisp is not enough to fully understand everything. However, I do not understand why cdlatex works well with latex mode, but not with org mode. Doesn't the linked configuration apply to both latex and org modes?

Yes, cdlatex-mode-map applies in both org and latex.

I usually use $ ... $ to write inline math equations. How would one properly configure this to work well in org mode? (i.e. as it works in latex mode)

I don't know. I don't have all the answers. Learn ELisp!

In Doom Emacs: "K" for describing symbol at point, "g d" for goto definition, "SPC h f"/"SPC h v" for describing functions/variables

roiholtzman commented 3 years ago

I still was not able to solve this issue, but it seems to me that for some reason cdlatex-pbb does not work well (or does not get called) in org-cdlatex-mode, while in cdlatex-mode it works great.

If someone has some tips on how to solve this, I'd appreciate it!