Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't display the math symbols represented by company-math. #18

Closed
hongyi-zhao opened this issue Jun 19, 2021 · 7 comments
Closed

Can't display the math symbols represented by company-math. #18

hongyi-zhao opened this issue Jun 19, 2021 · 7 comments

Comments

@hongyi-zhao
Copy link

hongyi-zhao commented Jun 19, 2021

On Ubuntu 20.04, I test the company-math package with some symbols listed in The Comprehensive LATEX Symbol List in Emacs/AUCTeX with some of the same symbols shown here. The Emacs configuration is as follows:

(use-package company-math)
;; local configuration for TeX modes
(defun my/latex-mode-setup ()
  (setq-local company-backends
              (append '((company-math-symbols-latex company-math-symbols-unicode company-latex-commands))
                      company-backends)))
;If you are using AUCTeX you might need to use TeX-mode-hook instead:
(add-hook 'TeX-mode-hook 'my/latex-mode-setup)

But I can't get the same display results represented here, see the following screenshots for more detailed info:

image
image

Any hints for this problem will be highly appreciated.

Regards,
HY

@vspinu
Copy link
Owner

vspinu commented Jun 21, 2021

Hi @hongyi-zhao Check your company-backends variables in the buffer. Some other backend might be creeping in or the company-math backends are not installed int he first place.

You can invoke the backend one by one like so M-x company-math-symbols-unicode RET and see if it is triggered correctly.

@hongyi-zhao
Copy link
Author

Check your company-backends variables in the buffer.

See the following given by M-x company-diag RET:

image

You can invoke the backend one by one like so M-x company-math-symbols-unicode RET and see if it is triggered correctly.

I tried with M-x company-math-symbols-unicode RET and M-x company-math-symbols-latex RET, but still failed to obtain the same results as you presented in this repo:

image

@vspinu
Copy link
Owner

vspinu commented Jun 22, 2021

Your latest screenshot is from company-capf, not from company-math backends. What is the value of company-backends in your tex buffer?

@hongyi-zhao
Copy link
Author

M-x describe-variable RET company-backends RET:

image

I'm currently use auctex, eglot, texlab, and company as the LaTeX document preparation environment. See the full configuration below:

(straight-use-package
 `(auctex :type git :host nil :repo "https://git.savannah.gnu.org/git/auctex.git"
    :pre-build ,(pcase system-type
                (`berkeley-unix '("gmake"))
                (_ '(
                    `("bash" "-c" "cd" ,(straight--repos-dir "auctex"))
                    ("./autogen.sh")
                    ("./configure" "--without-texmf-dir" "--with-lispdir=.") 
                    ("make")
                    )))))

     (setq TeX-data-directory (straight--repos-dir "auctex")
           TeX-lisp-directory TeX-data-directory)                   
    
; Or set the following variable via custom-set-variables in the opened buffer by the following command.
; M-x describe-variable RET preview-TeX-style-dir RET
;`(preview-TeX-style-dir ,(concat ".:" (straight--repos-dir "auctex") "latex:"))
(setq preview-TeX-style-dir (concat ".:" (straight--repos-dir "auctex") "latex:"))

(load "auctex.el" nil t t) 
(load "preview-latex.el" nil t t)

(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)

(use-package eglot
  :hook 
  ((TeX-mode . eglot-ensure))
  :config
(add-to-list 'eglot-server-programs
             '((latex-mode tex-mode context-mode texinfo-mode bibtex-mode) . ("texlab"))))

(use-package company
  :custom
  (company-idle-delay 0)
  (company-minimum-prefix-length 1)
  (company-tooltip-align-annotations t)
  (company-dabbrev-downcase nil)
  (company-dabbrev-other-buffers t) ; search buffers with the same major mode
  :bind
  ( :map company-active-map
    ("RET" . nil)
    ([return] . nil)
    ("C-w" . nil)
    ("TAB" . company-complete-selection)
    ("<tab>" . company-complete-selection)
    ("C-s" . company-complete-selection)  ; Mostly to use during yasnippet expansion
    ("C-n" . company-select-next)
    ("C-p" . company-select-previous))
  :hook
  ;(dashboard-after-initialize . global-company-mode)
  ; https://emacs.stackexchange.com/questions/39256/how-to-avail-of-hook-using-use-package
  (after-init . global-company-mode)
  :config
  (add-to-list 'company-begin-commands 'backward-delete-char-untabify))


(use-package company-math)
;; local configuration for TeX modes
(defun my/latex-mode-setup ()
  (setq-local company-backends
              (append '((company-math-symbols-latex company-math-symbols-unicode company-latex-commands))
                      company-backends)))
;If you are using AUCTeX you might need to use TeX-mode-hook instead:
(add-hook 'TeX-mode-hook 'my/latex-mode-setup)

@vspinu
Copy link
Owner

vspinu commented Jun 22, 2021

As expected, your configuration is not being triggered. Try tex-mode-hook. The tex/auctex hookup was always a mystery to me.

@hongyi-zhao
Copy link
Author

No, tex-mode-hook can't activate lsp like TeX-mode-hook.

@hongyi-zhao
Copy link
Author

I've figured out a workable configuration as shown here. So close this issue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants