vspinu / company-math

Completion back-ends for for math unicode symbols and latex tags
124 stars 8 forks source link

company-math-symbols-latex does not work #6

Closed luluman closed 8 years ago

luluman commented 8 years ago

"company-math-symbols-latex" mode seems not work right. I set "company-math-symbols-latex" to the global case, but company-mode won't pop up any complete suggestion even in math face. However, "company-math-symbols-unicode" mode works on every environments. I'm new to emacs, and don't know how to solve this problem. The emacs in my computer is 24.5 with company-mode and yasnippet. This is my setting '(add-to-list 'company-backends 'company-math-symbols-latex)'

vspinu commented 8 years ago

If you do M-x company-math-symbols-latex on a symbol does it work?

luluman commented 8 years ago

I have tried, the mini buffer pop an error "cannot complete at point".

vspinu commented 8 years ago

I have tried, the mini buffer pop an error "cannot complete at point".

Even on math fonts?

What if you set company-math-allow-latex-symbols-in-faces to t?

Like

(setq company-math-allow-latex-symbols-in-faces t)
vspinu commented 8 years ago

Why do you need latex-symbols everywhere? Aren't you interested in company-latex-commands instead?

luluman commented 8 years ago

Yeah, it works. Thank you very much. :+1:

luluman commented 8 years ago

It seems this plugin cannot distinguish math face and plain text in my emacs. So I have to enable it everywhere. Also, I like the style of "company-math-symbols-latex", it give me a feedback whether I have choose the right symbol. Thanks for your great help and the beautiful plugin.

vspinu commented 8 years ago

It seems this plugin cannot distinguish math face and plain text in my emacs.

Looks like your math is not in font-latex-math-face. Are you using auctex?

Go to the text in math face and press C-u C-x =. A full description of the character at point should appear. There should be a list of fonts as well. See what fonts are there and customize company-math-allow-latex-symbols-in-faces to include the math font.

luluman commented 8 years ago
         position: 359 of 362 (99%), column: 50
        character: SPC (displayed as SPC) (codepoint 32, #o40, #x20)
preferred charset: ascii (ASCII (ISO646 IRV))

code point in charset: 0x20 script: latin syntax: which means: whitespace category: .:Base, a:ASCII, l:Latin to input: type "C-x 8 RET HEX-CODEPOINT" or "C-x 8 RET NAME" buffer code: #x20 file code: #x20 (encoded by coding system utf-8-unix) display: terminal code #x20 Character code properties: customize what to show name: SPACE general-category: Zs (Separator, Space) decomposition: (32) (' ')

There are text properties here: face tex-math fortified t It shows like this. I don't know how to add this to company-math-allow-latex-symbols-in-face. By the way, I am not using auctex.

vspinu commented 8 years ago

I am not using auctex.

This was it. Without auctex the font is tex-math. I overlooked this. I am adding this face to the list. Could you please try it again with default settings and let me know if it worked.

I don't know how to add this to

You can always do M-x customize-group RET company-math RET and add tex-math to that list.

luluman commented 8 years ago

I use the latest (defcustom company-math-allow-latex-symbols-in-faces '(tex-math font-latex-math-face) and set (add-to-list 'company-backends 'company-math-symbols-latex) without (setq company-math-allow-latex-symbols-in-faces t) , but it does not work. Need I do M-x customize-group RET company-math RET and add tex-math to that list?

luluman commented 8 years ago

Also it seems when get across \[ \] in latex, the font change to face font-lock-keyword-face.

vspinu commented 8 years ago

You need to use setq instead of defcustom. defcustom sets the value only once per session and does not have any effect afterward (this is by elisp design):

(setq company-math-allow-latex-symbols-in-faces '(tex-math font-latex-math-face))

I actually suggested to re-install the package (from melpa or from github), but the above setting is equivalent.

Also it seems when get across [ ] in latex, the font change to face font-lock-keyword-face.

Simple tex-mode doesn't recognize \[. Auctex does; it puts the entire expression into font-latex-math-face. I suggest you install auctex. It's a much better system than the default plain emacs tex support.