redguardtoo / company-ctags

Fastest Emacs auto-completion using Company and Ctags
GNU General Public License v3.0
56 stars 3 forks source link

Ignore Case and Fuzzy Match not working? #13

Closed jazzychad closed 2 years ago

jazzychad commented 2 years ago

Hello! Loving company-ctags so far. However, I'm having an issue getting company-ctags-ignore-case and company-ctags-fuzzy-match-p working.

OS: MacOS 12.0.1 emacs: 27.2 company: 20211201.2335 (from melpa) company-ctags: 20210723.1322

I have set the relevant variables as such in my .emacs

(setq company-ctags-fuzzy-match-p t)
(setq company-ctags-ignore-case t)

(with-eval-after-load 'company
  (company-ctags-auto-setup))
(add-hook 'c-mode-hook 'company-mode)

describe-variable shows them set as non-nil (t), but no matter what I try to type in my .c files, the company completion candidates only appear if they match case and use a prefix (non-fuzzy).

Is there a way to debug this?

I have setup my TAGS file using the find . -name "*.[ch]" | ctags -e -L - command in the README

jazzychad commented 2 years ago

I should mention I do not have counsel installed.. it was unclear from the README whether that was required for fuzzy-matching.

redguardtoo commented 2 years ago

I can't reproduce the issue,

case insensitive match,

image

fuzzy match enabled, image

Make sure you are using company-ctags , not company-etags,

What's the output of C-h v company-backends?

You can just (setq company-backends '(company-ctags)) in .emacs and re-test.

Please note company-ctags-fuzzy-match-p is actually just partial string match. If it's nil, the input string should be strictly the prefix of candides. I can implement the real fuzzy match but it's slow and I'm not sure it's useful.

redguardtoo commented 2 years ago

case sensitive matching does have a bug, fixed. 313508b fixed a case sensitive bug (Chen Bin)

jazzychad commented 2 years ago

here is the describe-variable output of company-backends

Its value is
(company-bbdb company-semantic company-cmake company-capf company-clang company-files
              (company-dabbrev-code company-gtags company-ctags company-keywords)
              company-oddmuse company-dabbrev)
Original value was
(company-bbdb company-semantic company-cmake company-capf company-clang company-files
              (company-dabbrev-code company-gtags company-etags company-keywords)
              company-oddmuse company-dabbrev)

I'm not sure where -gtags or -etags are getting set. I have not (knowingly) installed any other backends. Are those just the default company backends?

When I manually set (setq company-backends '(company-ctags)) it does appear to work as intended (fuzzy (nonprefix) and case-insensitive matching).. however it doesn't do the function/argument autocomplete like it was before (presumably supplied by some other of the backends??).

example 1 s1 example 2 s2

with only company-ctags: s3 s4

Is there a best of both worlds?

redguardtoo commented 2 years ago

company-gtags

company-gtags is a backend for GNU Global which could extract more information from code. company-ctags could only extract tag name, no parameter information. So you need check other backends instead of company-ctags for parameter completion.

In your setup, the combined results of company-gtags and company-ctags are returned as candidates because they are in a group.

BTW, as you can see, company-capf is before the group of gtags&ctags. if company-capf returns non-empty result, the backend and the group after it will not be called.

lsp-mode uses company-capf, so if you use some LSP stuff, you need only lsp setup and company-capf.

jazzychad commented 2 years ago

Aha! Thank you for the detailed info. Sorry for the noise. But at least it uncovered a case-insensitive bug? 😅 I will tweak my setup to figure out what works best between all these backends. Thanks again!

redguardtoo commented 2 years ago

case sensitive bug is fixed for sure.